[Libreoffice-commits] online.git: loleaflet/src

Pranav Kant pranavk at collabora.com
Tue Feb 9 14:02:05 UTC 2016


 loleaflet/src/core/Socket.js |   39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

New commits:
commit 6f69af91e68e577aff4e4214ab584aaa8460896f
Author: Pranav Kant <pranavk at collabora.com>
Date:   Tue Feb 9 18:16:10 2016 +0530

    loleaflet: Fire event on initialization complete
    
    Change-Id: Iaba99d88b1ce770374f9f39a443b169c8c019d72
    Reviewed-on: https://gerrit.libreoffice.org/22234
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/core/Socket.js b/loleaflet/src/core/Socket.js
index cfd9788..68dc42d 100644
--- a/loleaflet/src/core/Socket.js
+++ b/loleaflet/src/core/Socket.js
@@ -19,6 +19,43 @@ L.Socket = L.Class.extend({
 		this.socket.onopen = L.bind(this._onOpen, this);
 		this.socket.onmessage = L.bind(this._onMessage, this);
 		this.socket.binaryType = 'arraybuffer';
+
+		// When all these conditions are met, fire statusindicator:initializationComplete
+		map.initConditions = {
+			'docLayer': false,
+			'statusindicatorfinish': false,
+			'StyleApply': false,
+			'CharFontName': false,
+			'updatepermission': false
+		};
+		map.initComplete = false;
+
+		map._fireInitComplete = L.bind(this._fireInitComplete, this);
+		map.on('updatepermission', function(e){
+			if (map.initComplete)
+				return;
+			map._fireInitComplete('updatepermission');
+		}).on('commandstatechanged', function(e){
+			if (map.initComplete)
+				return;
+			if (e.commandName === '.uno:StyleApply')
+				map._fireInitComplete('StyleApply');
+			else if (e.commandName === '.uno:CharFontName')
+				map._fireInitComplete('CharFontName');
+		});
+	},
+
+	_fireInitComplete: function (condition) {
+		if (this._map.initComplete)
+			return;
+
+		this._map.initConditions[condition] = true;
+		for (var key in this._map.initConditions) {
+			if (!this._map.initConditions[key])
+				return;
+		}
+		this._map.fire('statusindicator', {statusType: 'initializationComplete'});
+		this._map.initComplete = true;
 	},
 
 	close: function () {
@@ -171,6 +208,7 @@ L.Socket = L.Class.extend({
 
 			this._map._docLayer = docLayer;
 			this._map.addLayer(docLayer);
+			this._map._fireInitComplete('docLayer');
 		}
 
 		// these can arrive very early during the startup
@@ -185,6 +223,7 @@ L.Socket = L.Class.extend({
 		}
 		else if (textMsg.startsWith('statusindicatorfinish:')) {
 			this._map.fire('statusindicator', {statusType : 'finish'});
+			this._map._fireInitComplete('statusindicatorfinish');
 			return;
 		}
 


More information about the Libreoffice-commits mailing list