Added groups for plugins.

This commit is contained in:
Julia Radzhabova 2017-12-07 17:46:13 +03:00
parent 7de7841b3d
commit 4b4bef4e0b
5 changed files with 58 additions and 11 deletions

View file

@ -192,13 +192,22 @@ define([
if ( me.$toolbarPanelPlugins ) {
me.$toolbarPanelPlugins.empty();
var _group = $('<div class="group"></div>');
var _group = $('<div class="group"></div>'),
rank = -1;
collection.each(function (model) {
var new_rank = model.get('groupRank');
if (new_rank!==rank && rank>-1) {
_group.appendTo(me.$toolbarPanelPlugins);
$('<div class="separator long"></div>').appendTo(me.$toolbarPanelPlugins);
_group = $('<div class="group"></div>');
}
var btn = me.panelPlugins.createPluginButton(model);
if (btn) {
var $slot = $('<span class="slot"></span>').appendTo(_group);
btn.render($slot);
}
rank = new_rank;
});
_group.appendTo(me.$toolbarPanelPlugins);
}

View file

@ -84,7 +84,9 @@ define([
pluginObj: undefined,
allowSelected: false,
selected: false,
visible: true
visible: true,
groupName: '',
groupRank: 0
}
}
});

View file

@ -1994,15 +1994,27 @@ define([
baseUrl : item.baseUrl,
variations: variationsArr,
currentVariation: 0,
visible: pluginVisible
visible: pluginVisible,
groupName: (item.group) ? item.group.name : '',
groupRank: (item.group) ? item.group.rank : 0
}));
});
if ( uiCustomize!==false ) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
if ( !uiCustomize ) {
if (pluginStore) pluginStore.add(arr);
if ( !uiCustomize && pluginStore) {
arr = pluginStore.models.concat(arr);
arr.sort(function(a, b){
var rank_a = a.get('groupRank'),
rank_b = b.get('groupRank');
if (rank_a < rank_b)
return (rank_a==0) ? 1 : -1;
if (rank_a > rank_b)
return (rank_b==0) ? -1 : 1;
return 0;
});
pluginStore.reset(arr);
this.appOptions.canPlugins = !pluginStore.isEmpty();
}
} else if (!uiCustomize){

View file

@ -1766,15 +1766,27 @@ define([
baseUrl : item.baseUrl,
variations: variationsArr,
currentVariation: 0,
visible: pluginVisible
visible: pluginVisible,
groupName: (item.group) ? item.group.name : '',
groupRank: (item.group) ? item.group.rank : 0
}));
});
if (uiCustomize!==false) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
if ( !uiCustomize ) {
if (pluginStore) pluginStore.add(arr);
if ( !uiCustomize && pluginStore) {
arr = pluginStore.models.concat(arr);
arr.sort(function(a, b){
var rank_a = a.get('groupRank'),
rank_b = b.get('groupRank');
if (rank_a < rank_b)
return (rank_a==0) ? 1 : -1;
if (rank_a > rank_b)
return (rank_b==0) ? -1 : 1;
return 0;
});
pluginStore.reset(arr);
this.appOptions.canPlugins = !pluginStore.isEmpty();
}
} else if (!uiCustomize){

View file

@ -1962,15 +1962,27 @@ define([
baseUrl : item.baseUrl,
variations: variationsArr,
currentVariation: 0,
visible: pluginVisible
visible: pluginVisible,
groupName: (item.group) ? item.group.name : '',
groupRank: (item.group) ? item.group.rank : 0
}));
});
if (uiCustomize!==false) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
if (!uiCustomize) {
if (pluginStore) pluginStore.add(arr);
if ( !uiCustomize && pluginStore) {
arr = pluginStore.models.concat(arr);
arr.sort(function(a, b){
var rank_a = a.get('groupRank'),
rank_b = b.get('groupRank');
if (rank_a < rank_b)
return (rank_a==0) ? 1 : -1;
if (rank_a > rank_b)
return (rank_b==0) ? -1 : 1;
return 0;
});
pluginStore.reset(arr);
this.appOptions.canPlugins = !pluginStore.isEmpty();
}
} else if (!uiCustomize){