loleaflet/src/control/Permission.js | 7 ++++--- loleaflet/src/layer/marker/Marker.js | 13 +++++++++++++ loleaflet/src/layer/tile/TileLayer.js | 10 +++++++++- 3 files changed, 26 insertions(+), 4 deletions(-)
New commits: commit c56ef84129651e04eb904fc0474be72ae4bca8a2 Author: Pranav Kant <pran...@collabora.com> Date: Thu Apr 14 20:27:12 2016 +0530 loleaflet: Disable (graphic)selection markers without editlock Only session with 'edit' permission can move selection handles and graphic selection handles. Change-Id: Idc5cf634a13e201016eb4e4135392b917b622ad5 diff --git a/loleaflet/src/control/Permission.js b/loleaflet/src/control/Permission.js index 5be2554..3fa4d3b 100644 --- a/loleaflet/src/control/Permission.js +++ b/loleaflet/src/control/Permission.js @@ -10,10 +10,11 @@ L.Map.include({ } else if (perm === 'view' || perm === 'readonly') { this.dragging.enable(); + // For time being, treat view/readonly mode as mode without editlock // disable all user interaction, will need to add keyboard too - this._docLayer._onUpdateCursor(); - this._docLayer._clearSelections(); - this._docLayer._onUpdateTextSelection(); + //this._docLayer._onUpdateCursor(); + //this._docLayer._clearSelections(); + //this._docLayer._onUpdateTextSelection(); } this.fire('updatepermission', {perm : perm}); }, diff --git a/loleaflet/src/layer/marker/Marker.js b/loleaflet/src/layer/marker/Marker.js index 1d29485..28bd7b8 100644 --- a/loleaflet/src/layer/marker/Marker.js +++ b/loleaflet/src/layer/marker/Marker.js @@ -24,6 +24,19 @@ L.Marker = L.Layer.extend({ this._latlng = L.latLng(latlng); }, + setDraggable: function(val) { + if (!this.dragging) { + this.options.draggable = val; + return; + } + + if (val) { + this.dragging.enable(); + } else { + this.dragging.disable(); + } + }, + onAdd: function (map) { this._zoomAnimated = this._zoomAnimated && map.options.markerZoomAnimation; diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 07e4523..c7a1172 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -176,6 +176,13 @@ L.TileLayer = L.GridLayer.extend({ }, this); + map.on('updatepermission', function(e) { + // {En,Dis}able selection handles + for (var key in this._selectionHandles) { + this._selectionHandles[key].setDraggable(e.perm === 'edit'); + } + }, this); + for (var key in this._selectionHandles) { this._selectionHandles[key].on('drag dragend', this._onSelectionHandleDrag, this); } @@ -945,7 +952,7 @@ L.TileLayer = L.GridLayer.extend({ // Update group layer selection handler. _onUpdateGraphicSelection: function () { - if (this._graphicSelection && !this._isEmptyRectangle(this._graphicSelection)) { + if (this._graphicSelection && !this._isEmptyRectangle(this._graphicSelection) && this._map._permission === 'edit') { if (this._graphicMarker) { this._graphicMarker.off('editstart editend', this._onGraphicEdit, this); this._map.removeLayer(this._graphicMarker); @@ -1260,6 +1267,7 @@ L.TileLayer = L.GridLayer.extend({ var val = parseInt(textMsg.split(' ')[1]); if (!isNaN(val)) { this._map.fire('editlock', {value: val}); + this._map.setPermission(val ? 'edit' : 'readonly'); } }, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits