Author: max
Date: 2007-08-25 11:15:52 -0700 (Sat, 25 Aug 2007)
New Revision: 6239
Modified:
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
openlaszlo/branches/legals/lps/includes/source/embednew.js
Log:
20070824-maxcarlson-s by [EMAIL PROTECTED] on 2007-08-24 16:48:32 PDT
in /Users/maxcarlson/openlaszlo/legals-clean
for http://svn.openlaszlo.org/openlaszlo/branches/legals
Summary: Fix size of embedded DHTML apps
New Features:
Bugs Fixed: LPP-4579 - DHTML apps aren't sized properly when embedded in a page
with other HTML
Technical Reviewer: promanik
QA Reviewer: jcrowley
Doc Reviewer: (pending)
Documentation:
Release Notes:
Details: LzSprite.as - Add capabilities.readcanvassizefromsprite entry.
LzSprite.js - Set the container div's width and height like the flash embed
script does. Add capabilities.readcanvassizefromsprite entry. Avoid clipping
if capabilities.canvas_div_cannot_be_clipped == true.
LaszloCanvas.lzs - Only read sprite properties if
capabilities.readcanvassizefromsprite == true.
embednew.js - Store the correct sizes in the propcache.
Tests: See LPP-4579
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:00:33 UTC (rev 6238)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/dhtml/LzSprite.js
2007-08-25 18:15:52 UTC (rev 6239)
@@ -26,20 +26,19 @@
this.bgcolor = p.bgcolor;
}
if (p.width) {
+ root.style.width = p.width;
div.style.width = p.width;
var w = p.width.indexOf('%') != -1 ? p.width : parseInt(p.width);
this._w = w;
this.width = w;
}
if (p.height) {
+ root.style.height = p.height;
div.style.height = p.height;
var h = p.height.indexOf('%') != -1 ? p.height :
parseInt(p.height);
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';
@@ -230,6 +229,7 @@
rotation: false
// Scale canvas to percentage values
,scalecanvastopercentage: true
+ ,readcanvassizefromsprite: true
,opacity: true
,colortransform: false
,audio: false
@@ -381,7 +381,6 @@
var s = document.getElementById('lzsplash');
if (s) LzSprite.prototype.__discardElement(s);
- if (this._id) Lz[this._id]._ready();
}
}
@@ -1095,6 +1094,7 @@
* @access private
*/
LzSprite.prototype.__updateClip = function() {
+ if (this.isroot && this.capabilities.canvas_div_cannot_be_clipped == true)
return;
if (this.clip && this.width != null && this.width >= 0 && this.height !=
null && this.height >= 0) {
var s = 'rect(0px ' + this._w + ' ' + this._h + ' 0px)';
this.__LZdiv.style.clip = s
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
2007-08-25 18:00:33 UTC (rev 6238)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
2007-08-25 18:15:52 UTC (rev 6239)
@@ -36,6 +36,8 @@
rotation: true
// Avoid scaling canvas to percentage values - SWF already scales the
viewport size, so take window size literally to avoid scaling twice
,scalecanvastopercentage: false
+ // the canvas already knows its size
+ ,readcanvassizefromsprite: false
,opacity: true
,colortransform: true
,audio: true
Modified: openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
===================================================================
--- openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
2007-08-25 18:00:33 UTC (rev 6238)
+++ openlaszlo/branches/legals/WEB-INF/lps/lfc/views/LaszloCanvas.lzs
2007-08-25 18:15:52 UTC (rev 6239)
@@ -110,15 +110,17 @@
delete args.proxied;
this.sprite = new LzSprite(this, true);
- if (this.sprite.width) {
- args.width = this.sprite.width;
+ if (this.sprite.capabilities.readcanvassizefromsprite == true) {
+ if (this.sprite.width) {
+ args.width = this.sprite.width;
+ }
+ if (this.sprite.height) {
+ args.height = this.sprite.height;
+ }
+ if (this.sprite.bgcolor) {
+ args.bgcolor = this.sprite.bgcolor;
+ }
}
- if (this.sprite.height) {
- args.height = this.sprite.height;
- }
- if (this.sprite.bgcolor) {
- args.bgcolor = this.sprite.bgcolor;
- }
this.__canvaswidthratio = null;
this.width = Number(args.width);
Modified: openlaszlo/branches/legals/lps/includes/source/embednew.js
===================================================================
--- openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-08-25
18:00:33 UTC (rev 6238)
+++ openlaszlo/branches/legals/lps/includes/source/embednew.js 2007-08-25
18:15:52 UTC (rev 6239)
@@ -109,14 +109,13 @@
,setCanvasAttribute: Lz._setCanvasAttributeSWF
,getCanvasAttribute: Lz._getCanvasAttributeSWF
,callMethod: Lz._callMethodSWF
- ,_ready: Lz._ready
+ ,_loaded: Lz._loaded
,_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;
@@ -181,8 +180,8 @@
Lz.__propcache = {
bgcolor: properties.bgcolor
- ,width: properties.width.indexOf('%') == -1 ? properties.width +
'px' : '100%'
- ,height: properties.height.indexOf('%') == -1 ? properties.height
+ 'px' : '100%'
+ ,width: properties.width.indexOf('%') == -1 ? properties.width +
'px' : properties.width
+ ,height: properties.height.indexOf('%') == -1 ? properties.height
+ 'px' : properties.height
,id: properties.id
,appenddiv: Lz._getAppendDiv(properties.id, properties.appenddivid)
,url: url
@@ -192,7 +191,6 @@
Lz[properties.id] = {
runtime: 'dhtml'
,_id: properties.id
- ,_ready: Lz._ready
,setCanvasAttribute: Lz._setCanvasAttributeDHTML
,getCanvasAttribute: Lz._getCanvasAttributeDHTML
}
@@ -348,6 +346,7 @@
} else {
this._setCanvasAttributeQ.push([name, value, hist]);
}
+ dojo.flash.addLoadedListener(this._loaded);
}
}
,/**
@@ -381,27 +380,18 @@
_loaded: function () {
if (dojo.flash.info.commVersion == 8) {
// wait a bit longer for Flash to init
- setTimeout('Lz["'+Lz._swfid
+'"]._ready.call(Lz["'+Lz._swfid+'"])', 100);
+ setTimeout('Lz["'+Lz._id +'"]._setCanvasAttributeDequeue()', 100);
} else {
- Lz[Lz._swfid]._ready.call(Lz[Lz._swfid]);
+ Lz[Lz._id]._setCanvasAttributeDequeue();
}
}
,/** @access private */
_setCanvasAttributeDequeue: function () {
- while (this._setCanvasAttributeQ.length > 0) {
- var a = this._setCanvasAttributeQ.pop();
- this.setCanvasAttribute(a[0], a[1], a[2]);
+ while (Lz._setCanvasAttributeQ.length > 0) {
+ var a = Lz._setCanvasAttributeQ.pop();
+ Lz.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
@@ -413,7 +403,7 @@
if (dojo.flash.ready) {
return dojo.flash.comm.getCanvasAttribute(name);
} else {
- alert('Flash is not ready: getCanvasAttribute' + name);
+ alert('dojo.flash is not ready: getCanvasAttribute' + name);
}
}
@@ -547,13 +537,8 @@
* @param js:String javascript to call in the form
'foo.bar.methodcall(arg1,arg2,...)'
*/
_callMethodSWF: function (js) {
- if (dojo.flash.ready) {
+ if (dojo.flash.comm) {
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