[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/src
Jan Holesovsky
kendy at collabora.com
Thu Mar 29 08:38:11 UTC 2018
loleaflet/src/layer/marker/Cursor.js | 29 ++++++++++++++++++++++++++++-
loleaflet/src/layer/tile/TileLayer.js | 26 +++++++++++---------------
loleaflet/src/map/Map.js | 15 +++------------
3 files changed, 42 insertions(+), 28 deletions(-)
New commits:
commit e293b7faeed12b7a71786ded970bebd4d998c47b
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Mar 28 14:50:12 2018 +0200
Move the clipboard-container directly into the cursor.
Fixes a nasty additional browser's scrollbar that sometimes appearead on
PgDown.
Change-Id: I1b629de51fb5f82dceb007105eb4c3ee1d411d22
Reviewed-on: https://gerrit.libreoffice.org/52002
Reviewed-by: Andras Timar <andras.timar at collabora.com>
Tested-by: Andras Timar <andras.timar at collabora.com>
diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js
index 792a13485..1189d9f1a 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -16,13 +16,22 @@ L.Cursor = L.Layer.extend({
this._initLayout();
},
- onAdd: function () {
+ onAdd: function (map) {
+ this._map = map;
+
if (!this._container) {
this._initLayout();
}
this.update();
this.getPane().appendChild(this._container);
+
+ this._map._textArea = this._textArea;
+
+ L.DomEvent['off'](this._textArea, 'copy cut paste keydown keypress keyup compositionstart compositionupdate compositionend textInput', this._map._handleDOMEvent, this._map);
+ L.DomEvent['on'](this._textArea, 'copy cut paste keydown keypress keyup compositionstart compositionupdate compositionend textInput', this._map._handleDOMEvent, this._map);
+
+ this._textArea.focus();
},
onRemove: function () {
@@ -64,6 +73,15 @@ L.Cursor = L.Layer.extend({
}
},
+ show: function() {
+ L.DomUtil.setStyle(this._container, 'visibility', 'visible');
+ this._textArea.focus();
+ },
+
+ hide: function() {
+ L.DomUtil.setStyle(this._container, 'visibility', 'hidden');
+ },
+
showCursorHeader: function() {
if (this._cursorHeader) {
L.DomUtil.setStyle(this._cursorHeader, 'visibility', 'visible');
@@ -100,6 +118,15 @@ L.Cursor = L.Layer.extend({
L.DomEvent
.disableClickPropagation(this._cursor)
.disableScrollPropagation(this._container);
+
+ var textAreaContainer = L.DomUtil.create('div', 'clipboard-container', this._container);
+ textAreaContainer.id = 'doc-clipboard-container';
+ this._textArea = L.DomUtil.create('input', 'clipboard', textAreaContainer);
+ this._textArea.setAttribute('type', 'text');
+ this._textArea.setAttribute('autocorrect', 'off');
+ this._textArea.setAttribute('autocapitalize', 'off');
+ this._textArea.setAttribute('autocomplete', 'off');
+ this._textArea.setAttribute('spellcheck', 'false');
},
_setPos: function (pos) {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index de9351666..e0286f3cd 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -286,8 +286,6 @@ L.TileLayer = L.GridLayer.extend({
for (var key in this._selectionHandles) {
this._selectionHandles[key].on('drag dragend', this._onSelectionHandleDrag, this);
}
- this._textArea = map._textArea;
- this._textArea.focus();
map.setPermission(this.options.permission);
@@ -1449,19 +1447,17 @@ L.TileLayer = L.GridLayer.extend({
if (!this._cursorMarker) {
this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
+ this._map.addLayer(this._cursorMarker);
+
+ this._textArea = this._cursorMarker._textArea;
}
else {
+ this._cursorMarker.show();
this._cursorMarker.setLatLng(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())));
}
- this._map.addLayer(this._cursorMarker);
-
- // move the hidden input field with the cursor
- var clipContainer = L.DomUtil.get('doc-clipboard-container');
- var pos = this._map.latLngToContainerPoint(L.latLng(this._visibleCursor.getCenter())).round();
- L.DomUtil.setPosition(clipContainer, pos);
}
else if (this._cursorMarker) {
- this._map.removeLayer(this._cursorMarker);
+ this._cursorMarker.hide();
this._isCursorOverlayVisible = false;
}
},
@@ -1881,9 +1877,9 @@ L.TileLayer = L.GridLayer.extend({
_onCopy: function (e) {
e = e.originalEvent;
e.preventDefault();
- if (this._map._docLayer._textArea.value !== '') {
- L.Compatibility.clipboardSet(e, this._map._docLayer._textArea.value);
- this._map._docLayer._textArea.value = '';
+ if (this._textArea.value !== '') {
+ L.Compatibility.clipboardSet(e, this._textArea.value);
+ this._textArea.value = '';
} else if (this._selectionTextContent) {
L.Compatibility.clipboardSet(e, this._selectionTextContent);
@@ -1897,9 +1893,9 @@ L.TileLayer = L.GridLayer.extend({
_onCut: function (e) {
e = e.originalEvent;
e.preventDefault();
- if (this._map._docLayer._textArea.value !== '') {
- L.Compatibility.clipboardSet(e, this._map._docLayer._textArea.value);
- this._map._docLayer._textArea.value = '';
+ if (this._textArea.value !== '') {
+ L.Compatibility.clipboardSet(e, this._textArea.value);
+ this._textArea.value = '';
} else if (this._selectionTextContent) {
L.Compatibility.clipboardSet(e, this._selectionTextContent);
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 94f60dfa9..a30b2d507 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -662,9 +662,9 @@ L.Map = L.Evented.extend({
focus: function () {
console.debug('focus:');
- if (this._docLayer && document.activeElement !== this._docLayer._textArea) {
+ if (this._textArea && document.activeElement !== this._textArea) {
console.debug('focus: focussing');
- this._docLayer._textArea.focus();
+ this._textArea.focus();
}
},
@@ -692,14 +692,6 @@ L.Map = L.Evented.extend({
throw new Error('Map container is already initialized.');
}
- var textAreaContainer = L.DomUtil.create('div', 'clipboard-container', container.parentElement);
- textAreaContainer.id = 'doc-clipboard-container';
- this._textArea = L.DomUtil.create('input', 'clipboard', textAreaContainer);
- this._textArea.setAttribute('type', 'text');
- this._textArea.setAttribute('autocorrect', 'off');
- this._textArea.setAttribute('autocapitalize', 'off');
- this._textArea.setAttribute('autocomplete', 'off');
- this._textArea.setAttribute('spellcheck', 'false');
this._resizeDetector = L.DomUtil.create('iframe', 'resize-detector', container);
this._fileDownloader = L.DomUtil.create('iframe', '', container);
L.DomUtil.setStyle(this._fileDownloader, 'display', 'none');
@@ -823,8 +815,7 @@ L.Map = L.Evented.extend({
L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
'mouseover mouseout mousemove contextmenu dragover drop ' +
- 'keydown keypress keyup trplclick qdrplclick', this._handleDOMEvent, this);
- L.DomEvent[onOff](this._textArea, 'copy cut paste keydown keypress keyup compositionstart compositionupdate compositionend textInput', this._handleDOMEvent, this);
+ 'trplclick qdrplclick', this._handleDOMEvent, this);
if (this.options.trackResize && this._resizeDetector.contentWindow) {
L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
More information about the Libreoffice-commits
mailing list