silverstripe-subsites/javascript/SubsitesTreeDropdownField.js
Ingo Schommer e17ecfbdee FEATURE Support for VirtualPage-style linkage between subsites with new SubsiteVirtualPage class
ENHANCEMENT Allowing to select a subsite explicitly through admin-URLs, e.g. /admin/show/22/?SubsiteID=2
2008-12-02 03:50:06 +00:00

37 lines
1.3 KiB
JavaScript

SubsitesTreeDropdownField = Class.extend('TreeDropdownField');
SubsitesTreeDropdownField.prototype = {
//subsiteID: null,
ajaxGetTree: function(after) {
var ajaxURL = this.helperURLBase() + 'gettree?forceValues=' + this.inputTag.value;
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
if(this.subsiteID) ajaxURL += '&' + this.id + '_SubsiteID=' + this.subsiteID;
ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '';
new Ajax.Request(ajaxURL, {
method : 'get',
onSuccess : after,
onFailure : function(response) { errorMessage("Error getting data", response); }
})
},
ajaxExpansion: function() {
this.addNodeClass('loading');
var ul = this.treeNodeHolder();
ul.innerHTML = ss.i18n._t('LOADING');
var ajaxURL = this.options.dropdownField.helperURLBase() + 'getsubtree?&SubtreeRootID=' + this.getIdx();
// Customized: Append subsiteid (evaluated in SubsitesVirtualPage.php)
if(this.subsiteID) ajaxURL += '&' + this.id + '_SubsiteID=' + this.subsiteID;
ajaxURL += $('SecurityID') ? '&SecurityID=' + $('SecurityID').value : '';
new Ajax.Request(ajaxURL, {
onSuccess : this.installSubtree.bind(this),
onFailure : function(response) { errorMessage('error loading subtree', response); }
});
}
}
SubsitesTreeDropdownField.applyTo('div.SubsitesTreeDropdownField');