[fusion-commits] r2326 - branches/fusion-2.2/lib
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Mon Jan 24 03:55:25 EST 2011
Author: hubu
Date: 2011-01-24 00:55:25 -0800 (Mon, 24 Jan 2011)
New Revision: 2326
Modified:
branches/fusion-2.2/lib/fusion.js
Log:
submit on behalf of Ted Yang.
Fix ticket 429: Toolbar ( Main Menu) in TB Web doesn't display in IE9beta
https://trac.osgeo.org/fusion/ticket/429
Modified: branches/fusion-2.2/lib/fusion.js
===================================================================
--- branches/fusion-2.2/lib/fusion.js 2011-01-24 08:47:55 UTC (rev 2325)
+++ branches/fusion-2.2/lib/fusion.js 2011-01-24 08:55:25 UTC (rev 2326)
@@ -414,12 +414,23 @@
this.aLoadingScripts[i] = this.aScripts[i];
}
this.aScripts = [];
+
+ //Ted Yang fix: this is because script loaded will change aLoadingScripts. So we have to create a temp collection to store the loading script.
+ //See function scriptLoaded
+ //Now IE9beta, Safari, Firefox and Chrome all support onload event,
+ //but the IE9beta will triggered the event synchronously, so the aLoadingScripts will be changed before the "for sentence" is finished,
+ //this caused the needed scripts will not be loaded (nearly half of them)
+ var loadingScriptsTemp = [];
+ for (var i = 0; i < this.aLoadingScripts.length; i++) {
+ loadingScriptsTemp[i] = this.aLoadingScripts[i];
+ }
//add the script elements to the DOM to cause them to load.
- for (var i=0; i<this.aLoadingScripts.length; i++) {
- document.getElementsByTagName('head')[0].appendChild(this.aLoadingScripts[i]);
+ for (var i = 0; i < loadingScriptsTemp.length; i++) {
+ document.getElementsByTagName('head')[0].appendChild(loadingScriptsTemp[i]);
}
-
+
//if IE or Safari
+ //Safari has fixed this problem already, and IE9beta also seems to support the onload event, so this code is only for the old IEs.
this.checkLoadInterval = window.setInterval(
OpenLayers.Function.bind(this.checkLoadingScripts, this), 500);
},
@@ -503,6 +514,16 @@
* onload event. Safari also seems to have some problems.
*/
checkLoadingScripts: function() {
+ //In IE9beta, when one script is loaded and the this.aLoadingScripts.length is 0 (for example, there is only 1 item in the aLoadingScripts) ,
+ //the onload event will be triggered synchronously,
+ //but the "this.checkLoadInterval" is not created yet, so the clearInterval will failed to work in function scriptLoaded,
+ //so I add this code to fix this problem
+ //if IE9beta fix the problem, and we don't need to support the old IEs, maybe we can remove the checkLoadingScripts
+ if (this.aLoadingScripts.length == 0) {
+ window.clearInterval(this.checkLoadInterval);
+ return;
+ }
+
var agt=navigator.userAgent.toLowerCase();
for (var i=this.aLoadingScripts.length-1; i>=0; i--) {
var s = this.aLoadingScripts[i];
More information about the fusion-commits
mailing list