summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormert <mert.tumer@collabora.com>2020-02-20 18:36:09 +0300
committerMichael Meeks <michael.meeks@collabora.com>2020-02-21 18:07:02 +0100
commit864749bb1681e352f3c6e63548f31d3ede63422a (patch)
tree9581d51e078f957a304a42b1572c549c7bd53d8a
parentfd3e6fb722dfb1d5da724cff1767bd7dd6ec91ea (diff)
mobile: implemented popup for hyperlinks on calc
Change-Id: I6d22cc1d6b7da8afbb9cce70c3445634455b34d8 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89122 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
-rw-r--r--loleaflet/src/control/Control.Toolbar.js20
-rw-r--r--loleaflet/src/layer/tile/TileLayer.js13
2 files changed, 30 insertions, 3 deletions
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index c627e49cd..6c47153f2 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -2609,7 +2609,25 @@ function setupToolbar(e) {
});
map.on('hyperlinkclicked', function (e) {
- map.fire('warn', {url: e.url, map: map, cmd: 'openlink'});
+ if (e.url) {
+ if (e.coordinates) {
+ var strTwips = e.coordinates.match(/\d+/g);
+ var topLeftTwips = new L.Point(parseInt(strTwips[6]), parseInt(strTwips[1]));
+ var offset = new L.Point(parseInt(strTwips[2]), parseInt(strTwips[3]));
+ var bottomRightTwips = topLeftTwips.add(offset);
+ var cellCursor = new L.LatLngBounds(
+ map._docLayer._twipsToLatLng(topLeftTwips, map.getZoom()),
+ map._docLayer._twipsToLatLng(bottomRightTwips, map.getZoom()));
+ //click pos tweak
+ cellCursor._northEast.lng = cellCursor._southWest.lng;
+ map.hyperlinkPopup = new L.Popup({className: 'hyperlink-popup', closeButton: false, closeOnClick: false})
+ .setContent('<a href="' + e.url + '" target="_blank">' + e.url + '</a>')
+ .setLatLng(cellCursor._northEast)
+ .openOn(map);
+ } else {
+ map.fire('warn', {url: e.url, map: map, cmd: 'openlink'});
+ }
+ }
});
map.on('zoomend', function () {
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index 0939570e3..a0fff8280 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -1093,8 +1093,17 @@ L.TileLayer = L.GridLayer.extend({
},
_onHyperlinkClickedMsg: function (textMsg) {
- var link = textMsg.substring(18);
- this._map.fire('hyperlinkclicked', {url: link});
+ var link = null;
+ var coords = null;
+
+ if (textMsg.includes('coordinates')) {
+ var coordpos = textMsg.indexOf(' coordinates');
+ link = textMsg.substring(18, coordpos);
+ coords = textMsg.substring(coordpos+12);
+ } else
+ link = textMsg.substring(18);
+
+ this._map.fire('hyperlinkclicked', {url: link, coordinates: coords});
},
_onInvalidateCursorMsg: function (textMsg) {