2012-03-12 11:40:43 +01:00
|
|
|
(function($) {
|
|
|
|
|
2012-05-18 02:09:47 +02:00
|
|
|
$.entwine('ss.tree', function($){
|
2012-03-12 11:40:43 +01:00
|
|
|
$('.cms-tree').entwine({
|
|
|
|
getTreeConfig: function() {
|
2012-04-30 16:42:45 +02:00
|
|
|
var self = this, config = this._super(), hints = this.getHints();
|
2012-03-12 11:40:43 +01:00
|
|
|
config.plugins.push('contextmenu');
|
|
|
|
config.contextmenu = {
|
2012-03-19 02:05:09 +01:00
|
|
|
'items': function(node) {
|
|
|
|
// Build a list for allowed children as submenu entries
|
2012-05-07 14:45:39 +02:00
|
|
|
var pagetype = node.data('pagetype');
|
2012-03-19 02:05:09 +01:00
|
|
|
var id = node.data('id');
|
|
|
|
|
|
|
|
var allowedChildren = new Object;
|
2012-05-07 14:45:39 +02:00
|
|
|
$(hints[pagetype].allowedChildren).each(
|
2012-03-19 02:05:09 +01:00
|
|
|
function(key, val){
|
|
|
|
allowedChildren["allowedchildren-" + key ] = {
|
|
|
|
'label': '<span class="jstree-pageicon"></span>' + val.ssname,
|
2012-05-07 14:45:39 +02:00
|
|
|
'_class': 'class-' + val.pagetype,
|
2012-03-19 02:05:09 +01:00
|
|
|
'action': function(obj) {
|
2012-05-18 02:09:47 +02:00
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
2012-05-07 14:45:39 +02:00
|
|
|
self.data('urlAddpage'), id, val.pagetype
|
2012-04-30 16:42:45 +02:00
|
|
|
));
|
2012-03-19 02:05:09 +01:00
|
|
|
}
|
|
|
|
};
|
2012-03-12 11:40:43 +01:00
|
|
|
}
|
2012-03-19 02:05:09 +01:00
|
|
|
);
|
|
|
|
var menuitems =
|
|
|
|
{
|
|
|
|
'edit': {
|
|
|
|
'label': ss.i18n._t('Tree.EditPage'),
|
|
|
|
'action': function(obj) {
|
2012-05-18 02:09:47 +02:00
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
2012-04-30 16:42:45 +02:00
|
|
|
self.data('urlEditpage'), obj.data('id')
|
|
|
|
));
|
2012-03-19 02:05:09 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
// Test if there are any allowed Children and thus the possibility of adding some
|
|
|
|
if(allowedChildren.hasOwnProperty('allowedchildren-0')) {
|
|
|
|
menuitems['addsubpage'] = {
|
|
|
|
'label': ss.i18n._t('Tree.AddSubPage'),
|
|
|
|
'action': function(obj) {
|
2012-05-18 02:09:47 +02:00
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
2012-04-30 16:42:45 +02:00
|
|
|
self.data('urlAddpage'), id, 'Page'
|
|
|
|
));
|
2012-03-19 02:05:09 +01:00
|
|
|
},
|
|
|
|
'submenu': allowedChildren
|
|
|
|
};
|
|
|
|
}
|
|
|
|
return menuitems;
|
|
|
|
}
|
2012-03-12 11:40:43 +01:00
|
|
|
};
|
|
|
|
return config;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
2012-03-19 02:05:09 +01:00
|
|
|
|
2012-05-18 02:09:47 +02:00
|
|
|
}(jQuery));
|