From 04acc3ecc8657fbc581f88dbb7e7dac260d8f1e9 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 21 Oct 2016 17:09:58 +0300 Subject: [PATCH] Autostart plugin after loading plugins. --- apps/api/documents/api.js | 60 +++---------------- apps/common/main/lib/controller/Plugins.js | 3 +- apps/common/main/lib/view/Plugins.js | 5 ++ .../main/app/controller/Main.js | 6 +- .../main/app/controller/Main.js | 6 +- .../main/app/controller/Main.js | 6 +- 6 files changed, 29 insertions(+), 57 deletions(-) diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index fd4894e55..38554517a 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -111,60 +111,14 @@ toolbar: true }, plugins: { + autoStartGuid: 'asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}', url: '../../../../sdkjs-plugins/', - pluginsData: [{ - name : "chess (fen)", - guid : "asc.{FFE1F462-1EA2-4391-990D-4CC84940B754}", - baseUrl: "", - variations : [ - { - description : "chess", - url : "chess/index.html", - - icons : ["chess/icon.png", "chess/icon@2x.png"], - isViewer : true, - EditorsSupport : ["word", "cell", "slide"], - - isVisual : true, - isModal : true, - isInsideMode : false, - - initDataType : "ole", - initData : "", - - isUpdateOleOnResize : true, - - buttons : [ { text: "Ok", primary: true }, - { text: "Cancel", primary: false } ] - } - ] - }, - { - name : "glavred", - guid : "asc.{B631E142-E40B-4B4C-90B9-2D00222A286E}", - baseUrl: "", - variations : [ - { - description : "glavred", - url : "glavred/index.html", - - icons : ["glavred/icon.png", "glavred/icon@2x.png"], - isViewer : true, - EditorsSupport : ["word", "cell", "slide"], - - isVisual : true, - isModal : true, - isInsideMode : false, - - initDataType : "text", - initData : "", - - isUpdateOleOnResize : false, - - buttons : [ { text: "Ok", primary: true } ] - } - ] - } + pluginsData: [ + "helloworld/config.json", + "chess/config.json", + "speech/config.json", + "clipart/config.json", + ] } }, events: { diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index cc111a1fb..3ba2ad6fa 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -224,7 +224,8 @@ define([ url = ((plugin.get_BaseUrl().length == 0) ? this.panelPlugins.pluginsPath : plugin.get_BaseUrl()) + url; if (variation.get_InsideMode()) { - this.panelPlugins.openInsideMode(plugin.get_Name(), url); + if (!this.panelPlugins.openInsideMode(plugin.get_Name(), url)) + this.api.asc_pluginButtonClick(-1); } else { var me = this, arrBtns = variation.get_Buttons(), diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index e68c5104b..acba2de06 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -138,6 +138,8 @@ define([ }, openInsideMode: function(name, url) { + if (!this.pluginsPanel) return false; + this.pluginsPanel.toggleClass('hidden', true); this.currentPluginPanel.toggleClass('hidden', false); @@ -161,9 +163,12 @@ define([ this.iframePlugin.src = url; } + return true; }, closeInsideMode: function() { + if (!this.pluginsPanel) return; + if (this.iframePlugin) { this.currentPluginFrame.empty(); this.iframePlugin = null; diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index bb29b3882..371d90fff 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -1771,6 +1771,7 @@ define([ if (arr.length>0) this.updatePluginsList({ + autoStartGuid: plugins.autoStartGuid, url: plugins.url, pluginsData: arr }); @@ -1829,8 +1830,11 @@ define([ this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } - if (this.appOptions.canPlugins) + if (this.appOptions.canPlugins) { this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); + if (plugins.autoStartGuid) + this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); + } this.getApplication().getController('LeftMenu').enablePlugins(); }, diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 5a573bd0e..d199878aa 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -1545,6 +1545,7 @@ define([ if (arr.length>0) this.updatePluginsList({ + autoStartGuid: plugins.autoStartGuid, url: plugins.url, pluginsData: arr }); @@ -1603,8 +1604,11 @@ define([ this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } - if (this.appOptions.canPlugins) + if (this.appOptions.canPlugins) { this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); + if (plugins.autoStartGuid) + this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); + } this.getApplication().getController('LeftMenu').enablePlugins(); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index f5fbf3567..4d1b9f8dc 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1777,6 +1777,7 @@ define([ if (arr.length>0) this.updatePluginsList({ + autoStartGuid: plugins.autoStartGuid, url: plugins.url, pluginsData: arr }); @@ -1835,8 +1836,11 @@ define([ this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } - if (this.appOptions.canPlugins) + if (this.appOptions.canPlugins) { this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); + if (plugins.autoStartGuid) + this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); + } this.getApplication().getController('LeftMenu').enablePlugins(); },