Author: max
Date: 2007-08-25 11:35:44 -0700 (Sat, 25 Aug 2007)
New Revision: 6240
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/branches/legals/lps/includes/source/embednew.js
Log:
+ My last checkin blew these changes away - this should resolve that:
Summary: Add onload event that fires rowser javascript when the app is done
loading
New Features:
Bugs Fixed: LPP-4578 - Add API to find out when an LZX app has been loaded
Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: LzSprite.js - Store propcache.id for use in canvas init callback. Add
callback when canvas is initted.
LzBrowser.as - Clear out __jscallback if it's not a valid function.
embednew.js - Store necessary state in swfEmbed and dhtmlEmbed to get unified
_ready() call later. Move addLoadedListener() call to swfEmbed(). Fix _loaded
to call _ready() in the correct scope. Fix scope in _setCanvasAttributeQ().
Add implementation of _ready() which checks for the presence of an onload
method. If present, it is called. Clean up error for early
_getCanvasAttributeSWF() calls. _callMethodSWF() calls queue until flash is
ready.
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-08-25 18:15:52 UTC (rev 6239)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-08-25 18:35:44 UTC (rev 6240)
@@ -39,6 +39,9 @@
this._h = h;
this.height = h;
}
+ if (p.id) {
+ this._id = p.id;
+ }
if (this.quirks.canvas_div_cannot_be_clipped == false && p.width &&
p.width.indexOf('%') == -1 && p.height && p.height.indexOf('%') == -1 ) {
div.style.clip = 'rect(0px ' + this._w + ' ' + this._h + ' 0px)';
div.style.overflow = 'hidden';
@@ -381,6 +384,7 @@
var s = document.getElementById('lzsplash');
if (s) LzSprite.prototype.__discardElement(s);
+ if (this._id) Lz[this._id]._ready();
}
}
Modified: openlaszlo/branches/legals/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-08-25
18:15:52 UTC (rev 6239)
+++ openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-08-25
18:35:44 UTC (rev 6240)
@@ -109,13 +109,14 @@
,setCanvasAttribute: Lz._setCanvasAttributeSWF
,getCanvasAttribute: Lz._getCanvasAttributeSWF
,callMethod: Lz._callMethodSWF
- ,_loaded: Lz._loaded
+ ,_ready: Lz._ready
,_setCanvasAttributeDequeue: Lz._setCanvasAttributeDequeue
}
+ // for callbacks onload
+ Lz._swfid = properties.id;
+ dojo.flash.addLoadedListener(Lz._loaded);
if (! Lz['setCanvasAttribute']) {
Lz.setCanvasAttribute = Lz[properties.id].setCanvasAttribute;
- // for queuing
- Lz._id = properties.id;
}
if (! Lz['getCanvasAttribute']) Lz.getCanvasAttribute =
Lz[properties.id].getCanvasAttribute;
if (! Lz['callMethod']) Lz.callMethod = Lz[properties.id].callMethod;
@@ -191,6 +192,7 @@
Lz[properties.id] = {
runtime: 'dhtml'
,_id: properties.id
+ ,_ready: Lz._ready
,setCanvasAttribute: Lz._setCanvasAttributeDHTML
,getCanvasAttribute: Lz._getCanvasAttributeDHTML
}
@@ -346,7 +348,6 @@
} else {
this._setCanvasAttributeQ.push([name, value, hist]);
}
- dojo.flash.addLoadedListener(this._loaded);
}
}
,/**
@@ -380,18 +381,27 @@
_loaded: function () {
if (dojo.flash.info.commVersion == 8) {
// wait a bit longer for Flash to init
- setTimeout('Lz["'+Lz._id +'"]._setCanvasAttributeDequeue()', 100);
+ setTimeout('Lz["'+Lz._swfid
+'"]._ready.call(Lz["'+Lz._swfid+'"])', 100);
} else {
- Lz[Lz._id]._setCanvasAttributeDequeue();
+ Lz[Lz._swfid]._ready.call(Lz[Lz._swfid]);
}
}
,/** @access private */
_setCanvasAttributeDequeue: function () {
- while (Lz._setCanvasAttributeQ.length > 0) {
- var a = Lz._setCanvasAttributeQ.pop();
- Lz.setCanvasAttribute(a[0], a[1], a[2]);
+ while (this._setCanvasAttributeQ.length > 0) {
+ var a = this._setCanvasAttributeQ.pop();
+ this.setCanvasAttribute(a[0], a[1], a[2]);
}
}
+ ,/** @access private */
+ _ready: function () {
+ if (this._setCanvasAttributeQ) {
+ this._setCanvasAttributeDequeue();
+ }
+ if (this.onload && typeof this.onload == 'function') {
+ this.onload();
+ }
+ }
,/**
* Reads an attribute from the canvas of an embedded SWF application and
@@ -403,7 +413,7 @@
if (dojo.flash.ready) {
return dojo.flash.comm.getCanvasAttribute(name);
} else {
- alert('dojo.flash is not ready: getCanvasAttribute' + name);
+ alert('Flash is not ready: getCanvasAttribute' + name);
}
}
@@ -537,8 +547,13 @@
* @param js:String javascript to call in the form
'foo.bar.methodcall(arg1,arg2,...)'
*/
_callMethodSWF: function (js) {
- if (dojo.flash.comm) {
+ if (dojo.flash.ready) {
return dojo.flash.comm.callMethod(js);
+ } else {
+ this._lastjs = function() {
+ dojo.flash.comm.callMethod(js);
+ };
+ dojo.flash.addLoadedListener(this._lastjs);
}
}
_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins