[Libreoffice-commits] online.git: Branch 'distro/collabora/milestone-4' - 2 commits - loleaflet/dist loleaflet/src

Mihai Varga mihai.varga at collabora.com
Fri Aug 7 02:24:34 PDT 2015


 loleaflet/dist/leaflet.css               |    5 +++++
 loleaflet/src/control/Control.Buttons.js |   23 +++++++++++++++++++++--
 loleaflet/src/layer/tile/TileLayer.js    |   11 +++++++----
 3 files changed, 33 insertions(+), 6 deletions(-)

New commits:
commit e3ef6a75fb1e2b1c511f71f077a5e53a436492ca
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 7 12:22:19 2015 +0300

    loleaflet: disable buttons in viewing mode

diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 2c8beca..477f86f 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -329,10 +329,15 @@ a.leaflet-control-buttons:first-child,
 a.leaflet-control-buttons:hover:first-child {
 	margin-left: 0px;
 	}
+
 .leaflet-control-buttons-active {
 	border: thin solid;
 	}
 
+.leaflet-control-buttons-disabled{
+	opacity: 0.5;
+	}
+
 .leaflet-control-button-separator {
 	width: 14px;
 	height: 1px;
diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 3c971c7..dd7625c 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -33,6 +33,7 @@ L.Control.Buttons = L.Control.extend({
 				buttonsName, container, this._onButtonClick);
 		}
 		map.on('commandstatechanged', this._onStateChange, this);
+		map.on('updatepermission', this._onPermissionUpdate, this);
 
 		return container;
 	},
@@ -64,7 +65,7 @@ L.Control.Buttons = L.Control.extend({
 				callback: L.bind(this._onSaveAs, this)
 			});
 		}
-		else {
+		else if (this._map._docLayer._permission === 'edit') {
 			this._map.toggleCommandState(button.uno);
 		}
 	},
@@ -81,6 +82,12 @@ L.Control.Buttons = L.Control.extend({
 				else if (state === 'false') {
 					L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-active');
 				}
+				else if (state === 'enabled' && this._map._docLayer._permission === 'edit') {
+					L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
+				}
+				else if (state === 'disabled') {
+					L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
+				}
 			}
 		}
 	},
@@ -99,6 +106,18 @@ L.Control.Buttons = L.Control.extend({
 		if (e !== false) {
 			this._map.saveAs(e.url, e.format, e.options);
 		}
+	},
+
+	_onPermissionUpdate: function (e) {
+		for (var key in this._buttons) {
+			var button = this._buttons[key];
+			if (e.perm !== 'edit') {
+				L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
+			}
+			else {
+				L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled');
+			}
+		}
 	}
 });
 
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 1d815cc..bcda4aa 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -116,12 +116,15 @@ L.TileLayer = L.GridLayer.extend({
 		this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
 		this._textArea = this._map._textArea;
 		this._textArea.focus();
-		if (this.options.edit && !this.options.readOnly) {
-			this._map.setPermission('edit');
-		}
 		if (this.options.readOnly) {
 			this._map.setPermission('readonly');
 		}
+		else if (this.options.edit) {
+			this._map.setPermission('edit');
+		}
+		else {
+			this._map.setPermission('view');
+		}
 		this._map.fire('statusindicator', {statusType: 'loleafletloaded'});
 	},
 
commit 54f00fae191e5be5f5f87131f5f9cfa6e4761e70
Author: Mihai Varga <mihai.varga at collabora.com>
Date:   Fri Aug 7 11:48:31 2015 +0300

    loleaflet: forgot to rename command state event

diff --git a/loleaflet/src/control/Control.Buttons.js b/loleaflet/src/control/Control.Buttons.js
index 076c642..3c971c7 100644
--- a/loleaflet/src/control/Control.Buttons.js
+++ b/loleaflet/src/control/Control.Buttons.js
@@ -32,7 +32,7 @@ L.Control.Buttons = L.Control.extend({
 			button.el = this._createButton(key, button.title, button.iconName,
 				buttonsName, container, this._onButtonClick);
 		}
-		map.on('statechanged', this._onStateChange, this);
+		map.on('commandstatechanged', this._onStateChange, this);
 
 		return container;
 	},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 05a820f..1d815cc 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -341,7 +341,7 @@ L.TileLayer = L.GridLayer.extend({
 			var unoCmd = unoMsg.match('.uno:(.*)=')[1];
 			var state = unoMsg.match('.*=(.*)')[1];
 			if (unoCmd && state) {
-				this._map.fire('statechanged', {unoCmd : unoCmd, state : state});
+				this._map.fire('commandstatechanged', {unoCmd : unoCmd, state : state});
 			}
 		}
 		else if (textMsg.startsWith('status:')) {


More information about the Libreoffice-commits mailing list