[Libreoffice-commits] online.git: 2 commits - loleaflet/debug loleaflet/dist loleaflet/src
Mihai Varga
mihai.varga at collabora.com
Mon Jun 29 06:45:35 PDT 2015
loleaflet/debug/document/document_simple_example.html | 4 ++
loleaflet/dist/leaflet.css | 6 ++--
loleaflet/src/control/Control.EditView.js | 25 ++++++++++++++----
loleaflet/src/layer/tile/TileLayer.js | 17 ++++++------
4 files changed, 35 insertions(+), 17 deletions(-)
New commits:
commit 5ccda335ef4129e69f94bfc9c782f7cc71db55ac
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Mon Jun 29 16:43:47 2015 +0300
Start in edit mode by specifying it in the URL
http://.../host=host_address&file_path=file_path&edit=true
diff --git a/loleaflet/debug/document/document_simple_example.html b/loleaflet/debug/document/document_simple_example.html
index 8e2fb3f..d6b4f26 100644
--- a/loleaflet/debug/document/document_simple_example.html
+++ b/loleaflet/debug/document/document_simple_example.html
@@ -51,6 +51,7 @@
var filePath = getParameterByName('file_path');
var host = getParameterByName('host');
+ var editMode = getParameterByName('edit') === 'true';
if (filePath === '') {
alert('Wrong file_path, usage: file_path=/path/to/doc/');
}
@@ -70,7 +71,8 @@
////// Document layer ////
var docLayer = new L.TileLayer('', {
doc: filePath,
- useSocket : true
+ useSocket : true,
+ editMode: editMode
});
map.addLayer(docLayer);
diff --git a/loleaflet/src/control/Control.EditView.js b/loleaflet/src/control/Control.EditView.js
index 69874a8..c81787d 100644
--- a/loleaflet/src/control/Control.EditView.js
+++ b/loleaflet/src/control/Control.EditView.js
@@ -7,18 +7,19 @@ L.Control.EditViewSwitch = L.Control.extend({
position: 'topleft'
},
- onAdd: function () {
+ 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);
+ map.on('updatemode:view updatemode:edit', this._onUpdateMode, this);
container.appendChild(document.createTextNode('Enable editing'));
return container;
},
- _onChange: function() {
+ _onChange: function () {
var className = 'leaflet-editmode';
if (this._checkBox.checked) {
this._map.fire('editmode');
@@ -28,6 +29,20 @@ L.Control.EditViewSwitch = L.Control.extend({
this._map.fire('viewmode');
L.DomUtil.removeClass(this._map._container, className);
}
+ },
+
+ _onUpdateMode: function (e) {
+ var className = 'leaflet-editmode';
+ if (e.type === 'updatemode:edit') {
+ this._map.fire('editmode');
+ L.DomUtil.addClass(this._map._container, className);
+ this._checkBox.checked = true;
+ }
+ else if (e.type === 'updatemode:view') {
+ this._map.fire('viewmode');
+ L.DomUtil.removeClass(this._map._container, className);
+ this._checkBox.checked = false;
+ }
}
});
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index cb58afd..0c31520 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -168,7 +168,6 @@ L.TileLayer = L.GridLayer.extend({
this._map.socket.send('load url=' + this.options.doc);
this._map.socket.send('status');
}
- this._map.dragging.enable();
this._map._scrollContainer.onscroll = L.bind(this._onScroll, this);
this._map.on('zoomend resize', this._updateScrollOffset, this);
this._map.on('clearselection', this._clearSelections, this);
@@ -178,6 +177,9 @@ L.TileLayer = L.GridLayer.extend({
this._map.on('copy', this._onCopy, this);
this._startMarker.on('drag dragend', this._onSelectionHandleDrag, this);
this._endMarker.on('drag dragend', this._onSelectionHandleDrag, this);
+ if (this.options.editMode) {
+ this._map.fire('updatemode:edit');
+ }
},
getEvents: function () {
commit cfa891206357a3c902280ac46bfd954e1cc82c08
Author: Mihai Varga <mihai.varga at collabora.com>
Date: Mon Jun 29 15:54:25 2015 +0300
Start loleaflet in viewing mode
diff --git a/loleaflet/dist/leaflet.css b/loleaflet/dist/leaflet.css
index 25038ee..c192339 100644
--- a/loleaflet/dist/leaflet.css
+++ b/loleaflet/dist/leaflet.css
@@ -180,7 +180,7 @@
cursor: pointer;
}
.leaflet-container {
- cursor: text;
+ cursor: pointer;
}
.leaflet-crosshair,
.leaflet-crosshair .leaflet-interactive {
@@ -196,8 +196,8 @@
cursor: -webkit-grabbing;
cursor: -moz-grabbing;
}
-.leaflet-viewmode {
- cursor: pointer;
+.leaflet-editmode {
+ cursor: text;
}
/* visual tweaks */
diff --git a/loleaflet/src/control/Control.EditView.js b/loleaflet/src/control/Control.EditView.js
index 6032017..69874a8 100644
--- a/loleaflet/src/control/Control.EditView.js
+++ b/loleaflet/src/control/Control.EditView.js
@@ -14,18 +14,18 @@ L.Control.EditViewSwitch = L.Control.extend({
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'));
+ container.appendChild(document.createTextNode('Enable editing'));
return container;
},
_onChange: function() {
- var className = 'leaflet-viewmode';
+ var className = 'leaflet-editmode';
if (this._checkBox.checked) {
- this._map.fire('viewmode');
+ this._map.fire('editmode');
L.DomUtil.addClass(this._map._container, className);
}
else {
- this._map.fire('editmode');
+ this._map.fire('viewmode');
L.DomUtil.removeClass(this._map._container, className);
}
}
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 28013ca..cb58afd 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -168,13 +168,11 @@ 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.dragging.enable();
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);
this._map.on('copy', this._onCopy, this);
@@ -703,8 +701,6 @@ L.TileLayer = L.GridLayer.extend({
this._mouseEventsQueue.push(L.bind(function() {
this._postMouseEvent('buttondown', mousePos.x, mousePos.y, 1);}, this));
this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), 500);
-
- this._editMode = true;
}
else if (e.type === 'mouseup') {
this._selecting = false;
@@ -726,7 +722,6 @@ L.TileLayer = L.GridLayer.extend({
}, this));
this._holdMouseEvent = setTimeout(L.bind(this._executeMouseEvents, this), 250);
- this._editMode = true;
if (this._startMarker._icon) {
L.DomUtil.removeClass(this._startMarker._icon, 'leaflet-not-clickable');
}
@@ -793,11 +788,17 @@ L.TileLayer = L.GridLayer.extend({
// disable all user interaction, will need to add keyboard too
this._map.off('mousedown mouseup mouseover mouseout mousemove dblclick',
this._onMouseEvent, this);
+ this._editMode = false;
+ this._onUpdateCursor();
+ this._clearSelections();
+ this._onUpdateTextSelection();
}
else if (e.type === 'editmode') {
+ this._editMode = true;
this._map.dragging.disable();
this._map.on('mousedown mouseup mouseover mouseout mousemove dblclick',
this._onMouseEvent, this);
+ this._map._container.focus();
}
},
@@ -860,7 +861,6 @@ L.TileLayer = L.GridLayer.extend({
this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
this._cursorMarker = L.cursor(this._visibleCursor.getNorthWest());
- this._map._bDisableKeyboard = true;
this._map.addLayer(this._cursorMarker);
this._cursorMarker.setSize(pixBounds.getSize());
@@ -875,7 +875,6 @@ L.TileLayer = L.GridLayer.extend({
}
}
else if (this._cursorMarker) {
- this._map._bDisableKeyboard = false;
this._map.removeLayer(this._cursorMarker);
this._isCursorOverlayVisible = false;
}
More information about the Libreoffice-commits
mailing list