[embjopr-commits] EMBJOPR SVN: r831 - in trunk/core/src/main/webapp: js and 1 other directory.

embjopr-commits at lists.jboss.org embjopr-commits at lists.jboss.org
Tue Nov 3 23:19:03 EST 2009


Author: ozizka at redhat.com
Date: 2009-11-03 23:19:03 -0500 (Tue, 03 Nov 2009)
New Revision: 831

Added:
   trunk/core/src/main/webapp/js/window-part.js
Modified:
   trunk/core/src/main/webapp/WEB-INF/facelets/layout.xhtml
Log:
"WindowsUtilities not defined" JavaScript error fixed. (part of JBQA-2775)

Modified: trunk/core/src/main/webapp/WEB-INF/facelets/layout.xhtml
===================================================================
--- trunk/core/src/main/webapp/WEB-INF/facelets/layout.xhtml	2009-11-04 00:23:13 UTC (rev 830)
+++ trunk/core/src/main/webapp/WEB-INF/facelets/layout.xhtml	2009-11-04 04:19:03 UTC (rev 831)
@@ -46,6 +46,7 @@
         <link rel="icon" type="image/png" href="images/favicon.png"/>
         <link rel="apple-touch-icon" href="images/favicon.png"/>
 
+        <script type="text/javascript" src="js/window-part.js"></script>
         <script type="text/javascript" src="js/embedded.js"></script>
 
         <!--[if lt IE 7]>

Added: trunk/core/src/main/webapp/js/window-part.js
===================================================================
--- trunk/core/src/main/webapp/js/window-part.js	                        (rev 0)
+++ trunk/core/src/main/webapp/js/window-part.js	2009-11-04 04:19:03 UTC (rev 831)
@@ -0,0 +1,270 @@
+/* 
+ * This file is a copy of RHQ's window.js - see
+ * http://svn.rhq-project.org/repos/rhq/trunk/modules/enterprise/gui/portal-war/src/main/webapp/js/window.js
+ *
+ * Temporary solution for MyFaces.
+ */
+
+
+var WindowUtilities = {
+  // From dragdrop.js
+  getWindowScroll: function(parent) {
+    var T, L, W, H;
+    parent = parent || document.body;
+    if (parent != document.body) {
+      T = parent.scrollTop;
+      L = parent.scrollLeft;
+      W = parent.scrollWidth;
+      H = parent.scrollHeight;
+    }
+    else {
+      var w = window;
+      with (w.document) {
+        if (w.document.documentElement && documentElement.scrollTop) {
+          T = documentElement.scrollTop;
+          L = documentElement.scrollLeft;
+        } else if (w.document.body) {
+          T = body.scrollTop;
+          L = body.scrollLeft;
+        }
+        if (w.innerWidth) {
+          W = w.innerWidth;
+          H = w.innerHeight;
+        } else if (w.document.documentElement && documentElement.clientWidth) {
+          W = documentElement.clientWidth;
+          H = documentElement.clientHeight;
+        } else {
+          W = body.offsetWidth;
+          H = body.offsetHeight
+        }
+      }
+    }
+    return { top: T, left: L, width: W, height: H };
+  },
+  //
+  // getPageSize()
+  // Returns array with page width, height and window width, height
+  // Core code from - quirksmode.org
+  // Edit for Firefox by pHaez
+  //
+  getPageSize: function(parent){
+    parent = parent || document.body;
+    var windowWidth, windowHeight;
+    var pageHeight, pageWidth;
+    if (parent != document.body) {
+      windowWidth = parent.getWidth();
+      windowHeight = parent.getHeight();
+      pageWidth = parent.scrollWidth;
+      pageHeight = parent.scrollHeight;
+    }
+    else {
+      var xScroll, yScroll;
+
+      if (window.innerHeight && window.scrollMaxY) {
+        xScroll = document.body.scrollWidth;
+        yScroll = window.innerHeight + window.scrollMaxY;
+      } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
+        xScroll = document.body.scrollWidth;
+        yScroll = document.body.scrollHeight;
+      } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
+        xScroll = document.body.offsetWidth;
+        yScroll = document.body.offsetHeight;
+      }
+
+
+      if (self.innerHeight) {  // all except Explorer
+        windowWidth = self.innerWidth;
+        windowHeight = self.innerHeight;
+      } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
+        windowWidth = document.documentElement.clientWidth;
+        windowHeight = document.documentElement.clientHeight;
+      } else if (document.body) { // other Explorers
+        windowWidth = document.body.clientWidth;
+        windowHeight = document.body.clientHeight;
+      }
+
+      // for small pages with total height less then height of the viewport
+      if(yScroll < windowHeight){
+        pageHeight = windowHeight;
+      } else {
+        pageHeight = yScroll;
+      }
+
+      // for small pages with total width less then width of the viewport
+      if(xScroll < windowWidth){
+        pageWidth = windowWidth;
+      } else {
+        pageWidth = xScroll;
+      }
+    }
+    return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
+  },
+
+  disableScreen: function(className, overlayId, overlayOpacity, contentId, parent) {
+    WindowUtilities.initLightbox(overlayId, className, function() {this._disableScreen(className, overlayId, overlayOpacity, contentId)}.bind(this), parent || document.body);
+  },
+
+  _disableScreen: function(className, overlayId, overlayOpacity, contentId) {
+    // prep objects
+    var objOverlay = $(overlayId);
+
+    var pageSize = WindowUtilities.getPageSize(objOverlay.parentNode);
+
+    // Hide select boxes as they will 'peek' through the image in IE, store old value
+    if (contentId && Prototype.Browser.IE) {
+      WindowUtilities._hideSelect();
+      WindowUtilities._showSelect(contentId);
+    }
+
+    // set height of Overlay to take up whole page and show
+    objOverlay.style.height = (pageSize.pageHeight + 'px');
+    objOverlay.style.display = 'none';
+    if (overlayId == "overlay_modal" && Window.hasEffectLib && Windows.overlayShowEffectOptions) {
+      objOverlay.overlayOpacity = overlayOpacity;
+      new Effect.Appear(objOverlay, Object.extend({from: 0, to: overlayOpacity}, Windows.overlayShowEffectOptions));
+    }
+    else
+      objOverlay.style.display = "block";
+  },
+
+  enableScreen: function(id) {
+    id = id || 'overlay_modal';
+    var objOverlay =  $(id);
+    if (objOverlay) {
+      // hide lightbox and overlay
+      if (id == "overlay_modal" && Window.hasEffectLib && Windows.overlayHideEffectOptions)
+        new Effect.Fade(objOverlay, Object.extend({from: objOverlay.overlayOpacity, to:0}, Windows.overlayHideEffectOptions));
+      else {
+        objOverlay.style.display = 'none';
+        objOverlay.parentNode.removeChild(objOverlay);
+      }
+
+      // make select boxes visible using old value
+      if (id != "__invisible__")
+        WindowUtilities._showSelect();
+    }
+  },
+
+  _hideSelect: function(id) {
+    if (Prototype.Browser.IE) {
+      id = id ==  null ? "" : "#" + id + " ";
+      $$(id + 'select').each(function(element) {
+        if (! WindowUtilities.isDefined(element.oldVisibility)) {
+          element.oldVisibility = element.style.visibility ? element.style.visibility : "visible";
+          element.style.visibility = "hidden";
+        }
+      });
+    }
+  },
+
+  _showSelect: function(id) {
+    if (Prototype.Browser.IE) {
+      id = id ==  null ? "" : "#" + id + " ";
+      $$(id + 'select').each(function(element) {
+        if (WindowUtilities.isDefined(element.oldVisibility)) {
+          // Why?? Ask IE
+          try {
+            element.style.visibility = element.oldVisibility;
+          } catch(e) {
+            element.style.visibility = "visible";
+          }
+          element.oldVisibility = null;
+        }
+        else {
+          if (element.style.visibility)
+            element.style.visibility = "visible";
+        }
+      });
+    }
+  },
+
+  isDefined: function(object) {
+    return typeof(object) != "undefined" && object != null;
+  },
+
+  // initLightbox()
+  // Function runs on window load, going through link tags looking for rel="lightbox".
+  // These links receive onclick events that enable the lightbox display for their targets.
+  // The function also inserts html markup at the top of the page which will be used as a
+  // container for the overlay pattern and the inline image.
+  initLightbox: function(id, className, doneHandler, parent) {
+    // Already done, just update zIndex
+    if ($(id)) {
+      Element.setStyle(id, {zIndex: Windows.maxZIndex + 1});
+      Windows.maxZIndex++;
+      doneHandler();
+    }
+    // create overlay div and hardcode some functional styles (aesthetic styles are in CSS file)
+    else {
+      var objOverlay = document.createElement("div");
+      objOverlay.setAttribute('id', id);
+      objOverlay.className = "overlay_" + className
+      objOverlay.style.display = 'none';
+      objOverlay.style.position = 'absolute';
+      objOverlay.style.top = '0';
+      objOverlay.style.left = '0';
+      objOverlay.style.zIndex = Windows.maxZIndex + 1;
+      Windows.maxZIndex++;
+      objOverlay.style.width = '100%';
+      parent.insertBefore(objOverlay, parent.firstChild);
+      if (Prototype.Browser.WebKit && id == "overlay_modal") {
+        setTimeout(function() {doneHandler()}, 10);
+      }
+      else
+        doneHandler();
+    }
+  },
+
+  setCookie: function(value, parameters) {
+    document.cookie= parameters[0] + "=" + escape(value) +
+      ((parameters[1]) ? "; expires=" + parameters[1].toGMTString() : "") +
+      ((parameters[2]) ? "; path=" + parameters[2] : "") +
+      ((parameters[3]) ? "; domain=" + parameters[3] : "") +
+      ((parameters[4]) ? "; secure" : "");
+  },
+
+  getCookie: function(name) {
+    var dc = document.cookie;
+    var prefix = name + "=";
+    var begin = dc.indexOf("; " + prefix);
+    if (begin == -1) {
+      begin = dc.indexOf(prefix);
+      if (begin != 0) return null;
+    } else {
+      begin += 2;
+    }
+    var end = document.cookie.indexOf(";", begin);
+    if (end == -1) {
+      end = dc.length;
+    }
+    return unescape(dc.substring(begin + prefix.length, end));
+  },
+
+  _computeSize: function(content, id, width, height, margin, className) {
+    var objBody = document.body;
+    var tmpObj = document.createElement("div");
+    tmpObj.setAttribute('id', id);
+    tmpObj.className = className + "_content";
+
+    if (height)
+      tmpObj.style.height = height + "px"
+    else
+      tmpObj.style.width = width + "px"
+
+    tmpObj.style.position = 'absolute';
+    tmpObj.style.top = '0';
+    tmpObj.style.left = '0';
+    tmpObj.style.display = 'none';
+
+    tmpObj.innerHTML = content;
+    objBody.insertBefore(tmpObj, objBody.firstChild);
+
+    var size;
+    if (height)
+      size = $(tmpObj).getDimensions().width + margin;
+    else
+      size = $(tmpObj).getDimensions().height + margin;
+    objBody.removeChild(tmpObj);
+    return size;
+  }
+}



More information about the embjopr-commits mailing list