[seam-commits] Seam SVN: r11448 - in sandbox/trunk/modules/xwidgets: src/main/javascript and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Sat Aug 29 12:51:42 EDT 2009


Author: shane.bryzak at 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
===================================================================
--- 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 @@
+<?xml version="1.0" encoding="iso-8859-1" ?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<head>
+  <style>
+    html, body { height: 100% !important;}
+  </style>
+</head>
+
 <html>
-  <body style="background-color:#eeeeee">
+  <body style="background-color:#eeeeee;width:100%;height:100%">
     <h1>Panel Example</h1>
   
-    <div id="container" style="border:1px solid black;width:75%;height:75%"></div>
+    <div id="container" style="border:1px solid black;width:75%;height:50%"></div>
     
     <script src="../../src/main/javascript/xw.js"></script>
       

Modified: sandbox/trunk/modules/xwidgets/src/main/javascript/xw.js
===================================================================
--- 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 = function()
+{
+  var ua = navigator.userAgent;
+  var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]';
+  return {
+    IE:             !!window.attachEvent && !isOpera,
+    Opera:          isOpera,
+    WebKit:         ua.indexOf('AppleWebKit/') > -1,
+    Gecko:          ua.indexOf('Gecko') > -1 && ua.indexOf('KHTML') === -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 = function(element, cssRule)
 {
 	var strValue = "";
@@ -146,11 +167,21 @@
       border.left = parseInt(control.currentStyle.borderLeftWidth);
     } 
     else 
-    {
-      border.top = parseInt(getComputedStyle(control,null).getPropertyValue('border-top-width'));
-      border.right = parseInt(getComputedStyle(control,null).getPropertyValue('border-right-width'));
-      border.bottom = parseInt(getComputedStyle(control,null).getPropertyValue('border-bottom-width'));
-      border.left = parseInt(getComputedStyle(control,null).getPropertyValue('border-left-width'));
+    {    
+      try
+      {
+        border.top = parseInt(getComputedStyle(control,null).getPropertyValue('border-top-width'));
+        border.right = parseInt(getComputedStyle(control,null).getPropertyValue('border-right-width'));
+        border.bottom = parseInt(getComputedStyle(control,null).getPropertyValue('border-bottom-width'));
+        border.left = parseInt(getComputedStyle(control,null).getPropertyValue('border-left-width'));
+      }
+      catch (e) // last resort
+      {
+        border.top = parseInt(control.style.borderTopWidth);
+        border.right = parseInt(control.style.borderRightWidth);
+        border.bottom = parseInt(control.style.borderBottomWidth);
+        border.left = parseInt(control.style.borderLeftWidth);
+      }
     }
   } 
   else 
@@ -163,6 +194,22 @@
   return border;
 }
 
+xw.Sys.parseXml = function(body)
+{
+  try
+  {
+    var doc = new ActiveXObject("Microsoft.XMLDOM");
+    doc.async = "false";
+    doc.loadXML(body);
+    return doc;
+  }
+  catch (e)
+  {
+    var doc = new DOMParser().parseFromString(body, "text/xml");
+    return doc;
+  }
+}
+
 /**
  * A Map implementation
  */
@@ -431,8 +478,11 @@
   if (req.readyState == 4)
   {
     if (req.status == 200 || req.status == 0)
-    {
-      var viewRoot = req.responseXML.documentElement;
+    {
+      var viewRoot;
+      if (req.responseXml) viewRoot = req.responseXML.documentElement;
+      else viewRoot = xw.Sys.parseXml(req.responseText).documentElement;
+      
       if (viewRoot.tagName == "view")
       {
         xw.ViewManager.createView(viewRoot, container);
@@ -551,8 +601,8 @@
   
   xw.Bounds.prototype.applyToControl = function(control)
   {  
-    if (this.left != null) control.style.left = this.left;
-    if (this.top != null) control.style.top = this.top;    
+    if (this.left != null) control.style.left = this.left + "px";
+    if (this.top != null) control.style.top = this.top + "px";    
     
     for (var i in this.style) control.style[i] = this.style[i];              
   
@@ -596,23 +646,26 @@
     
     for (var i = 0; i < topControls.length; i++)
     {
-      this.bounds.put(topControls[i], new xw.Bounds(null, null, topControls[i].height, null)
+      var bounds = 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 += 1.0 * topControls[i].height;
     }
     
     for (var i = 0; i < bottomControls.length; i++)
     {
-      this.bounds.put(bottomControls[i], new xw.Bounds(null, null, bottomControls[i].height, null)
+      var bounds = new xw.Bounds(null, null, bottomControls[i].height, null)
         .addStyleProperty("position","absolute")
         .addStyleProperty("bottom", bottomSpace)
         .addStyleProperty("left", "0")
-        .addStyleProperty("right", "0")
-      );    
+        .addStyleProperty("right", "0");
+        
+      this.bounds.put(bottomControls[i], bounds);    
       bottomSpace += 1.0 * bottomControls[i].height;          
     }
     
@@ -620,9 +673,9 @@
     {
       this.bounds.put(leftControls[i], new xw.Bounds(null, null, null, leftControls[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 += 1.0 * leftControls[i].width;        
     }
@@ -631,9 +684,9 @@
     {
       this.bounds.put(rightControls[i], new xw.Bounds(null, null, null, rightControls[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 += 1.0 * rightControls[i].width;
     }
@@ -642,10 +695,10 @@
     {
       this.bounds.put(clientControls[i], new xw.Bounds(null, null, null, null)
         .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")
       );    
     }
   



More information about the seam-commits mailing list