loleaflet/src/control/Control.Presentation.js | 46 ++++++++++++++++++-------- 1 file changed, 33 insertions(+), 13 deletions(-)
New commits: commit 4ed8b37e9cd0a118819e4a1d73f5b9d059573ef4 Author: Henry Castro <[email protected]> Date: Sun Feb 7 18:42:12 2016 -0400 loleaflet: rework Control.Presentation.js toolbar items diff --git a/loleaflet/src/control/Control.Presentation.js b/loleaflet/src/control/Control.Presentation.js index 188f252..6cac3ba 100644 --- a/loleaflet/src/control/Control.Presentation.js +++ b/loleaflet/src/control/Control.Presentation.js @@ -2,6 +2,7 @@ * L.Control.Presentation is used for common commands for slides. */ +/* global vex */ L.Control.Presentation = L.Control.extend({ options: { position: 'topleft' @@ -12,9 +13,9 @@ L.Control.Presentation = L.Control.extend({ container = L.DomUtil.create('div', buttonsName + '-container' + ' leaflet-bar'); this._buttons = { - 'insertpage': {title: 'Insert Page', iconName: 'insertpage.png'}, - 'duplicatepage': {title: 'Duplicate Page', iconName: 'duplicatepage.png'}, - 'deletepage': {title: 'Delete Page', iconName: 'deletepage.png'} + 'insertpage': {title: 'Insert Page', uno: 'InsertPage', iconName: 'insertpage.png'}, + 'duplicatepage': {title: 'Duplicate Page', uno: 'DuplicatePage', iconName: 'duplicatepage.png'}, + 'deletepage': {title: 'Delete Page', uno: 'DeletePage', iconName: 'deletepage.png'} }; for (var key in this._buttons) { @@ -23,20 +24,23 @@ L.Control.Presentation = L.Control.extend({ buttonsName, container, this._onButtonClick); } - map.on('updateparts', this._updateDisabled, this); + map.on('commandstatechanged', this._onStateChange, this); + map.on('updatepermission', this._onPermissionUpdate, this); return container; }, - _updateDisabled: function (e) { - if (e.docType === 'presentation') { - return; - } - - for (var key in this._buttons) { - var button = this._buttons[key]; - L.DomUtil.addClass(button.el, 'leaflet-disabled'); - L.DomUtil.addClass(button.el, 'leaflet-control-buttons-disabled'); + _onPermissionUpdate: function (e) { + for (var id in this._buttons) { + var button = this._buttons[id]; + if (button.uno) { + if (e.perm !== 'edit' || this._map.getDocType() !== 'presentation') { + L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-disabled'); + } + else { + L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled'); + } + } } }, @@ -77,6 +81,22 @@ L.Control.Presentation = L.Control.extend({ } }, + _onStateChange: function (e) { + var commandName = e.commandName; + var enabled = e.state; + for (var key in this._buttons) { + var button = this._buttons[key]; + if ('.uno:' + button.uno === commandName) { + if (enabled === 'true' && this._map._docLayer._permission === 'edit') { + L.DomUtil.removeClass(button.el.firstChild, 'leaflet-control-buttons-disabled'); + } + else if (enabled === 'false') { + L.DomUtil.addClass(button.el.firstChild, 'leaflet-control-buttons-disabled'); + } + } + } + }, + _onDelete: function (e) { if (e !== false) { this._map.deletePage(); _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
