Commit 35722617 authored by Julia Radzhabova's avatar Julia Radzhabova

[DE] Добавлено меню для плагинов.

parent 55f0280b
......@@ -84,8 +84,8 @@ define([
}
},
onAfterRender: function(historyView) {
historyView.viewPluginsList.on('item:click', _.bind(this.onSelectPlugin, this));
onAfterRender: function(panelPlugins) {
panelPlugins.viewPluginsList.on('item:click', _.bind(this.onSelectPlugin, this));
this.bindViewEvents(this.panelPlugins, this.events);
},
......@@ -126,9 +126,71 @@ define([
onSelectPlugin: function(picker, item, record, e){
var btn = $(e.target);
if (btn && btn.hasClass('plugin-caret')) {
// show plugin menu
var menu = this.panelPlugins.pluginMenu;
if (menu.isVisible()) {
menu.hide();
return;
}
var showPoint, me = this,
currentTarget = $(e.currentTarget),
parent = $(this.panelPlugins.el),
offset = currentTarget.offset(),
offsetParent = parent.offset();
showPoint = [offset.left - offsetParent.left + currentTarget.width(), offset.top - offsetParent.top + currentTarget.height()/2];
if (record != undefined) {
for (var i = 0; i < menu.items.length; i++) {
menu.removeItem(menu.items[i]); i--;
}
menu.removeAll();
var variations = record.get('variations');
for (var i=0; i<variations.length; i++) {
var variation = variations[i],
mnu = new Common.UI.MenuItem({
caption : variation.get('description'),
value : parseInt(variation.get('index'))
}).on('click', function(item, e) {
if (me.api) {
me.api.asc_pluginRun(record.get('guid'), item.value, '');
}
});
menu.addItem(mnu);
}
}
var menuContainer = parent.find('#menu-plugin-container');
if (!menu.rendered) {
if (menuContainer.length < 1) {
menuContainer = $('<div id="menu-plugin-container" style="position: absolute; z-index: 10000;"><div class="dropdown-toggle" data-toggle="dropdown"></div></div>', menu.id);
parent.append(menuContainer);
}
menu.render(menuContainer);
menu.cmpEl.attr({tabindex: "-1"});
menu.on('show:after', function(cmp) {
if (cmp && cmp.menuAlignEl)
cmp.menuAlignEl.toggleClass('over', true);
}).on('hide:after', function(cmp) {
if (cmp && cmp.menuAlignEl)
cmp.menuAlignEl.toggleClass('over', false);
});
}
menuContainer.css({left: showPoint[0], top: showPoint[1]});
menu.menuAlignEl = currentTarget;
menu.setOffset(-11, -currentTarget.height()/2 + 2);
menu.show();
_.delay(function() {
menu.cmpEl.focus();
}, 10);
e.stopPropagation();
e.preventDefault();
} else
this.api.asc_pluginRun(record.get('guid'), record.get('currentVariation'), '');
this.api.asc_pluginRun(record.get('guid'), 0, '');
},
onPluginShow: function(plugin) {
......
......@@ -50,7 +50,7 @@ define([
'use strict';
Common.Views.Plugins = Common.UI.BaseView.extend(_.extend({
el: '#id-plugins-settings',
el: '#left-panel-plugins',
storePlugins: undefined,
template: _.template([
......@@ -100,11 +100,17 @@ define([
].join(''))
});
this.lockedControls.push(this.viewPluginsList);
this.viewPluginsList.cmpEl.off('click');
this.pluginName = $('#current-plugin-header label');
this.pluginsPanel = $('#plugins-box');
this.currentPluginPanel = $('#current-plugin-box');
this.pluginMenu = new Common.UI.Menu({
menuAlign : 'tr-br',
items: []
});
this.trigger('render:after', this);
return this;
},
......
......@@ -558,7 +558,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');
......
......@@ -1719,7 +1719,7 @@ define([
if (isSupported && (isEdit || itemVar.isViewer))
variationsArr.push(new Common.Models.PluginVariation({
description: itemVar.description,
index: itemVar.index,
index: variationsArr.length,
url : itemVar.url,
icons : itemVar.icons,
isViewer: itemVar.isViewer,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment