unlocked plugins in toolbar

This commit is contained in:
Maxim Kadushkin 2017-08-11 14:01:27 +03:00
parent 2cf4c10d0b
commit dad9b2127d
10 changed files with 117 additions and 43 deletions

View file

@ -57,10 +57,14 @@ define([
this.addListeners({ this.addListeners({
'Toolbar': { 'Toolbar': {
'render:before' : function (toolbar) { 'render:before' : function (toolbar) {
// var tab = {action: 'plugins', caption: 'Addons'}; var isedit = this.getApplication().getController('Main').appOptions.isEdit;
// var $panel = me.panelPlugins.getPanel();
// if ( isedit ) {
// toolbar.addTab(tab, $panel, 4); 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': { 'Common.Views.Plugins': {
@ -287,13 +291,14 @@ define([
this.panelPlugins.openNotVisualMode(plugin.get_Guid()); this.panelPlugins.openNotVisualMode(plugin.get_Guid());
}, },
onPluginClose: function() { onPluginClose: function(plugin) {
if (this.pluginDlg) if (this.pluginDlg)
this.pluginDlg.close(); this.pluginDlg.close();
else if (this.panelPlugins.iframePlugin) else if (this.panelPlugins.iframePlugin)
this.panelPlugins.closeInsideMode(); this.panelPlugins.closeInsideMode();
else else {
this.panelPlugins.closeNotVisualMode(); this.panelPlugins.closeNotVisualMode(plugin.guid);
}
}, },
onPluginResize: function(size, minSize, maxSize, callback ) { onPluginResize: function(size, minSize, maxSize, callback ) {

View file

@ -79,9 +79,9 @@ define([
this.lockedControls = []; this.lockedControls = [];
Common.UI.BaseView.prototype.initialize.call(this, arguments); Common.UI.BaseView.prototype.initialize.call(this, arguments);
(new Promise(function (resolve) { Common.NotificationCenter.on('app:ready', function (mode) {
Common.NotificationCenter.on('app:ready', function (m) { resolve(m); }); Common.Utils.asyncCall(this._onAppReady, this, mode);
})).then(this._onAppReady.bind(this)); }.bind(this));
}, },
render: function(el) { render: function(el) {
@ -126,16 +126,16 @@ define([
if ( !this.storePlugins.isEmpty() ) { if ( !this.storePlugins.isEmpty() ) {
var _group = $('<div class="group"></div>'); var _group = $('<div class="group"></div>');
this.storePlugins.each(function (model) { this.storePlugins.each(function (model) {
var btn = new Common.UI.Button({ // var btn = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top', // cls: 'btn-toolbar x-huge icon-top',
iconCls: 'img-commonctrl review-prev', // iconCls: 'img-commonctrl review-prev',
caption: model.get('name'), // caption: model.get('name'),
value: model.get('guid'), // value: model.get('guid'),
hint: model.get('name') // hint: model.get('name')
}); // });
//
var $slot = $('<span class="slot"></span>').appendTo(_group); // var $slot = $('<span class="slot"></span>').appendTo(_group);
btn.render($slot); // btn.render($slot);
}); });
_group.appendTo(_panel); _group.appendTo(_panel);
@ -166,9 +166,11 @@ define([
btn.render($slot); btn.render($slot);
model.set('button', btn); model.set('button', btn);
me.lockedControls.push(btn);
}); });
parent.html(_group); parent.html(_group);
$('<div class="separator long"></div>').prependTo(parent);
} }
}, },
@ -217,6 +219,8 @@ define([
this.iframePlugin.src = url; this.iframePlugin.src = url;
} }
this.fireEvent('plugin:open', [this, 'onboard', 'open']);
return true; return true;
}, },
@ -229,16 +233,30 @@ define([
} }
this.currentPluginPanel.toggleClass('hidden', true); this.currentPluginPanel.toggleClass('hidden', true);
this.pluginsPanel.toggleClass('hidden', false); this.pluginsPanel.toggleClass('hidden', false);
this.fireEvent('plugin:open', [this, 'onboard', 'close']);
}, },
openNotVisualMode: function(pluginGuid) { openNotVisualMode: function(pluginGuid) {
var rec = this.viewPluginsList.store.findWhere({guid: pluginGuid}); // var rec = this.viewPluginsList.store.findWhere({guid: pluginGuid});
if (rec) // if ( rec ) {
this.viewPluginsList.cmpEl.find('#' + rec.get('id')).parent().addClass('selected'); // 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() { closeNotVisualMode: function(guid) {
this.viewPluginsList.cmpEl.find('.selected').removeClass('selected'); // this.viewPluginsList.cmpEl.find('.selected').removeClass('selected');
var model = this.storePlugins.findWhere({guid: guid});
if ( model ) {
model.get('button').toggle(false);
}
}, },
_onLoad: function() { _onLoad: function() {
@ -282,7 +300,8 @@ define([
strPlugins: 'Plugins', strPlugins: 'Plugins',
textLoading: 'Loading', textLoading: 'Loading',
textStart: 'Start' textStart: 'Start',
groupCaption: 'Addons'
}, Common.Views.Plugins || {})); }, Common.Views.Plugins || {}));

View file

@ -142,4 +142,8 @@
.dropdown-menu { .dropdown-menu {
min-width: 100px; min-width: 100px;
} }
.separator:first-child {
display: none;
}
} }

View file

@ -57,7 +57,6 @@ define([
initialize: function() { initialize: function() {
this.addListeners({ this.addListeners({
/** coauthoring begin **/
'Common.Views.Chat': { 'Common.Views.Chat': {
'hide': _.bind(this.onHideChat, this) 'hide': _.bind(this.onHideChat, this)
}, },
@ -68,15 +67,17 @@ define([
this.clickMenuFileItem('header', 'history'); this.clickMenuFileItem('header', 'history');
}.bind(this) }.bind(this)
}, },
'LeftMenu': {
'comments:show': _.bind(this.commentsShowHide, this, 'show'),
'comments:hide': _.bind(this.commentsShowHide, this, 'hide')
},
/** coauthoring end **/
'Common.Views.About': { 'Common.Views.About': {
'show': _.bind(this.aboutShowHide, this, false), 'show': _.bind(this.aboutShowHide, this, false),
'hide': _.bind(this.aboutShowHide, this, true) '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': { 'FileMenu': {
'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'), 'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'),
'menu:show': _.bind(this.menuFilesShowHide, this, 'show'), 'menu:show': _.bind(this.menuFilesShowHide, this, 'show'),
@ -190,7 +191,7 @@ define([
enablePlugins: function() { enablePlugins: function() {
if (this.mode.canPlugins) { 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')); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins'));
} else } else
this.leftMenu.btnPlugins.hide(); 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() { showHistory: function() {
var maincontroller = DE.getController('Main'); var maincontroller = DE.getController('Main');
if (!maincontroller.loadMask) if (!maincontroller.loadMask)

View file

@ -186,6 +186,7 @@
"Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start", "Common.Views.Plugins.textStart": "Start",
"Common.Views.Plugins.groupCaption": "Addons",
"Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name", "Common.Views.RenameDialog.textName": "File name",

View file

@ -57,23 +57,24 @@ define([
initialize: function() { initialize: function() {
this._state = { no_slides: undefined }; this._state = { no_slides: undefined };
this.addListeners({ this.addListeners({
/** coauthoring begin **/
'Common.Views.Chat': { 'Common.Views.Chat': {
'hide': _.bind(this.onHideChat, this) 'hide': _.bind(this.onHideChat, this)
}, },
'Common.Views.Header': { 'Common.Views.Header': {
'click:users': _.bind(this.clickStatusbarUsers, this) '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': { 'LeftMenu': {
'panel:show': _.bind(this.menuExpand, this), 'panel:show': _.bind(this.menuExpand, this),
'comments:show': _.bind(this.commentsShowHide, this, 'show'), 'comments:show': _.bind(this.commentsShowHide, this, 'show'),
'comments:hide': _.bind(this.commentsShowHide, this, 'hide') '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': { 'FileMenu': {
'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'), 'menu:hide': _.bind(this.menuFilesShowHide, this, 'hide'),
'menu:show': _.bind(this.menuFilesShowHide, this, 'show'), 'menu:show': _.bind(this.menuFilesShowHide, this, 'show'),
@ -179,7 +180,7 @@ define([
enablePlugins: function() { enablePlugins: function() {
if (this.mode.canPlugins) { 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')); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins'));
} else } else
this.leftMenu.btnPlugins.hide(); 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', textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document', newDocumentTitle : 'Unnamed document',
requestEditRightsText : 'Requesting editing rights...' requestEditRightsText : 'Requesting editing rights...'

View file

@ -119,6 +119,7 @@
"Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start", "Common.Views.Plugins.textStart": "Start",
"Common.Views.Plugins.groupCaption": "Addons",
"Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name", "Common.Views.RenameDialog.textName": "File name",

View file

@ -347,3 +347,9 @@
border: 1px solid @gray; border: 1px solid @gray;
.background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px); .background-ximage('@{app-image-path}/toolbar/math.png', '@{app-image-path}/toolbar/math@2x.png', 1500px);
} }
#plugins-panel {
.separator:first-child {
display: inline-block;
}
}

View file

@ -47,10 +47,12 @@ define([
initialize: function() { initialize: function() {
this.addListeners({ this.addListeners({
/** coauthoring begin **/
'Common.Views.Chat': { 'Common.Views.Chat': {
'hide': _.bind(this.onHideChat, this) 'hide': _.bind(this.onHideChat, this)
}, },
'Common.Views.Plugins': {
'plugin:open': _.bind(this.onPluginOpen, this)
},
'Statusbar': { 'Statusbar': {
'click:users': _.bind(this.clickStatusbarUsers, this) 'click:users': _.bind(this.clickStatusbarUsers, this)
}, },
@ -60,7 +62,6 @@ define([
'comments:show': _.bind(this.commentsShowHide, this, true), 'comments:show': _.bind(this.commentsShowHide, this, true),
'comments:hide': _.bind(this.commentsShowHide, this, false) 'comments:hide': _.bind(this.commentsShowHide, this, false)
}, },
/** coauthoring end **/
'Common.Views.About': { 'Common.Views.About': {
'show': _.bind(this.aboutShowHide, this, true), 'show': _.bind(this.aboutShowHide, this, true),
'hide': _.bind(this.aboutShowHide, this, false) 'hide': _.bind(this.aboutShowHide, this, false)
@ -188,7 +189,7 @@ define([
enablePlugins: function() { enablePlugins: function() {
if (this.mode.canPlugins) { 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')); this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins'));
} else } else
this.leftMenu.btnPlugins.hide(); 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', textNoTextFound : 'Text not found',
newDocumentTitle : 'Unnamed document', newDocumentTitle : 'Unnamed document',
textItemEntireCell : 'Entire cell contents', textItemEntireCell : 'Entire cell contents',

View file

@ -105,6 +105,7 @@
"Common.Views.Plugins.strPlugins": "Plugins", "Common.Views.Plugins.strPlugins": "Plugins",
"Common.Views.Plugins.textLoading": "Loading", "Common.Views.Plugins.textLoading": "Loading",
"Common.Views.Plugins.textStart": "Start", "Common.Views.Plugins.textStart": "Start",
"Common.Views.Plugins.groupCaption": "Addons",
"Common.Views.RenameDialog.cancelButtonText": "Cancel", "Common.Views.RenameDialog.cancelButtonText": "Cancel",
"Common.Views.RenameDialog.okButtonText": "Ok", "Common.Views.RenameDialog.okButtonText": "Ok",
"Common.Views.RenameDialog.textName": "File name", "Common.Views.RenameDialog.textName": "File name",