From dad9b2127dd21c850126df603bbc8a372624b088 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Fri, 11 Aug 2017 14:01:27 +0300 Subject: [PATCH] unlocked plugins in toolbar --- apps/common/main/lib/controller/Plugins.js | 19 ++++--- apps/common/main/lib/view/Plugins.js | 57 ++++++++++++------- apps/common/main/resources/less/plugins.less | 4 ++ .../main/app/controller/LeftMenu.js | 26 ++++++--- apps/documenteditor/main/locale/en.json | 1 + .../main/app/controller/LeftMenu.js | 27 ++++++--- apps/presentationeditor/main/locale/en.json | 1 + .../main/resources/less/toolbar.less | 6 ++ .../main/app/controller/LeftMenu.js | 18 +++++- apps/spreadsheeteditor/main/locale/en.json | 1 + 10 files changed, 117 insertions(+), 43 deletions(-) diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 6bd81688b..552d22d42 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -57,10 +57,14 @@ define([ this.addListeners({ 'Toolbar': { 'render:before' : function (toolbar) { - // var tab = {action: 'plugins', caption: 'Addons'}; - // var $panel = me.panelPlugins.getPanel(); - // - // toolbar.addTab(tab, $panel, 4); + var isedit = this.getApplication().getController('Main').appOptions.isEdit; + + if ( isedit ) { + var tab = {action: 'plugins', caption: me.panelPlugins.groupCaption}; + var $panel = me.panelPlugins.getPanel(); + + toolbar.addTab(tab, $panel, 4); // TODO: clear plugins list in left panel + } } }, 'Common.Views.Plugins': { @@ -287,13 +291,14 @@ define([ this.panelPlugins.openNotVisualMode(plugin.get_Guid()); }, - onPluginClose: function() { + onPluginClose: function(plugin) { if (this.pluginDlg) this.pluginDlg.close(); else if (this.panelPlugins.iframePlugin) this.panelPlugins.closeInsideMode(); - else - this.panelPlugins.closeNotVisualMode(); + else { + this.panelPlugins.closeNotVisualMode(plugin.guid); + } }, onPluginResize: function(size, minSize, maxSize, callback ) { diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index f86e05933..0eaa83803 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -79,9 +79,9 @@ define([ this.lockedControls = []; Common.UI.BaseView.prototype.initialize.call(this, arguments); - (new Promise(function (resolve) { - Common.NotificationCenter.on('app:ready', function (m) { resolve(m); }); - })).then(this._onAppReady.bind(this)); + Common.NotificationCenter.on('app:ready', function (mode) { + Common.Utils.asyncCall(this._onAppReady, this, mode); + }.bind(this)); }, render: function(el) { @@ -126,16 +126,16 @@ define([ if ( !this.storePlugins.isEmpty() ) { var _group = $('
'); this.storePlugins.each(function (model) { - var btn = new Common.UI.Button({ - cls: 'btn-toolbar x-huge icon-top', - iconCls: 'img-commonctrl review-prev', - caption: model.get('name'), - value: model.get('guid'), - hint: model.get('name') - }); - - var $slot = $('').appendTo(_group); - btn.render($slot); + // var btn = new Common.UI.Button({ + // cls: 'btn-toolbar x-huge icon-top', + // iconCls: 'img-commonctrl review-prev', + // caption: model.get('name'), + // value: model.get('guid'), + // hint: model.get('name') + // }); + // + // var $slot = $('').appendTo(_group); + // btn.render($slot); }); _group.appendTo(_panel); @@ -166,9 +166,11 @@ define([ btn.render($slot); model.set('button', btn); + me.lockedControls.push(btn); }); parent.html(_group); + $('
').prependTo(parent); } }, @@ -217,6 +219,8 @@ define([ this.iframePlugin.src = url; } + + this.fireEvent('plugin:open', [this, 'onboard', 'open']); return true; }, @@ -229,16 +233,30 @@ define([ } this.currentPluginPanel.toggleClass('hidden', true); this.pluginsPanel.toggleClass('hidden', false); + + this.fireEvent('plugin:open', [this, 'onboard', 'close']); }, openNotVisualMode: function(pluginGuid) { - var rec = this.viewPluginsList.store.findWhere({guid: pluginGuid}); - if (rec) - this.viewPluginsList.cmpEl.find('#' + rec.get('id')).parent().addClass('selected'); + // var rec = this.viewPluginsList.store.findWhere({guid: pluginGuid}); + // if ( rec ) { + // this.viewPluginsList.cmpEl.find('#' + rec.get('id')).parent().addClass('selected'); + // } + + var model = this.storePlugins.findWhere({guid: pluginGuid}); + if ( model ) { + var _btn = model.get('button'); + _btn && _btn.toggle(true); + } }, - closeNotVisualMode: function() { - this.viewPluginsList.cmpEl.find('.selected').removeClass('selected'); + closeNotVisualMode: function(guid) { + // this.viewPluginsList.cmpEl.find('.selected').removeClass('selected'); + + var model = this.storePlugins.findWhere({guid: guid}); + if ( model ) { + model.get('button').toggle(false); + } }, _onLoad: function() { @@ -282,7 +300,8 @@ define([ strPlugins: 'Plugins', textLoading: 'Loading', - textStart: 'Start' + textStart: 'Start', + groupCaption: 'Addons' }, Common.Views.Plugins || {})); diff --git a/apps/common/main/resources/less/plugins.less b/apps/common/main/resources/less/plugins.less index b53c4f6ad..862005198 100644 --- a/apps/common/main/resources/less/plugins.less +++ b/apps/common/main/resources/less/plugins.less @@ -142,4 +142,8 @@ .dropdown-menu { min-width: 100px; } + + .separator:first-child { + display: none; + } } \ No newline at end of file diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 5b65bea3f..b88fd82a5 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -57,7 +57,6 @@ define([ initialize: function() { this.addListeners({ - /** coauthoring begin **/ 'Common.Views.Chat': { 'hide': _.bind(this.onHideChat, this) }, @@ -68,15 +67,17 @@ define([ this.clickMenuFileItem('header', 'history'); }.bind(this) }, - 'LeftMenu': { - 'comments:show': _.bind(this.commentsShowHide, this, 'show'), - 'comments:hide': _.bind(this.commentsShowHide, this, 'hide') - }, - /** coauthoring end **/ 'Common.Views.About': { 'show': _.bind(this.aboutShowHide, this, false), 'hide': _.bind(this.aboutShowHide, this, true) }, + 'Common.Views.Plugins': { + 'plugin:open': _.bind(this.onPluginOpen, this) + }, + 'LeftMenu': { + 'comments:show': _.bind(this.commentsShowHide, this, 'show'), + 'comments:hide': _.bind(this.commentsShowHide, this, 'hide') + }, 'FileMenu': { 'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'), 'menu:show': _.bind(this.menuFilesShowHide, this, 'show'), @@ -190,7 +191,7 @@ define([ enablePlugins: function() { if (this.mode.canPlugins) { - this.leftMenu.btnPlugins.show(); + // this.leftMenu.btnPlugins.show(); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins')); } else this.leftMenu.btnPlugins.hide(); @@ -630,6 +631,17 @@ define([ } }, + onPluginOpen: function(panel, type, action) { + if ( type == 'onboard' ) { + if ( action == 'open' ) { + this.leftMenu.panelPlugins.show(); + this.leftMenu.onBtnMenuClick({pressed:true, options: {action: 'plugins'}}); + } else { + this.leftMenu.close(); + } + } + }, + showHistory: function() { var maincontroller = DE.getController('Main'); if (!maincontroller.loadMask) diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 9ccfc2422..f9d28b416 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -186,6 +186,7 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.Plugins.groupCaption": "Addons", "Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.textName": "File name", diff --git a/apps/presentationeditor/main/app/controller/LeftMenu.js b/apps/presentationeditor/main/app/controller/LeftMenu.js index b5d58c9c9..d81d58843 100644 --- a/apps/presentationeditor/main/app/controller/LeftMenu.js +++ b/apps/presentationeditor/main/app/controller/LeftMenu.js @@ -57,23 +57,24 @@ define([ initialize: function() { this._state = { no_slides: undefined }; this.addListeners({ - /** coauthoring begin **/ 'Common.Views.Chat': { 'hide': _.bind(this.onHideChat, this) }, 'Common.Views.Header': { 'click:users': _.bind(this.clickStatusbarUsers, this) }, + 'Common.Views.Plugins': { + 'plugin:open': _.bind(this.onPluginOpen, this) + }, + 'Common.Views.About': { + 'show': _.bind(this.aboutShowHide, this, false), + 'hide': _.bind(this.aboutShowHide, this, true) + }, 'LeftMenu': { 'panel:show': _.bind(this.menuExpand, this), 'comments:show': _.bind(this.commentsShowHide, this, 'show'), 'comments:hide': _.bind(this.commentsShowHide, this, 'hide') }, - /** coauthoring end **/ - 'Common.Views.About': { - 'show': _.bind(this.aboutShowHide, this, false), - 'hide': _.bind(this.aboutShowHide, this, true) - }, 'FileMenu': { 'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'), 'menu:show': _.bind(this.menuFilesShowHide, this, 'show'), @@ -179,7 +180,7 @@ define([ enablePlugins: function() { if (this.mode.canPlugins) { - this.leftMenu.btnPlugins.show(); + // this.leftMenu.btnPlugins.show(); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins')); } else this.leftMenu.btnPlugins.hide(); @@ -518,6 +519,18 @@ define([ } }, + onPluginOpen: function(panel, type, action) { + if ( type == 'onboard' ) { + if ( action == 'open' ) { + this.leftMenu.btnThumbs.toggle(false, false); + this.leftMenu.panelPlugins.show(); + this.leftMenu.onBtnMenuClick({pressed:true, options: {action: 'plugins'}}); + } else { + this.leftMenu.close(); + } + } + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', requestEditRightsText : 'Requesting editing rights...' diff --git a/apps/presentationeditor/main/locale/en.json b/apps/presentationeditor/main/locale/en.json index 09ef7cbe9..59760fd72 100644 --- a/apps/presentationeditor/main/locale/en.json +++ b/apps/presentationeditor/main/locale/en.json @@ -119,6 +119,7 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.Plugins.groupCaption": "Addons", "Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.textName": "File name", diff --git a/apps/presentationeditor/main/resources/less/toolbar.less b/apps/presentationeditor/main/resources/less/toolbar.less index a0958f747..e8d92a23c 100644 --- a/apps/presentationeditor/main/resources/less/toolbar.less +++ b/apps/presentationeditor/main/resources/less/toolbar.less @@ -347,3 +347,9 @@ border: 1px solid @gray; .background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px); } + +#plugins-panel { + .separator:first-child { + display: inline-block; + } +} \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js index 0b1b30e41..eefc44585 100644 --- a/apps/spreadsheeteditor/main/app/controller/LeftMenu.js +++ b/apps/spreadsheeteditor/main/app/controller/LeftMenu.js @@ -47,10 +47,12 @@ define([ initialize: function() { this.addListeners({ - /** coauthoring begin **/ 'Common.Views.Chat': { 'hide': _.bind(this.onHideChat, this) }, + 'Common.Views.Plugins': { + 'plugin:open': _.bind(this.onPluginOpen, this) + }, 'Statusbar': { 'click:users': _.bind(this.clickStatusbarUsers, this) }, @@ -60,7 +62,6 @@ define([ 'comments:show': _.bind(this.commentsShowHide, this, true), 'comments:hide': _.bind(this.commentsShowHide, this, false) }, - /** coauthoring end **/ 'Common.Views.About': { 'show': _.bind(this.aboutShowHide, this, true), 'hide': _.bind(this.aboutShowHide, this, false) @@ -188,7 +189,7 @@ define([ enablePlugins: function() { if (this.mode.canPlugins) { - this.leftMenu.btnPlugins.show(); + // this.leftMenu.btnPlugins.show(); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins')); } else this.leftMenu.btnPlugins.hide(); @@ -724,6 +725,17 @@ define([ } }, + onPluginOpen: function(panel, type, action) { + if ( type == 'onboard' ) { + if ( action == 'open' ) { + this.leftMenu.panelPlugins.show(); + this.leftMenu.onBtnMenuClick({pressed:true, options: {action: 'plugins'}}); + } else { + this.leftMenu.close(); + } + } + }, + textNoTextFound : 'Text not found', newDocumentTitle : 'Unnamed document', textItemEntireCell : 'Entire cell contents', diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 1922dcb9b..f3af89dfc 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -105,6 +105,7 @@ "Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textStart": "Start", + "Common.Views.Plugins.groupCaption": "Addons", "Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.textName": "File name",