Author: max
Date: 2007-08-07 18:24:40 -0700 (Tue, 07 Aug 2007)
New Revision: 5959

Modified:
   
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
   
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
   openlaszlo/branches/wafflecone/lps/includes/source/embednew.js
   openlaszlo/branches/wafflecone/test/history/history.lzx
Log:
Change 20070807-maxcarlson-F by [EMAIL PROTECTED] on 2007-08-07 14:38:37 PDT
    in /Users/maxcarlson/openlaszlo/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Turn off history persistence by default

New Features:

Bugs Fixed: LPP-4442 - history mechanism seems to take effect on startup

Technical Reviewer: promanik
QA Reviewer: ben
Doc Reviewer: (pending)

Documentation:

Release Notes:

Details: history.lzx - Change example to use new setPersist(true) API (so 
persistence still works in swf)

LzHistory.as - Turn persistence off by default.  Rename setHistory to 
__setHistory.  Add more safety checking and warnings to save() method (using 
3.4-style code would have hanged the browser before).  Clean up existing 
persistent object, if any in __initPersist().  Add setPersist() API to turn 
persistence on/off.

LzHistory.js - Add setPersist() API with warning for DHTML (not yet 
implemented).

embednew.js -  Make sure initial history event is sent even if the hash is 
empty.
    

Tests: silver/main.lzx?lzr=swf8 now has correct back-button behavior.  
http://localhost:8080/wafflecone/test/history/ works as before - with 
persistence across page reloads in swf via setPersist(true)



Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
===================================================================
--- 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
 2007-08-07 23:47:40 UTC (rev 5958)
+++ 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
 2007-08-08 01:24:40 UTC (rev 5959)
@@ -205,4 +205,8 @@
     if (this.onoffset.ready) this.onoffset.sendEvent(0);
 }
 
+LzHistory.setPersist = function() {
+    if ($debug) Debug.warn('History persistence is not implemented in DHTML.');
+}
+
 Lz.__dhtmlhistoryready = true;

Modified: 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
===================================================================
--- 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
   2007-08-07 23:47:40 UTC (rev 5958)
+++ 
openlaszlo/branches/wafflecone/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
   2007-08-08 01:24:40 UTC (rev 5959)
@@ -34,8 +34,8 @@
 /**
   * @access private
   */
-LzHistory.setHistory = function(s) {
-    //Debug.write('setHistory', s);
+LzHistory.__setHistory = function(s) {
+    //Debug.write('__setHistory', s);
     LzBrowser._jsreset();
     LzBrowser.callJS('Lz._setHash("' + s + '")', false);
     this.__lzloading = true;
@@ -48,7 +48,7 @@
     return SharedObject.getLocal(n);
 }
 
-LzHistory.persist = true;
+LzHistory.persist = false;
 
 // The current offset (zero-based) in the history value stack. 
 LzHistory.offset = 0;
@@ -191,6 +191,10 @@
   * e.g. scope.setAttribute('attribute_name_to_set', value). 
   */
 LzHistory.save = function(who, prop, val) {
+    if (typeof who != 'string') {
+        if (who['id']) who = who['id'];
+        if ($debug) Debug.warn('Warning: LzHistory.save() requires a view ID 
to be passed in as a string for the first argument.');
+    }
     // strip off __ so keys can be listed
     if (val == null) val = global[who][prop];
     if (this.__lzloading) {
@@ -199,9 +203,9 @@
         this.__lzloadcache[who] = {c: who, n: prop, v: val};
         this.__loadcacheused = true;
     } else {
-        //Debug.write('set state of ',u,' to ', this.__lzcurrstate);
         this.__lzcurrstate[who] = {c: who, n: prop, v: val};
         this.__lzdirty = true;
+        //Debug.write('set state of ',who,' to ', this.__lzcurrstate);
     }
 }
 
@@ -244,7 +248,7 @@
     if (this.__lzhistq.length >= o) {
         //Debug.write('move', o, this.__lzhistq.length, this.__lzhistq);
         //this.offset = o;
-        this.setHistory(o);
+        this.__setHistory(o);
     }
 }
 
@@ -284,7 +288,9 @@
                 //Debug.write('restoring', i, d[i]);
             }
         }
-    }
+    } else {
+        if (this._persistso) this._persistso = null;
+    }    
 }
 
 LzHistory.clear = function() {
@@ -300,4 +306,9 @@
     if (this.onoffset.ready) this.onoffset.sendEvent(0);
 }
 
+LzHistory.setPersist = function(p) {
+    this.persist = p;
+    this.__initPersist();
+}
+
 LzHistory.__initPersist();

Modified: openlaszlo/branches/wafflecone/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/branches/wafflecone/lps/includes/source/embednew.js      
2007-08-07 23:47:40 UTC (rev 5958)
+++ openlaszlo/branches/wafflecone/lps/includes/source/embednew.js      
2007-08-08 01:24:40 UTC (rev 5959)
@@ -556,6 +556,8 @@
     ,/** @access private */
     _checklocationhash: function() {
         var h = window.top.location.hash;
+        // Make sure initial history event is sent even if the hash is empty
+        if (h == '') h = '#0';
         if (h != this.__lasthash && h.length > 1) {
             if (h.indexOf('_lz') != -1) {
                 this.__lasthash = h;

Modified: openlaszlo/branches/wafflecone/test/history/history.lzx
===================================================================
--- openlaszlo/branches/wafflecone/test/history/history.lzx     2007-08-07 
23:47:40 UTC (rev 5958)
+++ openlaszlo/branches/wafflecone/test/history/history.lzx     2007-08-08 
01:24:40 UTC (rev 5959)
@@ -6,6 +6,9 @@
     <method event="onfoo" args="f">
         Debug.write('external call', f); 
     </method>
+    <method event="oninit">
+        LzHistory.setPersist(true);
+    </method>
 
     <class name="histinputtext" extends="inputtext">
         <method event="onblur">


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to