[Libreoffice-commits] online.git: 2 commits - loleaflet/src
Pranav Kant
pranavk at collabora.co.uk
Wed Apr 26 07:47:56 UTC 2017
loleaflet/src/layer/AnnotationManager.js | 23 +++++++++++++++++++----
loleaflet/src/map/Map.js | 13 +++++++++----
2 files changed, 28 insertions(+), 8 deletions(-)
New commits:
commit e3ef5d01afa5773e5562a5e5a30274c0d4ee1761
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Apr 26 13:15:10 2017 +0530
loleaflet: Allow mouse clicks to pass through comment/redline selection
Otherwise, it was not possible to use the mouse to click on the text
beneath the text selection svg layer. This simulates a mouse click on
the document after selecting the comment.
Change-Id: Ia2717a0a4356f40e31db94b68563abffc87cac37
diff --git a/loleaflet/src/layer/AnnotationManager.js b/loleaflet/src/layer/AnnotationManager.js
index eff34d7d..f35c7588 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -57,13 +57,21 @@ L.AnnotationManager = L.Class.extend({
color = viewId >= 0 ? L.LOUtil.rgbToHex(this._map.getViewColor(viewId)) : '#43ACE8';
if (rectangles.length > 0) {
comment.textSelected = L.polygon(rectangles, {
- interactive: true,
+ pointerEvents: 'all',
+ interactive: false,
fillColor: color,
fillOpacity: 0.25,
weight: 2,
opacity: 0.25
});
- comment.textSelected.on('click', function() {
+ 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
this.selectById(comment.id);
}, this);
}
@@ -88,11 +96,18 @@ L.AnnotationManager = L.Class.extend({
color = viewId >= 0 ? L.LOUtil.rgbToHex(this._map.getViewColor(viewId)) : '#43ACE8';
if (rectangles.length > 0) {
redline.textSelected = L.polygon(rectangles, {
- interactive: true,
+ pointerEvents: 'all',
+ interactive: false,
fillOpacity: 0,
opacity: 0
});
- redline.textSelected.on('click', function() {
+ 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);
+
this.selectById(redline.id);
}, this);
}
commit 91421bae3d09ba15a71db3101d21b3b08b5de0d2
Author: Pranav Kant <pranavk at collabora.co.uk>
Date: Wed Apr 26 13:15:03 2017 +0530
loleaflet: Allow selecting annotations in readonly mode too
Change-Id: I5c58baf95a1cbbb2ffbe756de30e596e2c35e6fb
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 3a2ce54d..755d99d0 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -981,11 +981,16 @@ L.Map = L.Evented.extend({
// For touch devices, to pop-up the keyboard, it is required to call
// .focus() method on hidden input within actual 'click' event here
// Calling from some other place with no real 'click' event doesn't work
- if (type === 'click' && this._permission === 'edit') {
- this._textArea.blur();
- this._textArea.focus();
- if (this._docLayer && this._docLayer._annotations && this._docLayer._annotations.unselect)
+ if (type === 'click') {
+ if (this._permission === 'edit') {
+ this._textArea.blur();
+ this._textArea.focus();
+ }
+
+ // unselect if anything is selected already
+ if (this._docLayer && this._docLayer._annotations && this._docLayer._annotations.unselect) {
this._docLayer._annotations.unselect();
+ }
}
// we need to keep track if we have entered/left the map
More information about the Libreoffice-commits
mailing list