From b696238a4f4f2f965fbb59cb14a20c3d968946fa Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 22 Mar 2023 21:22:42 +0300 Subject: [PATCH] Fix click on button in the plugin's window --- apps/common/main/lib/controller/Plugins.js | 27 +++++++++---------- apps/common/main/lib/view/Plugins.js | 6 ++--- .../forms/app/controller/Plugins.js | 17 +++++------- 3 files changed, 22 insertions(+), 28 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 91a539180b..76a8749246 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -382,8 +382,8 @@ define([ if (urlAddition) url += urlAddition; if (variation.get_InsideMode()) { - if (!this.panelPlugins.openInsideMode(plugin.get_Name(lang), url, frameId)) - this.api.asc_pluginButtonClick(-1); + if (!this.panelPlugins.openInsideMode(plugin.get_Name(lang), url, frameId, plugin.get_Guid())) + this.api.asc_pluginButtonClick(-1, plugin.get_Guid()); } else { var me = this, isCustomWindow = variation.get_CustomWindow(), @@ -410,14 +410,18 @@ define([ url: url, frameId : frameId, buttons: isCustomWindow ? undefined : newBtns, - toolcallback: _.bind(this.onToolClose, this), + toolcallback: function(event) { + me.api.asc_pluginButtonClick(-1, plugin.get_Guid()); + }, help: !!help, loader: plugin.get_Loader(), modal: isModal!==undefined ? isModal : true }); me.pluginDlg.on({ 'render:after': function(obj){ - obj.getChild('.footer .dlg-btn').on('click', _.bind(me.onDlgBtnClick, me)); + obj.getChild('.footer .dlg-btn').on('click', function(event) { + me.api.asc_pluginButtonClick(parseInt(event.currentTarget.attributes['result'].value), plugin.get_Guid()); + }); me.pluginContainer = me.pluginDlg.$window.find('#id-plugin-container'); }, 'close': function(obj){ @@ -433,7 +437,7 @@ define([ help && window.open(help, '_blank'); }, 'header:click': function(type){ - me.api.asc_pluginButtonClick(type); + me.api.asc_pluginButtonClick(type, plugin.get_Guid()); } }); @@ -461,14 +465,9 @@ define([ callback.call(); } }, - - onDlgBtnClick: function(event) { - var state = event.currentTarget.attributes['result'].value; - this.api.asc_pluginButtonClick(parseInt(state)); - }, onToolClose: function() { - this.api.asc_pluginButtonClick(-1); + this.api.asc_pluginButtonClick(-1, this.panelPlugins ? this.panelPlugins._state.insidePlugin : undefined); }, onPluginMouseUp: function(x, y) { @@ -807,7 +806,7 @@ define([ frameId : frameId, buttons: isCustomWindow ? undefined : newBtns, toolcallback: function(event) { - me.api.asc_pluginButtonClick(-1, undefined, frameId); + me.api.asc_pluginButtonClick(-1, variation.guid, frameId); }, help: !!help, modal: isModal!==undefined ? isModal : true @@ -815,7 +814,7 @@ define([ me.customPluginsDlg[frameId].on({ 'render:after': function(obj){ obj.getChild('.footer .dlg-btn').on('click', function(event) { - me.api.asc_pluginButtonClick(parseInt(event.currentTarget.attributes['result'].value), undefined, frameId); + me.api.asc_pluginButtonClick(parseInt(event.currentTarget.attributes['result'].value), variation.guid, frameId); }); me.customPluginsDlg[frameId].options.pluginContainer = me.customPluginsDlg[frameId].$window.find('#id-plugin-container'); }, @@ -832,7 +831,7 @@ define([ help && window.open(help, '_blank'); }, 'header:click': function(type){ - me.api.asc_pluginButtonClick(type, undefined, frameId); + me.api.asc_pluginButtonClick(type, variation.guid, frameId); } }); diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index fdc5304574..b4668aed57 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -222,7 +222,7 @@ define([ } }, - openInsideMode: function(name, url, frameId) { + openInsideMode: function(name, url, frameId, guid) { if (!this.pluginsPanel) return false; this.pluginsPanel.toggleClass('hidden', true); @@ -249,7 +249,7 @@ define([ this.iframePlugin.src = url; } - + this._state.insidePlugin = guid; this.fireEvent('plugin:open', [this, 'onboard', 'open']); return true; }, @@ -263,7 +263,7 @@ define([ } this.currentPluginPanel.toggleClass('hidden', true); // this.pluginsPanel.toggleClass('hidden', false); - + this._state.insidePlugin = undefined; this.fireEvent('plugin:open', [this, 'onboard', 'close']); }, diff --git a/apps/documenteditor/forms/app/controller/Plugins.js b/apps/documenteditor/forms/app/controller/Plugins.js index bbf808a384..db9465efbd 100644 --- a/apps/documenteditor/forms/app/controller/Plugins.js +++ b/apps/documenteditor/forms/app/controller/Plugins.js @@ -174,14 +174,18 @@ define([ url: url, frameId : frameId, buttons: isCustomWindow ? undefined : newBtns, - toolcallback: _.bind(this.onToolClose, this), + toolcallback: function(event) { + me.api.asc_pluginButtonClick(-1, plugin.get_Guid()); + }, help: !!help, loader: plugin.get_Loader(), modal: isModal!==undefined ? isModal : true }); me.pluginDlg.on({ 'render:after': function(obj){ - obj.getChild('.footer .dlg-btn').on('click', _.bind(me.onDlgBtnClick, me)); + obj.getChild('.footer .dlg-btn').on('click', function(event) { + me.api.asc_pluginButtonClick(parseInt(event.currentTarget.attributes['result'].value), plugin.get_Guid()); + }); me.pluginContainer = me.pluginDlg.$window.find('#id-plugin-container'); }, 'close': function(obj){ @@ -218,15 +222,6 @@ define([ } }, - onDlgBtnClick: function(event) { - var state = event.currentTarget.attributes['result'].value; - this.api.asc_pluginButtonClick(parseInt(state)); - }, - - onToolClose: function() { - this.api.asc_pluginButtonClick(-1); - }, - onPluginMouseUp: function(x, y) { if (this.pluginDlg) { if (this.pluginDlg.binding.dragStop) this.pluginDlg.binding.dragStop();