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 [EMAIL PROTECTED] 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: LPP-4999 - IE resets history to #0 after visiting another site and 
pressing the back button, LPP-5016 - _parse gets called before canvas is 
initialized

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
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to