2007-07-19 12:40:05 +02:00
|
|
|
|
|
|
|
Behaviour.register({
|
|
|
|
'#Form_EditForm' : {
|
|
|
|
initialise : function() {
|
2008-10-16 04:09:46 +02:00
|
|
|
this.openTab = null;
|
2007-07-19 12:40:05 +02:00
|
|
|
this.prepareForm();
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Processing called whenever a page is loaded in the right - including the initial one
|
|
|
|
*/
|
|
|
|
prepareForm : function() {
|
|
|
|
ajaxActionsAtTop('Form_EditForm', 'form_actions', 'right');
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Request a page from the server via Ajax
|
|
|
|
*/
|
|
|
|
getPageFromServer : function(id) {
|
|
|
|
if(id) {
|
|
|
|
this.receivingID = id;
|
|
|
|
|
|
|
|
// Treenode might not exist if that part of the tree is closed
|
|
|
|
var treeNode = $('sitetree').getTreeNodeByIdx(id);
|
|
|
|
|
|
|
|
if(treeNode) treeNode.addNodeClass('loading');
|
|
|
|
|
|
|
|
statusMessage("loading...");
|
|
|
|
|
2008-10-01 08:43:15 +02:00
|
|
|
var requestURL = 'admin/reports/show/' + id;
|
2007-07-19 12:40:05 +02:00
|
|
|
new Ajax.Request(requestURL, {
|
|
|
|
asynchronous : true,
|
|
|
|
method : 'post',
|
|
|
|
postBody : 'ajax=1',
|
|
|
|
onSuccess : this.successfullyReceivedPage.bind(this),
|
|
|
|
onFailure : function(response) {
|
|
|
|
errorMessage('error loading page',response);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
throw("getPageFromServer: Bad page ID: " + id);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
successfullyReceivedPage : function(response) {
|
|
|
|
this.loadNewPage(response.responseText);
|
|
|
|
|
|
|
|
// Treenode might not exist if that part of the tree is closed
|
|
|
|
var treeNode = $('sitetree').getTreeNodeByIdx(this.receivingID);
|
|
|
|
if(treeNode) {
|
|
|
|
$('sitetree').changeCurrentTo(treeNode);
|
|
|
|
treeNode.removeNodeClass('loading');
|
|
|
|
}
|
|
|
|
statusMessage('');
|
|
|
|
|
|
|
|
if( this.openTab ) {
|
|
|
|
openTab( this.openTab );
|
|
|
|
this.openTab = null;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
didntReceivePage : function(response) {
|
|
|
|
errorMessage('error loading page', response);
|
|
|
|
$('sitetree').getTreeNodeByIdx(this.elements.ID.value).removeNodeClass('loading');
|
|
|
|
},
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Load a new page into the right-hand form
|
|
|
|
*/
|
|
|
|
loadNewPage : function(formContent) {
|
|
|
|
rightHTML = formContent;
|
|
|
|
rightHTML = rightHTML.replace(/href *= *"#/g, 'href="' + window.location.href.replace(/#.*$/,'') + '#');
|
|
|
|
|
2009-04-29 03:44:28 +02:00
|
|
|
// Note: TinyMCE coupling
|
|
|
|
tinymce_removeAll();
|
|
|
|
|
2007-07-19 12:40:05 +02:00
|
|
|
// Prepare iframes for removal, otherwise we get loading bugs
|
|
|
|
var i, allIframes = this.getElementsByTagName('iframe');
|
|
|
|
if(allIframes) for(i=0;i<allIframes.length;i++) {
|
|
|
|
allIframes[i].contentWindow.location.href = 'about:blank';
|
|
|
|
allIframes[i].parentNode.removeChild(allIframes[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
this.innerHTML = rightHTML;
|
|
|
|
|
|
|
|
allIframes = this.getElementsByTagName('iframe');
|
|
|
|
if(allIframes) for(i=0;i<allIframes.length;i++) {
|
|
|
|
try {
|
|
|
|
allIframes[i].contentWindow.location.href = allIframes[i].src;
|
|
|
|
} catch(er) {alert(er.message);}
|
|
|
|
}
|
|
|
|
|
|
|
|
_TAB_DIVS_ON_PAGE = [];
|
|
|
|
|
|
|
|
try {
|
|
|
|
var tabs = document.getElementsBySelector('#Form_EditForm ul.tabstrip');
|
|
|
|
} catch(er) {/* alert('a: '+ er.message + '\n' + er.line);*/ }
|
|
|
|
try {
|
|
|
|
for(var i=0;i<tabs.length;i++) if(tabs[i].tagName) initTabstrip(tabs[i]);
|
|
|
|
} catch(er) { /*alert('b: '+ er.message + '\n' + er.line); */}
|
|
|
|
|
|
|
|
// if(this.prepareForm) this.prepareForm();
|
|
|
|
Behaviour.apply($('Form_EditForm'));
|
|
|
|
if(this.prepareForm)
|
|
|
|
this.prepareForm();
|
|
|
|
|
|
|
|
this.resetElements();
|
|
|
|
|
|
|
|
window.ontabschanged();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|