Author: max
Date: 2007-09-28 15:02:38 -0700 (Fri, 28 Sep 2007)
New Revision: 6683
Modified:
openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
openlaszlo/trunk/lps/includes/source/embednew.js
openlaszlo/trunk/lps/includes/source/flash.js
openlaszlo/trunk/lps/includes/source/lzhistory.js
Log:
Change 20070928-maxcarlson-r by [EMAIL PROTECTED] on 2007-09-28 13:30:10 PDT
in /Users/maxcarlson/openlaszlo/trunk-clean
for http://svn.openlaszlo.org/openlaszlo/trunk
Summary: One more time: Hand marge r6661 from wafflecone to trunk
New Features:
Bugs Fixed:
Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: LzHistory.as - Use correct syntax for LzBrowser.callJS(). Clear out
old __lzloading code. Initialize persistence and add explicit callback to
Lz.history in receiveHistory().
LzHistory.js - Clear out old __lzloading code.
LaszloCanvas.lzs - Rely on browser history event callbacks to initialize
history state instead of explicit call at canvas init time.
embednew.js - Clean up extra window.onload event, comments. Set Lz.loaded to
true when load is finished. Use anonymous function in _callMethodSWF() to
prevent overwrites.
lzhistory.js - Store and reset the document title in IE to keep the window
title from changing. Make init code more specific to each browser. Use
Lz.callMethod() to set the history state instead of calling dojo.flash.comm.
Don't set top.location.hash to '#0' in IE - use '#' instead. Add
__receivedhistory() callback to receive history from Flash.
flash.js - Ensure callback methods are executed in the proper scope for flash <
8.
Tests: http://localhost:8080/trunk/test/history/history.lzx in dhtml, swf7 and
8 in Firefox mac, IE 6/7 and Safari 2.
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
2007-09-28 21:49:13 UTC (rev 6682)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/dhtml/LzHistory.js
2007-09-28 22:02:38 UTC (rev 6683)
@@ -37,7 +37,6 @@
LzHistory.setHistory = function(s) {
//Debug.write('setHistory', s);
Lz.history.set(s);
- this.__lzloading = true;
}
/**
@@ -54,12 +53,6 @@
LzHistory.__lzhistq = [];
/** @access private */
LzHistory.__lzcurrstate = {};
-/** @access private */
-LzHistory.__lzloading = false;
-/** @access private */
-LzHistory.__lzloadcache = {};
-/** @access private */
-LzHistory.__loadcacheused = false;
DeclareEvent(LzHistory, 'onoffset' );
@@ -81,23 +74,6 @@
//Debug.write('restoring state ', global[o.c], o.c, o.n, o.v);
global[o.c].setAttribute(o.n, o.v);
}
-
-
- // copy values cached during load
- if (this.__loadcacheused) {
- var out = this.__lzhistq[this.offset];
- if (out == null) out = {};
- var u;
- for (u in this.__lzloadcache) {
- //Debug.write('restoring', o, this.__lzloadcache[u]);
- out[u] = this.__lzloadcache[u];
- }
- this.__lzhistq[this.offset] = out;
- this.__lzloadcache = {};
- this.__loadcacheused = false;
- }
-
- this.__lzloading = false;
}
/**
@@ -137,16 +113,9 @@
LzHistory.save = function(who, prop, val) {
// strip off __ so keys can be listed
if (val == null) val = global[who][prop];
- if (this.__lzloading) {
- //Debug.write('caching');
- // cache values until load finishes
- 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 ',u,' to ', this.__lzcurrstate);
+ this.__lzcurrstate[who] = {c: who, n: prop, v: val};
+ this.__lzdirty = true;
}
/**
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
2007-09-28 21:49:13 UTC (rev 6682)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/services/platform/swf/LzHistory.as
2007-09-28 22:02:38 UTC (rev 6683)
@@ -37,8 +37,7 @@
LzHistory.__setHistory = function(s) {
//Debug.write('__setHistory', s);
LzBrowser._jsreset();
- LzBrowser.callJS('Lz.history.set', false, s);
- this.__lzloading = true;
+ LzBrowser.callJS('Lz.history.set', null, s);
}
/**
@@ -58,50 +57,35 @@
LzHistory.__lzhistq = [];
/** @access private */
LzHistory.__lzcurrstate = {};
-/** @access private */
-LzHistory.__lzloading = false;
-/** @access private */
-LzHistory.__lzloadcache = {};
-/** @access private */
-LzHistory.__loadcacheused = false;
DeclareEvent(LzHistory, 'onoffset' );
-
/**
* @access private
*/
LzHistory.receiveHistory = function(o){
- //Debug.write('onhistory ', o, this.__lzhistq);
+ if (this.persist && ! this._persistso) {
+ this.__initPersist();
+ }
+ var l = this.__lzhistq.length;
o *= 1;
- if (! o) o = 0;
- if (o > this.__lzhistq.length - 1) o = this.__lzhistq.length;
- this.offset = o;
- if (this.onoffset.ready) this.onoffset.sendEvent(o);
-
+ if (! o) {
+ o = 0;
+ } else if (o > l - 1) {
+ o = l;
+ }
+
var h = this.__lzhistq[o];
for (var u in h) {
- var o = h[u];
- //Debug.write('restoring state ', global[o.c], o.c, o.n, o.v);
- global[o.c].setAttribute(o.n, o.v);
+ var obj = h[u];
+ //Debug.write('restoring state ', global[obj], obj, obj.n, obj.v);
+ global[u].setAttribute(obj.n, obj.v);
}
-
-
- // copy values cached during load
- if (this.__loadcacheused) {
- var out = this.__lzhistq[this.offset];
- if (out == null) out = {};
- var u;
- for (u in this.__lzloadcache) {
- //Debug.write('restoring', o, this.__lzloadcache[u]);
- out[u] = this.__lzloadcache[u];
- }
- this.__lzhistq[this.offset] = out;
- this.__lzloadcache = {};
- this.__loadcacheused = false;
- }
-
- this.__lzloading = false;
+
+ this.offset = o;
+ //Debug.write('onhistory ', o, this.__lzhistq);
+ if (this.onoffset.ready) this.onoffset.sendEvent(o);
+ LzBrowser.callJS('Lz.history.__receivedhistory', false, o + '');
}
/**
@@ -197,16 +181,9 @@
}
// strip off __ so keys can be listed
if (val == null) val = global[who][prop];
- if (this.__lzloading) {
- //Debug.write('caching');
- // cache values until load finishes
- this.__lzloadcache[who] = {c: who, n: prop, v: val};
- this.__loadcacheused = true;
- } else {
- this.__lzcurrstate[who] = {c: who, n: prop, v: val};
- this.__lzdirty = true;
- //Debug.write('set state of ',who,' to ', this.__lzcurrstate);
- }
+ this.__lzcurrstate[who] = {n: prop, v: val};
+ this.__lzdirty = true;
+ //Debug.write('set state of ',who,' to ', this.__lzcurrstate);
}
/**
@@ -224,7 +201,7 @@
if (this.persist) {
if (! this._persistso) {
- this._persistso = this.getPersist('historystate');
+ this.__initPersist();
}
//Debug.write('_persistso: ', this._persistso);
this._persistso.data[this.offset] = this.__lzcurrstate;
@@ -268,12 +245,6 @@
this.move(-1);
}
-/** get history from local object
- * @access private
- */
-LzHistory.__restorehistory = function() {
- this.receiveHistory(this.offset);
-}
/** @access private */
LzHistory.__initPersist = function() {
if (this.persist) {
Modified: openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2007-09-28
21:49:13 UTC (rev 6682)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/views/LaszloCanvas.lzs 2007-09-28
22:02:38 UTC (rev 6683)
@@ -499,10 +499,6 @@
this.init();
this.sprite.init(true);
- if ($dhtml) {
- } else {
- LzHistory.__restorehistory();
- }
if (this.oninit.ready) this.oninit.sendEvent( this );
if (this.datapath && this.datapath.__LZApplyDataOnInit) {
this.datapath.__LZApplyDataOnInit();
Modified: openlaszlo/trunk/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/embednew.js 2007-09-28 21:49:13 UTC
(rev 6682)
+++ openlaszlo/trunk/lps/includes/source/embednew.js 2007-09-28 22:02:38 UTC
(rev 6683)
@@ -389,6 +389,7 @@
,/** @access private */
_ready: function (cref) {
this.loaded = true;
+ Lz.loaded = true;
if (this._setCanvasAttributeQ) {
this._setCanvasAttributeDequeue();
}
@@ -551,10 +552,10 @@
if (this.loaded) {
return dojo.flash.comm.callMethod(js);
} else {
- this._lastjs = function() {
+ var f = function() {
dojo.flash.comm.callMethod(js);
};
- dojo.flash.addLoadedListener(this._lastjs);
+ dojo.flash.addLoadedListener(f);
}
}
,/** @access private */
@@ -567,17 +568,8 @@
}
return root;
}
- /* TODO max: look at this and see if there is a merge conflict,
- from wafflecone. [bshine 2007.09.14] */
,/** @access private */
- _checkHistory: function() {
- window.setInterval('Lz._checklocationhash()', 300)
- }
- /* TODO max: look at this and see if there is a merge conflict,
- from wafflecone. [bshine 2007.09.14] */
- ,/** @access private */
_sendMouseWheel: function(d) {
if (d != null) this.callMethod("LzKeys.__mousewheelEvent(" + d + ")");
}
};
-window.onload = Lz._checkHistory;
Modified: openlaszlo/trunk/lps/includes/source/flash.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/flash.js 2007-09-28 21:49:13 UTC
(rev 6682)
+++ openlaszlo/trunk/lps/includes/source/flash.js 2007-09-28 22:02:38 UTC
(rev 6683)
@@ -1012,17 +1012,19 @@
// the method name has a dot in it, such as "dojo.flash.loaded", we
// eval it so that the method gets run against an instance
var runMe;
+ var scope = window;
if(functionName.indexOf(".") == -1){ // global function
runMe = window[functionName];
}else{
// instance function
runMe = eval(functionName);
+ scope = eval(functionName.substring(0,
functionName.lastIndexOf(".")));
}
// make the call and get the results
var results = null;
if(runMe != null){
- results = runMe.apply(null, flashArgs);
+ results = runMe.apply(scope, flashArgs);
}
results += '';
Modified: openlaszlo/trunk/lps/includes/source/lzhistory.js
===================================================================
--- openlaszlo/trunk/lps/includes/source/lzhistory.js 2007-09-28 21:49:13 UTC
(rev 6682)
+++ openlaszlo/trunk/lps/includes/source/lzhistory.js 2007-09-28 22:02:38 UTC
(rev 6683)
@@ -9,27 +9,34 @@
Lz.history = {
_currentstate: null
,init: function() {
+ var _this = Lz.history;
+ _this._title = top.document.title;
Lz.__BrowserDetect.init();
- Lz.history._currentstate = Lz.history.get();
+ var currstate = _this.get();
if (Lz.__BrowserDetect.isSafari) {
// must track state ourselves...
- Lz.history._historylength = history.length;
- Lz.history._history = [];
- for (var i = 1; i < Lz.history._historylength; i++) {
- Lz.history._history.push('');
+ _this._historylength = history.length;
+ _this._history = [];
+ for (var i = 1; i < _this._historylength; i++) {
+ _this._history.push('');
}
- Lz.history._history.push(Lz.history._currentstate);
+ _this._history.push(currstate);
var form = document.createElement('form');
form.method = 'get';
document.body.appendChild(form);
- Lz.history._form = form;
+ _this._form = form;
if (! top.document.location.lzaddr) {
top.document.location.lzaddr = {};
}
if (top.document.location.lzaddr.history) {
- Lz.history._history =
top.document.location.lzaddr.history.split(',');
+ _this._history =
top.document.location.lzaddr.history.split(',');
}
+ if (currstate != '') {
+ _this.set(currstate)
+ }
} else if (Lz.__BrowserDetect.isIE) {
+ var currstate = top.location.hash;
+ if (currstate) currstate = currstate.substring(1);
// use an iframe;
var i = document.createElement('iframe');
Lz.__setAttr(i, 'id', 'lzHistory');
@@ -38,29 +45,27 @@
i.style.position = 'absolute';
i.style.display = 'none';
i.style.left = '-1000px';
- Lz.history._iframe = document.getElementById('lzHistory');
- var doc = Lz.history._iframe.contentWindow.document;
+ _this._iframe = document.getElementById('lzHistory');
+ var doc = _this._iframe.contentDocument ||
_this._iframe.contentWindow.document;
doc.open();
doc.close();
- if (Lz.history._currentstate != '') doc.location.hash = '#' +
Lz.history._currentstate;
+ //alert('currstate ' + currstate);
+ if (currstate != '') {
+ doc.location.hash = '#' + currstate;
+ _this._parse(currstate)
+ _this._currentstate = currstate;
+ }
+ } else {
+ if (currstate != '') {
+ _this._parse(currstate)
+ _this._currentstate = currstate;
+ }
}
- if (Lz.history._currentstate != '')
Lz.history._parse(Lz.history._currentstate)
- //alert('init');
+ //alert('init ' + currstate);
setInterval('Lz.history._checklocationhash()', 100)
}
,/** @access private */
- _historyEvent: function (value) {
- if (dojo.flash.ready) {
- //alert(value);
- dojo.flash.comm.receiveHistory(value + '');
- return true;
- } else {
- //alert('dojo.flash is not ready: _historyEvent' + value);
- }
- }
-
- ,/** @access private */
_checklocationhash: function() {
if (dojo.flash && dojo.flash.info && dojo.flash.info.installing)
return;
if (Lz.__BrowserDetect.isSafari) {
@@ -84,10 +89,13 @@
if (Lz.__BrowserDetect.isIE) {
if (h != this._currentstate) {
- top.location.hash = '#' + h;
+ top.location.hash = h == '0' ? '' : '#' + h;
this._currentstate = h;
this._parse(h);
}
+ if (top.document.title != this._title) {
+ top.document.title = this._title;
+ }
} else {
this._currentstate = h;
this._parse(h);
@@ -103,8 +111,8 @@
var hash = '#' + s;
if (Lz.__BrowserDetect.isIE) {
- top.location.hash = hash;
- var doc = Lz.history._iframe.contentWindow.document;
+ top.location.hash = hash == '#0' ? '' : hash;
+ var doc = Lz.history._iframe.contentDocument ||
Lz.history._iframe.contentWindow.document;
doc.open();
doc.close();
doc.location.hash = hash;
@@ -144,12 +152,12 @@
}
,/** @access private */
_parse: function(h) {
+ var _this = Lz.history;
// TODO: send events to all apps
- if (h.length == 0 || h == this._lasthash) return;
- //alert('_parse '+ h);
+ if (h.length == 0 || h == _this._lasthash) return;
if (h.indexOf('_lz') != -1) {
// TODO: use rison
- this._lasthash = h;
+ _this._lasthash = h;
h = h.substring(3);
var a = h.split(',');
for (var j = 0; j < a.length; j++) {
@@ -161,15 +169,13 @@
if (window['canvas']) canvas.setAttribute(name, val);
}
} else {
+ //alert('_parse test' + h + ', ' + _this._lasthash);
//history id
- if (Lz.history._historyEvent(h)) {
- // if successful, don't send again
- this._lasthash = h;
- }
+ if (Lz.callMethod && h != Lz.history._lasthash)
Lz.callMethod("LzHistory.receiveHistory(" + h + ")");
if (Lz.__dhtmlhistoryready && LzHistory &&
LzHistory['receiveHistory']) {
- //alert(h);
+ //alert('dhtml ' + h);
LzHistory.receiveHistory(h);
- this._lasthash = h;
+ _this._lasthash = h;
}
}
}
@@ -187,5 +193,10 @@
this.set('_lz' + o);
//window.frames['_lzhist'].location = newurl;
}
+ ,/** @access private called from flash */
+ __receivedhistory: function(h) {
+ Lz.history._lasthash = h + '';
+ //alert('__receivedhistory '+ Lz.history._lasthash);
+ }
};
window.onload = Lz.history.init;
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins