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

Pranav Kant pranavk at collabora.com
Wed Apr 20 11:21:21 UTC 2016


 loleaflet/dist/toolbar/toolbar.js     |   21 +++++++++++++++++++++
 loleaflet/src/control/Permission.js   |    7 +++----
 loleaflet/src/layer/tile/TileLayer.js |   21 +++++++++++++++++----
 3 files changed, 41 insertions(+), 8 deletions(-)

New commits:
commit 616cb5f451940beb76acaa60ba385934c9fa2535
Author: Pranav Kant <pranavk at collabora.com>
Date:   Wed Apr 20 16:45:39 2016 +0530

    bccu#1689: Show a popup when non-editlock view tries to edit
    
    Show a popup on 'mousedown' and 'keypress' events for
    non-editlock modes.
    
    Change-Id: I3a8a964d6a507549f521f3f831a4c623d202c86c

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 9953090..3e3e0e7 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -898,6 +898,17 @@ map.on('editlock', function (e) {
 	});
 });
 
+map.on('mousedown keypress', function(e) {
+	if (!map._editlock) {
+		$('#takeeditlabel')
+			.w2tag('Click to take edit')
+			.html('VIEWING');
+		setTimeout(function() {
+			$('#takeeditlabel').w2tag('');
+		}, 3000);
+	}
+});
+
 map.on('locontextmenu', function (e) {
 	// TODO: context menu handling...
 });
commit 14b672bf5f098286349e2a0a668b365968e2b87a
Author: Pranav Kant <pranavk at collabora.com>
Date:   Wed Apr 20 16:15:36 2016 +0530

    bccu#1707: Do not mix editlock with permissions
    
    For some reason, text cursor gets stuck making it impossible to
    type in the document. This only happens with firefox + owncloud.
    
    Lets keep the editlock state separately in map, and do not yet
    mix the permissions with editlock state.
    
    Change-Id: If4193d08b7228cde510321ec5b4c892b8617d8a7

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 7a33cf6..9953090 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -886,6 +886,16 @@ map.on('editlock', function (e) {
 			$('#takeeditlabel').w2tag('');
 		}, 3000);
 	}
+
+	toolbar = w2ui['toolbar-up'];
+	// {En,Dis}able toolbar buttons
+	formatButtons.forEach(function (id) {
+		if (e.value) {
+			toolbar.enable(id);
+		} else {
+			toolbar.disable(id);
+		}
+	});
 });
 
 map.on('locontextmenu', function (e) {
diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js
index 3fa4d3b..5be2554 100644
--- a/loleaflet/src/control/Permission.js
+++ b/loleaflet/src/control/Permission.js
@@ -10,11 +10,10 @@ L.Map.include({
 		}
 		else if (perm === 'view' || perm === 'readonly') {
 			this.dragging.enable();
-			// For time being, treat view/readonly mode as mode without editlock
 			// disable all user interaction, will need to add keyboard too
-			//this._docLayer._onUpdateCursor();
-			//this._docLayer._clearSelections();
-			//this._docLayer._onUpdateTextSelection();
+			this._docLayer._onUpdateCursor();
+			this._docLayer._clearSelections();
+			this._docLayer._onUpdateTextSelection();
 		}
 		this.fire('updatepermission', {perm : perm});
 	},
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 9a8dbe9..477492d 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -176,10 +176,10 @@ L.TileLayer = L.GridLayer.extend({
 			},
 		this);
 
-		map.on('updatepermission', function(e) {
+		map.on('editlock', function(e) {
 			// {En,Dis}able selection handles
 			for (var key in this._selectionHandles) {
-				this._selectionHandles[key].setDraggable(e.perm === 'edit');
+				this._selectionHandles[key].setDraggable(e.value);
 			}
 		}, this);
 
@@ -951,16 +951,22 @@ L.TileLayer = L.GridLayer.extend({
 
 	// Update group layer selection handler.
 	_onUpdateGraphicSelection: function () {
-		if (this._graphicSelection && !this._isEmptyRectangle(this._graphicSelection) && this._map._permission === 'edit') {
+		if (this._graphicSelection && !this._isEmptyRectangle(this._graphicSelection)) {
 			if (this._graphicMarker) {
 				this._graphicMarker.off('editstart editend', this._onGraphicEdit, this);
 				this._map.removeLayer(this._graphicMarker);
 			}
+
+			if (!this._map._editlock) {
+				return;
+			}
+
 			this._graphicMarker = L.rectangle(this._graphicSelection, {fill: false});
 			if (!this._graphicMarker) {
 				this._map.fire('error', {msg: 'Graphic marker initialization', cmd: 'marker', kind: 'failed', id: 1});
 				return;
 			}
+
 			this._graphicMarker.editing.enable();
 			this._graphicMarker.on('editstart editend', this._onGraphicEdit, this);
 			this._map.addLayer(this._graphicMarker);
@@ -1265,8 +1271,15 @@ L.TileLayer = L.GridLayer.extend({
 	_onEditLock: function (textMsg) {
 		var val = parseInt(textMsg.split(' ')[1]);
 		if (!isNaN(val)) {
+			this._map._editlock = val;
 			this._map.fire('editlock', {value: val});
-			this._map.setPermission(val ? 'edit' : 'readonly');
+
+			// we want graphic selection handles to appear ...
+			// when editlock is taken, and dissappear when it is taken away
+			if (!val) {
+				this._graphicSelection = null;
+			}
+			this._onUpdateGraphicSelection();
 		}
 	},
 


More information about the Libreoffice-commits mailing list