mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-09-06 01:31:09 +02:00
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@104369 467b73ca-7a2a-4603-9d3b-597d59a354a9
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
/**
|
|
* File: CMSMain.Tree.js
|
|
*/
|
|
if(typeof SiteTreeHandlers == 'undefined') SiteTreeHandlers = {};
|
|
SiteTreeHandlers.parentChanged_url = 'admin/ajaxupdateparent';
|
|
SiteTreeHandlers.orderChanged_url = 'admin/ajaxupdatesort';
|
|
SiteTreeHandlers.loadPage_url = 'admin/getitem';
|
|
SiteTreeHandlers.loadTree_url = 'admin/getsubtree';
|
|
|
|
TreeContextMenu = {
|
|
'Edit this page' : function(treeNode) {
|
|
treeNode.selectTreeNode();
|
|
},
|
|
'Duplicate page and children' : function(treeNode) {
|
|
// First save the page silently (without confirmation) and then duplicate the page.
|
|
jQuery('#Form_EditForm').entwine('ss').ajaxSubmit(null, treeNode.duplicatePageWithChildren.bind(treeNode));
|
|
},
|
|
'Duplicate just this page' : function(treeNode) {
|
|
// First save the page silently (without confirmation) and then duplicate the page.
|
|
jQuery('#Form_EditForm').entwine('ss').ajaxSubmit(null, treeNode.duplicatePageWithChildren.bind(treeNode));
|
|
},
|
|
'Sort sub-pages' : function(treeNode) {
|
|
var children = treeNode.treeNodeHolder().childTreeNodes();
|
|
var sortedChildren = children.sort(function(a, b) {
|
|
var titleA = a.aTag.innerHTML.replace(/<[^>]*>/g,'');
|
|
var titleB = b.aTag.innerHTML.replace(/<[^>]*>/g,'');
|
|
return titleA < titleB ? -1 : (titleA > titleB ? 1 : 0);
|
|
});
|
|
|
|
var i,child;
|
|
for(i=0;child=sortedChildren[i];i++) {
|
|
treeNode.appendTreeNode(child);
|
|
}
|
|
|
|
treeNode.onOrderChanged(sortedChildren,treeNode);
|
|
}
|
|
};
|