1 SiteTreeHandlers.parentChanged_url = 'admin/security/ajaxupdateparent';
2 SiteTreeHandlers.orderChanged_url = 'admin/security/ajaxupdatesort';
3 SiteTreeHandlers.loadPage_url = 'admin/security/getitem';
5 _HANDLER_FORMS['deletegroup'] = 'deletegroup_options';
9 * @todo Remove duplication between this and the CMSMain Add page action
12 button_onclick : function() {
13 addgroup.form_submit();
17 form_submit : function() {
18 var st = $('sitetree');
19 $('addgroup_options').elements.ParentID.value = st.firstSelected() ? st.getIdxOf(st.firstSelected()) : 0;
20 Ajax.SubmitForm('addgroup_options', null, {
21 onSuccess : Ajax.Evaluator,
22 onFailure : function(response) {
23 errorMessage('Error adding page', response);
35 button_onclick : function() {
36 /*if( $('deletegroup_options').style.display == 'none' )
37 $('deletegroup_options').style.display = 'block';
39 $('deletegroup_options').style.display = 'none';*/
41 if(treeactions.toggleSelection(this)) {
42 $('deletegroup_options').style.display = 'block';
44 deletegroup.o1 = $('sitetree').observeMethod('SelectionChanged', deletegroup.treeSelectionChanged);
45 deletegroup.o2 = $('deletegroup_options').observeMethod('Close', deletegroup.popupClosed);
46 addClass($('sitetree'),'multiselect');
48 deletegroup.selectedNodes = { };
50 var sel = $('sitetree').firstSelected();
51 if(sel && sel.className.indexOf('nodelete') == -1) {
52 var selIdx = $('sitetree').getIdxOf(sel);
53 deletegroup.selectedNodes[selIdx] = true;
54 sel.removeNodeClass('current');
55 sel.addNodeClass('selected');
58 $('deletegroup_options').style.display = 'none';
63 treeSelectionChanged : function(selectedNode) {
64 var idx = $('sitetree').getIdxOf(selectedNode);
66 if(selectedNode.className.indexOf('nodelete') == -1) {
67 if(selectedNode.selected) {
68 selectedNode.removeNodeClass('selected');
69 selectedNode.selected = false;
70 deletegroup.selectedNodes[idx] = false;
73 selectedNode.addNodeClass('selected');
74 selectedNode.selected = true;
75 deletegroup.selectedNodes[idx] = true;
82 popupClosed : function() {
83 removeClass($('sitetree'),'multiselect');
84 $('sitetree').stopObserving(deletegroup.o1);
85 $('deletegroup_options').stopObserving(deletegroup.o2);
87 for(var idx in deletegroup.selectedNodes) {
88 if(deletegroup.selectedNodes[idx]) {
89 node = $('sitetree').getTreeNodeByIdx(idx);
91 node.removeNodeClass('selected');
92 node.selected = false;
98 form_submit : function() {
100 for(var idx in deletegroup.selectedNodes) {
101 if(deletegroup.selectedNodes[idx]) csvIDs += (csvIDs ? "," : "") + idx;
104 if(confirm("Do you really want to these groups?")) {
105 $('deletegroup_options').elements.csvIDs.value = csvIDs;
107 Ajax.SubmitForm('deletegroup_options', null, {
108 onSuccess : function(response) {
109 Ajax.Evaluator(response);
112 if((sel = $('sitetree').firstSelected()) && sel.parentNode) sel.addNodeClass('current');
113 else $('Form_EditForm').innerHTML = "";
115 treeactions.closeSelection($('deletegroup'));
117 onFailure : function(response) {
118 errorMessage('Error deleting pages', response);
122 $('deletegroup').getElementsByTagName('button')[0].onclick();
125 alert("Please select at least 1 group.");
134 * Initialisation function to set everything up
136 Behaviour.addLoader(function () {
138 Observable.applyTo($('addgroup_options'));
139 $('addgroup').onclick = addgroup.button_onclick;
140 $('addgroup').getElementsByTagName('button')[0].onclick = function() {return false;};
141 $('addgroup_options').onsubmit = addgroup.form_submit;
143 // Set up delete page
144 Observable.applyTo($('deletegroup_options'));
145 $('deletegroup').onclick = deletegroup.button_onclick;
146 $('deletegroup').getElementsByTagName('button')[0].onclick = function() {return false;};
147 $('deletegroup_options').onsubmit = deletegroup.form_submit;