Author: lindner
Date: Thu Jun  9 08:44:15 2011
New Revision: 1133721

URL: http://svn.apache.org/viewvc?rev=1133721&view=rev
Log:
Patch from mhermanto: Split out gadgets.util to subpackages more focussed on 
what it does.

Added:
    shindig/trunk/features/src/main/javascript/features/core.util.base/
    shindig/trunk/features/src/main/javascript/features/core.util.base/base.js
    
shindig/trunk/features/src/main/javascript/features/core.util.base/feature.xml
      - copied, changed from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util.event/
    shindig/trunk/features/src/main/javascript/features/core.util.event/event.js
    
shindig/trunk/features/src/main/javascript/features/core.util.event/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util.onload/
    
shindig/trunk/features/src/main/javascript/features/core.util.onload/feature.xml
      - copied, changed from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml
    
shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js
      - copied, changed from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util/taming.js
    
shindig/trunk/features/src/main/javascript/features/core.util.onload/taming.js
      - copied, changed from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util/taming.js
Modified:
    shindig/trunk/features/pom.xml
    shindig/trunk/features/src/main/javascript/features/caja/feature.xml
    shindig/trunk/features/src/main/javascript/features/container/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.io/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js
    
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util/feature.xml
    shindig/trunk/features/src/main/javascript/features/core.util/taming.js
    shindig/trunk/features/src/main/javascript/features/core.util/util.js
    shindig/trunk/features/src/main/javascript/features/features.txt
    shindig/trunk/features/src/main/javascript/features/rpc/feature.xml

Modified: shindig/trunk/features/pom.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/pom.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/pom.xml (original)
+++ shindig/trunk/features/pom.xml Thu Jun  9 08:44:15 2011
@@ -113,7 +113,10 @@
                 <source>core.json/json-jsimpl.js</source>
                 <source>core.json/json-flatten.js</source>
                 <source>shindig.auth/auth.js</source>
+                <source>core.util.base/base.js</source>
                 <source>core.util.dom/dom.js</source>
+                <source>core.util.event/event.js</source>
+                <source>core.util.onload/onload.js</source>
                 <source>core.util.string/string.js</source>
                 <source>core.util.urlparams/urlparams.js</source>
                 <source>core.util/util.js</source>

Modified: shindig/trunk/features/src/main/javascript/features/caja/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/caja/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/caja/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/caja/feature.xml Thu 
Jun  9 08:44:15 2011
@@ -19,7 +19,7 @@ specific language governing permissions 
 <feature>
   <name>caja</name>
   <dependency>core.io</dependency>
-  <dependency>core.util</dependency>
+  <dependency>core.util.onload</dependency>
   <dependency>taming</dependency>
   <gadget>
     <script src="taming.js"/>

Modified: 
shindig/trunk/features/src/main/javascript/features/container/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/container/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/container/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/container/feature.xml 
Thu Jun  9 08:44:15 2011
@@ -23,7 +23,6 @@ under the License.
   <dependency>core.log</dependency>
   <dependency>shindig.auth</dependency>
   <dependency>shindig.uri.ext</dependency>
-  <dependency>core.util</dependency>
   <dependency>osapi</dependency>
   <dependency>rpc</dependency>
   <container>

Modified: 
shindig/trunk/features/src/main/javascript/features/core.io/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.io/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.io/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.io/feature.xml Thu 
Jun  9 08:44:15 2011
@@ -33,7 +33,8 @@
   <dependency>shindig.auth</dependency>
   <dependency>core.config.base</dependency>
   <dependency>core.json</dependency>
-  <dependency>core.util</dependency>
+  <dependency>core.util.base</dependency>
+  <dependency>core.util.urlparams</dependency>
   <all>
     <script src="io.js"/>
     <script src="taming.js" caja="1"/>

Added: 
shindig/trunk/features/src/main/javascript/features/core.util.base/base.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.base/base.js?rev=1133721&view=auto
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.base/base.js 
(added)
+++ shindig/trunk/features/src/main/javascript/features/core.util.base/base.js 
Thu Jun  9 08:44:15 2011
@@ -0,0 +1,80 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview General purpose utilities that gadgets can use.
+ */
+
+/**
+ * @static
+ * @class Provides general-purpose utility functions.
+ * @name gadgets.util
+ */
+gadgets.util = gadgets.util || {};
+
+/**
+ * Creates a closure that is suitable for passing as a callback.
+ * Any number of arguments
+ * may be passed to the callback;
+ * they will be received in the order they are passed in.
+ *
+ * @param {Object} scope The execution scope; may be null if there is no
+ *     need to associate a specific instance of an object with this
+ *     callback.
+ * @param {function(Object,Object)} callback The callback to invoke when this 
is run;
+ *     any arguments passed in will be passed after your initial arguments.
+ * @param {Object} var_args Initial arguments to be passed to the callback.
+ *
+ * @member gadgets.util
+ * @private Implementation detail.
+ */
+gadgets.util.makeClosure = function(scope, callback, var_args) {
+  // arguments isn't a real array, so we copy it into one.
+  var baseArgs = [];
+  for (var i = 2, j = arguments.length; i < j; ++i) {
+    baseArgs.push(arguments[i]);
+  }
+  return function() {
+    // append new arguments.
+    var tmpArgs = baseArgs.slice();
+    for (var i = 0, j = arguments.length; i < j; ++i) {
+      tmpArgs.push(arguments[i]);
+    }
+    return callback.apply(scope, tmpArgs);
+  };
+};
+
+
+/**
+ * Utility function for generating an "enum" from an array.
+ *
+ * @param {Array.<string>} values The values to generate.
+ * @return {Object.<string,string>} An object with member fields to handle
+ *   the enum.
+ *
+ * @private Implementation detail.
+ */
+gadgets.util.makeEnum = function(values) {
+  var i, v, obj = {};
+  for (i = 0; (v = values[i]); ++i) {
+    obj[v] = v;
+  }
+  return obj;
+};
+

