Patrick W. Fraley <pf <at> comsulting.de> writes:
...
Now is this possible? I would not like to include all code and js
for
each modules view in the main page, since this would make it very
huge
and very slow.
Thanks
Patrick
Another solution would be to load just the Javascript u need
encapsulated in functions dinamically from the server i use a
function to do that, basically what i have is this:
This is the function wich loads the script at run time.
function LoadScript(url)
{
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
And then u can load a script like this:
//ShowLogin.js
ShowLogin = function()
{
var winLogin = new QxWindow("Login");
winLogin.set({resizeable : false, modal : true, width: 250, height:
120, showMaximize : false, showMinimize : false, allowMaximize :
false,
allowMinimize : false, showClose : false, centered : true });
d.add(winLogin);
// Nick
var lbl1 = new QxAtom("Nick:");
lbl1.set({ left: 10, top: 5});
winLogin.add(lbl1);
var tbNick = new QxTextField;
tbNick.set({ left: 100, top: 5, width: 100, height: 14});
winLogin.add(tbNick);
// Ponemos el foco en el tb de nick
tbNick.addEventListener("appear", function(e) {
this.focus();
});
// End Nick
// Pass
var lbl2 = new QxAtom("Password:");
lbl2.set({ left: 10, top: 35});
winLogin.add(lbl2);
var tbPass = new QxPasswordField;
tbPass.set({ left: 100, top: 35, width: 100, height: 14});
winLogin.add(tbPass);
// End Pass
// Login Button
var btnLogin = new QxButton("Login", "icons/16/button-ok.png");
btnLogin.setLocation(50, 70);
btnLogin.set({height: 24, width : 75});
winLogin.add(btnLogin);
btnLogin.addEventListener("execute", function(e) {
var name = tbNick.getValue();
var passTmp = tbPass.getValue();
var pass = hex_sha1(passTmp);
var resu = LoginUser( name, pass);
if(resu){
userConected = resu.Usuario[0];
winLogin.close();
winLogin = null;
UpdateMenu();
}
});
// End Login Button
// Cancel Button
var btnCancelar = new QxButton("Cancelar", "icons/16/button-
cancel.png");
btnCancelar.setLocation(130, 70);
btnCancelar.set({height: 24, width : 75});
winLogin.add(btnCancelar);
btnCancelar.addEventListener("execute", function(e) {
winLogin.close();
winLogin = null;
});
// End Cancel Button
winLogin.open();
}
LoginUser = function(nick, pass)
{
proxies.LoginService.func = null;
var ret = proxies.LoginService.UserLogin(nick, pass);
if(ret)
return eval('(' + ret + ')');
else
return null;
}
loginIncluded = true;
ShowLogin();
Note the call to ShowLogin(); at the end of the file i use this trick
to get the function executed just after the script is loaded because
with the dinamyc method of loading the browser doesn't wait until
script is loaded so u cant put a call to the function after the call
to load the script, i do that in thsi way:
...
case "Login":
if(!loginIncluded )
LoadScript("scripts/Login.js");
else
ShowLogin();
break;
...
In the first case when login is not included yet we simply call the
LoadScript function and when the script has finnished loading the
ShowLogin function is executed, in the second case we can simply call
ShowLogin because the script is already loaded.
I hope this helps you.
VoidMain
-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting
language
that extends applications into web and mobile media. Attend the live
webcast
and join the prime developer group breaking into this new coding
territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121
642
_______________________________________________
Qooxdoo-devel mailing list
Qooxdoo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel