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({
'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 ) {

View file

@ -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 = $('<div class="group"></div>');
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 = $('<span class="slot"></span>').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 = $('<span class="slot"></span>').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);
$('<div class="separator long"></div>').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 || {}));

View file

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

View file

@ -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)

View file

@ -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",

View file

@ -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...'

View file

@ -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",

View file

@ -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;
}
}

View file

@ -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',

View file

@ -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",