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

Pranav Kant pranavk at collabora.co.uk
Tue Sep 20 05:49:09 UTC 2016


 loleaflet/dist/toolbar/toolbar.js     |   60 ++--------------------------------
 loleaflet/main.js                     |    2 -
 loleaflet/src/layer/tile/TileLayer.js |   16 ---------
 3 files changed, 6 insertions(+), 72 deletions(-)

New commits:
commit 77e219ceff24dd4a566dfdf4f82a6929fe9a563e
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Tue Sep 20 10:57:39 2016 +0530

    loleaflet: Kill editlock code, completely
    
    Editlock buttons have already been removed; most of this code is
    unreachable/useless anyways.
    
    Don't listen to editlock messages anymore, and always set the map
    permission to edit unless specified.
    
    Change-Id: I2ee672e72beaa48a7c6cd0bbd1c548ff10a251d1

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index f6597f2..8e4e6aa 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -123,13 +123,6 @@ function onClick(id, item, subItem) {
 			map.setPart(id);
 		}
 	}
-	else if (id === 'takeedit') {
-		if (!item.checked) {
-			map._socket.sendMessage('takeedit');
-			// And advertise which page we're on.
-			map._socket.sendMessage('setclientpart part=' + map._docLayer._selectedPart);
-		}
-	}
 	else if (id === 'searchprev') {
 		map.search(L.DomUtil.get('search-input').value, true);
 	}
@@ -496,8 +489,6 @@ var formatButtons = {
 	'incrementindent': true, 'decrementindent': true, 'insertgraphic': true
 };
 
-var takeEditPopupMessage = '<div>' + _('You are viewing now.') + '<br/>' + _('Click here to take edit.') + '</div>';
-var takeEditPopupTimeout = null;
 var userJoinedPopupMessage = '<div>' + _('%user has joined') + '</div>';
 var userLeftPopupMessage = '<div>' + _('%user has left') + '</div>';
 var userPopupTimeout = null;
@@ -1004,7 +995,9 @@ map.on('commandstatechanged', function (e) {
 		}
 		// only store the state for now;
 		// buttons with stored state === enabled will
-		// be enabled when we get the editlock
+		// be enabled later (if we are in editmode)
+		// If we are in viewmode, these store states will be used
+		// when we get the edit access
 		else if (state === 'enabled') {
 			formatButtons[id] = true;
 		}
@@ -1012,8 +1005,7 @@ map.on('commandstatechanged', function (e) {
 			formatButtons[id] = false;
 		}
 
-		// Change the toolbar button state immediately
-		// if we already have the editlock
+		// Change the toolbar button states immediately if we are in editmode
 		if (map._permission === 'edit' && (state === 'enabled' || state === 'disabled')) {
 			// in case some buttons are in toolbar-up-more, find
 			// them and en/dis-able them.
@@ -1211,33 +1203,7 @@ map.on('hyperlinkclicked', function (e) {
 });
 
 map.on('updatepermission', function (e) {
-	var toolbar = w2ui['toolbar-down'];
-	if (e.perm === 'edit') {
-		toolbar.disable('takeedit');
-		toolbar.set('takeedit', {hint: _('You are editing (others can only view)'), caption: _('EDITING')});
-	}
-	else if (e.perm === 'view') {
-		toolbar.enable('takeedit');
-		toolbar.set('takeedit', {hint: _('Take edit lock (others can only view)'), caption: _('VIEWING')});
-		$('#tb_toolbar-down_item_takeedit')
-			.w2overlay({
-				class: 'loleaflet-font',
-				html: takeEditPopupMessage,
-				style: 'padding: 5px'
-			});
-		clearTimeout(takeEditPopupTimeout);
-		takeEditPopupTimeout = setTimeout(function() {
-			$('#tb_toolbar-down_item_takeedit').w2overlay('');
-			clearTimeout(takeEditPopupTimeout);
-			takeEditPopupTimeout = null;
-		}, 3000);
-	}
-	else if (e.perm === 'readonly') {
-		toolbar.disable('takeedit');
-		toolbar.set('takeedit', {hint: _('You are locked in readonly mode'), caption: _('READONLY')});
-	}
-
-	toolbar = w2ui['toolbar-up'];
+	var toolbar = w2ui['toolbar-up'];
 	var toolbarUpMore = w2ui['toolbar-up-more'];
 	// {En,Dis}able toolbar buttons
 	for (var id in formatButtons) {
@@ -1317,22 +1283,6 @@ map.on('updatepermission', function (e) {
 	}
 });
 
-map.on('mouseup keypress', function() {
-	if (map._permission === 'view') {
-		$('#tb_toolbar-down_item_takeedit')
-			.w2overlay({
-				html: takeEditPopupMessage,
-				style: 'padding: 5px'
-			});
-		clearTimeout(takeEditPopupTimeout);
-		takeEditPopupTimeout = setTimeout(function() {
-			$('#tb_toolbar-down_item_takeedit').w2overlay('');
-			clearTimeout(takeEditPopupTimeout);
-			takeEditPopupTimeout = null;
-		}, 3000);
-	}
-});
-
 map.on('statusindicator', function (e) {
 	if (e.statusType === 'loleafletloaded') {
 		var data = [''];
diff --git a/loleaflet/main.js b/loleaflet/main.js
index bf6141e..7ae3246 100644
--- a/loleaflet/main.js
+++ b/loleaflet/main.js
@@ -55,7 +55,7 @@ if (title === '') {
     title = decodeURIComponent(filePath.substring(filePath.lastIndexOf('/')+1));
 }
 
-var permission = getParameterByName('permission');
+var permission = getParameterByName('permission') || 'edit';
 var timestamp = getParameterByName('timestamp');
 // Shows close button if non-zero value provided
 var closebutton = getParameterByName('closebutton');
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 67c5f03..4317e17 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -354,9 +354,6 @@ L.TileLayer = L.GridLayer.extend({
 		else if (textMsg.startsWith('unocommandresult:')) {
 			this._onUnoCommandResultMsg(textMsg);
 		}
-		else if (textMsg.startsWith('editlock:')) {
-			this._onEditLock(textMsg);
-		}
 		else if (textMsg.startsWith('contextmenu:')) {
 			this._onContextMenuMsg(textMsg);
 		}
@@ -1628,19 +1625,6 @@ L.TileLayer = L.GridLayer.extend({
 		}
 	},
 
-	_onEditLock: function (textMsg) {
-		// if we have explicitly set this as readonly,
-		// then never listen server for editlock
-		if (this._map._permission === 'readonly') {
-			return;
-		}
-
-		var perm = parseInt(textMsg.split(' ')[1]) === 1 ? 'edit' : 'view';
-		if (perm !== this._map._permission) {
-			this._map.setPermission(perm);
-		}
-	},
-
 	_invalidatePreviews: function () {
 		if (this._map._docPreviews && this._previewInvalidations.length > 0) {
 			var toInvalidate = {};


More information about the Libreoffice-commits mailing list