2008-12-02 04:50:06 +01:00
|
|
|
SubsitesTreeDropdownField = Class.extend('TreeDropdownField');
|
|
|
|
SubsitesTreeDropdownField.prototype = {
|
|
|
|
|
2010-03-01 04:05:13 +01:00
|
|
|
subsiteID: function() {
|
|
|
|
var subsiteSel = $$('#CopyContentFromID_SubsiteID select')[0];
|
|
|
|
subsiteSel.onchange = (function() {
|
|
|
|
this.createTreeNode(true);
|
|
|
|
this.ajaxGetTree((function(response) {
|
|
|
|
this.newTreeReady(response, true);
|
|
|
|
this.updateTreeLabel();
|
|
|
|
}).bind(this));
|
|
|
|
}).bind(this);
|
|
|
|
return subsiteSel.options[subsiteSel.selectedIndex].value;
|
|
|
|
},
|
2008-12-02 04:50:06 +01:00
|
|
|
|
|
|
|
ajaxGetTree: function(after) {
|
2010-03-01 22:56:55 +01:00
|
|
|
// Can't force value because it might be on a different subsite!
|
2010-03-01 23:34:03 +01:00
|
|
|
var ajaxURL = this.buildURL('gettree?forceValues=' + 0); //this.inputTag.value;
|
2008-12-02 04:50:06 +01:00
|
|
|
|
2010-03-01 22:56:55 +01:00
|
|
|
// Customised: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
2010-03-01 22:38:32 +01:00
|
|
|
ajaxURL += '&' + this.inputTag.name + '_SubsiteID=' + parseInt(this.subsiteID());
|
2008-12-02 04:50:06 +01:00
|
|
|
|
|
|
|
ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '';
|
|
|
|
new Ajax.Request(ajaxURL, {
|
|
|
|
method : 'get',
|
|
|
|
onSuccess : after,
|
|
|
|
onFailure : function(response) { errorMessage("Error getting data", response); }
|
|
|
|
})
|
|
|
|
},
|
|
|
|
|
2009-07-30 04:11:02 +02:00
|
|
|
// This ajaxExpansion function is actually attached as a method on the tree object; therefore, this.getIdx() is a method
|
2010-03-01 22:26:44 +01:00
|
|
|
// note also this.tree.options.dropdownField.subsiteID() must be called, not this.subsiteID()
|
2008-12-02 04:50:06 +01:00
|
|
|
ajaxExpansion: function() {
|
|
|
|
this.addNodeClass('loading');
|
|
|
|
var ul = this.treeNodeHolder();
|
|
|
|
ul.innerHTML = ss.i18n._t('LOADING');
|
|
|
|
|
2010-03-01 23:34:12 +01:00
|
|
|
var ajaxURL = this.options.dropdownField.buildURL('getsubtree?SubtreeRootID=' + this.getIdx());
|
2008-12-02 04:50:06 +01:00
|
|
|
|
2009-08-13 07:23:16 +02:00
|
|
|
// Find the root of the tree - this points to a list item in the tree, not the root div we actually want
|
|
|
|
// @todo: We should be using framework API calls to find the tree
|
|
|
|
var tree = this;
|
|
|
|
while (tree && !tree.className.match(/(^| )SubsitesTreeDropdownField( |$)/)) tree = tree.parentNode;
|
2008-12-02 04:50:06 +01:00
|
|
|
|
2009-08-13 07:23:16 +02:00
|
|
|
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
|
2010-03-01 23:28:36 +01:00
|
|
|
ajaxURL += '&' + this.options.dropdownField.inputTag.name + '_SubsiteID=' + parseInt(this.options.dropdownField.subsiteID());
|
2009-08-13 07:23:16 +02:00
|
|
|
|
2008-12-02 04:50:06 +01:00
|
|
|
new Ajax.Request(ajaxURL, {
|
|
|
|
onSuccess : this.installSubtree.bind(this),
|
|
|
|
onFailure : function(response) { errorMessage('error loading subtree', response); }
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2010-03-01 22:56:55 +01:00
|
|
|
SubsitesTreeDropdownField.applyTo('div.SubsitesTreeDropdownField');
|