[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/src

Pranav Kant pranavk at collabora.co.uk
Fri Mar 30 13:29:48 UTC 2018


 loleaflet/src/layer/marker/Cursor.js  |   34 +---------------------------------
 loleaflet/src/layer/tile/TileLayer.js |   28 ++++++++++++++++------------
 loleaflet/src/map/Map.js              |   16 +++++++++++++---
 3 files changed, 30 insertions(+), 48 deletions(-)

New commits:
commit 1c1880093c7c4bc4de16526c89750d0a6ca2dec8
Author: Pranav Kant <pranavk at collabora.co.uk>
Date:   Fri Mar 30 00:47:08 2018 +0530

    Revert everything related to putting clipboard inside cursor-cont.
    
    Revert "Only create clipboard for one cursor"
    This reverts commit 98b53ae956782ce7366a2d4b29e80ce31b748058.
    
    Revert "Fix for incorrect map positioning"
    This reverts commit 950b60719abefeca07c65add6dda2f7ae0aeb.
    
    Revert "Move the clipboard-container directly into the cursor."
    This reverts commit e293b7faeed12b7a71786ded970bebd4d998c47b.
    
    Change-Id: Ie5ebcc7a645f6ef1cdbc9fd90bcdef22de54df95
    Reviewed-on: https://gerrit.libreoffice.org/52131
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/marker/Cursor.js b/loleaflet/src/layer/marker/Cursor.js
index c370aa13e..792a13485 100644
--- a/loleaflet/src/layer/marker/Cursor.js
+++ b/loleaflet/src/layer/marker/Cursor.js
@@ -16,24 +16,13 @@ L.Cursor = L.Layer.extend({
 		this._initLayout();
 	},
 
-	onAdd: function (map) {
-		this._map = map;
-
+	onAdd: function () {
 		if (!this._container) {
 			this._initLayout();
 		}
 
 		this.update();
 		this.getPane().appendChild(this._container);
-
-		if (this._textArea && !this._map._textArea) {
-			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 () {
@@ -75,16 +64,6 @@ L.Cursor = L.Layer.extend({
 		}
 	},
 
-	show: function() {
-		L.DomUtil.setStyle(this._container, 'visibility', 'visible');
-		if (this._textArea)
-			this._textArea.focus();
-	},
-
-	hide: function() {
-		L.DomUtil.setStyle(this._container, 'visibility', 'hidden');
-	},
-
 	showCursorHeader: function() {
 		if (this._cursorHeader) {
 			L.DomUtil.setStyle(this._cursorHeader, 'visibility', 'visible');
@@ -121,17 +100,6 @@ L.Cursor = L.Layer.extend({
 		L.DomEvent
 			.disableClickPropagation(this._cursor)
 			.disableScrollPropagation(this._container);
-
-		if (this.options.clipboard) {
-			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 6b79a6429..de9351666 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -286,6 +286,8 @@ 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);
 
@@ -1446,18 +1448,20 @@ L.TileLayer = L.GridLayer.extend({
 			var cursorPos = this._visibleCursor.getNorthWest();
 
 			if (!this._cursorMarker) {
-				this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true, clipboard: true});
-				this._map.addLayer(this._cursorMarker);
-
-				this._textArea = this._cursorMarker._textArea;
+				this._cursorMarker = L.cursor(cursorPos, pixBounds.getSize().multiplyBy(this._map.getZoomScale(this._map.getZoom())), {blink: true});
 			}
 			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._cursorMarker.hide();
+			this._map.removeLayer(this._cursorMarker);
 			this._isCursorOverlayVisible = false;
 		}
 	},
@@ -1877,9 +1881,9 @@ L.TileLayer = L.GridLayer.extend({
 	_onCopy: function (e) {
 		e = e.originalEvent;
 		e.preventDefault();
-		if (this._textArea.value !== '') {
-			L.Compatibility.clipboardSet(e, this._textArea.value);
-			this._textArea.value = '';
+		if (this._map._docLayer._textArea.value !== '') {
+			L.Compatibility.clipboardSet(e, this._map._docLayer._textArea.value);
+			this._map._docLayer._textArea.value = '';
 		} else if (this._selectionTextContent) {
 			L.Compatibility.clipboardSet(e, this._selectionTextContent);
 
@@ -1893,9 +1897,9 @@ L.TileLayer = L.GridLayer.extend({
 	_onCut: function (e) {
 		e = e.originalEvent;
 		e.preventDefault();
-		if (this._textArea.value !== '') {
-			L.Compatibility.clipboardSet(e, this._textArea.value);
-			this._textArea.value = '';
+		if (this._map._docLayer._textArea.value !== '') {
+			L.Compatibility.clipboardSet(e, this._map._docLayer._textArea.value);
+			this._map._docLayer._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 cf1fb7216..7cbca20a4 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._textArea && document.activeElement !== this._textArea) {
+		if (this._docLayer && document.activeElement !== this._docLayer._textArea) {
 			console.debug('focus: focussing');
-			this._textArea.focus();
+			this._docLayer._textArea.focus();
 		}
 	},
 
@@ -692,6 +692,14 @@ 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');
@@ -821,7 +829,8 @@ L.Map = L.Evented.extend({
 
 		L.DomEvent[onOff](this._container, 'click dblclick mousedown mouseup ' +
 			'mouseover mouseout mousemove contextmenu dragover drop ' +
-			'trplclick qdrplclick', this._handleDOMEvent, this);
+			'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);
 
 		if (this.options.trackResize && this._resizeDetector.contentWindow) {
 			L.DomEvent[onOff](this._resizeDetector.contentWindow, 'resize', this._onResize, this);
@@ -1063,6 +1072,7 @@ L.Map = L.Evented.extend({
 		// Calling from some other place with no real 'click' event doesn't work
 		if (type === 'click') {
 			if (this._permission === 'edit') {
+				this._textArea.blur();
 				this._textArea.focus();
 			}
 


More information about the Libreoffice-commits mailing list