diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index 632e50cb2..440f16216 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -141,6 +141,13 @@ define([ toggleGroup: 'leftMenuGroup' }); + this.btnComments.hide(); + this.btnChat.hide(); + + this.btnComments.on('click', _.bind(this.onBtnMenuClick, this)); + this.btnChat.on('click', _.bind(this.onBtnMenuClick, this)); + /** coauthoring end **/ + this.btnPlugins = new Common.UI.Button({ el: $('#left-btn-plugins'), hint: this.tipPlugins, @@ -148,15 +155,8 @@ define([ disabled: true, toggleGroup: 'leftMenuGroup' }); - - this.btnComments.hide(); - this.btnChat.hide(); this.btnPlugins.hide(); - - this.btnComments.on('click', _.bind(this.onBtnMenuClick, this)); - this.btnChat.on('click', _.bind(this.onBtnMenuClick, this)); this.btnPlugins.on('click', _.bind(this.onBtnMenuClick, this)); - /** coauthoring end **/ this.btnSearch.on('click', _.bind(this.onBtnMenuClick, this)); this.btnAbout.on('toggle', _.bind(this.onBtnMenuToggle, this)); @@ -279,12 +279,12 @@ define([ this.panelChat['hide'](); this.btnChat.toggle(false, true); } - if (this.mode.canPlugins && this.panelPlugins) { - this.panelPlugins['hide'](); - this.btnPlugins.toggle(false, true); - } } /** coauthoring end **/ + if (this.mode.canPlugins && this.panelPlugins) { + this.panelPlugins['hide'](); + this.btnPlugins.toggle(false, true); + } }, isOpened: function() { diff --git a/apps/spreadsheeteditor/main/app.js b/apps/spreadsheeteditor/main/app.js index c0a989b12..b1640b119 100644 --- a/apps/spreadsheeteditor/main/app.js +++ b/apps/spreadsheeteditor/main/app.js @@ -157,7 +157,8 @@ require([ 'Main', 'Common.Controllers.Fonts', 'Common.Controllers.Chat', - 'Common.Controllers.Comments' + 'Common.Controllers.Comments', + 'Common.Controllers.Plugins' ] }); @@ -182,7 +183,8 @@ require([ 'common/main/lib/util/LocalStorage', 'common/main/lib/controller/Fonts', 'common/main/lib/controller/Comments', - 'common/main/lib/controller/Chat' + 'common/main/lib/controller/Chat', + 'common/main/lib/controller/Plugins' ], function() { app.start(); }); diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index ba09e9f45..2822704d9 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -181,6 +181,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) { @@ -496,6 +504,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 ) { @@ -605,7 +614,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.api.isCellEdited!==true) { this.leftMenu.close(); Common.NotificationCenter.trigger('layout:changed', 'leftmenu'); diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index 028b7100e..ec72b226c 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -136,6 +136,7 @@ define([ // Initialize api gateway this.editorConfig = {}; + 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)); @@ -250,6 +251,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.headerView = this.getApplication().getController('Viewport').getView('Common.Views.Header'); this.headerView.setCanBack(this.appOptions.canBackToFolder === true); @@ -584,10 +587,18 @@ define([ statusbarView = statusbarController.getView('Statusbar'), leftMenuView = leftmenuController.getView('LeftMenu'), documentHolderView = documentHolderController.getView('DocumentHolder'), - chatController = application.getController('Common.Controllers.Chat'); + chatController = application.getController('Common.Controllers.Chat'), + pluginsController = application.getController('Common.Controllers.Plugins'); leftMenuView.getMenu('file').loadDocument({doc:me.appOptions.spreadsheet}); leftmenuController.setMode(me.appOptions).createDelayedElements().setApi(me.api); + + if (!me.appOptions.isLightVersion && !me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { + pluginsController.setApi(me.api); + me.updatePluginsList(me.plugins); + me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); + } + leftMenuView.disableMenu('all',false); if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram && me.appOptions.canBranding) { @@ -1685,6 +1696,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(); + }, + 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.', criticalErrorTitle: 'Error', notcriticalErrorTitle: 'Warning', diff --git a/apps/spreadsheeteditor/main/app/template/LeftMenu.template b/apps/spreadsheeteditor/main/app/template/LeftMenu.template index 039703e46..72e966931 100644 --- a/apps/spreadsheeteditor/main/app/template/LeftMenu.template +++ b/apps/spreadsheeteditor/main/app/template/LeftMenu.template @@ -6,6 +6,7 @@ + @@ -14,5 +15,6 @@