Copied: 
shindig/trunk/features/src/main/javascript/features/core.util.base/feature.xml 
(from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.base/feature.xml?p2=shindig/trunk/features/src/main/javascript/features/core.util.base/feature.xml&p1=shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml&r1=1133720&r2=1133721&rev=1133721&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.base/feature.xml 
Thu Jun  9 08:44:15 2011
@@ -17,13 +17,13 @@
   specific language governing permissions and limitations under the License.
 -->
 <feature>
-  <name>core.util.dom</name>
+  <name>core.util.base</name>
   <dependency>globals</dependency>
   <all>
-    <script src="dom.js"/>
+    <script src="base.js"/>
     <api>
-      <exports type="js">gadgets.util.createElement</exports>
-      <exports type="js">gadgets.util.getBodyElement</exports>
+      <exports type="js">gadgets.util.makeClosure</exports>
+      <exports type="js">gadgets.util.makeEnum</exports>
     </api>
   </all>
 </feature>

Modified: 
shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.util.dom/dom.js 
Thu Jun  9 08:44:15 2011
@@ -32,6 +32,33 @@ gadgets.util = gadgets.util || {};
 
   var XHTML_SPEC = 'http://www.w3.org/1999/xhtml';
 
+  function attachAttributes(elem, opt_attribs) {
+    var attribs = opt_attribs || {};
+    for (var attrib in attribs) {
+      if (attribs.hasOwnProperty(attrib)) {
+        elem[attrib] = attribs[attrib];
+      }
+    }
+  }
+
+  function stringifyElement(tagName, opt_attribs) {
+    var arr = ['<', tagName];
+    var attribs = opt_attribs || {};
+    for (var attrib in attribs) {
+      if (attribs.hasOwnProperty(attrib)) {
+        arr.push(' ');
+        arr.push(attrib);
+        arr.push('="');
+        arr.push(gadgets.util.escapeString(attribs[attrib]));
+        arr.push('"');
+      }
+    }
+    arr.push('></');
+    arr.push(tagName);
+    arr.push('>');
+    return arr.join('');
+  }
+
   /**
    * Creates an HTML or XHTML element.
    * @param {string} tagName The type of element to construct.
@@ -49,6 +76,36 @@ gadgets.util = gadgets.util || {};
   };
 
   /**
+   * Creates an HTML or XHTML iframe element with attributes.
+   * @param {Object=} opt_attribs Optional set of attributes to attach. The
+   * only working attributes are spelled the same way in XHTML attribute
+   * naming (most strict, all-lower-case), HTML attribute naming (less strict,
+   * case-insensitive), and JavaScript property naming (some properties named
+   * incompatibly with XHTML/HTML).
+   * @return {Element} The DOM node representing body.
+   */
+  gadgets.util.createIframeElement = function(opt_attribs) {
+    var frame = gadgets.util.createElement('iframe');
+    try {
+      // TODO: provide automatic mapping to only set the needed
+      // and JS-HTML-XHTML compatible subset through stringifyElement (just
+      // 'name' and 'id', AFAIK). The values of the attributes will be
+      // stringified should the stringifyElement code path be taken (IE)
+      var tagString = stringifyElement('iframe', opt_attribs);
+      var ieFrame = gadgets.util.createElement(tagString);
+      if (ieFrame &&
+          ((!frame) ||
+           ((ieFrame.tagName == frame.tagName) &&
+            (ieFrame.namespaceURI == frame.namespaceURI)))) {
+        frame = ieFrame;
+      }
+    } catch (nonStandardCallFailed) {
+    }
+    attachAttributes(frame, opt_attribs);
+    return frame;
+  };  
+
+  /**
    * Gets the HTML or XHTML body element.
    * @return {Element} The DOM node representing body.
    */

Modified: 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml 
Thu Jun  9 08:44:15 2011
@@ -23,6 +23,7 @@
     <script src="dom.js"/>
     <api>
       <exports type="js">gadgets.util.createElement</exports>
+      <exports type="js">gadgets.util.createIframeElement</exports>
       <exports type="js">gadgets.util.getBodyElement</exports>
     </api>
   </all>

Added: 
shindig/trunk/features/src/main/javascript/features/core.util.event/event.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.event/event.js?rev=1133721&view=auto
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.util.event/event.js 
(added)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.event/event.js 
Thu Jun  9 08:44:15 2011
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+/**
+ * @fileoverview General purpose utilities that gadgets can use.
+ */
+
+gadgets.util = gadgets.util || {};
+
+/**
+ * Attach an event listener to given DOM element (Not a gadget standard)
+ *
+ * @param {Object} elem  DOM element on which to attach event.
+ * @param {string} eventName  Event type to listen for.
+ * @param {function()} callback  Invoked when specified event occurs.
+ * @param {boolean} useCapture  If true, initiates capture.
+ */
+gadgets.util.attachBrowserEvent = function(elem, eventName, callback, 
useCapture) {
+  if (typeof elem.addEventListener != 'undefined') {
+    elem.addEventListener(eventName, callback, useCapture);
+  } else if (typeof elem.attachEvent != 'undefined') {
+    elem.attachEvent('on' + eventName, callback);
+  } else {
+    gadgets.warn('cannot attachBrowserEvent: ' + eventName);
+  }
+};
+
+/**
+ * Remove event listener. (Shindig internal implementation only)
+ *
+ * @param {Object} elem  DOM element from which to remove event.
+ * @param {string} eventName  Event type to remove.
+ * @param {function()} callback  Listener to remove.
+ * @param {boolean} useCapture  Specifies whether listener being removed was 
added with
+ *                              capture enabled.
+ */
+gadgets.util.removeBrowserEvent = function(elem, eventName, callback, 
useCapture) {
+  if (elem.removeEventListener) {
+    elem.removeEventListener(eventName, callback, useCapture);
+  } else if (elem.detachEvent) {
+    elem.detachEvent('on' + eventName, callback);
+  } else {
+    gadgets.warn('cannot removeBrowserEvent: ' + eventName);
+  }
+};
+

Added: 
shindig/trunk/features/src/main/javascript/features/core.util.event/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.event/feature.xml?rev=1133721&view=auto
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.util.event/feature.xml 
(added)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.event/feature.xml 
Thu Jun  9 08:44:15 2011
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License. You may obtain a copy of the License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+-->
+<feature>
+  <name>core.util.event</name>
+  <dependency>globals</dependency>
+  <dependency>core.log</dependency>
+  <all>
+    <script src="event.js"/>
+    <api>
+      <exports type="js">gadgets.util.attachBrowserEvent</exports>
+      <exports type="js">gadgets.util.removeBrowserEvent</exports>
+    </api>
+  </all>
+</feature> 
+

Copied: 
shindig/trunk/features/src/main/javascript/features/core.util.onload/feature.xml
 (from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.onload/feature.xml?p2=shindig/trunk/features/src/main/javascript/features/core.util.onload/feature.xml&p1=shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml&r1=1133720&r2=1133721&rev=1133721&view=diff
==============================================================================
--- 
shindig/trunk/features/src/main/javascript/features/core.util.dom/feature.xml 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.onload/feature.xml
 Thu Jun  9 08:44:15 2011
@@ -17,13 +17,15 @@
   specific language governing permissions and limitations under the License.
 -->
 <feature>
-  <name>core.util.dom</name>
+  <name>core.util.onload</name>
   <dependency>globals</dependency>
   <all>
-    <script src="dom.js"/>
+    <script src="onload.js"/>
+    <script src="taming.js" caja="1"/>
     <api>
-      <exports type="js">gadgets.util.createElement</exports>
-      <exports type="js">gadgets.util.getBodyElement</exports>
+      <exports type="js">gadgets.util.registerOnLoadHandler</exports>
+      <exports type="js">gadgets.util.runOnLoadHandlers</exports>
     </api>
   </all>
 </feature>
+

Copied: 
shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js 
(from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util/taming.js)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js?p2=shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js&p1=shindig/trunk/features/src/main/javascript/features/core.util/taming.js&r1=1133720&r2=1133721&rev=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/taming.js 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.onload/onload.js 
Thu Jun  9 08:44:15 2011
@@ -18,13 +18,39 @@
  */
 
 /**
- * @class
- * Tame and expose core gadgets.* API to cajoled gadgets
+ * @fileoverview General purpose utilities that gadgets can use.
  */
-tamings___.push(function(imports) {
-  caja___.whitelistFuncs([
-    [gadgets.util, 'getFeatureParameters'],
-    [gadgets.util, 'hasFeature'],
-    [gadgets.util, 'registerOnLoadHandler']
-  ]);
-});
+
+/**
+ * @static
+ * @class Provides general-purpose utility functions for onload.
+ * @name gadgets.util
+ */
+gadgets.util = gadgets.util || {};
+
+(function() {
+
+  var onLoadHandlers = [];
+
+  /**
+   * Registers an onload handler.
+   * @param {function()} callback The handler to run.
+   *
+   * @member gadgets.util
+   */
+  gadgets.util.registerOnLoadHandler = function(callback) {
+    onLoadHandlers.push(callback);
+  };
+
+  /**
+   * Runs all functions registered via registerOnLoadHandler.
+   * @private Only to be used by the container, not gadgets.
+   */
+  gadgets.util.runOnLoadHandlers = function() {
+    for (var i = 0, j = onLoadHandlers.length; i < j; ++i) {
+      onLoadHandlers[i]();
+    }
+  };
+
+})();
+

Copied: 
shindig/trunk/features/src/main/javascript/features/core.util.onload/taming.js 
(from r1133720, 
shindig/trunk/features/src/main/javascript/features/core.util/taming.js)
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util.onload/taming.js?p2=shindig/trunk/features/src/main/javascript/features/core.util.onload/taming.js&p1=shindig/trunk/features/src/main/javascript/features/core.util/taming.js&r1=1133720&r2=1133721&rev=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/taming.js 
(original)
+++ 
shindig/trunk/features/src/main/javascript/features/core.util.onload/taming.js 
Thu Jun  9 08:44:15 2011
@@ -23,8 +23,7 @@
  */
 tamings___.push(function(imports) {
   caja___.whitelistFuncs([
-    [gadgets.util, 'getFeatureParameters'],
-    [gadgets.util, 'hasFeature'],
     [gadgets.util, 'registerOnLoadHandler']
   ]);
 });
+

Modified: 
shindig/trunk/features/src/main/javascript/features/core.util/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/feature.xml 
Thu Jun  9 08:44:15 2011
@@ -21,24 +21,19 @@
   <dependency>globals</dependency>
   <dependency>taming</dependency>
   <dependency>core.config</dependency>
+  <dependency>core.util.base</dependency>
   <dependency>core.util.dom</dependency>
+  <dependency>core.util.event</dependency>
+  <dependency>core.util.onload</dependency>
   <dependency>core.util.string</dependency>
   <dependency>core.util.urlparams</dependency>
   <all>
     <script src="util.js"/>
     <script src="taming.js" caja="1"/>
     <api>
-      <exports type="js">gadgets.util.makeClosure</exports>
-      <exports type="js">gadgets.util.makeEnum</exports>
       <exports type="js">gadgets.util.getFeatureParameters</exports>
       <exports type="js">gadgets.util.hasFeature</exports>
       <exports type="js">gadgets.util.getServices</exports>
-      <exports type="js">gadgets.util.registerOnLoadHandler</exports>
-      <exports type="js">gadgets.util.runOnLoadHandlers</exports>
-      <exports type="js">gadgets.util.attachBrowserEvent</exports>
-      <exports type="js">gadgets.util.removeBrowserEvent</exports>
-      <!-- TODO: move to core.util.dom -->
-      <exports type="js">gadgets.util.createIframeElement</exports>
     </api>
   </all>
 </feature>

Modified: 
shindig/trunk/features/src/main/javascript/features/core.util/taming.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/taming.js?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/taming.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/taming.js Thu 
Jun  9 08:44:15 2011
@@ -24,7 +24,6 @@
 tamings___.push(function(imports) {
   caja___.whitelistFuncs([
     [gadgets.util, 'getFeatureParameters'],
-    [gadgets.util, 'hasFeature'],
-    [gadgets.util, 'registerOnLoadHandler']
+    [gadgets.util, 'hasFeature']
   ]);
 });

Modified: shindig/trunk/features/src/main/javascript/features/core.util/util.js
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/core.util/util.js?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/core.util/util.js 
(original)
+++ shindig/trunk/features/src/main/javascript/features/core.util/util.js Thu 
Jun  9 08:44:15 2011
@@ -32,34 +32,6 @@ gadgets.util = gadgets.util || {};
   
   var features = {};
   var services = {};
-  var onLoadHandlers = [];
-
-  function attachAttributes(elem, opt_attribs) {
-    var attribs = opt_attribs || {};
-    for (var attrib in attribs) {
-      if (attribs.hasOwnProperty(attrib)) {
-        elem[attrib] = attribs[attrib];
-      }
-    }
-  }
-
-  function stringifyElement(tagName, opt_attribs) {
-    var arr = ['<', tagName];
-    var attribs = opt_attribs || {};
-    for (var attrib in attribs) {
-      if (attribs.hasOwnProperty(attrib)) {
-        arr.push(' ');
-        arr.push(attrib);
-        arr.push('="');
-        arr.push(gadgets.util.escapeString(attribs[attrib]));
-        arr.push('"');
-      }
-    }
-    arr.push('></');
-    arr.push(tagName);
-    arr.push('>');
-    return arr.join('');
-  }
 
   /**
    * Initializes feature parameters.
@@ -72,55 +44,6 @@ gadgets.util = gadgets.util || {};
   }
 
   /**
-   * Creates a closure that is suitable for passing as a callback.
-   * Any number of arguments
-   * may be passed to the callback;
-   * they will be received in the order they are passed in.
-   *
-   * @param {Object} scope The execution scope; may be null if there is no
-   *     need to associate a specific instance of an object with this
-   *     callback.
-   * @param {function(Object,Object)} callback The callback to invoke when 
this is run;
-   *     any arguments passed in will be passed after your initial arguments.
-   * @param {Object} var_args Initial arguments to be passed to the callback.
-   *
-   * @member gadgets.util
-   * @private Implementation detail.
-   */
-  gadgets.util.makeClosure = function(scope, callback, var_args) {
-    // arguments isn't a real array, so we copy it into one.
-    var baseArgs = [];
-    for (var i = 2, j = arguments.length; i < j; ++i) {
-      baseArgs.push(arguments[i]);
-    }
-    return function() {
-      // append new arguments.
-      var tmpArgs = baseArgs.slice();
-      for (var i = 0, j = arguments.length; i < j; ++i) {
-        tmpArgs.push(arguments[i]);
-      }
-      return callback.apply(scope, tmpArgs);
-    };
-  };
-
-  /**
-   * Utility function for generating an "enum" from an array.
-   *
-   * @param {Array.<string>} values The values to generate.
-   * @return {Object.<string,string>} An object with member fields to handle
-   *   the enum.
-   *
-   * @private Implementation detail.
-   */
-  gadgets.util.makeEnum = function(values) {
-    var i, v, obj = {};
-    for (i = 0; (v = values[i]); ++i) {
-      obj[v] = v;
-    }
-    return obj;
-  };
-
-  /**
    * Gets the feature parameters.
    *
    * @param {string} feature The feature to get parameters for.
@@ -156,92 +79,4 @@ gadgets.util = gadgets.util || {};
     return services;
   };
 
-  /**
-   * Registers an onload handler.
-   * @param {function()} callback The handler to run.
-   *
-   * @member gadgets.util
-   */
-  gadgets.util.registerOnLoadHandler = function(callback) {
-    onLoadHandlers.push(callback);
-  };
-
-  /**
-   * Runs all functions registered via registerOnLoadHandler.
-   * @private Only to be used by the container, not gadgets.
-   */
-  gadgets.util.runOnLoadHandlers = function() {
-    for (var i = 0, j = onLoadHandlers.length; i < j; ++i) {
-      onLoadHandlers[i]();
-    }
-  };
-
-  /**
-   * Attach an event listener to given DOM element (Not a gadget standard)
-   *
-   * @param {Object} elem  DOM element on which to attach event.
-   * @param {string} eventName  Event type to listen for.
-   * @param {function()} callback  Invoked when specified event occurs.
-   * @param {boolean} useCapture  If true, initiates capture.
-   */
-  gadgets.util.attachBrowserEvent = function(elem, eventName, callback, 
useCapture) {
-    if (typeof elem.addEventListener != 'undefined') {
-      elem.addEventListener(eventName, callback, useCapture);
-    } else if (typeof elem.attachEvent != 'undefined') {
-      elem.attachEvent('on' + eventName, callback);
-    } else {
-      gadgets.warn('cannot attachBrowserEvent: ' + eventName);
-    }
-  };
-
-  /**
-   * Remove event listener. (Shindig internal implementation only)
-   *
-   * @param {Object} elem  DOM element from which to remove event.
-   * @param {string} eventName  Event type to remove.
-   * @param {function()} callback  Listener to remove.
-   * @param {boolean} useCapture  Specifies whether listener being removed was 
added with
-   *                              capture enabled.
-   */
-  gadgets.util.removeBrowserEvent = function(elem, eventName, callback, 
useCapture) {
-    if (elem.removeEventListener) {
-      elem.removeEventListener(eventName, callback, useCapture);
-    } else if (elem.detachEvent) {
-      elem.detachEvent('on' + eventName, callback);
-    } else {
-      gadgets.warn('cannot removeBrowserEvent: ' + eventName);
-    }
-  };
-
-  /**
-   * Creates an HTML or XHTML iframe element with attributes.
-   * @param {Object=} opt_attribs Optional set of attributes to attach. The
-   * only working attributes are spelled the same way in XHTML attribute
-   * naming (most strict, all-lower-case), HTML attribute naming (less strict,
-   * case-insensitive), and JavaScript property naming (some properties named
-   * incompatibly with XHTML/HTML).
-   * @return {Element} The DOM node representing body.
-   */
-  gadgets.util.createIframeElement = function(opt_attribs) {
-    // TODO: move to core.util.dom.
-    var frame = gadgets.util.createElement('iframe');
-    try {
-      // TODO: provide automatic mapping to only set the needed
-      // and JS-HTML-XHTML compatible subset through stringifyElement (just
-      // 'name' and 'id', AFAIK). The values of the attributes will be
-      // stringified should the stringifyElement code path be taken (IE)
-      var tagString = stringifyElement('iframe', opt_attribs);
-      var ieFrame = gadgets.util.createElement(tagString);
-      if (ieFrame &&
-          ((!frame) ||
-           ((ieFrame.tagName == frame.tagName) &&
-            (ieFrame.namespaceURI == frame.namespaceURI)))) {
-        frame = ieFrame;
-      }
-    } catch (nonStandardCallFailed) {
-    }
-    attachAttributes(frame, opt_attribs);
-    return frame;
-  };
-
 })();

