summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-03-25 10:45:18 -0400
committerAndras Timar <andras.timar@collabora.com>2020-03-26 17:59:00 +0100
commitaf1dd174b6aba48151bdb9e7286545433a876dad (patch)
tree2475db285f8c97536ba429f091549285ce11bea8
parent2b4e95ef004173be055b1d6592b6ba7c097911a4 (diff)
leaflet: refactor dialog isCursorVisible into member
Safer and more readable. Change-Id: I37b551c0b8f7f445ed09a1ab24e00e06c64e8dad Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91082 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com> Reviewed-by: Andras Timar <andras.timar@collabora.com> Reviewed-on: https://gerrit.libreoffice.org/c/online/+/91135 Tested-by: Andras Timar <andras.timar@collabora.com>
-rw-r--r--loleaflet/src/control/Control.LokDialog.js17
1 files changed, 11 insertions, 6 deletions
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 67387016a..5d9edd5dc 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -158,6 +158,10 @@ L.Control.LokDialog = L.Control.extend({
return (id in this._dialogs) && this._dialogs[id].isCalcInputBar;
},
+ isCursorVisible: function(id) {
+ return (id in this._dialogs) && this._dialogs[id].cursorVisible;
+ },
+
_isSelectionHandle: function(el) {
return L.DomUtil.hasClass(el, 'leaflet-selection-marker-start') ||
L.DomUtil.hasClass(el, 'leaflet-selection-marker-end');
@@ -379,8 +383,9 @@ L.Control.LokDialog = L.Control.extend({
} else if (e.action === 'cursor_visible') {
// cursor_visible implies focus has changed, but can
// be misleading when it flips back on forth on typing!
- this._dialogs[e.id].cursorVisible = e.visible === 'true';
- if (this._dialogs[e.id].cursorVisible) {
+ var visible = (e.visible === 'true');
+ this._dialogs[e.id].cursorVisible = visible;
+ if (visible) {
$('#' + strId + '-cursor').css({display: 'block'});
this._map.fire('changefocuswidget', {winId: e.id, dialog: this, acceptInput: true}); // Us.
}
@@ -407,7 +412,7 @@ L.Control.LokDialog = L.Control.extend({
_updateDialogCursor: function(dlgId, x, y, height) {
var strId = this._toStrId(dlgId);
var dialogCursor = L.DomUtil.get(strId + '-cursor');
- var cursorVisible = dlgId in this._dialogs && this._dialogs[dlgId].cursorVisible;
+ var cursorVisible = this.isCursorVisible(dlgId);
L.DomUtil.setStyle(dialogCursor, 'height', height + 'px');
L.DomUtil.setStyle(dialogCursor, 'display', cursorVisible ? 'block' : 'none');
// set the position of the cursor container element
@@ -574,12 +579,12 @@ L.Control.LokDialog = L.Control.extend({
if (window.mode.isMobile()) {
if (!this.mobileSidebarVisible)
return;
- // On desktop, grab the focus only when there is a visible cursor on the sidebar.
- } else if (!this._isOpen(dlgId) || !this._dialogs[dlgId].cursorVisible) {
+ } else if (!this._isOpen(dlgId) || !this.isCursorVisible(dlgId)) {
+ // On desktop, grab the focus only when there is a visible cursor on the sidebar.
return;
}
}
- else if (this._isCalcInputBar(dlgId) && (!this._isOpen(dlgId) || !this._dialogs[dlgId].cursorVisible)) {
+ else if (this._isCalcInputBar(dlgId) && (!this._isOpen(dlgId) || !this.isCursorVisible(dlgId))) {
return;
}