[fusion-commits] r2320 - sandbox/adsk/2.3r/widgets
svn_fusion at osgeo.org
svn_fusion at osgeo.org
Tue Jan 18 00:16:25 EST 2011
Author: liuar
Date: 2011-01-17 21:16:25 -0800 (Mon, 17 Jan 2011)
New Revision: 2320
Modified:
sandbox/adsk/2.3r/widgets/Legend.js
Log:
Fix ticket #425 ("Stop Running this Script" with Fusion & IE when too many items in legend) in adsk branch
Modified: sandbox/adsk/2.3r/widgets/Legend.js
===================================================================
--- sandbox/adsk/2.3r/widgets/Legend.js 2011-01-17 20:15:35 UTC (rev 2319)
+++ sandbox/adsk/2.3r/widgets/Legend.js 2011-01-18 05:16:25 UTC (rev 2320)
@@ -563,6 +563,31 @@
this.updateLayer(group.layers[i], fScale);
}
},
+ // *****************************************************************//
+ // RepeatingOperation and createAndAppendTreeItem are help methods
+ // to prevent 'Stop running this script' message in IE
+ // *****************************************************************//
+ RepeatingOperation: function(op, maxCount, yieldEveryIteration) {
+ var index = 0;
+ var count = 0;
+ this.step = function(instance, layer, range, scale, bCheckBox) {
+ while(count < maxCount) {
+ count++;
+
+ if (++index >= yieldEveryIteration) {
+ index = 0;
+ setTimeout(function() { op(instance, layer, range.styles[count], scale, bCheckBox); }, 1, [])
+ return;
+ }
+ op(instance, layer, range.styles[count], scale, bCheckBox);
+ }
+ };
+ },
+ createAndAppendTreeItem: function(instance, layer, style, scale, bCheckBox){
+ var item = instance.createTreeItem(layer, style, scale, bCheckBox);
+ layer.legend.treeItem.append(item);
+ },
+
updateLayer: function(layer, fScale) {
var checkbox = layer.isBaseMapLayer ? false : this.bIncludeVisToggle;
@@ -598,10 +623,22 @@
layer.legend.treeItem.remove(layer.legend.treeItem.nodes[0]);
}
}
- for (var i=0; i<range.styles.length; i++) {
- var item = this.createTreeItem(layer, range.styles[i], fScale, false);
- layer.legend.treeItem.append(item);
+ // for (var i=0; i<range.styles.length; i++) {
+ // var item = this.createTreeItem(layer, range.styles[i], fScale, false);
+ // layer.legend.treeItem.append(item);
+ // }
+ var agent = navigator.userAgent.toLowerCase();
+ var msie = agent.indexOf("msie") != -1;
+ if(msie && range.styles.length > 0) {
+ var ro = new this.RepeatingOperation(this.createAndAppendTreeItem, range.styles.length, 10);
+ ro.step(this, layer, range, fScale, false);
}
+ else {
+ for (var i=0; i<range.styles.length; i++) {
+ var item = this.createTreeItem(layer, range.styles[i], fScale, false);
+ layer.legend.treeItem.append(item);
+ }
+ }
} else {
var style = range.styles[0];
More information about the fusion-commits
mailing list