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) {
|
2013-03-11 21:20:01 +01:00
|
|
|
|
2012-12-03 16:33:06 +01:00
|
|
|
var menuitems = {
|
|
|
|
'edit': {
|
|
|
|
'label': ss.i18n._t('Tree.EditPage'),
|
|
|
|
'action': function(obj) {
|
2013-03-14 17:31:36 +01:00
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
2012-12-03 16:33:06 +01:00
|
|
|
self.data('urlEditpage'), obj.data('id')
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
2013-03-14 17:31:36 +01:00
|
|
|
|
|
|
|
// Add "show as list"
|
|
|
|
if(!node.hasClass('nochildren')) {
|
|
|
|
menuitems['showaslist'] = {
|
|
|
|
'label': ss.i18n._t('Tree.ShowAsList'),
|
|
|
|
'action': function(obj) {
|
|
|
|
$('.cms-container').entwine('.ss').loadPanel(
|
|
|
|
self.data('urlListview') + '&ParentID=' + obj.data('id'),
|
|
|
|
null,
|
|
|
|
// Default to list view tab
|
|
|
|
{tabState: {'pages-controller-cms-content': {'tabSelector': '.content-listview'}}}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2012-05-25 00:36:42 +02:00
|
|
|
|
2012-03-19 02:05:09 +01:00
|
|
|
// Build a list for allowed children as submenu entries
|
2012-12-03 16:33:06 +01:00
|
|
|
var pagetype = node.data('pagetype'),
|
|
|
|
id = node.data('id'),
|
|
|
|
disallowedChildren = hints[pagetype].disallowedChildren,
|
|
|
|
allowedChildren = $.extend(true, {}, hints['All']), // clone
|
|
|
|
disallowedClass,
|
|
|
|
menuAllowedChildren = {},
|
|
|
|
hasAllowedChildren = false;
|
2012-03-19 02:05:09 +01:00
|
|
|
|
2012-12-03 16:33:06 +01:00
|
|
|
// Filter allowed
|
|
|
|
if(disallowedChildren) {
|
|
|
|
for(var i=0; i<disallowedChildren.length; i++) {
|
|
|
|
disallowedClass = disallowedChildren[i];
|
|
|
|
if(allowedChildren[disallowedClass]) {
|
|
|
|
delete allowedChildren[disallowedClass];
|
2013-03-11 21:20:01 +01:00
|
|
|
}
|
2012-03-12 11:40:43 +01:00
|
|
|
}
|
2012-12-03 16:33:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Convert to menu entries
|
|
|
|
$.each(allowedChildren, function(klass, klassData){
|
|
|
|
hasAllowedChildren = true;
|
|
|
|
menuAllowedChildren["allowedchildren-" + klass ] = {
|
|
|
|
'label': '<span class="jstree-pageicon"></span>' + klassData.title,
|
|
|
|
'_class': 'class-' + klass,
|
|
|
|
'action': function(obj) {
|
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
2013-03-11 21:20:01 +01:00
|
|
|
self.data('urlAddpage'), id, klass
|
2012-12-03 16:33:06 +01:00
|
|
|
));
|
2012-03-19 02:05:09 +01:00
|
|
|
}
|
|
|
|
};
|
2012-12-03 16:33:06 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
if(hasAllowedChildren) {
|
2012-03-19 02:05:09 +01:00
|
|
|
menuitems['addsubpage'] = {
|
2012-12-03 16:33:06 +01:00
|
|
|
'label': ss.i18n._t('Tree.AddSubPage'),
|
|
|
|
'submenu': menuAllowedChildren
|
|
|
|
};
|
2013-03-11 21:20:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
menuitems['duplicate'] = {
|
|
|
|
'label': ss.i18n._t('Tree.Duplicate'),
|
|
|
|
'submenu': [
|
|
|
|
{
|
|
|
|
'label': ss.i18n._t('Tree.ThisPageOnly'),
|
|
|
|
'action': function(obj) {
|
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
|
|
|
self.data('urlDuplicate'), obj.data('id')
|
|
|
|
));
|
|
|
|
}
|
|
|
|
},{
|
|
|
|
'label': ss.i18n._t('Tree.ThisPageAndSubpages'),
|
|
|
|
'action': function(obj) {
|
|
|
|
$('.cms-container').entwine('.ss').loadPanel(ss.i18n.sprintf(
|
|
|
|
self.data('urlDuplicatewithchildren'), obj.data('id')
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
};
|
2012-12-03 16:33:06 +01:00
|
|
|
|
2012-03-19 02:05:09 +01:00
|
|
|
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));
|