Modified: shindig/trunk/features/src/main/javascript/features/features.txt
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/features.txt?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/features.txt (original)
+++ shindig/trunk/features/src/main/javascript/features/features.txt Thu Jun  9 
08:44:15 2011
@@ -36,8 +36,11 @@ features/core.log/feature.xml
 features/core.none/feature.xml
 features/core.prefs/feature.xml
 features/core.util/feature.xml
-features/core.util.string/feature.xml
+features/core.util.base/feature.xml
 features/core.util.dom/feature.xml
+features/core.util.event/feature.xml
+features/core.util.onload/feature.xml
+features/core.util.string/feature.xml
 features/core.util.urlparams/feature.xml
 features/core/feature.xml
 features/dynamic-height.height/feature.xml

Modified: shindig/trunk/features/src/main/javascript/features/rpc/feature.xml
URL: 
http://svn.apache.org/viewvc/shindig/trunk/features/src/main/javascript/features/rpc/feature.xml?rev=1133721&r1=1133720&r2=1133721&view=diff
==============================================================================
--- shindig/trunk/features/src/main/javascript/features/rpc/feature.xml 
(original)
+++ shindig/trunk/features/src/main/javascript/features/rpc/feature.xml Thu Jun 
 9 08:44:15 2011
@@ -21,8 +21,8 @@ specific language governing permissions 
   <dependency>globals</dependency>
   <dependency>core.config.base</dependency>
   <dependency>core.json</dependency>
-  <!-- TODO: only depend on core.util.dom and core.util.urlparams -->
-  <dependency>core.util</dependency>
+  <dependency>core.util.onload</dependency>
+  <dependency>core.util.urlparams</dependency>
   <all>
     <api>
       <exports type="js">gadgets.rpc.config</exports>


Reply via email to