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

Henry Castro hcastro at collabora.com
Thu Feb 15 15:36:57 UTC 2018


 loleaflet/src/layer/AnnotationManager.js |   19 ++++---------------
 loleaflet/src/layer/marker/Annotation.js |    4 +++-
 2 files changed, 7 insertions(+), 16 deletions(-)

New commits:
commit a5250566f98645b2bee03aa86fcf261a5824e9c8
Author: Henry Castro <hcastro at collabora.com>
Date:   Thu Feb 1 21:43:15 2018 -0400

    loleaflet: propagate text selected events to parent element
    
    Change-Id: I9b88c42b6bf40dfe856e92f345633855234c7a5d
    Reviewed-on: https://gerrit.libreoffice.org/49126
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-by: pranavk <pranavk at collabora.co.uk>
    Tested-by: pranavk <pranavk at collabora.co.uk>

diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index c3e9b9a2..5636456b 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -70,15 +70,9 @@ L.AnnotationManager = L.Class.extend({
 				weight: 2,
 				opacity: 0.25
 			});
+			comment.textSelected.addEventParent(this._map);
 			L.DomEvent.on(comment.textSelected, 'contextmenu', L.DomEvent.preventDefault);
-			comment.textSelected.on('click', function(e) {
-				// Simulate a click at this position in the document
-				var latlng = this._map.mouseEventToLatLng(e.originalEvent);
-				var pos = this._map._docLayer._latLngToTwips(latlng);
-				this._map._docLayer._postMouseEvent('buttondown', pos.x, pos.y, 1, 1, 0);
-				this._map._docLayer._postMouseEvent('buttonup', pos.x, pos.y, 1, 1, 0);
-
-				// Also select this comment
+			comment.textSelected.on('click', function() {
 				this.selectById(comment.id);
 			}, this);
 		}
@@ -108,14 +102,9 @@ L.AnnotationManager = L.Class.extend({
 				fillOpacity: 0,
 				opacity: 0
 			});
+			redline.textSelected.addEventParent(this._map);
 			L.DomEvent.on(redline.textSelected, 'contextmenu', L.DomEvent.preventDefault);
-			redline.textSelected.on('click', function(e) {
-				// Simulate a click at this position in the document
-				var latlng = this._map.mouseEventToLatLng(e.originalEvent);
-				var pos = this._map._docLayer._latLngToTwips(latlng);
-				this._map._docLayer._postMouseEvent('buttondown', pos.x, pos.y, 1, 1, 0);
-				this._map._docLayer._postMouseEvent('buttonup', pos.x, pos.y, 1, 1, 0);
-
+			redline.textSelected.on('click', function() {
 				this.selectById(redline.id);
 			}, this);
 		}
diff --git a/loleaflet/src/layer/marker/Annotation.js b/loleaflet/src/layer/marker/Annotation.js
index 9682034d..73c4b560 100644
--- a/loleaflet/src/layer/marker/Annotation.js
+++ b/loleaflet/src/layer/marker/Annotation.js
@@ -37,7 +37,8 @@ L.Annotation = L.Layer.extend({
 	onRemove: function (map) {
 		map._panes.popupPane.removeChild(this._container);
 		if (this._data.textSelected) {
-			this._map.removeLayer(this._data.textSelected);
+			this._data.textSelected.removeEventParent(map);
+			map.removeLayer(this._data.textSelected);
 		}
 		this._map = null;
 	},
@@ -52,6 +53,7 @@ L.Annotation = L.Layer.extend({
 
 	setData: function (data) {
 		if (this._data.textSelected) {
+			this._data.textSelected.removeEventParent(this._map);
 			this._map.removeLayer(this._data.textSelected);
 		}
 		this._data = data;


More information about the Libreoffice-commits mailing list