loleaflet/dist/toolbar/toolbar.js | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-)
New commits: commit e4c0e3706712e188e520d0e06fc0bbc87bf74bf7 Author: Pranav Kant <[email protected]> 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/35471 Reviewed-by: pranavk <[email protected]> Tested-by: pranavk <[email protected]> Reviewed-by: Thorsten Behrens <[email protected]> Tested-by: Thorsten Behrens <[email protected]> diff --git a/loleaflet/dist/toolbar/toolbar.js b/loleaflet/dist/toolbar/toolbar.js index 7d5ab254..87b0bc4f 100644 --- a/loleaflet/dist/toolbar/toolbar.js +++ b/loleaflet/dist/toolbar/toolbar.js @@ -327,6 +327,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', @@ -380,8 +385,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'}, @@ -434,6 +439,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(); } }); @@ -520,21 +534,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; _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
