[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-4' - 6 commits - loleaflet/build loleaflet/debug loleaflet/dist loleaflet/README loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Thu Aug 6 08:11:18 PDT 2015
loleaflet/README | 10 +++++++-
loleaflet/build/deps.js | 7 ++++++
loleaflet/debug/document/document_simple_example.html | 21 +++++++++---------
loleaflet/dist/leaflet.css | 5 ----
loleaflet/src/control/Control.Dialog.js | 18 +++++++++++++++
loleaflet/src/control/Permission.js | 7 ------
loleaflet/src/control/Scroll.js | 3 ++
loleaflet/src/layer/tile/TileLayer.js | 14 ++++++++----
loleaflet/src/map/Map.js | 9 ++-----
9 files changed, 62 insertions(+), 32 deletions(-)
New commits:
commit c88f81f6ee52770836dd42cd62dccb9ccd28c49d
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 18:07:38 2015 +0300
loleaflet: dialog control
diff --git a/loleaflet/src/control/Control.Dialog.js b/loleaflet/src/control/Control.Dialog.js
new file mode 100644
index 0000000..98a6b48
--- /dev/null
+++ b/loleaflet/src/control/Control.Dialog.js
@@ -0,0 +1,18 @@
+/*
+ * L.Control.Dialog used for displaying alerts
+ */
+
+L.Control.Dialog = L.Control.extend({
+ onAdd: function (map) {
+ map.on('error', this._onError, this);
+ return document.createElement('div');
+ },
+
+ _onError: function (e) {
+ vex.dialog.alert(e.msg);
+ }
+});
+
+L.control.dialog = function (options) {
+ return new L.Control.Dialog(options);
+};
commit 265fd68bb6b8fc0bd2d6c649898bb5572111b1cf
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 18:06:29 2015 +0300
loleaflet: always use text cursor except when dragging
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index da34f0c..2c8beca 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -180,7 +180,7 @@
cursor: pointer;
}
.leaflet-container {
- cursor: pointer;
+ cursor: text;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
@@ -196,9 +196,6 @@
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
}
-.leaflet-editmode {
- cursor: text;
- }
/* visual tweaks */
diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js
index 9950612..8d80993 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -4,10 +4,8 @@
L.Map.include({
setPermission: function (perm) {
this._docLayer._permission = perm;
- var className = 'leaflet-editmode';
if (perm === 'edit') {
this.dragging.disable();
- L.DomUtil.addClass(this._container, className);
}
else if (perm === 'view' || perm === 'readonly') {
this.dragging.enable();
@@ -15,7 +13,6 @@ L.Map.include({
this._docLayer._onUpdateCursor();
this._docLayer._clearSelections();
this._docLayer._onUpdateTextSelection();
- L.DomUtil.removeClass(this._container, className);
}
this.fire('updatepermission', {perm : perm});
},
@@ -24,17 +21,13 @@ L.Map.include({
if (this._docLayer._permission === 'edit') {
return;
}
- var className = 'leaflet-editmode';
this.dragging.disable();
- L.DomUtil.addClass(this._container, className);
},
disableSelection: function () {
if (this._docLayer._permission === 'edit') {
return;
}
- var className = 'leaflet-editmode';
this.dragging.enable();
- L.DomUtil.removeClass(this._container, className);
}
});
commit 322737786197ae2d82d14a96964cd290d5ab5c85
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 17:41:56 2015 +0300
loleaflet: on error fire 'error' events
Those events are now handled by a removable control
diff --git a/loleaflet/README b/loleaflet/README
index 18577ac..67faeeb 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -152,6 +152,12 @@ Writer pages:
+ e.currentPage = the page on which the cursor lies
+ e.pages = number of pages
+ e.docType = document type, should be 'text'
+
+Error:
+ - events
+ map.on('error', function (e) {}) where
+ + e.msg = a message describing the error
+
Contributing
------------
diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index 2974882..62ef933 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -268,6 +268,13 @@ var deps = {
desc: 'Creates and handles the scrollbar'
},
+ ControlDialog: {
+ src: ['control/Control.js',
+ 'control/Control.Dialog.js'],
+ heading: 'Controls',
+ desc: 'Handles vex dialogs for displaying alerts'
+ },
+
ControlAttrib: {
src: ['control/Control.js',
'control/Control.Attribution.js'],
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index 5a75be0..234a2bc 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -75,6 +75,7 @@
globalMap.addControl(L.control.selection());
globalMap.addControl(L.control.statusIndicator());
globalMap.addControl(L.control.scroll());
+ globalMap.addControl(L.control.dialog());
////// Document layer ////
var docLayer = new L.TileLayer('', {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 0f2e5be..eb8ca81 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -95,7 +95,7 @@ L.TileLayer = L.GridLayer.extend({
_initDocument: function () {
if (!this._map.socket) {
- console.log('Socket initialization error');
+ this._map.fire('error', {msg: 'Socket initialization error'});
return;
}
if (this.options.doc) {
@@ -486,7 +486,7 @@ L.TileLayer = L.GridLayer.extend({
this._map.fire('setpart', {currentPart: this._currentPart});
}
else if (this._docType === 'text') {
- map.fire('pagenumberchanged', {
+ this._map.fire('pagenumberchanged', {
currentPage: part,
pages: this._pages,
docType: this._docType
@@ -497,7 +497,7 @@ L.TileLayer = L.GridLayer.extend({
this._map.fire('searchnotfound');
}
else if (textMsg.startsWith('error:')) {
- vex.dialog.alert(textMsg);
+ this._map.fire('error', {msg: textMsg.substring(7)});
}
},
@@ -723,7 +723,7 @@ L.TileLayer = L.GridLayer.extend({
e = e.originalEvent;
e.preventDefault();
if (!this._selectionTextContent) {
- vex.dialog.alert('Oops, no content available yet');
+ this._map.fire('error', {msg: 'Oops, no content available yet'});
}
else {
e.clipboardData.setData('text/plain', this._selectionTextContent);
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3420044..aa7333e 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -442,8 +442,7 @@ L.Map = L.Evented.extend({
try {
this.socket = new WebSocket(this.options.server);
} catch (e) {
- console.log(e);
- vex.dialog.alert('Socket connection error');
+ this.fire('error', {msg: 'Socket connection error'});
return;
}
this.socket.onerror = L.bind(this._onSocketError, this);
@@ -754,13 +753,11 @@ L.Map = L.Evented.extend({
},
_onSocketError: function (e) {
- console.log(e);
- vex.dialog.alert('Socket connection error');
+ this.fire('error', {msg: 'Socket connection error'});
},
_onSocketClose: function (e) {
- console.log(e);
- vex.dialog.alert('Socket connection closed');
+ this.fire('error', {msg: 'Socket connection closed'});
}
});
commit 144011f12008fe00894972d8ad799977367b6238
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 17:04:00 2015 +0300
loleaflet: notify when the document is initialized
diff --git a/loleaflet/README b/loleaflet/README
index c2f0531..18577ac 100644
--- a/loleaflet/README
+++ b/loleaflet/README
@@ -101,9 +101,11 @@ Parts (like slides in presentation, or sheets in spreadsheets):
Statusindicator (when the document is loading):
- events
map.on('statusindicator', function (e) {}) where:
- + e.statusType = 'start' | 'setvalue' | 'finish'
+ + e.statusType = 'start' | 'setvalue' | 'finish' | 'loleafletloaded'
+ e.value == a value from 0 to 100 indicating the status
if the statusType is 'setvalue
+ + 'loleafletloaded' is fired when the JS code is initialized and the document
+ load request is sent and we're waiting for the tiles
Save:
- API:
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index e1aa455..0f2e5be 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -121,6 +121,7 @@ L.TileLayer = L.GridLayer.extend({
if (this.options.readOnly) {
this._map.setPermission('readonly');
}
+ this._map.fire('statusindicator', {statusType: 'loleafletloaded'});
},
getEvents: function () {
commit 8766a414ebe5f15b1879e46b6f3d6879f26c520b
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 16:53:43 2015 +0300
loleaflet: rename the global map variable to avoid referencing it
To avoid mistakes like writing 'map.fire' instead of 'this._map.fire'
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index eae6cdf..5a75be0 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -57,7 +57,7 @@
vex.dialog.alert('Wrong host, usage: host=ws://localhost:9980');
}
- var map = L.map('map', {
+ var globalMap = L.map('map', {
center: [0, 0],
zoom: 10,
minZoom: 1,
@@ -67,14 +67,14 @@
});
////// Controls /////
- map.addControl(L.control.buttons());
- map.addControl(L.control.zoom());
- map.addControl(L.control.parts());
- map.addControl(L.control.search());
- map.addControl(L.control.permissionSwitch());
- map.addControl(L.control.selection());
- map.addControl(L.control.statusIndicator());
- map.addControl(L.control.scroll());
+ globalMap.addControl(L.control.buttons());
+ globalMap.addControl(L.control.zoom());
+ globalMap.addControl(L.control.parts());
+ globalMap.addControl(L.control.search());
+ globalMap.addControl(L.control.permissionSwitch());
+ globalMap.addControl(L.control.selection());
+ globalMap.addControl(L.control.statusIndicator());
+ globalMap.addControl(L.control.scroll());
////// Document layer ////
var docLayer = new L.TileLayer('', {
@@ -84,6 +84,6 @@
timestamp: timestamp,
readOnly: false
});
- map.addLayer(docLayer);
+ globalMap.addLayer(docLayer);
</script>
</body></html>
commit 3bbf7dfc7087d0f35dd83976257b142ab4bdd487
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Thu Aug 6 16:48:41 2015 +0300
loleaflet: update scroll offset after dragging
The scroll offset is updated on the 'moveend' event which occurs
after the document has been released. But we don't want to update the
scroll offset when scrolling
diff --git a/loleaflet/src/control/Scroll.js b/loleaflet/src/control/Scroll.js
index e20b3e1..fab91bf 100644
--- a/loleaflet/src/control/Scroll.js
+++ b/loleaflet/src/control/Scroll.js
@@ -6,6 +6,7 @@ L.Map.include({
if (typeof (x) !== 'number' || typeof (y) !== 'number') {
return;
}
+ this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(x, y), {animate: false});
},
@@ -28,11 +29,13 @@ L.Map.include({
scrollTop: function (y) {
var offset = this.scrollOffset();
+ this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(0, y - offset.y), {animate: false});
},
scrollLeft: function (x) {
var offset = this.scrollOffset();
+ this.off('moveend', this._docLayer._updateScrollOffset, this._docLayer);
this.panBy(new L.Point(x - offset.x, 0), {animate: false});
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index c426fe0..e1aa455 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -110,6 +110,7 @@ L.TileLayer = L.GridLayer.extend({
this._map.on('clearselection', this._clearSelections, this);
this._map.on('copy', this._onCopy, this);
this._map.on('zoomend', this._onUpdateCursor, this);
+ this._map.on('dragstart', this._onDragStart, this);
this._startMarker.on('drag dragend', this._onSelectionHandleDrag, this);
this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
this._textArea = this._map._textArea;
@@ -726,6 +727,10 @@ L.TileLayer = L.GridLayer.extend({
else {
e.clipboardData.setData('text/plain', this._selectionTextContent);
}
+ },
+
+ _onDragStart: function () {
+ this._map.on('moveend', this._updateScrollOffset, this);
}
});
More information about the Libreoffice-commits
mailing list