loleaflet/src/layer/AnnotationManager.js |   15 ++++++++++++---
 loleaflet/src/map/Map.js                 |    2 ++
 2 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit c62728d3a865c8d2f4e8d0fb4cecb21ee395b50f
Author: Pranav Kant <pran...@collabora.co.uk>
Date:   Wed Apr 19 19:13:25 2017 +0530

    loleaflet: Select and deselect comment upon mouse click
    
    Make comment overlays clickable and when clicked select the
    corresponding annotation. Also deselect when clicked where there is no
    comment overlay.
    
    Change-Id: Id9236862eec86b7508978ad8fe803455e03adbe2
    (cherry picked from commit 4a8caa40e88561cfeb046c83da29b144c287016b)
    Reviewed-on: https://gerrit.libreoffice.org/36695
    Reviewed-by: Jan Holesovsky <ke...@collabora.com>
    Tested-by: Jan Holesovsky <ke...@collabora.com>

diff --git a/loleaflet/src/layer/AnnotationManager.js 
b/loleaflet/src/layer/AnnotationManager.js
index d29b2d46..b3f2d74c 100644
--- a/loleaflet/src/layer/AnnotationManager.js
+++ b/loleaflet/src/layer/AnnotationManager.js
@@ -47,20 +47,23 @@ L.AnnotationManager = L.Class.extend({
 
        adjustComment: function(comment) {
                var rectangles, color, viewId;
+               comment.trackchange = false;
+               rectangles = 
L.PolyUtil.rectanglesToPolygons(L.LOUtil.stringToRectangles(comment.textRange 
|| comment.anchorPos), this._map._docLayer);
                comment.anchorPos = L.LOUtil.stringToBounds(comment.anchorPos);
                comment.anchorPix = 
this._map._docLayer._twipsToPixels(comment.anchorPos.min);
-               comment.trackchange = false;
-               rectangles = 
L.PolyUtil.rectanglesToPolygons(L.LOUtil.stringToRectangles(comment.textRange), 
this._map._docLayer);
                viewId = this._map.getViewId(comment.author);
                color = viewId >= 0 ? 
L.LOUtil.rgbToHex(this._map.getViewColor(viewId)) : '#43ACE8';
                if (rectangles.length > 0) {
                        comment.textSelected = L.polygon(rectangles, {
-                               pointerEvents: 'none',
+                               interactive: true,
                                fillColor: color,
                                fillOpacity: 0.25,
                                weight: 2,
                                opacity: 0.25
                        });
+                       comment.textSelected.on('click', function() {
+                               this.selectById(comment.id);
+                       }, this);
                }
        },
 
@@ -178,6 +181,12 @@ L.AnnotationManager = L.Class.extend({
                }
        },
 
+       selectById: function(commentId) {
+               var idx = this.getRootIndexOf(commentId);
+               this._selected = this._items[idx];
+               this.update();
+       },
+
        update: function () {
                if (this._selected) {
                        var point0, point1, point2;
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index c76d4393..af9f7233 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -979,6 +979,8 @@ L.Map = L.Evented.extend({
                if (type === 'click' && this._permission === 'edit') {
                        this._textArea.blur();
                        this._textArea.focus();
+                       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
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to