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

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Sat Dec 15 20:54:35 UTC 2018


 loleaflet/js/toolbar.js  |  108 +++++++++++------------------------------------
 loleaflet/src/map/Map.js |    1 
 2 files changed, 27 insertions(+), 82 deletions(-)

New commits:
commit 3cb37c86078699c055c6951a1686e899696ae394
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Sat Dec 15 21:51:30 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 21:53:39 2018 +0100

    loleaflet: do not register event handlers multiple times
    
    E.g. users were counted 2x in desktop mode, 3x in mobile mode.
    
    Change-Id: Ia7215558a5f1bef2c053e16b61a02c0f9d96d9c1

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index dd1a54c2c..c2088739b 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1002,10 +1002,6 @@ function initMobileToolbar(toolItems) {
 			L.DomEvent.preventDefault(e);
 		}
 	});
-
-	map.on('deselectuser', deselectUser);
-	map.on('addview', onAddView);
-	map.on('removeview', onRemoveView);
 }
 
 function initNormalToolbar(toolItems) {
@@ -2539,8 +2535,6 @@ function setupToolbar(e) {
 
 	map.on('doclayerinit', onDocLayerInit);
 	map.on('wopiprops', onWopiProps);
-	map.on('addview', onAddView);
-	map.on('removeview', onRemoveView);
 	map.on('updatepermission', onUpdatePermission);
 	map.on('commandresult', onCommandResult);
 	map.on('updateparts pagenumberchanged', onUpdateParts);
commit 854330b934e6b58c4398a81e98e66baaa085189f
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Sat Dec 15 21:30:30 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 21:30:30 2018 +0100

    loleaflet: when we hide userlist, we should hide userlistbreak, too
    
    Change-Id: I54e85a601b0200ab4f9a1c1e3d4dbd1d7e41a631

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index a0c209bd6..dd1a54c2c 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -2359,8 +2359,10 @@ function updateUserListCount() {
 
 	if (count > 1) {
 		$('#tb_actionbar_item_userlist').show();
+		$('#tb_actionbar_item_userlistbreak').show();
 	} else {
 		$('#tb_actionbar_item_userlist').hide();
+		$('#tb_actionbar_item_userlistbreak').hide();
 	}
 }
 
commit a0b31751e32dfac9f3ec411ab2642724209fffcb
Author:     Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Wed Dec 12 19:03:09 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 20:27:37 2018 +0100

    Fix show/hide toolbar items mechanism
    
    Change-Id: I4afa61123b4b1ed98e67d2b3cac08544b7b99bdb

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 10b0065a3..a0c209bd6 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -58,8 +58,8 @@ function _updateVisibilityForToolbar(toolbar) {
 	console.log('explicitly hiding: ' + toHide);
 	console.log('explicitly showing: ' + toShow);
 
-	toolbar.hide(toHide);
-	toolbar.show(toShow);
+	toHide.forEach(function(item) { toolbar.hide(item); });
+	toShow.forEach(function(item) { toolbar.show(item); });
 }
 
 function _updateToolbarsVisibility() {
@@ -806,7 +806,7 @@ function createToolbar() {
 		{type: 'button',  id: 'insertsymbol', img: 'insertsymbol', hint: _UNO('.uno:InsertSymbol', '', true), uno: 'InsertSymbol'},
 		{type: 'spacer'},
 		{type: 'button',  id: 'edit',  img: 'edit'},
-		{type: 'button',  id: 'fold',  img: 'fold', mobile: false},
+		{type: 'button',  id: 'fold',  img: 'fold', mobile: false, hidden: true},
 		{type: 'button',  id: 'hamburger-tablet',  img: 'hamburger', desktop: false, mobile: false, tablet: true, hidden: true}
 	];
 
commit 768ea329131fc6bf17544fac788848473d7d6e81
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Tue Dec 11 16:50:30 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 20:23:43 2018 +0100

    toolbar: Allow the mobile / tablet items start in the hidden state.
    
    Change-Id: Iae2dc8a71f729ed0d31bbf3a0428f7010abe9c50

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 60d2a270d..10b0065a3 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -38,59 +38,33 @@ global.mode = {
 
 var nUsers, oneUser, noUser;
 
-function _mobilify() {
-	var toolbarUp = w2ui['editbar'];
-	var statusbar = w2ui['actionbar'];
+function _updateVisibilityForToolbar(toolbar) {
+	var isDesktop = _inDesktopMode();
+	var isMobile = _inMobileMode();
+	var isTablet = _inTabletMode();
 
-	toolbarUp.items.forEach(function(item) {
-		if ((item.mobile === false ||
-		     (!window.ThisIsAMobileApp && item.mobilebrowser === false)) && !item.hidden) {
-			toolbarUp.hide(item.id);
-		}
-	});
+	var toShow = [];
+	var toHide = [];
 
-	statusbar.items.forEach(function(item) {
-		if (item.mobile === false && !item.hidden) {
-			statusbar.hide(item.id);
+	toolbar.items.forEach(function(item) {
+		if (((isMobile && item.mobile === false) || (isTablet && item.tablet === false) || (isDesktop && item.desktop === false) || (!window.ThisIsAMobileApp && item.mobilebrowser === false)) && !item.hidden) {
+			toHide.push(item.id);
+		}
+		else if (((isMobile && item.mobile === true) || (isTablet && item.tablet === true) || (isDesktop && item.desktop === true) || (window.ThisIsAMobileApp && item.mobilebrowser === true)) && item.hidden) {
+			toShow.push(item.id);
 		}
 	});
 
-	if (_inTabletMode()) {
-		toolbarUp.items.forEach(function(item) {
-			if (item.tablet === false && !item.hidden) {
-				toolbarUp.hide(item.id);
-			}
-			else if (item.tablet === true && item.hidden) {
-				toolbarUp.show(item.id);
-			}
-		});
+	console.log('explicitly hiding: ' + toHide);
+	console.log('explicitly showing: ' + toShow);
 
-		statusbar.items.forEach(function(item) {
-			if (item.tablet === false && !item.hidden) {
-				statusbar.hide(item.id);
-			}
-			else if (item.tablet === true && item.hidden) {
-				statusbar.show(item.id);
-			}
-		});
-	}
+	toolbar.hide(toHide);
+	toolbar.show(toShow);
 }
 
-function _prepareDesktop() {
-	var toolbarUp = w2ui['editbar'];
-	var statusbar = w2ui['actionbar'];
-
-	toolbarUp.items.forEach(function(item) {
-		if (item.desktop === false && !item.hidden) {
-			toolbarUp.hide(item.id);
-		}
-	});
-
-	statusbar.items.forEach(function(item) {
-		if (item.desktop === false && !item.hidden) {
-			statusbar.hide(item.id);
-		}
-	});
+function _updateToolbarsVisibility() {
+	_updateVisibilityForToolbar(w2ui['editbar']);
+	_updateVisibilityForToolbar(w2ui['actionbar']);
 }
 
 function resizeToolbar() {
@@ -689,7 +663,7 @@ var fontsizesSelectValue;
 
 function createToolbar() {
 	var toolItems = [
-		{type: 'button',  id: 'closemobile',  img: 'closemobile', desktop: false, mobile: false, tablet: true},
+		{type: 'button',  id: 'closemobile',  img: 'closemobile', desktop: false, mobile: false, tablet: true, hidden: true},
 		{type: 'button',  id: 'save', img: 'save', hint: _UNO('.uno:Save')},
 		{type: 'button',  id: 'print', img: 'print', hint: _UNO('.uno:Print', 'text'), mobile: false},
 		{type: 'break', id: 'savebreak', mobile: false},
@@ -833,7 +807,7 @@ function createToolbar() {
 		{type: 'spacer'},
 		{type: 'button',  id: 'edit',  img: 'edit'},
 		{type: 'button',  id: 'fold',  img: 'fold', mobile: false},
-		{type: 'button',  id: 'hamburger-tablet',  img: 'hamburger', desktop: false, mobile: false, tablet: true}
+		{type: 'button',  id: 'hamburger-tablet',  img: 'hamburger', desktop: false, mobile: false, tablet: true, hidden: true}
 	];
 
 	if (_inMobileMode()) {
@@ -1736,8 +1710,9 @@ function onDocLayerInit() {
 		map.signingInitializeBar();
 	}
 
+	_updateToolbarsVisibility();
+
 	if (L.Browser.mobile) {
-		_mobilify();
 		nUsers = '%n';
 		oneUser = '1';
 		noUser = '0';
@@ -1747,10 +1722,6 @@ function onDocLayerInit() {
 		oneUser = _('1 user');
 		noUser = _('0 users');
 		$('#document-name-input').show();
-
-		if (_inDesktopMode()) {
-			_prepareDesktop();
-		}
 	}
 
 	updateUserListCount();
commit ad3af4fe9aa51241f8ea66c81d011706bc09759d
Author:     Jan Holesovsky <kendy at collabora.com>
AuthorDate: Fri Nov 16 15:20:33 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 19:43:26 2018 +0100

    mobile: Re-introduce the user list in the mobile version.
    
    Revert "loleaflet: remove user list" and several other bits that are
    needed for the users list functionality.
    
    Change-Id: Iee294630c2af5240394a848bbce0156d691ef7a0

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index e2c437b54..60d2a270d 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -1028,6 +1028,10 @@ function initMobileToolbar(toolItems) {
 			L.DomEvent.preventDefault(e);
 		}
 	});
+
+	map.on('deselectuser', deselectUser);
+	map.on('addview', onAddView);
+	map.on('removeview', onRemoveView);
 }
 
 function initNormalToolbar(toolItems) {
@@ -2273,8 +2277,6 @@ function onUpdatePermission(e) {
 	}
 }
 
-
-
 function onUseritemClicked(e) { // eslint-disable-line no-unused-vars
 	var docLayer = map._docLayer;
 	var viewId = parseInt(e.currentTarget.id.replace('user-', ''));
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index bad0ac53a..122c74aee 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -1399,6 +1399,7 @@ L.Map = L.Evented.extend({
 			}
 		}
 		else {
+			this.fire('deselectuser', {viewId: this._docLayer._followThis});
 			this._docLayer._followThis = -1;
 		}
 	},
commit d1c019841db4e1656d8f904b3ad9a449e0072f5f
Author:     Andras Timar <andras.timar at collabora.com>
AuthorDate: Sat Dec 15 19:31:05 2018 +0100
Commit:     Andras Timar <andras.timar at collabora.com>
CommitDate: Sat Dec 15 19:31:05 2018 +0100

    loleaflet: use onRemoveView function
    
    Change-Id: I5f2ffda6ee45810fc063b57e8dd9f7a0174a5055

diff --git a/loleaflet/js/toolbar.js b/loleaflet/js/toolbar.js
index 3991ae1be..e2c437b54 100644
--- a/loleaflet/js/toolbar.js
+++ b/loleaflet/js/toolbar.js
@@ -2562,35 +2562,10 @@ function setupToolbar(e) {
 		}
 	});
 
-	map.on('removeview', function(e) {
-		$('#tb_actionbar_item_userlist')
-			.w2overlay({
-				class: 'loleaflet-font',
-				html: userLeftPopupMessage.replace('%user', e.username),
-				style: 'padding: 5px'
-			});
-		clearTimeout(userPopupTimeout);
-		userPopupTimeout = setTimeout(function() {
-			$('#tb_actionbar_item_userlist').w2overlay('');
-			clearTimeout(userPopupTimeout);
-			userPopupTimeout = null;
-		}, 3000);
-
-		if (e.viewId === map._docLayer._followThis) {
-			map._docLayer._followThis = -1;
-			map._docLayer._followUser = false;
-		}
-
-		var userlistItem = w2ui['actionbar'].get('userlist');
-		if (userlistItem !== null) {
-			userlistItem.html = $(userlistItem.html).find('#user-' + e.viewId).remove().end()[0].outerHTML;
-			updateUserListCount();
-		}
-	});
-
 	map.on('doclayerinit', onDocLayerInit);
 	map.on('wopiprops', onWopiProps);
 	map.on('addview', onAddView);
+	map.on('removeview', onRemoveView);
 	map.on('updatepermission', onUpdatePermission);
 	map.on('commandresult', onCommandResult);
 	map.on('updateparts pagenumberchanged', onUpdateParts);


More information about the Libreoffice-commits mailing list