Author: tmckay
Date: 2011-01-26 20:11:22 +0000 (Wed, 26 Jan 2011)
New Revision: 4488
Modified:
branches/1.3.2/cumin/python/cumin/stat.strings
branches/1.3.2/cumin/resources/app.js
Log:
Merge revision 4487 from trunk. Original comment:
fix for bz 672604 - There were two problems here:
1. the flash charts were not restoring their duration after a page refresh. Fixed by using
swfobject's javascript callback function after chart loads.
2. both flash and png charts would only refresh one of the charts on the page. If two
charts were changed and the page was reloaded, only one was restored correctly. The fix
was to not call settimeout in the mootools "each" block.
Modified: branches/1.3.2/cumin/python/cumin/stat.strings
===================================================================
--- branches/1.3.2/cumin/python/cumin/stat.strings 2011-01-26 19:37:04 UTC (rev 4487)
+++ branches/1.3.2/cumin/python/cumin/stat.strings 2011-01-26 20:11:22 UTC (rev 4488)
@@ -189,9 +189,9 @@
}
function changeDuration(state, a, id, attempt) {
- li = a.parentNode;
- ul = li.parentNode;
- as = ul.getElementsByTagName('a');
+ var li = a.parentNode;
+ var ul = li.parentNode;
+ var as = ul.getElementsByTagName('a');
for (var i=0; i < as.length; i++) {
as[i].className = (as[i] == a) ? "selected" : "";
}
@@ -224,17 +224,14 @@
return false;
} else {
var chart = cumin.getFlashChart(id);
- if (chart == null) {
+ if ((chart == null) || (typeof chart.geturl == "undefined")) {
if (typeof attempt == "undefined")
attempt = 1;
- if (attempt < 2)
- setTimeout(function () {changeDuration(state, a, id, attempt+1);},
1000);
+ if (attempt < 10)
+ setTimeout(function () {changeDuration(state, a, id, attempt+1);}, 100);
return false;
}
- if (typeof chart.geturl != "undefined")
- chart.geturl("got_chart_url", id, state);
- else
- wooly.log("geturl not definded for " + id);
+ chart.geturl("got_chart_url", id, state);
}
return false;
}
@@ -315,7 +312,7 @@
cumin.setupChart('{id}', {width});
} else {
swfobject.embedSWF("resource?name=open-flash-chart.swf",
"{id}_chart", "{width}", "{height}", "9.0.0",
"",
- {"data-file":"{href}"}, {wmode: "opaque"});
+ {"data-file":"{href}"}, {wmode: "opaque"},
null, cumin.processHash);
wooly.addPageUpdateListener(function () { cumin.updateFlashChart('{id}');
});
window.addEvent('domready',function () {
@@ -345,17 +342,15 @@
wooly.addPageUpdateListener(function () {if
(document.images["{id}"].className == "Loading") return;
cumin.updateChart("{id}");});
cumin.setupChart('{id}', '{fullpage_href}');
} else {
- swfobject.embedSWF("resource?name=open-flash-chart.swf",
"{id}_chart", "96%", "{height}", "9.0.0",
"",
- {"data-file":"{href}"}, {wmode: "opaque"});
- wooly.addPageUpdateListener(function () { cumin.updateFlashChart('{id}');
});
cumin.forceChart = function () {
var chart = cumin.getFlashChart('{id}');
if (chart) {
chart.height = window.getSize().y * 0.96;
}
}
- // ugly, but it works for now
- window.addEvent('domready', function () {setTimeout( cumin.forceChart,
1000 )});
+ swfobject.embedSWF("resource?name=open-flash-chart.swf",
"{id}_chart", "96%", "{height}", "9.0.0",
"",
+ {"data-file":"{href}"}, {wmode: "opaque"},
null, cumin.forceChart);
+ wooly.addPageUpdateListener(function () { cumin.updateFlashChart('{id}');
});
window.addEvent('resize', cumin.forceChart);
}
//]]>
Modified: branches/1.3.2/cumin/resources/app.js
===================================================================
--- branches/1.3.2/cumin/resources/app.js 2011-01-26 19:37:04 UTC (rev 4487)
+++ branches/1.3.2/cumin/resources/app.js 2011-01-26 20:11:22 UTC (rev 4488)
@@ -416,23 +416,51 @@
wooly.log("reload not definded for " + id);
}
-window.addEvent('domready',function () {
- var hash = wooly.session.hash();
- for (var key in hash) {
- if (!(hash[key] instanceof Function)) {
- var oChart = $(key);
- if (oChart) {
- var links = oChart.getElements('a');
+/* called after page with a flash chart loads
+ called once for each chart on the page
+ used to parse the url hash and restore the chart's
+ duration to what was requested
+*/
+cumin.processHash = function (e) {
+ if (e.success) {
+ var hash = wooly.session.hash();
+ var key = e.id.replace("_chart", "");
+ if (typeof hash[key] != "undefined") {
+ var oChartHtml = $(key);
+ if (oChartHtml) {
+ var links = oChartHtml.getElements('a');
var state = hash[key];
$each(links, function (item) {
if (item.get('state') == state) {
- setTimeout(function() {changeDuration(state, item, key);}, 0);
+ changeDuration(state, item, key);
}
});
}
}
}
+}
+
+window.addEvent('domready',function () {
+ var hash = wooly.session.hash();
+ for (var key in hash) {
+ if (!(hash[key] instanceof Function)) {
+ var oImg = document.images[key];
+ if (oImg) {
+ var oChart = $(key);
+ if (oChart) {
+ var links = oChart.getElements('a');
+ var state = hash[key];
+
+ $each(links, function (item) {
+ if (item.get('state') == state) {
+ changeDuration(state, item, key);
+ }
+ });
+ }
+ }
+ }
+ }
});
function ofc_range(id, href, low, high) {