From c161b84cfd215fd654127441842ba4f247e2b02e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Jul 2022 16:16:51 +0300 Subject: [PATCH 1/4] Fix close button on 175% scale --- apps/common/main/resources/less/window.less | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/common/main/resources/less/window.less b/apps/common/main/resources/less/window.less index e17517464b..1e7978e882 100644 --- a/apps/common/main/resources/less/window.less +++ b/apps/common/main/resources/less/window.less @@ -46,8 +46,8 @@ &:before, &:after { content: ' '; position: absolute; - left: 7px; - left: calc(7px / @pixel-ratio-factor); + left: 8px; + left: calc(8px / @pixel-ratio-factor); top: @scaled-one-px-value-ie; top: @scaled-one-px-value; height: 14px; From 7b7a5793201b79f165c1268c15a33e623bbd4908 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Jul 2022 19:16:46 +0300 Subject: [PATCH 2/4] Handle loader parameter for plugins --- apps/common/main/lib/controller/Plugins.js | 1 + apps/common/main/lib/view/PluginDlg.js | 17 ++++++++++------- .../forms/app/controller/Plugins.js | 1 + 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index ba115f40d0..15818dc1a1 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -381,6 +381,7 @@ define([ buttons: isCustomWindow ? undefined : newBtns, toolcallback: _.bind(this.onToolClose, this), help: !!help, + loader: plugin.get_Loader(), modal: isModal!==undefined ? isModal : true }); me.pluginDlg.on({ diff --git a/apps/common/main/lib/view/PluginDlg.js b/apps/common/main/lib/view/PluginDlg.js index 81a5e0ce55..0c5fc46939 100644 --- a/apps/common/main/lib/view/PluginDlg.js +++ b/apps/common/main/lib/view/PluginDlg.js @@ -77,6 +77,7 @@ define([ _options.tpl = _.template(this.template)(_options); this.url = options.url || ''; + this.loader = (options.loader!==undefined) ? options.loader : true; this.frameId = options.frameId || 'plugin_iframe'; Common.UI.Window.prototype.initialize.call(this, _options); }, @@ -102,13 +103,15 @@ define([ iframe.onload = _.bind(this._onLoad,this); var me = this; - setTimeout(function(){ - if (me.isLoaded) return; - me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')}); - me.loadMask.setTitle(me.textLoading); - me.loadMask.show(); - if (me.isLoaded) me.loadMask.hide(); - }, 500); + if (this.loader) { + setTimeout(function(){ + if (me.isLoaded) return; + me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')}); + me.loadMask.setTitle(me.textLoading); + me.loadMask.show(); + if (me.isLoaded) me.loadMask.hide(); + }, 500); + } iframe.src = this.url; $('#id-plugin-placeholder').append(iframe); diff --git a/apps/documenteditor/forms/app/controller/Plugins.js b/apps/documenteditor/forms/app/controller/Plugins.js index 8178f66740..da8e2eeb8d 100644 --- a/apps/documenteditor/forms/app/controller/Plugins.js +++ b/apps/documenteditor/forms/app/controller/Plugins.js @@ -175,6 +175,7 @@ define([ buttons: isCustomWindow ? undefined : newBtns, toolcallback: _.bind(this.onToolClose, this), help: !!help, + loader: plugin.get_Loader(), modal: isModal!==undefined ? isModal : true }); me.pluginDlg.on({ From 00b63283bd8b4331df0f78c8fda6ef7c06124d6b Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 28 Jul 2022 22:59:50 +0300 Subject: [PATCH 3/4] Show back button in the header of the plugin dialog --- apps/common/main/lib/controller/Plugins.js | 13 ++++++++++ apps/common/main/lib/view/PluginDlg.js | 28 +++++++++++++++++++++ apps/common/main/resources/less/window.less | 6 +++++ 3 files changed, 47 insertions(+) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 15818dc1a1..af94c18319 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -162,6 +162,8 @@ define([ this.api.asc_registerCallback("asc_onPluginMouseMove", _.bind(this.onPluginMouseMove, this)); this.api.asc_registerCallback('asc_onPluginsReset', _.bind(this.resetPluginsList, this)); this.api.asc_registerCallback('asc_onPluginsInit', _.bind(this.onPluginsInit, this)); + this.api.asc_registerCallback('asc_onPluginShowButton', _.bind(this.onPluginsShowButton, this)); + this.api.asc_registerCallback('asc_onPluginHideButton', _.bind(this.onPluginsHideButton, this)); this.loadPlugins(); } @@ -400,6 +402,9 @@ define([ }, 'help': function(){ help && window.open(help, '_blank'); + }, + 'header:click': function(type){ + me.api.asc_pluginButtonClick(type); } }); @@ -459,6 +464,14 @@ define([ this.parsePlugins(pluginsdata) }, + onPluginsShowButton: function(type) { + this.pluginDlg && this.pluginDlg.showButton(type); + }, + + onPluginsHideButton: function(type) { + this.pluginDlg && this.pluginDlg.hideButton(type); + }, + runAutoStartPlugins: function() { if (this.autostart && this.autostart.length > 0) { this.api.asc_pluginRun(this.autostart.shift(), 0, ''); diff --git a/apps/common/main/lib/view/PluginDlg.js b/apps/common/main/lib/view/PluginDlg.js index 0c5fc46939..87ce5443db 100644 --- a/apps/common/main/lib/view/PluginDlg.js +++ b/apps/common/main/lib/view/PluginDlg.js @@ -91,6 +91,8 @@ define([ if (!this.options.header) this._headerFooterHeight -= 34; this._headerFooterHeight += ((parseInt(this.$window.css('border-top-width')) + parseInt(this.$window.css('border-bottom-width')))); + this.$window.find('.header').prepend($('')); + var iframe = document.createElement("iframe"); iframe.id = this.frameId; iframe.name = 'pluginFrameEditor'; @@ -183,6 +185,32 @@ define([ } }, + showButton: function(type) { + var header = this.$window.find('.header .tools.left'); + if (type=='back') { + var btn = header.find('#id-plugindlg-' + type); + if (btn.length<1) { + btn = $('
'); + btn.on('click', _.bind(function() { + this.fireEvent('header:click',type); + }, this)); + header.prepend(btn); + } + btn.show(); + header.removeClass('hidden'); + } + }, + + hideButton: function(type) { + var header = this.$window.find('.header .tools.left'); + if (type=='back') { + var btn = header.find('#id-plugindlg-' + type); + if (btn.length>0) { + btn.hide(); + } + } + }, + textLoading : 'Loading' }, Common.Views.PluginDlg || {})); }); \ No newline at end of file diff --git a/apps/common/main/resources/less/window.less b/apps/common/main/resources/less/window.less index 1e7978e882..c8c05adc9f 100644 --- a/apps/common/main/resources/less/window.less +++ b/apps/common/main/resources/less/window.less @@ -116,6 +116,12 @@ position: absolute; right: 0; padding-right: 6px; + + &.left { + left: 0; + right: auto; + padding-left: 6px; + } } .tool.help { From f5065e33b93ffd2b994bc68cc6ab63911760d407 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 29 Jul 2022 13:27:09 +0300 Subject: [PATCH 4/4] Refactoring --- apps/common/main/lib/controller/Plugins.js | 12 ++++++------ apps/common/main/lib/view/PluginDlg.js | 16 ++++++++-------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index af94c18319..b17280eab3 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -162,8 +162,8 @@ define([ this.api.asc_registerCallback("asc_onPluginMouseMove", _.bind(this.onPluginMouseMove, this)); this.api.asc_registerCallback('asc_onPluginsReset', _.bind(this.resetPluginsList, this)); this.api.asc_registerCallback('asc_onPluginsInit', _.bind(this.onPluginsInit, this)); - this.api.asc_registerCallback('asc_onPluginShowButton', _.bind(this.onPluginsShowButton, this)); - this.api.asc_registerCallback('asc_onPluginHideButton', _.bind(this.onPluginsHideButton, this)); + this.api.asc_registerCallback('asc_onPluginShowButton', _.bind(this.onPluginShowButton, this)); + this.api.asc_registerCallback('asc_onPluginHideButton', _.bind(this.onPluginHideButton, this)); this.loadPlugins(); } @@ -464,12 +464,12 @@ define([ this.parsePlugins(pluginsdata) }, - onPluginsShowButton: function(type) { - this.pluginDlg && this.pluginDlg.showButton(type); + onPluginShowButton: function(id) { + this.pluginDlg && this.pluginDlg.showButton(id); }, - onPluginsHideButton: function(type) { - this.pluginDlg && this.pluginDlg.hideButton(type); + onPluginHideButton: function(id) { + this.pluginDlg && this.pluginDlg.hideButton(id); }, runAutoStartPlugins: function() { diff --git a/apps/common/main/lib/view/PluginDlg.js b/apps/common/main/lib/view/PluginDlg.js index 87ce5443db..3fc614de03 100644 --- a/apps/common/main/lib/view/PluginDlg.js +++ b/apps/common/main/lib/view/PluginDlg.js @@ -185,14 +185,14 @@ define([ } }, - showButton: function(type) { + showButton: function(id) { var header = this.$window.find('.header .tools.left'); - if (type=='back') { - var btn = header.find('#id-plugindlg-' + type); + if (id=='back') { + var btn = header.find('#id-plugindlg-' + id); if (btn.length<1) { - btn = $('
'); + btn = $('
'); btn.on('click', _.bind(function() { - this.fireEvent('header:click',type); + this.fireEvent('header:click',id); }, this)); header.prepend(btn); } @@ -201,10 +201,10 @@ define([ } }, - hideButton: function(type) { + hideButton: function(id) { var header = this.$window.find('.header .tools.left'); - if (type=='back') { - var btn = header.find('#id-plugindlg-' + type); + if (id=='back') { + var btn = header.find('#id-plugindlg-' + id); if (btn.length>0) { btn.hide(); }