mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-10-22 11:05:53 +02:00
FEATURE: Add onLoad callback handler CMSLoadFunctions
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@96440 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
2e762da45e
commit
904fcf02d0
@ -1,3 +1,41 @@
|
|||||||
|
/**
|
||||||
|
* CMSLoadFunctions provides the ability to have 'onLoad' functions for pages
|
||||||
|
* in the CMS.
|
||||||
|
* These callbacks will be executed when a page has been loaded after clicking
|
||||||
|
* on it in the left-hand Site Content Tree.
|
||||||
|
* The usual document.ready functions won't work in this case as the page data
|
||||||
|
* is loaded via AJAX.
|
||||||
|
*
|
||||||
|
* A function will not be added twice, even if add() is called twice.
|
||||||
|
*
|
||||||
|
* Usage:
|
||||||
|
* CMSLoadFunctions.add(function(){ ... });
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
CMSLoadFunctions = {
|
||||||
|
add: function(fn) {
|
||||||
|
if (!this.load_functions) {
|
||||||
|
this.load_functions = [];
|
||||||
|
}
|
||||||
|
if (!(fn in this.load_functions)) {
|
||||||
|
this.load_functions.push(fn);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
run: function() {
|
||||||
|
if (!this.load_functions) {
|
||||||
|
this.load_functions = [];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(var i=0; i < this.load_functions.length; i++) {
|
||||||
|
var fn = this.load_functions[i];
|
||||||
|
if(typeof(fn) == 'function') {
|
||||||
|
fn();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
CMSForm = Class.extend('ChangeTracker').extend('Observable');
|
CMSForm = Class.extend('ChangeTracker').extend('Observable');
|
||||||
CMSForm.prototype = {
|
CMSForm.prototype = {
|
||||||
@ -263,6 +301,7 @@ CMSRightForm.prototype = {
|
|||||||
statusMessage('');
|
statusMessage('');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMSLoadFunctions.run();
|
||||||
// must wait until the javascript has finished
|
// must wait until the javascript has finished
|
||||||
document.body.style.cursor = 'default';
|
document.body.style.cursor = 'default';
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user