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

Pranav Kant pranavk at collabora.co.uk
Sat Dec 17 20:28:15 UTC 2016


 loleaflet/dist/toolbar/toolbar.js |   36 +++++++++++++++++++-----------------
 1 file changed, 19 insertions(+), 17 deletions(-)

New commits:
commit c927448d3cdd8b87b007fa2c810abe147c2c5218
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 16 22:08:17 2016 +0530

    loleaflet: Cleanup & fix default numbering/bullet state
    
    Automatically initialize formatButtons internal object to
    preclude the possibility of one forgetting to enter the id of the
    button in formatButtons object.
    
    Fix 'id' of default numbering/bullet button after which it is
    correctly showing the state now.
    
    Change-Id: I57247e1b0e6d462153a47d31a883ceb04ecff74b
    Reviewed-on: https://gerrit.libreoffice.org/32101
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit d1a3d365b01400907486ee8b57884465fd3073a2)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 8eb1215..2c14936 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -328,6 +328,11 @@ function onColorPick(e, color) {
 	map.focus();
 }
 
+// This object is used to store enabled/disabled state of each and every eligible item
+// (i.e the one having UNO command) of toolbar-up. When the permission is changed to/from
+// edit/view mode, state from this object is read and then applied on corresponding buttons
+var formatButtons = {};
+
 $(function () {
 	$('#toolbar-up-more').w2toolbar({
 		name: 'toolbar-up-more',
@@ -379,8 +384,8 @@ $(function () {
 			{type: 'button',  id: 'sortascending',  img: 'sortascending', hint: _('Sort Ascending'), uno: 'SortAscending'},
 			{type: 'button',  id: 'sortdescending',  img: 'sortdescending', hint: _('Sort Descending'), uno: 'SortDescending'},
 			{type: 'break',   id: 'break-align'},
-			{type: 'button',  id: 'bullet',  img: 'bullet', hint: _('Bullets on/off'), uno: 'DefaultBullet'},
-			{type: 'button',  id: 'numbering',  img: 'numbering', hint: _('Numbering on/off'), uno: 'DefaultNumbering'},
+			{type: 'button',  id: 'defaultbullet',  img: 'bullet', hint: _('Bullets on/off'), uno: 'DefaultBullet'},
+			{type: 'button',  id: 'defaultnumbering',  img: 'numbering', hint: _('Numbering on/off'), uno: 'DefaultNumbering'},
 			{type: 'break',   id: 'break-numbering'},
 			{type: 'button',  id: 'incrementindent',  img: 'incrementindent', hint: _('Increase indent'), uno: 'IncrementIndent'},
 			{type: 'button',  id: 'decrementindent',  img: 'decrementindent', hint: _('Decrease indent'), uno: 'DecrementIndent'},
@@ -433,6 +438,15 @@ $(function () {
 				}
 			}
 
+			// Intialize the formatButtons object
+			if (Object.keys(formatButtons).length === 0) {
+				for (var itemIdx in w2ui['toolbar-up'].items) {
+					if (w2ui['toolbar-up'].items[itemIdx].uno) {
+						formatButtons[w2ui['toolbar-up'].items[itemIdx].id] = true;
+					}
+				}
+			}
+
 			insertTable();
 		}
 	});
@@ -519,21 +533,6 @@ $(function () {
 	});
 });
 
-// This object is used to track enabled/disabled state when one is in view mode
-var formatButtons = {
-	'undo': true, 'redo': true, 'save': true,
-	'bold': true, 'italic': true, 'underline': true, 'strikeout': true,
-	'insertannotation': true, 'inserttable': true,
-	'fontcolor': true, 'backcolor': true, 'bullet': true, 'numbering': true,
-	'alignleft': true, 'alignhorizontal': true, 'alignright': true, 'alignblock': true,
-	'incrementindent': true, 'decrementindent': true, 'insertgraphic': true,
-	'insertfootnote': true, 'repair': true, 'specialcharacter': true,
-	'wraptext': true, 'togglemergecells': true, 'numberformatcurrency': true,
-	'numberformatpercent': true, 'numberformatdecimal': true, 'numberformatdate': true,
-	'numberformatincdecimals': true, 'numberformatdecdecimals': true,
-	'sortascending': true, 'sortdescending': true
-};
-
 var userJoinedPopupMessage = '<div>' + _('%user has joined') + '</div>';
 var userLeftPopupMessage = '<div>' + _('%user has left') + '</div>';
 var userPopupTimeout = null;
commit 995af107f30a03414fe4fd4b3c8115c803fbb139
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Dec 16 20:15:40 2016 +0530

    Handle enabled/disabled, true/false toolbar button states
    
    If we get a true/false, assume its enabled.
    
    Change-Id: I364c7cd611481757b674877ed44ac6ee0f6b0e58
    Reviewed-on: https://gerrit.libreoffice.org/32089
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>
    (cherry picked from commit 56cb689a6457a5e3b9f8b7c60155b9d114584f77)
    Signed-off-by: Andras Timar <andras.timar at collabora.com>

diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js
index 29524cf..8eb1215 100644
--- a/loleaflet/dist/toolbar/toolbar.js
+++ b/loleaflet/dist/toolbar/toolbar.js
@@ -1026,10 +1026,12 @@ map.on('commandstatechanged', function (e) {
 	var id = commandName.toLowerCase().substr(5);
 	if (typeof formatButtons[id] !== 'undefined') {
 		if (state === 'true') {
+			toolbar.enable(id);
 			toolbar.check(id);
 			toolbarUpMore.check(id);
 		}
 		else if (state === 'false') {
+			toolbar.enable(id);
 			toolbar.uncheck(id);
 			toolbarUpMore.uncheck(id);
 		}
@@ -1053,6 +1055,7 @@ map.on('commandstatechanged', function (e) {
 				toolbar.enable(id);
 				toolbarUpMore.enable(id);
 			} else {
+				toolbar.uncheck(id);
 				toolbar.disable(id);
 				toolbarUpMore.disable(id);
 			}


More information about the Libreoffice-commits mailing list