[Libreoffice-commits] online.git: loleaflet/src
Libreoffice Gerrit user
logerrit at kemper.freedesktop.org
Wed Aug 8 20:16:12 UTC 2018
loleaflet/src/layer/marker/ClipboardContainer.js | 20 ++++++++++++--
loleaflet/src/layer/tile/TileLayer.js | 32 ++++++++++++-----------
2 files changed, 36 insertions(+), 16 deletions(-)
New commits:
commit 6a70fe02c6db3570dc4c5650fc046a25814c4806
Author: Henry Castro <hcastro at collabora.com>
AuthorDate: Sun Aug 5 18:30:16 2018 -0400
Commit: Henry Castro <hcastro at collabora.com>
CommitDate: Wed Aug 8 16:15:39 2018 -0400
loleaflet: mobile: show the cursor only if clipContainer is focused
Change-Id: I209952df810d23b244e8b963304115fd81e30a81
diff --git a/loleaflet/src/layer/marker/ClipboardContainer.js b/loleaflet/src/layer/marker/ClipboardContainer.js
index aa6d42a99..cb7b74a9a 100644
--- a/loleaflet/src/layer/marker/ClipboardContainer.js
+++ b/loleaflet/src/layer/marker/ClipboardContainer.js
@@ -18,7 +18,9 @@ L.ClipboardContainer = L.Layer.extend({
L.DomEvent.on(this._textArea, 'copy cut paste ' +
'keydown keypress keyup ' +
'compositionstart compositionupdate compositionend textInput',
- this._map._handleDOMEvent, this._map);
+ this._map._handleDOMEvent, this._map)
+ .on(this._textArea, 'focus', this.onGotFocus, this)
+ .on(this._textArea, 'blur', this.onLostFocus, this);
},
onRemove: function () {
@@ -29,10 +31,24 @@ L.ClipboardContainer = L.Layer.extend({
L.DomEvent.off(this._textArea, 'copy cut paste ' +
'keydown keypress keyup ' +
'compositionstart compositionupdate compositionend textInput',
- this._map._handleDOMEvent, this._map);
+ this._map._handleDOMEvent, this._map)
+ .off(this._textArea, 'focus', this.onGotFocus, this)
+ .off(this._textArea, 'blur', this.onLostFocus, this);
+ },
+
+ onGotFocus: function () {
+ this.setLatLng(this._map._docLayer._updateCursorPos());
+ },
+
+ onLostFocus: function () {
+ this._map.removeLayer(this._map._docLayer._cursorMarker);
},
focus: function(focus) {
+ if (this._map._permission !== 'edit') {
+ return;
+ }
+
if (focus === false) {
this._textArea.blur();
} else {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 2d2a25fb6..15292feda 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1538,6 +1538,22 @@ L.TileLayer = L.GridLayer.extend({
this._onUpdateCursor();
},
+ _updateCursorPos: function () {
+ var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
+ this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
+ var cursorPos = this._visibleCursor.getNorthWest();
+
+ if (!this._cursorMarker) {
+ this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
+ }
+ else {
+ this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
+ }
+
+ this._map.addLayer(this._cursorMarker);
+ return this._visibleCursor.getNorthWest();
+ },
+
// Update cursor layer (blinking cursor).
_onUpdateCursor: function (scroll) {
var cursorPos = this._visibleCursor.getNorthWest();
@@ -1570,23 +1586,11 @@ L.TileLayer = L.GridLayer.extend({
// the state of the document (if the falgs are set)
_updateCursorAndOverlay: function (/*update*/) {
if (this._map._permission === 'edit'
+ && this._map._clipboardContainer._textArea === document.activeElement
&& this._isCursorVisible
&& this._isCursorOverlayVisible
&& !this._isEmptyRectangle(this._visibleCursor)) {
-
- var pixBounds = L.bounds(this._map.latLngToLayerPoint(this._visibleCursor.getSouthWest()),
- this._map.latLngToLayerPoint(this._visibleCursor.getNorthEast()));
-
- var cursorPos = this._visibleCursor.getNorthWest();
-
- if (!this._cursorMarker) {
- this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
- }
- else {
- this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
- }
- this._map.addLayer(this._cursorMarker);
- this._map._clipboardContainer.setLatLng(this._visibleCursor.getNorthWest());
+ this._updateCursorPos();
}
else if (this._cursorMarker) {
this._map.removeLayer(this._cursorMarker);
More information about the Libreoffice-commits
mailing list