diff options
author | Szymon Kłos <szymon.klos@collabora.com> | 2021-09-02 09:56:15 +0200 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2021-09-14 13:20:25 +0200 |
commit | 7762ac768e06c755a9072cdb8835b4afd97769ae (patch) | |
tree | 68f4532c3d0aef5b8945ea22e27c9cab280882df | |
parent | leaflet: avoid font picker overlapping menu dropdowns (diff) | |
download | online-7762ac768e06c755a9072cdb8835b4afd97769ae.tar.gz online-7762ac768e06c755a9072cdb8835b4afd97769ae.zip |
jsdialog: prevent from document losing focus on toolbutton click
Signed-off-by: Szymon Kłos <szymon.klos@collabora.com>
Change-Id: I350c9887d588b0e765040aead239c486ee0c7021
-rw-r--r-- | loleaflet/src/control/Control.JSDialogBuilder.js | 15 | ||||
-rw-r--r-- | loleaflet/src/control/Control.NotebookbarBuilder.js | 21 |
2 files changed, 35 insertions, 1 deletions
diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js index b8dd840abb..158b259212 100644 --- a/loleaflet/src/control/Control.JSDialogBuilder.js +++ b/loleaflet/src/control/Control.JSDialogBuilder.js @@ -223,6 +223,13 @@ L.Control.JSDialogBuilder = L.Control.extend({ L.ColorPicker.ID = 0; }, + _preventDocumentLosingFocusOnClick: function(div) { + $(div).on('mousedown',function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + }, + _toolitemHandler: function(parentContainer, data, builder) { if (data.command || data.postmessage) { var handler = builder._toolitemHandlers[data.command]; @@ -1974,6 +1981,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ $('#' + parentData.id + ' .ui-treeview-entry').removeClass('selected'); builder.callback('iconview', 'activate', parentData, entry.row, builder); }); + builder._preventDocumentLosingFocusOnClick(parentContainer); } }, @@ -2473,7 +2481,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ controls['arrow'] = arrow; } - $(div).on('click.toolbutton',function () { + $(div).on('click.toolbutton',function (e) { if (!$(div).hasClass('disabled')) { builder.refreshSidebar = true; if (data.postmessage) @@ -2481,8 +2489,12 @@ L.Control.JSDialogBuilder = L.Control.extend({ else builder.callback('toolbutton', 'click', button, data.command, builder); } + e.preventDefault(); + e.stopPropagation(); }); + builder._preventDocumentLosingFocusOnClick(div); + if (data.enabled === 'false' || data.enabled === false) $(button).prop('disabled', true); if (window.mode.isMobile()) @@ -2673,6 +2685,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ $(sectionTitle).click(function () { builder.callback('toolbutton', 'click', sectionTitle, data.command, builder); }); + builder._preventDocumentLosingFocusOnClick(sectionTitle); return false; }, diff --git a/loleaflet/src/control/Control.NotebookbarBuilder.js b/loleaflet/src/control/Control.NotebookbarBuilder.js index 5601b9b2b0..1288afd175 100644 --- a/loleaflet/src/control/Control.NotebookbarBuilder.js +++ b/loleaflet/src/control/Control.NotebookbarBuilder.js @@ -457,6 +457,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ } }); }); + builder._preventDocumentLosingFocusOnClick(div); } return false; @@ -469,6 +470,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.showHyperlinkDialog(); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _headerFooterControl: function(parentContainer, data, builder) { @@ -482,6 +484,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ builder.callback('toolbutton', 'click', control.button, command, builder); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _insertTextBoxControl: function(parentContainer, data, builder) { @@ -491,6 +494,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.sendUnoCommand(data.command + '?CreateDirectly:bool=true'); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _showResolvedAnnotationsControl: function(parentContainer, data, builder) { @@ -503,6 +507,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ val = (val === 'true' || val === true); builder.map.showResolvedComments(!val); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _onlineHelpControl: function(parentContainer, data, builder) { @@ -512,6 +517,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { L.control.menubar()._executeAction.bind({_map: builder.options.map})(undefined, {id: data.id}); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _insertTableControl: function(parentContainer, data, builder) { @@ -529,6 +535,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ }); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _shapesControl: function(parentContainer, data, builder) { @@ -550,6 +557,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ }); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _conditionalFormatControl: function(parentContainer, data, builder) { @@ -566,6 +574,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ }); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _borderStyleControl: function(parentContainer, data, builder) { @@ -582,6 +591,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ }); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _insertGraphicControl: function(parentContainer, data, builder) { @@ -608,12 +618,14 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ L.DomUtil.get('insertgraphic').click(); } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _insertAnnotationControl: function(parentContainer, data, builder) { var control = builder._unoToolButton(parentContainer, data, builder); $(control.container).unbind('click.toolbutton'); $(control.container).click(function () {builder.map.insertComment();}); + builder._preventDocumentLosingFocusOnClick(control.container); }, _clipboardButtonControl: function(parentContainer, data, builder) { @@ -625,6 +637,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ builder.map._clip.filterExecCopyPaste(data.command); }); } + builder._preventDocumentLosingFocusOnClick(control.container); }, _lineSpacingControl: function(parentContainer, data, builder) { @@ -657,6 +670,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ } }); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _symbolControl: function(parentContainer, data, builder) { @@ -666,6 +680,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.sendUnoCommand('.uno:InsertSymbol'); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _startPresentationControl: function(parentContainer, data, builder) { @@ -675,6 +690,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.fire('fullscreen'); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _saveControl: function(parentContainer, data, builder) { @@ -690,6 +706,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ } } }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _saveAsControl: function(parentContainer, data, builder) { @@ -700,6 +717,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.openSaveAs(); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _shareAsControl: function(parentContainer, data, builder) { @@ -709,6 +727,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.openShare(); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _printControl: function(parentContainer, data, builder) { @@ -719,6 +738,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.print(); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _revHistoryControl: function(parentContainer, data, builder) { @@ -728,6 +748,7 @@ L.Control.NotebookbarBuilder = L.Control.JSDialogBuilder.extend({ $(control.container).click(function () { builder.map.openRevisionHistory(); }); + builder._preventDocumentLosingFocusOnClick(control.container); }, _menubarControl: function(parentContainer, data, builder) { |