mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-11 19:08:40 +00:00
add a js loader class, taken from http://www.extjs.com/forum/showthread.php?p=272104
This commit is contained in:
parent
137be4c8f1
commit
45840727e9
1 changed files with 47 additions and 1 deletions
|
@ -994,3 +994,49 @@ Ext.override(Ext.form.TriggerField, {
|
||||||
onShow: Ext.form.TriggerField.superclass.onShow,
|
onShow: Ext.form.TriggerField.superclass.onShow,
|
||||||
onHide: Ext.form.TriggerField.superclass.onHide
|
onHide: Ext.form.TriggerField.superclass.onHide
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Ext.ux.JSLoader = function(options) {
|
||||||
|
|
||||||
|
Ext.ux.JSLoader.scripts[++Ext.ux.JSLoader.index] = {
|
||||||
|
url: options.url,
|
||||||
|
success: true,
|
||||||
|
jsLoadObj: null,
|
||||||
|
options: options,
|
||||||
|
onLoad: options.onLoad || Ext.emptyFn,
|
||||||
|
onError: options.onError || Ext.ux.JSLoader.stdError
|
||||||
|
};
|
||||||
|
|
||||||
|
Ext.Ajax.request({
|
||||||
|
url: options.url,
|
||||||
|
params: options.params,
|
||||||
|
scriptIndex: Ext.ux.JSLoader.index,
|
||||||
|
success: function(response, options) {
|
||||||
|
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
||||||
|
try {
|
||||||
|
script.jsLoadObj = Ext.decode(response.responseText);
|
||||||
|
Ext.applyIf(script.jsLoadObj,{jsLoad: function(){return Ext.ComponentMgr.create(script.jsLoadObj);}});
|
||||||
|
var comp = script.jsLoadObj.jsLoad();
|
||||||
|
if (comp.remoteInit){
|
||||||
|
comp.remoteInit();
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
script.success = false;
|
||||||
|
script.onError(script.options, e);
|
||||||
|
}
|
||||||
|
if (script.success) script.onLoad(comp,script.options);
|
||||||
|
},
|
||||||
|
failure: function(response, options) {
|
||||||
|
var script = Ext.ux.JSLoader.scripts[options.scriptIndex];
|
||||||
|
script.success = false;
|
||||||
|
script.onError(script.options, response.status);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
Ext.ux.JSLoader.index = 0;
|
||||||
|
Ext.ux.JSLoader.scripts = [];
|
||||||
|
|
||||||
|
Ext.ux.JSLoader.stdError = function(options, e) {
|
||||||
|
// throw(e);
|
||||||
|
window.alert('Error loading script:\n\n' + options.url + '\n\nstatus: ' + e);
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue