[Libreoffice-commits] online.git: 2 commits - loleaflet/build loleaflet/debug loleaflet/README loleaflet/src

Mihai Varga mihai.varga at collabora.com
Thu Aug 6 07:43:21 PDT 2015


 loleaflet/README                                      |   10 +++++++++-
 loleaflet/build/deps.js                               |    7 +++++++
 loleaflet/debug/document/document_simple_example.html |    1 +
 loleaflet/src/layer/tile/TileLayer.js                 |    9 +++++----
 loleaflet/src/map/Map.js                              |    9 +++------
 5 files changed, 25 insertions(+), 11 deletions(-)

New commits:
commit 1379326bcf74ef1bd838498879bc131a5ded9007
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 d0c3243..fd021b0 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) {
@@ -494,7 +494,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
@@ -505,7 +505,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)});
 		}
 	},
 
@@ -731,7 +731,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 e0dda7b9288e8a592884ad24a4575cbe835894ee
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 56f0004..d0c3243 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 () {


More information about the Libreoffice-commits mailing list