diff --git a/apps/presentationeditor/main/app.js b/apps/presentationeditor/main/app.js index ab2809514..823fb4594 100644 --- a/apps/presentationeditor/main/app.js +++ b/apps/presentationeditor/main/app.js @@ -157,7 +157,8 @@ require([ , 'Common.Controllers.Chat', 'Common.Controllers.Comments', /** coauthoring end **/ - 'Common.Controllers.ExternalDiagramEditor' + ,'Common.Controllers.Plugins' + ,'Common.Controllers.ExternalDiagramEditor' ] }); @@ -184,6 +185,7 @@ require([ ,'common/main/lib/controller/Comments', 'common/main/lib/controller/Chat', /** coauthoring end **/ + 'common/main/lib/controller/Plugins', 'presentationeditor/main/app/view/ChartSettings', 'common/main/lib/controller/ExternalDiagramEditor' ], function() { diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index e5d1f2100..6a25afa1b 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -172,6 +172,14 @@ define([ return this; }, + enablePlugins: function() { + if (this.mode.canPlugins) { + this.leftMenu.btnPlugins.show(); + this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins')); + } else + this.leftMenu.btnPlugins.hide(); + }, + clickMenuFileItem: function(menu, action, isopts) { var close_menu = true; switch (action) { @@ -331,6 +339,7 @@ define([ this.leftMenu.btnComments.setDisabled(true); this.leftMenu.btnChat.setDisabled(true); /** coauthoring end **/ + this.leftMenu.btnPlugins.setDisabled(true); this.leftMenu.getMenu('file').setMode({isDisconnected: true}); if ( this.dlgSearch ) { @@ -445,7 +454,14 @@ define([ $.fn.dropdown.Constructor.prototype.keydown.call(menu_opened[0], e); return false; } - if (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed || + if (this.mode.canPlugins && this.leftMenu.panelPlugins) { + menu_opened = this.leftMenu.panelPlugins.$el.find('#menu-plugin-container.open > [data-toggle="dropdown"]'); + if (menu_opened.length) { + $.fn.dropdown.Constructor.prototype.keydown.call(menu_opened[0], e); + return false; + } + } + if (this.leftMenu.btnFile.pressed || this.leftMenu.btnAbout.pressed || this.leftMenu.btnPlugins.pressed || $(e.target).parents('#left-menu').length ) { this.leftMenu.close(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 3c45a134a..b8a6b5c06 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -127,6 +127,7 @@ define([ // Initialize api gateway this.editorConfig = {}; this.appOptions = {}; + this.plugins = undefined; Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); @@ -222,6 +223,8 @@ define([ this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object') && (typeof (this.editorConfig.customization.goback) == 'object') && !_.isEmpty(this.editorConfig.customization.goback.url); this.appOptions.canBack = this.editorConfig.nativeApp !== true && this.appOptions.canBackToFolder === true; + this.appOptions.canPlugins = false; + this.plugins = this.editorConfig.plugins; this.getApplication() .getController('Viewport') @@ -606,7 +609,8 @@ define([ fontsController = application.getController('Common.Controllers.Fonts'), rightmenuController = application.getController('RightMenu'), leftmenuController = application.getController('LeftMenu'), - chatController = application.getController('Common.Controllers.Chat'); + chatController = application.getController('Common.Controllers.Chat'), + pluginsController = application.getController('Common.Controllers.Plugins'); leftmenuController.getView('LeftMenu').getMenu('file').loadDocument({doc:me.document}); leftmenuController.setMode(me.appOptions).setApi(me.api).createDelayedElements(); @@ -614,6 +618,10 @@ define([ chatController.setApi(this.api).setMode(this.appOptions); application.getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); + pluginsController.setApi(me.api); + me.updatePluginsList(me.plugins); + me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); + documentHolderController.setApi(me.api); documentHolderController.createDelayedElements(); statusbarController.createDelayedElements(); @@ -1478,6 +1486,61 @@ define([ if (url) this.iframePrint.src = url; }, + updatePluginsList: function(plugins) { + var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'), + isEdit = this.appOptions.isEdit; + if (pluginStore && plugins) { + var arr = []; + plugins.pluginsData.forEach(function(item){ + var variations = item.variations, + variationsArr = []; + variations.forEach(function(itemVar){ + var isSupported = false; + for (var i=0; i0) + arr.push(new Common.Models.Plugin({ + name : item.name, + guid: item.guid, + baseUrl : item.baseUrl, + variations: variationsArr, + currentVariation: 0 + })); + }); + + pluginStore.reset(arr); + + this.appOptions.pluginsPath = (plugins.url); + this.appOptions.canPlugins = (arr.length>0); + } else { + this.appOptions.pluginsPath = ''; + this.appOptions.canPlugins = false; + } + if (this.appOptions.canPlugins) + this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions); + this.getApplication().getController('LeftMenu').enablePlugins(); + }, + // Translation leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', defaultTitleText: 'ONLYOFFICE Presentation Editor', diff --git a/apps/presentationeditor/main/app/template/LeftMenu.template b/apps/presentationeditor/main/app/template/LeftMenu.template index 66816e4ab..a3d8675a3 100644 --- a/apps/presentationeditor/main/app/template/LeftMenu.template +++ b/apps/presentationeditor/main/app/template/LeftMenu.template @@ -7,6 +7,7 @@ + @@ -15,5 +16,6 @@