loleaflet/build/deps.js                               |    7 ++
 loleaflet/debug/document/document_simple_example.html |    1 
 loleaflet/dist/leaflet.css                            |    9 +++
 loleaflet/src/control/Control.EditView.js             |   44 ++++++++++++++++++
 loleaflet/src/layer/tile/TileLayer.js                 |   17 ++++++
 5 files changed, 77 insertions(+), 1 deletion(-)

New commits:
commit bd642c3d370aa4b5507fc28f5eaba819894bc60a
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue May 26 20:56:08 2015 +0300

    Make the view/edit text in the control unselectable

diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 1729efb..cd63ccd 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -295,6 +295,15 @@
        font-size: 24px;
        }
 
+/* View / Edit mode control */
+.leaflet-control-editviewswitch {
+       -webkit-touch-callout: none;
+       -webkit-user-select: none;
+       -khtml-user-select: none;
+       -moz-user-select: none;
+       -ms-user-select: none;
+       user-select: none;
+       }
 
 /* layers control */
 
commit 22232e070fa11144a1159670aa27ab0211a4fd68
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue May 26 20:51:19 2015 +0300

    Dragging will be handled in the js code

diff --git a/loleaflet/debug/document/document_simple_example.html 
b/loleaflet/debug/document/document_simple_example.html
index 9bbfd62..9f49456 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -63,7 +63,6 @@
             minZoom: 1,
             maxZoom: 20,
             server: host,
-            dragging: false,
             doubleClickZoom: false
             });
 
commit 77b8e0d1264179fc98c35ec300cdae5f9ec72f85
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue May 26 20:48:59 2015 +0300

    Edit/View switching handler

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index db4f5c7..acbe575 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -63,12 +63,15 @@ L.TileLayer = L.GridLayer.extend({
                        this._map.socket.send('load url=' + this.options.doc);
                        this._map.socket.send('status');
                }
+               this._map.dragging.disable();
                this._map._scrollContainer.onscroll = L.bind(this._onScroll, 
this);
                this._map.on('zoomend resize', this._updateScrollOffset, this);
                this._map.on('clearselection', this._clearSelections, this);
                this._map.on('prevpart nextpart', this._onSwitchPart, this);
                this._map.on('mousedown mouseup mouseover mouseout mousemove 
dblclick',
                                this._onMouseEvent, this);
+               this._map.on('viewmode editmode', this._updateEditViewMode, 
this);
+               this._map.on('drag', this._updateScrollOffset, this);
        },
 
        setUrl: function (url, noRedraw) {
@@ -476,6 +479,20 @@ L.TileLayer = L.GridLayer.extend({
                }
                this._update();
                this._pruneTiles();
+       },
+
+       _updateEditViewMode: function (e) {
+               if (e.type === 'viewmode') {
+                       this._map.dragging.enable();
+                       // disable all user interaction, will need to add 
keyboard too
+                       this._map.off('mousedown mouseup mouseover mouseout 
mousemove dblclick',
+                                       this._onMouseEvent, this);
+               }
+               else if (e.type === 'editmode') {
+                       this._map.dragging.disable();
+                       this._map.on('mousedown mouseup mouseover mouseout 
mousemove dblclick',
+                                       this._onMouseEvent, this);
+               }
        }
 });
 
commit 7b79f0edd5fd6ed9c0eac158f2f95be1c9094378
Author: Mihai Varga <mihai.va...@collabora.com>
Date:   Tue May 26 20:47:45 2015 +0300

    Control for switching between viewing and editing mode

diff --git a/loleaflet/build/deps.js b/loleaflet/build/deps.js
index d1d4fc3..b3e838d 100644
--- a/loleaflet/build/deps.js
+++ b/loleaflet/build/deps.js
@@ -220,6 +220,13 @@ var deps = {
                desc: 'Parts control with two buttons (previous / next).'
        },
 
+       ControlEditViewSwitch: {
+               src: ['control/Control.js',
+                     'control/Control.EditView.js'],
+               heading: 'Controls',
+               desc: 'Switches from viewing to editing mode and backwards'
+       },
+
        ControlAttrib: {
                src: ['control/Control.js',
                      'control/Control.Attribution.js'],
diff --git a/loleaflet/src/control/Control.EditView.js 
b/loleaflet/src/control/Control.EditView.js
new file mode 100644
index 0000000..248c341
--- /dev/null
+++ b/loleaflet/src/control/Control.EditView.js
@@ -0,0 +1,44 @@
+/*
+ * L.Control.EditView is used for switching between viewing and editing mode
+ */
+
+L.Control.EditViewSwitch = L.Control.extend({
+       options: {
+               position: 'topleft',
+       },
+
+       onAdd: function (map) {
+               var partName = 'leaflet-control-editviewswitch',
+                   container = L.DomUtil.create('label', partName + ' 
leaflet-bar');
+
+        this._checkBox = L.DomUtil.create('input', 'editview-cb', container);
+        this._checkBox.type = 'checkbox';
+        L.DomEvent.on(this._checkBox, 'change', this._onChange, this);
+               container.appendChild(document.createTextNode('View only'));
+               return container;
+       },
+
+    _onChange: function() {
+        if (this._checkBox.checked) {
+            this._map.fire('viewmode');
+        }
+        else {
+            this._map.fire('editmode');
+        }
+    }
+});
+
+L.Map.mergeOptions({
+       editViewSwitchControl: true
+});
+
+L.Map.addInitHook(function () {
+       if (this.options.editViewSwitchControl) {
+               this.editViewSwitchControl = new L.Control.EditViewSwitch();
+               this.addControl(this.editViewSwitchControl);
+       }
+});
+
+L.control.editViewSwitch = function (options) {
+       return new L.Control.EditViewSwitch(options);
+};
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to