[TYPO3-core] Gremlin #1577: use ajax to open popup menus
Martin Kutschker
Martin.Kutschker at blackbox.net
Thu Nov 10 15:27:22 CET 2005
Sebastian Kurfuerst <sebastian at garbage-group.de> writes on
Thu, 10 Nov 2005 12:13:58 +0100 (MET):
> Hi Masi,
>
> > The JS code uses try/catch statements. This will throw JS errors on
> > old browsers. Do we care? I think we don't for the BE as we don't
> > even
> > support IE 5.5 (flexforms won't work).
> what solution would you suggest? t3lib_ajax could be used in the
> frontend as well. The used code is common in all ajax
> implementations...
I'd do simple if's and I'd use JS ojects. Untested code below:
function t3js_AJAX_doRequest(url) {
if (this.reqType =" "none") {
return $fallback(url); // create with PHP!!
}
this.reqObj.open("GET", url, true);
// etc but without the delete obviously
}
function t3js_AJAX {
if (typeof ActiveXObject != "undefined") {
this.reqObj = new ActiveXObject("Msxml2.XMLHTTP");
if (this.reqObj) {
this.reqType = "MS2";
} else {
this.reqObj = new ActiveXObject("Microsoft.XMLHTTP");
this.reqType = "MS1";
}
} else if typeof XMLHttpRequest != "undefined") {
this.reqObj = new XMLHttpRequest();
this.reqType = "W3C";
} else {
this.reqType = "none";
}
this.doRequest = t3js_AJAX_doRequest;
}
What's missing is to move the $fallbak out of the JS code. The Js code should live in it's own file. Customizaton should either be done by well-know global JS vars or by arguments to the constructor, etc.
JS-Code that's generated by PHP is hard to read in source form and hard to maintain.
Masi
More information about the TYPO3-team-core
mailing list