|
|
|
Author: max
Date: 2007-11-02 11:33:04 -0700 (Fri, 02 Nov 2007) New Revision: 7097 Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/LaszloLibrary.lzs openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzSprite.as openlaszlo/branches/wafflecone/lps/includes/source/embednew.js openlaszlo/branches/wafflecone/lps/includes/source/lzhistory.js Log: Change 20071101-maxcarlson-S by maxcarlson@Plastik on 2007-11-01 19:38:19 PDT in /Users/maxcarlson/openlaszlo/wafflecone for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone Summary: Fix lzhistory behavior when another page is visited and the back-button is used. New Features: Bugs Fixed: Technical Reviewer: promanik QA Reviewer: jcrowley Doc Reviewer: (pending) Documentation: Release Notes: Details: LzSprite.as - Delay DojoExternalInterface initialization 'til canvas init time. LaszloLibrary.lzs - Delay DojoExternalInterface initialization 'til canvas init time. embednew.js - Add dojo.flash.addLoadedListener(Lz.history.init) instead of using window.onload. Check for presence of dojo.flash.comm.callMethod() before calling. lzhistory.js - _parse() only sets canvas attribute when Lz.loaded == true. Add window.onunload=function () {} to fix back button behavior in Firefox. Tests: Test a SOLO compile of this application: <canvas width="100%" height="100%" debug="true" proxied="false"> <attribute name="stateValue" type="string" value="null"/> <simplelayout axis="x"/> <button text="Next"> <handler name="onclick"> var cur = Number(canvas.stateValue); if(isNaN(cur)) { cur = 0; } cur++; LzBrowser.loadJS("Lz.setCanvasAttribute('stateValue', '" + escape(cur) + "', true)"); </handler> </button> <button text="Google"> <handler name="onclick"> LzBrowser.loadURL('http://google.com/'); </handler> </button> <text text="${canvas.stateValue}" resize="true" x="100" y="100"/> </canvas> Run the SOLO compile, step forward a few times, then click the 'google' button. Pressing the back button after google loads should work in ie7, firefox and google. Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/LaszloLibrary.lzs =================================================================== --- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/LaszloLibrary.lzs 2007-11-02 18:16:25 UTC (rev 7096) +++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/LaszloLibrary.lzs 2007-11-02 18:33:04 UTC (rev 7097) @@ -47,15 +47,6 @@ if ($as2) { // Initialize the DojoExternalInterface class DojoExternalInterface = new DojoExternalInterfaceClass(); - - // Expose your methods - DojoExternalInterface.addCallback("getCanvasAttribute", LzHistory, LzHistory.getCanvasAttribute); - DojoExternalInterface.addCallback("setCanvasAttribute", LzHistory, LzHistory.setCanvasAttribute); - DojoExternalInterface.addCallback("callMethod", LzHistory, LzHistory.callMethod); - DojoExternalInterface.addCallback("receiveHistory", LzHistory, LzHistory.receiveHistory); - - // Tell JavaScript that you are ready to have method calls - DojoExternalInterface.loaded(); } if ($debug) { Modified: openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzSprite.as =================================================================== --- openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-11-02 18:16:25 UTC (rev 7096) +++ openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-11-02 18:33:04 UTC (rev 7097) @@ -15,6 +15,7 @@ if (isroot) { + this.isroot = true; var is = _root.spriteroot; if (! is) { var is = _root.attachMovie('empty', 'spriteroot', 1000); @@ -221,6 +222,16 @@ LzSprite.prototype.init = function( ) { this.__LZmovieClipRef._visible = this.visible; this.__LZbgRef._visible = this.visible; + if (this.isroot) { + // Expose your methods + DojoExternalInterface.addCallback("getCanvasAttribute", LzHistory, LzHistory.getCanvasAttribute); + DojoExternalInterface.addCallback("setCanvasAttribute", LzHistory, LzHistory.setCanvasAttribute); + DojoExternalInterface.addCallback("callMethod", LzHistory, LzHistory.callMethod); + DojoExternalInterface.addCallback("receiveHistory", LzHistory, LzHistory.receiveHistory); + + // Tell JavaScript that you are ready to have method calls + DojoExternalInterface.loaded(); + } } Modified: openlaszlo/branches/wafflecone/lps/includes/source/embednew.js =================================================================== --- openlaszlo/branches/wafflecone/lps/includes/source/embednew.js 2007-11-02 18:16:25 UTC (rev 7096) +++ openlaszlo/branches/wafflecone/lps/includes/source/embednew.js 2007-11-02 18:33:04 UTC (rev 7097) @@ -117,6 +117,7 @@ // for callbacks onload Lz._swfid = properties.id; dojo.flash.addLoadedListener(Lz._loaded); + dojo.flash.addLoadedListener(Lz.history.init) if (! Lz['setCanvasAttribute']) { Lz.setCanvasAttribute = Lz[properties.id].setCanvasAttribute; } @@ -335,7 +336,7 @@ * @param hist:Boolean value - if true, add a history event. */ _setCanvasAttributeSWF: function (name, value, hist) { - if (this.loaded) { + if (this.loaded && dojo.flash.comm['callMethod']) { if (hist) { Lz.history._store(name, value); } else { Modified: openlaszlo/branches/wafflecone/lps/includes/source/lzhistory.js =================================================================== --- openlaszlo/branches/wafflecone/lps/includes/source/lzhistory.js 2007-11-02 18:16:25 UTC (rev 7096) +++ openlaszlo/branches/wafflecone/lps/includes/source/lzhistory.js 2007-11-02 18:33:04 UTC (rev 7097) @@ -170,7 +170,7 @@ var _this = Lz.history; // TODO: send events to all apps if (h.length == 0 || h == _this._lasthash) return; - if (h.indexOf('_lz') != -1) { + if (Lz.loaded && h.indexOf('_lz') != -1) { // TODO: use rison _this._lasthash = h; h = h.substring(3); @@ -229,4 +229,7 @@ } } }; -window.onload = Lz.history.init; +if (Lz.__BrowserDetect.isFirefox) { + // If this is present, then Firefox does not do its Javascript caching and onload will get fired when coming back to the page. Thanks Jes! + window.onunload = function() {}; +} _______________________________________________ Laszlo-checkins mailing list Laszlo-checkins@openlaszlo.org http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins Author: max
Date: 2007-11-05 12:03:56 -0800 (Mon, 05 Nov 2007) New Revision: 7133 Modified: openlaszlo/trunk/ openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as openlaszlo/trunk/lps/includes/source/embednew.js openlaszlo/trunk/lps/includes/source/lzhistory.js Log: Change 20071102-maxcarlson-v by maxcarlson@Plastik on 2007-11-02 17:35:12 PDT in /Users/maxcarlson/openlaszlo/trunk-clean for http://svn.openlaszlo.org/openlaszlo/trunk Summary: Merge wafflecone r7097 to trunk New Features: Bugs Fixed: Technical Reviewer: promanik QA Reviewer: jcrowley Doc Reviewer: (pending) Documentation: Release Notes: Details: Plastik:trunk-clean maxcarlson$ ~/openlaszlo/tools/svn/svnmerge.py merge -r 709 7 -S ../wafflecone U WEB-INF/lps/lfc/kernel/swf/LzSprite.as U WEB-INF/lps/lfc/LaszloLibrary.lzs U lps/includes/source/embednew.js U lps/includes/source/lzhistory.js property 'svnmerge-integrated' set on '.' Tests: Test a SOLO compile of this application: <canvas width="100%" height="100%" debug="true" proxied="false"> <attribute name="stateValue" type="string" value="null"/> <simplelayout axis="x"/> <button text="Next"> <handler name="onclick"> var cur = Number(canvas.stateValue); if(isNaN(cur)) { cur = 0; } cur++; LzBrowser.loadJS("Lz.setCanvasAttribute('stateValue', '" + escape(cur) + "', true)"); </handler> </button> <button text="Google"> <handler name="onclick"> LzBrowser.loadURL('http://google.com/'); </handler> </button> <text text="${canvas.stateValue}" resize="true" x="100" y="100"/> </canvas> Run the SOLO compile, step forward a few times, then click the 'google' button. Pressing the back button after google loads should work in ie7, firefox and google. Property changes on: openlaszlo/trunk ___________________________________________________________________ Name: svnmerge-integrated - /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7013 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661 /openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334 + /openlaszlo/branches/paperpie:1-6504,6506-6574,6576-7013 /openlaszlo/branches/wafflecone:1-5746,5818-6068,6070-6205,6207-6213,6216-6265,6267-6368,6370-6431,6433-6450,6497,6509,6661,7097 /openlaszlo/trunk:1-3892,3894-3952,3954-4393,4395-4461,4463-4467,4469-4471,4473-5085,5087-5171,5173-5203,5205-5209,5211-5331,5333-5334 Modified: openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs =================================================================== --- openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs 2007-11-05 20:00:28 UTC (rev 7132) +++ openlaszlo/trunk/WEB-INF/lps/lfc/LaszloLibrary.lzs 2007-11-05 20:03:56 UTC (rev 7133) @@ -47,15 +47,6 @@ if ($as2) { // Initialize the DojoExternalInterface class DojoExternalInterface = new DojoExternalInterfaceClass(); - - // Expose your methods - DojoExternalInterface.addCallback("getCanvasAttribute", LzHistory, LzHistory.getCanvasAttribute); - DojoExternalInterface.addCallback("setCanvasAttribute", LzHistory, LzHistory.setCanvasAttribute); - DojoExternalInterface.addCallback("callMethod", LzHistory, LzHistory.callMethod); - DojoExternalInterface.addCallback("receiveHistory", LzHistory, LzHistory.receiveHistory); - - // Tell JavaScript that you are ready to have method calls - DojoExternalInterface.loaded(); } if ($debug) { Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as =================================================================== --- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-11-05 20:00:28 UTC (rev 7132) +++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as 2007-11-05 20:03:56 UTC (rev 7133) @@ -15,6 +15,7 @@ if (isroot) { + this.isroot = true; var is = _root.spriteroot; if (! is) { var is = _root.attachMovie('empty', 'spriteroot', 1000); @@ -218,6 +219,16 @@ LzSprite.prototype.init = function( ) { this.__LZmovieClipRef._visible = this.visible; this.__LZbgRef._visible = this.visible; + if (this.isroot) { + // Expose your methods + DojoExternalInterface.addCallback("getCanvasAttribute", LzHistory, LzHistory.getCanvasAttribute); + DojoExternalInterface.addCallback("setCanvasAttribute", LzHistory, LzHistory.setCanvasAttribute); + DojoExternalInterface.addCallback("callMethod", LzHistory, LzHistory.callMethod); + DojoExternalInterface.addCallback("receiveHistory", LzHistory, LzHistory.receiveHistory); + + // Tell JavaScript that you are ready to have method calls + DojoExternalInterface.loaded(); + } } Modified: openlaszlo/trunk/lps/includes/source/embednew.js =================================================================== --- openlaszlo/trunk/lps/includes/source/embednew.js 2007-11-05 20:00:28 UTC (rev 7132) +++ openlaszlo/trunk/lps/includes/source/embednew.js 2007-11-05 20:03:56 UTC (rev 7133) @@ -118,6 +118,7 @@ // for callbacks onload Lz._swfid = properties.id; dojo.flash.addLoadedListener(Lz._loaded); + dojo.flash.addLoadedListener(Lz.history.init) if (! Lz['setCanvasAttribute']) { Lz.setCanvasAttribute = Lz[properties.id].setCanvasAttribute; } @@ -348,7 +349,7 @@ * @param hist:Boolean value - if true, add a history event. */ _setCanvasAttributeSWF: function (name, value, hist) { - if (this.loaded) { + if (this.loaded && dojo.flash.comm['callMethod']) { if (hist) { Lz.history._store(name, value); } else { Modified: openlaszlo/trunk/lps/includes/source/lzhistory.js =================================================================== --- openlaszlo/trunk/lps/includes/source/lzhistory.js 2007-11-05 20:00:28 UTC (rev 7132) +++ openlaszlo/trunk/lps/includes/source/lzhistory.js 2007-11-05 20:03:56 UTC (rev 7133) @@ -170,7 +170,7 @@ var _this = Lz.history; // TODO: send events to all apps if (h.length == 0 || h == _this._lasthash) return; - if (h.indexOf('_lz') != -1) { + if (Lz.loaded && h.indexOf('_lz') != -1) { // TODO: use rison _this._lasthash = h; h = h.substring(3); @@ -229,4 +229,7 @@ } } }; -window.onload = Lz.history.init; +if (Lz.__BrowserDetect.isFirefox) { + // If this is present, then Firefox does not do its Javascript caching and onload will get fired when coming back to the page. Thanks Jes! + window.onunload = function() {}; +} _______________________________________________ Laszlo-checkins mailing list Laszlo-checkins@openlaszlo.org http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins (wafflecone branch r7102 - cranberry RC)
FF works as described IE 6 returns a blank screen when the next button is clicked the second time I tried the code in the bug (not the zip). The behavior is the same in IE 6, returns a blank screen when the next button is clicked the second time.The URL for IE6 is http://127.0.0.1:8080/lps-4.0.7/my-apps/4999.lzx#
(wafflecone build r7137 - cranberry RC)
Seeing the same behavior as r7102. Note the IE6 test results do not match the results of the reporters. There is a known issue with this not working in IE 6. Fortunately, there is a workaround, described in LPP-5056.
(wafflecone build r7137 - cranberry RC)
LPP-5056 covers the problems in IE6. Also, it is being deployed for FNAC with the workaround. There is quite a bit of implicit testing at FNAC. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
1) In embed-compressed.js, Lz.history.init was being called before Lz._loaded. As a result, the parse function was not setting the canvas attribute to the value that was in the URL when the page was loaded. To solve this, I removed the onload event at the end of the page and added the following to line 53:
dojo.flash.addLoadedListener(Lz.history.init)
2) Even after #1, something (not sure what) still depends on onload. However, in Firefox, if you use the back button to get back to a page, onload does not get fired (see my previous email for details). To solve this, I defined an onunload event. If this is present, then Firefox does not do its Javascript caching and onload will get fired when coming back to the page. So, at the end of the file, I added:
window.onunload=function donothing() {}
These two modifications allow the desired functionality to work properly in Firefox. The use case that needs to be supported in each browser is as follows:
1) Go to test.html
=> App is shown, 0 is displayed in the app. Nothing is in the URL.
2) Click 'Next' twice
=> 2 is displayed in the app. URL has the anchor #_lzstateValue=2
3) Click on "Go to Google" link
=> Google.com is shown
4) Click on back button
=> App is shown again. URL has the anchor #_lzstateValue=2. 2 is displayed in the app.
Currently, with the aforementioned modifications to the JS script, this works perfectly in Firefox. The results for IE are:
1) BROKEN: The URL shows #0 (I'm not sure if this is really a big deal, although it's probably caused by the same problem as step #4)
2) Works
3) Works
4) BROKEN: The URL shows #0, 0 is displayed in the app
The results for Safari are:
1) Works
2) Works
3) Works
4) Works. In a more complicated application, however, the initial value is never set on the canvas... Could this be a timing issue?