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