From seam-commits at lists.jboss.org Sat Aug 29 12:51:42 2009
Content-Type: multipart/mixed; boundary="===============7405939258636843508=="
MIME-Version: 1.0
From: seam-commits at lists.jboss.org
To: seam-commits at lists.jboss.org
Subject: [seam-commits] Seam SVN: r11448 - in sandbox/trunk/modules/xwidgets:
src/main/javascript and 1 other directory.
Date: Sat, 29 Aug 2009 12:51:42 -0400
Message-ID: <200908291651.n7TGpgNH031455@svn01.web.mwc.hst.phx2.redhat.com>
--===============7405939258636843508==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: shane.bryzak(a)jboss.com
Date: 2009-08-29 12:51:42 -0400 (Sat, 29 Aug 2009)
New Revision: 11448
Modified:
sandbox/trunk/modules/xwidgets/examples/panels/index.html
sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
Log:
use standards mode
Modified: sandbox/trunk/modules/xwidgets/examples/panels/index.html
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sandbox/trunk/modules/xwidgets/examples/panels/index.html 2009-08-28 21=
:17:16 UTC (rev 11447)
+++ sandbox/trunk/modules/xwidgets/examples/panels/index.html 2009-08-29 16=
:51:42 UTC (rev 11448)
@@ -1,8 +1,16 @@
+
+
+
+
+
+
-
+
Panel Example
=
-
+
=
=
Modified: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js 2009-08-28 21:=
17:16 UTC (rev 11447)
+++ sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js 2009-08-29 16:=
51:42 UTC (rev 11448)
@@ -11,6 +11,22 @@
}
=
Package("xw");
+
+/**
+ * Browser info - based on Prototype JS
+ */
+xw.Browser =3D function()
+{
+ var ua =3D navigator.userAgent;
+ var isOpera =3D Object.prototype.toString.call(window.opera) =3D=3D '[ob=
ject Opera]';
+ return {
+ IE: !!window.attachEvent && !isOpera,
+ Opera: isOpera,
+ WebKit: ua.indexOf('AppleWebKit/') > -1,
+ Gecko: ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') =3D=3D=
=3D -1,
+ MobileSafari: /Apple.*Mobile.*Safari/.test(ua)
+ }
+} =
=
/**
* System Utils =
@@ -116,6 +132,11 @@
}
}
=
+/**
+ * Returns the specified style for an element
+ *
+ * TODO - probably need to fix this up for safari - use xw.Sys.getBorder()=
as an example
+ */ =
xw.Sys.getStyle =3D function(element, cssRule)
{
var strValue =3D "";
@@ -146,11 +167,21 @@
border.left =3D parseInt(control.currentStyle.borderLeftWidth);
} =
else =
- {
- border.top =3D parseInt(getComputedStyle(control,null).getPropertyVa=
lue('border-top-width'));
- border.right =3D parseInt(getComputedStyle(control,null).getProperty=
Value('border-right-width'));
- border.bottom =3D parseInt(getComputedStyle(control,null).getPropert=
yValue('border-bottom-width'));
- border.left =3D parseInt(getComputedStyle(control,null).getPropertyV=
alue('border-left-width'));
+ { =
+ try
+ {
+ border.top =3D parseInt(getComputedStyle(control,null).getProperty=
Value('border-top-width'));
+ border.right =3D parseInt(getComputedStyle(control,null).getProper=
tyValue('border-right-width'));
+ border.bottom =3D parseInt(getComputedStyle(control,null).getPrope=
rtyValue('border-bottom-width'));
+ border.left =3D parseInt(getComputedStyle(control,null).getPropert=
yValue('border-left-width'));
+ }
+ catch (e) // last resort
+ {
+ border.top =3D parseInt(control.style.borderTopWidth);
+ border.right =3D parseInt(control.style.borderRightWidth);
+ border.bottom =3D parseInt(control.style.borderBottomWidth);
+ border.left =3D parseInt(control.style.borderLeftWidth);
+ }
}
} =
else =
@@ -163,6 +194,22 @@
return border;
}
=
+xw.Sys.parseXml =3D function(body)
+{
+ try
+ {
+ var doc =3D new ActiveXObject("Microsoft.XMLDOM");
+ doc.async =3D "false";
+ doc.loadXML(body);
+ return doc;
+ }
+ catch (e)
+ {
+ var doc =3D new DOMParser().parseFromString(body, "text/xml");
+ return doc;
+ }
+}
+
/**
* A Map implementation
*/
@@ -431,8 +478,11 @@
if (req.readyState =3D=3D 4)
{
if (req.status =3D=3D 200 || req.status =3D=3D 0)
- {
- var viewRoot =3D req.responseXML.documentElement;
+ {
+ var viewRoot;
+ if (req.responseXml) viewRoot =3D req.responseXML.documentElement;
+ else viewRoot =3D xw.Sys.parseXml(req.responseText).documentElement;
+ =
if (viewRoot.tagName =3D=3D "view")
{
xw.ViewManager.createView(viewRoot, container);
@@ -551,8 +601,8 @@
=
xw.Bounds.prototype.applyToControl =3D function(control)
{ =
- if (this.left !=3D null) control.style.left =3D this.left;
- if (this.top !=3D null) control.style.top =3D this.top; =
+ if (this.left !=3D null) control.style.left =3D this.left + "px";
+ if (this.top !=3D null) control.style.top =3D this.top + "px"; =
=
for (var i in this.style) control.style[i] =3D this.style[i]; =
=
=
@@ -596,23 +646,26 @@
=
for (var i =3D 0; i < topControls.length; i++)
{
- this.bounds.put(topControls[i], new xw.Bounds(null, null, topControl=
s[i].height, null)
+ var bounds =3D new xw.Bounds(null, null, topControls[i].height, null)
.addStyleProperty("position", "absolute")
- .addStyleProperty("top", topSpace)
+ .addStyleProperty("top", topSpace + "px")
.addStyleProperty("left", "0")
- .addStyleProperty("right", "0")
- );
+ .addStyleProperty("right", "0"); =
+ =
+ this.bounds.put(topControls[i], bounds);
+
topSpace +=3D 1.0 * topControls[i].height;
}
=
for (var i =3D 0; i < bottomControls.length; i++)
{
- this.bounds.put(bottomControls[i], new xw.Bounds(null, null, bottomC=
ontrols[i].height, null)
+ var bounds =3D new xw.Bounds(null, null, bottomControls[i].height, n=
ull)
.addStyleProperty("position","absolute")
.addStyleProperty("bottom", bottomSpace)
.addStyleProperty("left", "0")
- .addStyleProperty("right", "0")
- ); =
+ .addStyleProperty("right", "0");
+ =
+ this.bounds.put(bottomControls[i], bounds); =
bottomSpace +=3D 1.0 * bottomControls[i].height; =
}
=
@@ -620,9 +673,9 @@
{
this.bounds.put(leftControls[i], new xw.Bounds(null, null, null, lef=
tControls[i].width)
.addStyleProperty("position", "absolute")
- .addStyleProperty("left", leftSpace)
- .addStyleProperty("top", topSpace)
- .addStyleProperty("bottom", bottomSpace)
+ .addStyleProperty("left", leftSpace + "px")
+ .addStyleProperty("top", topSpace + "px")
+ .addStyleProperty("bottom", bottomSpace + "px")
);
leftSpace +=3D 1.0 * leftControls[i].width; =
}
@@ -631,9 +684,9 @@
{
this.bounds.put(rightControls[i], new xw.Bounds(null, null, null, ri=
ghtControls[i].width)
.addStyleProperty("position", "absolute")
- .addStyleProperty("right", rightSpace)
- .addStyleProperty("top", topSpace)
- .addStyleProperty("bottom", bottomSpace)
+ .addStyleProperty("right", rightSpace + "px")
+ .addStyleProperty("top", topSpace + "px")
+ .addStyleProperty("bottom", bottomSpace + "px")
);
rightSpace +=3D 1.0 * rightControls[i].width;
}
@@ -642,10 +695,10 @@
{
this.bounds.put(clientControls[i], new xw.Bounds(null, null, null, n=
ull)
.addStyleProperty("position", "absolute")
- .addStyleProperty("left", leftSpace)
- .addStyleProperty("right", rightSpace)
- .addStyleProperty("top", topSpace)
- .addStyleProperty("bottom", bottomSpace)
+ .addStyleProperty("left", leftSpace + "px")
+ .addStyleProperty("right", rightSpace + "px")
+ .addStyleProperty("top", topSpace + "px")
+ .addStyleProperty("bottom", bottomSpace + "px")
); =
}
=
--===============7405939258636843508==--