Set full plugins list to sdk, but add buttons to the toolbar using "EditorsSupport" field .
This commit is contained in:
parent
1afc0e47de
commit
f37d4b53ac
|
@ -177,6 +177,7 @@ define([
|
|||
var me = this;
|
||||
if ( me.$toolbarPanelPlugins ) {
|
||||
var btn = me.panelPlugins.createPluginButton(model);
|
||||
if (!btn) return;
|
||||
|
||||
var _group = $('> .group', me.$toolbarPanelPlugins);
|
||||
var $slot = $('<span class="slot"></span>').appendTo(_group);
|
||||
|
@ -191,10 +192,12 @@ define([
|
|||
|
||||
var _group = $('<div class="group"></div>');
|
||||
collection.each(function (model) {
|
||||
var $slot = $('<span class="slot"></span>').appendTo(_group);
|
||||
me.panelPlugins.createPluginButton(model).render($slot);
|
||||
var btn = me.panelPlugins.createPluginButton(model);
|
||||
if (btn) {
|
||||
var $slot = $('<span class="slot"></span>').appendTo(_group);
|
||||
btn.render($slot);
|
||||
}
|
||||
});
|
||||
|
||||
_group.appendTo(me.$toolbarPanelPlugins);
|
||||
}
|
||||
},
|
||||
|
|
|
@ -66,7 +66,8 @@ define([
|
|||
isUpdateOleOnResize: false,
|
||||
buttons: [],
|
||||
size: [800, 600],
|
||||
initOnSelectionChanged: false
|
||||
initOnSelectionChanged: false,
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -82,7 +83,8 @@ define([
|
|||
currentVariation: 0,
|
||||
pluginObj: undefined,
|
||||
allowSelected: false,
|
||||
selected: false
|
||||
selected: false,
|
||||
visible: true
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -93,7 +93,7 @@ define([
|
|||
store: this.storePlugins,
|
||||
enableKeyEvents: false,
|
||||
itemTemplate: _.template([
|
||||
'<div id="<%= id %>" class="item-plugins" style="display: block;">',
|
||||
'<div id="<%= id %>" class="item-plugins" style="display: <% if (visible) {%> block; <%} else {%> none; <% } %>">',
|
||||
'<div class="plugin-icon" style="background-image: url(' + '<%= baseUrl %>' + '<%= variations[currentVariation].get("icons")[((window.devicePixelRatio > 1) ? 1 : 0) + (variations[currentVariation].get("icons").length>2 ? 2 : 0)] %>);"></div>',
|
||||
'<% if (variations.length>1) { %>',
|
||||
'<div class="plugin-caret img-commonctrl"></div>',
|
||||
|
@ -147,25 +147,27 @@ define([
|
|||
var me = this;
|
||||
var _group = $('<div class="group"></div>');
|
||||
this.storePlugins.each(function (model) {
|
||||
var modes = model.get('variations'),
|
||||
guid = model.get('guid'),
|
||||
icons = modes[model.get('currentVariation')].get('icons'),
|
||||
_icon_url = model.get('baseUrl') + icons[((window.devicePixelRatio > 1) ? 1 : 0) + (icons.length>2 ? 2 : 0)],
|
||||
btn = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconImg: _icon_url,
|
||||
caption: model.get('name'),
|
||||
menu: modes && modes.length > 1,
|
||||
split: modes && modes.length > 1,
|
||||
value: guid,
|
||||
hint: model.get('name')
|
||||
});
|
||||
if (model.get('visible')) {
|
||||
var modes = model.get('variations'),
|
||||
guid = model.get('guid'),
|
||||
icons = modes[model.get('currentVariation')].get('icons'),
|
||||
_icon_url = model.get('baseUrl') + icons[((window.devicePixelRatio > 1) ? 1 : 0) + (icons.length>2 ? 2 : 0)],
|
||||
btn = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconImg: _icon_url,
|
||||
caption: model.get('name'),
|
||||
menu: modes && modes.length > 1,
|
||||
split: modes && modes.length > 1,
|
||||
value: guid,
|
||||
hint: model.get('name')
|
||||
});
|
||||
|
||||
var $slot = $('<span class="slot"></span>').appendTo(_group);
|
||||
btn.render($slot);
|
||||
var $slot = $('<span class="slot"></span>').appendTo(_group);
|
||||
btn.render($slot);
|
||||
|
||||
model.set('button', btn);
|
||||
me.lockedControls.push(btn);
|
||||
model.set('button', btn);
|
||||
me.lockedControls.push(btn);
|
||||
}
|
||||
});
|
||||
|
||||
parent.html(_group);
|
||||
|
@ -260,9 +262,11 @@ define([
|
|||
var model = this.storePlugins.findWhere({guid: guid});
|
||||
if ( model ) {
|
||||
var _btn = model.get('button');
|
||||
_btn.toggle(false);
|
||||
if (_btn.menu && _btn.menu.items.length>0) {
|
||||
_btn.menu.items[0].setCaption(this.textStart);
|
||||
if (_btn) {
|
||||
_btn.toggle(false);
|
||||
if (_btn.menu && _btn.menu.items.length>0) {
|
||||
_btn.menu.items[0].setCaption(this.textStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -276,31 +280,36 @@ define([
|
|||
},
|
||||
|
||||
createPluginButton: function (model) {
|
||||
if (!model.get('visible'))
|
||||
return null;
|
||||
|
||||
var me = this;
|
||||
|
||||
var modes = model.get('variations'),
|
||||
guid = model.get('guid'),
|
||||
icons = modes[model.get('currentVariation')].get('icons'),
|
||||
icon_url = model.get('baseUrl') + icons[((window.devicePixelRatio > 1) ? 1 : 0) + (icons.length > 2 ? 2 : 0)];
|
||||
|
||||
var _menu_items = [];
|
||||
_.each(model.get('variations'), function(variation, index) {
|
||||
if (variation.get('visible'))
|
||||
_menu_items.push({
|
||||
caption : index > 0 ? variation.get('description') : me.textStart,
|
||||
value : parseInt(variation.get('index'))
|
||||
});
|
||||
});
|
||||
|
||||
var btn = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconImg: icon_url,
|
||||
caption: model.get('name'),
|
||||
menu: modes && modes.length > 1,
|
||||
split: modes && modes.length > 1,
|
||||
value: guid,
|
||||
hint: model.get('name')
|
||||
});
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconImg: icon_url,
|
||||
caption: model.get('name'),
|
||||
menu: _menu_items.length > 1,
|
||||
split: _menu_items.length > 1,
|
||||
value: guid,
|
||||
hint: model.get('name')
|
||||
});
|
||||
|
||||
if ( btn.split ) {
|
||||
var _menu_items = [];
|
||||
_.each(model.get('variations'), function(version, index) {
|
||||
_menu_items.push({
|
||||
caption : index > 0 ? version.get('description') : me.textStart,
|
||||
value : parseInt(version.get('index'))
|
||||
});
|
||||
});
|
||||
|
||||
btn.setMenu(
|
||||
new Common.UI.Menu({
|
||||
items: _menu_items,
|
||||
|
|
|
@ -1906,32 +1906,33 @@ define([
|
|||
if (plugins) {
|
||||
var arr = [], arrUI = [];
|
||||
plugins.pluginsData.forEach(function(item){
|
||||
var variationsArr = [];
|
||||
var variationsArr = [],
|
||||
pluginVisible = false;
|
||||
item.variations.forEach(function(itemVar){
|
||||
if ( (isEdit || itemVar.isViewer) &&
|
||||
_.contains(itemVar.EditorsSupport, 'word') )
|
||||
{
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
var visible = (isEdit || itemVar.isViewer) && _.contains(itemVar.EditorsSupport, 'word');
|
||||
if ( visible ) pluginVisible = true;
|
||||
|
||||
if (item.isUICustomizer ) {
|
||||
arrUI.push(item.baseUrl + itemVar.url)
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1) ) : itemVar.url,
|
||||
icons: icons
|
||||
});
|
||||
if (item.isUICustomizer ) {
|
||||
visible && arrUI.push(item.baseUrl + itemVar.url);
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
|
||||
variationsArr.push(model);
|
||||
}
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1) ) : itemVar.url,
|
||||
icons: icons,
|
||||
visible: visible
|
||||
});
|
||||
|
||||
variationsArr.push(model);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -1941,7 +1942,8 @@ define([
|
|||
guid: item.guid,
|
||||
baseUrl : item.baseUrl,
|
||||
variations: variationsArr,
|
||||
currentVariation: 0
|
||||
currentVariation: 0,
|
||||
visible: pluginVisible
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
@ -1678,32 +1678,34 @@ define([
|
|||
if (uiCustomize!==undefined && (pluginStore.findWhere({baseUrl : item.baseUrl}) || pluginStore.findWhere({guid : item.guid}))) return;
|
||||
|
||||
var variations = item.variations,
|
||||
variationsArr = [];
|
||||
variationsArr = [],
|
||||
pluginVisible = false;
|
||||
variations.forEach(function(itemVar){
|
||||
var isSupported = itemVar.EditorsSupport.includes('slide');
|
||||
var isSupported = itemVar.EditorsSupport.includes('slide'),
|
||||
visible = isSupported && (isEdit || itemVar.isViewer);
|
||||
if ( visible ) pluginVisible = true;
|
||||
|
||||
if ( isSupported && (isEdit || itemVar.isViewer) ){
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
|
||||
if ( item.isUICustomizer ) {
|
||||
arrUI.push(item.baseUrl + itemVar.url);
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
if ( item.isUICustomizer ) {
|
||||
visible && arrUI.push(item.baseUrl + itemVar.url);
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1) ) : itemVar.url,
|
||||
icons: icons
|
||||
});
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1) ) : itemVar.url,
|
||||
icons: icons,
|
||||
visible: visible
|
||||
});
|
||||
|
||||
variationsArr.push(model);
|
||||
}
|
||||
variationsArr.push(model);
|
||||
}
|
||||
});
|
||||
if (variationsArr.length>0 && !item.isUICustomizer)
|
||||
|
@ -1712,7 +1714,8 @@ define([
|
|||
guid: item.guid,
|
||||
baseUrl : item.baseUrl,
|
||||
variations: variationsArr,
|
||||
currentVariation: 0
|
||||
currentVariation: 0,
|
||||
visible: pluginVisible
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
|
@ -1873,32 +1873,33 @@ define([
|
|||
if (uiCustomize!==undefined && (pluginStore.findWhere({baseUrl : item.baseUrl}) || pluginStore.findWhere({guid : item.guid}))) return;
|
||||
|
||||
var variations = item.variations,
|
||||
variationsArr = [];
|
||||
variationsArr = [],
|
||||
pluginVisible = false;
|
||||
variations.forEach(function(itemVar){
|
||||
if ((isEdit || itemVar.isViewer) &&
|
||||
itemVar.EditorsSupport.includes('cell') )
|
||||
{
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
var visible = (isEdit || itemVar.isViewer) && itemVar.EditorsSupport.includes('cell');
|
||||
if ( visible ) pluginVisible = true;
|
||||
|
||||
if ( item.isUICustomizer ) {
|
||||
arrUI.push(item.baseUrl + itemVar.url);
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
var icons = itemVar.icons;
|
||||
if (item.oldVersion) { // for compatibility with previouse version of server, where plugins.url is used.
|
||||
icons = [];
|
||||
itemVar.icons.forEach(function(icon){
|
||||
icons.push(icon.substring(icon.lastIndexOf("\/")+1));
|
||||
});
|
||||
}
|
||||
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1)) : itemVar.url,
|
||||
icons: icons
|
||||
});
|
||||
if ( item.isUICustomizer ) {
|
||||
visible && arrUI.push(item.baseUrl + itemVar.url);
|
||||
} else {
|
||||
var model = new Common.Models.PluginVariation(itemVar);
|
||||
|
||||
variationsArr.push(model);
|
||||
}
|
||||
model.set({
|
||||
index: variationsArr.length,
|
||||
url: (item.oldVersion) ? (itemVar.url.substring(itemVar.url.lastIndexOf("\/") + 1)) : itemVar.url,
|
||||
icons: icons,
|
||||
visible: visible
|
||||
});
|
||||
|
||||
variationsArr.push(model);
|
||||
}
|
||||
});
|
||||
if (variationsArr.length>0 && !item.isUICustomizer)
|
||||
|
@ -1907,7 +1908,8 @@ define([
|
|||
guid: item.guid,
|
||||
baseUrl : item.baseUrl,
|
||||
variations: variationsArr,
|
||||
currentVariation: 0
|
||||
currentVariation: 0,
|
||||
visible: pluginVisible
|
||||
}));
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue