pandora_cms/static/js/localInit.cms.js
2018-08-10 15:00:09 +01:00

63 lines
1.9 KiB
JavaScript

pandora.localInit = function() {
var plugins = [];
plugins.push(ExtrasMenu());
plugins.length && load();
function load() {
patchReload();
plugins.forEach(function(plugin) { plugin.load() });
}
function patchReload() {
var reload = pandora.$ui.appPanel.reload;
pandora.$ui.appPanel.reload = function() {
reload();
load();
}
}
function ExtrasMenu() {
var that = {};
var css = {
//margin: '2px',
},
$item = Ox.MenuButton({
items: [
].concat(pandora.user.level == 'admin' ? [
{id: 'rename', title: 'Rename Keyword...'},
{id: 'manage', title: 'Manage Keywords...'},
] : [], [
{id: 'correlations', title: 'Show Correlations...'},
{id: 'ontology', title: 'Open Ontology Graph'},
]),
style: 'rounded',
title: 'set',
tooltip: Ox._('Extras'),
type: 'image'
}).css(css).bindEvent({
click: function(data) {
if (data.id == 'rename') {
pandora.ui.renameKeywordDialog().open()
} else if (data.id == 'manage') {
pandora.ui.manageKeywordsDialog().open()
} else if (data.id == 'correlations') {
pandora.ui.correlationsDialog().open()
} else if (data.id == 'ontology') {
pandora.openLink('/static/ontology/');
}
},
}),
plugins = [];
that.load = function() {
pandora.$ui.mainMenu.find('.OxExtras').prepend($item);
pandora.$ui.extraItem = $item;
};
return that;
}
}