summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAshod Nakashian <ashod.nakashian@collabora.co.uk>2020-01-13 22:49:48 -0500
committerJan Holesovsky <kendy@collabora.com>2020-01-28 11:43:53 +0100
commit84c0cd277f43552941e8e3b702a85bf6eb9e5bbb (patch)
tree1378a729df112587be55ec91d1629c1ae0fe31e2
parentleaflet: onEditorLostFocus -> onFocusDialog (diff)
downloadonline-84c0cd277f43552941e8e3b702a85bf6eb9e5bbb.tar.gz
online-84c0cd277f43552941e8e3b702a85bf6eb9e5bbb.zip
leaflet: new event to notify of focus change
Change-Id: I30a8a1a2d1a8d46708db5748035e14daa76f5e14
-rw-r--r--loleaflet/src/control/Control.LokDialog.js14
-rw-r--r--loleaflet/src/map/Map.js12
2 files changed, 25 insertions, 1 deletions
diff --git a/loleaflet/src/control/Control.LokDialog.js b/loleaflet/src/control/Control.LokDialog.js
index 6ee870b7de..84513d46f4 100644
--- a/loleaflet/src/control/Control.LokDialog.js
+++ b/loleaflet/src/control/Control.LokDialog.js
@@ -121,6 +121,8 @@ L.Control.LokDialog = L.Control.extend({
map.on('closepopups', this._onClosePopups, this);
map.on('closesidebar', this._closeSidebar, this);
map.on('editorgotfocus', this._onEditorGotFocus, this);
+ // Fired to signal that the input focus is being changed.
+ map.on('changefocuswidget', this._changeFocusWidget, this);
L.DomEvent.on(document, 'mouseup', this.onCloseCurrentPopUp, this);
},
@@ -343,13 +345,15 @@ L.Control.LokDialog = L.Control.extend({
$('#' + strId).dialog('option', 'title', e.title);
}
} else if (e.action === 'cursor_visible') {
+ // cursor_visible means focus has changed.
this._dialogs[e.id].cursorVisible = e.visible === 'true';
if (this._dialogs[e.id].cursorVisible) {
$('#' + strId + '-cursor').css({display: 'block'});
- this._map.onFocusDialog(this, e.id);
+ this._map.fire('changefocuswidget', {winId: e.id, dialog: this}); // Us.
}
else {
$('#' + strId + '-cursor').css({display: 'none'});
+ this._map.fire('changefocuswidget', {winId: 0, dialog: null}); // Editor.
}
} else if (e.action === 'close') {
parent = this._getParentId(e.id);
@@ -955,6 +959,14 @@ L.Control.LokDialog = L.Control.extend({
}
},
+ // Focus is being changed, update states.
+ _changeFocusWidget: function (e) {
+ if (e.winId === 0) {
+ // We lost the focus.
+ this._onEditorGotFocus();
+ }
+ },
+
_paintDialog: function(parentId, rectangle, imgData) {
var strId = this._toStrId(parentId);
var canvas = document.getElementById(strId + '-canvas');
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index 95a30fddfc..2b13de11c0 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -245,6 +245,9 @@ L.Map = L.Evented.extend({
this.on('editorgotfocus', this._onEditorGotFocus, this);
+ // Fired to signal that the input focus is being changed.
+ this.on('changefocuswidget', this._changeFocusWidget, this);
+
// View info (user names and view ids)
this._viewInfo = {};
this._viewInfoByUserName = {};
@@ -1379,6 +1382,15 @@ L.Map = L.Evented.extend({
this._activate();
},
+ // Focus is being changed, update states.
+ _changeFocusWidget: function (e) {
+ if (e.winId === 0) {
+ this._onEditorGotFocus();
+ } else {
+ this.onFocusDialog(e.dialog, e.winId);
+ }
+ },
+
_onUpdateProgress: function (e) {
if (e.statusType === 'start') {
if (this._socket.socket.readyState === 1) {