loleaflet/src/control/Control.Toolbar.js | 6 +--- loleaflet/src/layer/tile/TileLayer.js | 33 +++++++++++++++----------- loleaflet/src/map/handler/Map.TouchGesture.js | 6 ++-- 3 files changed, 25 insertions(+), 20 deletions(-)
New commits: commit 2462bf7a19daa56fe2fea9681587c22e6503c360 Author: mert <mert.tu...@collabora.com> AuthorDate: Wed Feb 26 16:58:30 2020 +0300 Commit: Andras Timar <andras.ti...@collabora.com> CommitDate: Mon Mar 16 15:57:57 2020 +0100 hyperlink popup clean up hyperlink popups shouldnt contain href for links also we shouldnt show popup for internal links core must handle it Change-Id: Ice5535890a6c45cea7a3d9f70b21ad5f9e66f2eb Reviewed-on: https://gerrit.libreoffice.org/c/online/+/89550 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Andras Timar <andras.ti...@collabora.com> diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js index 9e8d87d8c..79d392563 100644 --- a/loleaflet/src/control/Control.Toolbar.js +++ b/loleaflet/src/control/Control.Toolbar.js @@ -2626,10 +2626,8 @@ function setupToolbar(e) { 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); + map._docLayer._closeURLPopUp(); + map._docLayer._showURLPopUp(cellCursor._northEast, e.url); } else { map.fire('warn', {url: e.url, map: map, cmd: 'openlink'}); } diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js index 52660885a..d302dccc4 100644 --- a/loleaflet/src/layer/tile/TileLayer.js +++ b/loleaflet/src/layer/tile/TileLayer.js @@ -1112,6 +1112,21 @@ L.TileLayer = L.GridLayer.extend({ } }, + _showURLPopUp: function(position, url) { + // # for internal links + if (!url.startsWith('#')) { + this._map.hyperlinkPopup = new L.Popup({className: 'hyperlink-popup', closeButton: false, closeOnClick: false}) + .setContent('<div id="hyperlinkpopup" style="color: #000099; text-decoration: underline;">'+url+'</div>') + .setLatLng(position) + .openOn(this._map); + } + }, + + _closeURLPopUp: function() { + this._map.closePopup(this._map.hyperlinkPopup); + this._map.hyperlinkPopup = null; + }, + _onHyperlinkClickedMsg: function (textMsg) { var link = null; var coords = null; @@ -1148,13 +1163,9 @@ L.TileLayer = L.GridLayer.extend({ this._map.lastActionByUser = false; this._map.hyperlinkUnderCursor = obj.hyperlink; - this._map.closePopup(this._map.hyperlinkPopup); - this._map.hyperlinkPopup = null; + this._closeURLPopUp(); if (obj.hyperlink && obj.hyperlink.link) { - this._map.hyperlinkPopup = new L.Popup({className: 'hyperlink-popup', closeButton: false, closeOnClick: false}) - .setContent('<a href="' + obj.hyperlink.link + '" target="_blank">' + obj.hyperlink.link + '</a>') - .setLatLng(cursorPos) - .openOn(this._map); + this._showURLPopUp(cursorPos, obj.hyperlink.link); } if (!this._map.editorHasFocus() && (modifierViewId === this._viewId) && (this._map._permission === 'edit')) { @@ -2915,19 +2926,15 @@ L.TileLayer = L.GridLayer.extend({ targetURL = targetURL.split('"').join(''); targetURL = this._map.makeURLFromStr(targetURL); - this._map.closePopup(this._map.hyperlinkPopup); - this._map.hyperlinkPopup = null; + this._closeURLPopUp(); if (targetURL) { - this._map.hyperlinkPopup = new L.Popup({className: 'hyperlink-popup', closeButton: false, closeOnClick: false}) - .setContent('<a href="' + targetURL + '" target="_blank">' + targetURL + '</a>') - .setLatLng(this._cellCursorMarker._bounds._northEast) - .openOn(this._map); + this._showURLPopUp(this._cellCursorMarker._bounds._northEast, targetURL); } } else if (this._map.hyperlinkPopup) { - this._map.closePopup(this._map.hyperlinkPopup); + this._closeURLPopUp(); } }, diff --git a/loleaflet/src/map/handler/Map.TouchGesture.js b/loleaflet/src/map/handler/Map.TouchGesture.js index 1fc7479c6..20143958f 100644 --- a/loleaflet/src/map/handler/Map.TouchGesture.js +++ b/loleaflet/src/map/handler/Map.TouchGesture.js @@ -326,9 +326,9 @@ L.Map.TouchGesture = L.Handler.extend({ this._toolbar.remove(); // clicked a hyperlink popup - not really designed for this. - if (this._map.hyperlinkPopup && e.target && - this._map.hyperlinkPopup._contentNode == e.target.parentNode) - this._map.fire('hyperlinkclicked', {url: e.target.href}); + if (this._map.hyperlinkPopup && e.target && e.target.id === 'hyperlinkpopup' && + this._map.hyperlinkPopup._contentNode == e.target.parentNode) + this._map.fire('hyperlinkclicked', {url: e.target.innerHTML}); this._map.fire('closepopups'); this._map.fire('closemobilewizard'); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits