click-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sa...@apache.org
Subject svn commit: r790944 - /incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js
Date Fri, 03 Jul 2009 15:11:51 GMT
Author: sabob
Date: Fri Jul  3 15:11:51 2009
New Revision: 790944

URL: http://svn.apache.org/viewvc?rev=790944&view=rev
Log:
update to prototype 1.6.1-rc3

Modified:
    incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js

Modified: incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js
URL: http://svn.apache.org/viewvc/incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js?rev=790944&r1=790943&r2=790944&view=diff
==============================================================================
--- incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js (original)
+++ incubator/click/trunk/click/extras/src/META-INF/web/click/prototype/prototype.js Fri Jul
 3 15:11:51 2009
@@ -1,4 +1,4 @@
-/*  Prototype JavaScript framework, version 1.6.1_rc2
+/*  Prototype JavaScript framework, version 1.6.1_rc3
  *  (c) 2005-2009 Sam Stephenson
  *
  *  Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,38 +7,42 @@
  *--------------------------------------------------------------------------*/
 
 var Prototype = {
-  Version: '1.6.1_rc2',
+  Version: '1.6.1_rc3',
 
-  Browser: {
-    IE:     !!(window.attachEvent &&
-      navigator.userAgent.indexOf('Opera') === -1),
-    Opera:  navigator.userAgent.indexOf('Opera') > -1,
-    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1,
-    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 &&
-      navigator.userAgent.indexOf('KHTML') === -1,
-    MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/)
-  },
+  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)
+    }
+  })(),
 
   BrowserFeatures: {
     XPath: !!document.evaluate,
     SelectorsAPI: !!document.querySelector,
     ElementExtensions: (function() {
-      if (window.HTMLElement && window.HTMLElement.prototype)
-        return true;
-      if (window.Element && window.Element.prototype)
-        return true;
+      var constructor = window.Element || window.HTMLElement;
+      return !!(constructor && constructor.prototype);
     })(),
     SpecificElementExtensions: (function() {
       if (typeof window.HTMLDivElement !== 'undefined')
         return true;
 
       var div = document.createElement('div');
-      if (div['__proto__'] && div['__proto__'] !==
-       document.createElement('form')['__proto__']) {
-        return true;
+      var form = document.createElement('form');
+      var isSupported = false;
+
+      if (div['__proto__'] && (div['__proto__'] !== form['__proto__'])) {
+        isSupported = true;
       }
 
-      return false;
+      div = form = null;
+
+      return isSupported;
     })()
   },
 
@@ -75,6 +79,7 @@
 /* Based on Alex Arnell's inheritance implementation. */
 
 var Class = (function() {
+  function subclass() {};
   function create() {
     var parent = null, properties = $A(arguments);
     if (Object.isFunction(properties[0]))
@@ -89,7 +94,6 @@
     klass.subclasses = [];
 
     if (parent) {
-      var subclass = function() {};
       subclass.prototype = parent.prototype;
       klass.prototype = new subclass;
       parent.subclasses.push(klass);
@@ -476,7 +480,7 @@
   }
 
   function stripTags() {
-    return this.replace(/<\/?[^>]+>/gi, '');
+    return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
   }
 
   function stripScripts() {
@@ -508,6 +512,7 @@
       div.childNodes[0].nodeValue) : '';
   }
 
+
   function toQueryParams(separator) {
     var match = this.strip().match(/([^?#]*)(#.*)?$/);
     if (!match) return { };
@@ -629,7 +634,7 @@
     sub:            sub,
     scan:           scan,
     truncate:       truncate,
-    strip:          strip,
+    strip:          String.prototype.trim ? String.prototype.trim : strip,
     stripTags:      stripTags,
     stripScripts:   stripScripts,
     extractScripts: extractScripts,
@@ -669,13 +674,13 @@
 if ('<\n>'.escapeHTML() !== '&lt;\n&gt;') {
   String.prototype.escapeHTML = function() {
     return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
-  }
+  };
 }
 
 if ('&lt;\n&gt;'.unescapeHTML() !== '<\n>') {
   String.prototype.unescapeHTML = function() {
     return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
-  }
+  };
 }
 var Template = Class.create({
   initialize: function(template, pattern) {
@@ -684,11 +689,11 @@
   },
 
   evaluate: function(object) {
-    if (Object.isFunction(object.toTemplateReplacements))
+    if (object && Object.isFunction(object.toTemplateReplacements))
       object = object.toTemplateReplacements();
 
     return this.template.gsub(this.pattern, function(match) {
-      if (object == null) return '';
+      if (object == null) return (match[1] + '');
 
       var before = match[1] || '';
       if (before == '\\') return match[2];
@@ -961,7 +966,7 @@
 })();
 function $A(iterable) {
   if (!iterable) return [];
-  if ('toArray' in iterable) return iterable.toArray();
+  if ('toArray' in Object(iterable)) return iterable.toArray();
   var length = iterable.length || 0, results = new Array(length);
   while (length--) results[length] = iterable[length];
   return results;
@@ -1894,9 +1899,9 @@
 
       if (SELECT_ELEMENT_INNERHTML_BUGGY || TABLE_ELEMENT_INNERHTML_BUGGY) {
         if (tagName in Element._insertionTranslations.tags) {
-          $A(element.childNodes).each(function(node) {
-            element.removeChild(node);
-          });
+          while (element.firstChild) {
+            element.removeChild(element.firstChild);
+          }
           Element._getContentFromAnonymousElement(tagName, content.stripScripts())
             .each(function(node) {
               element.appendChild(node)
@@ -2000,7 +2005,7 @@
   },
 
   ancestors: function(element) {
-    return $(element).recursivelyCollect('parentNode');
+    return Element.recursivelyCollect(element, 'parentNode');
   },
 
   descendants: function(element) {
@@ -2021,16 +2026,17 @@
   },
 
   previousSiblings: function(element) {
-    return $(element).recursivelyCollect('previousSibling');
+    return Element.recursivelyCollect(element, 'previousSibling');
   },
 
   nextSiblings: function(element) {
-    return $(element).recursivelyCollect('nextSibling');
+    return Element.recursivelyCollect(element, 'nextSibling');
   },
 
   siblings: function(element) {
     element = $(element);
-    return element.previousSiblings().reverse().concat(element.nextSiblings());
+    return Element.previousSiblings(element).reverse()
+      .concat(Element.nextSiblings(element));
   },
 
   match: function(element, selector) {
@@ -2042,22 +2048,22 @@
   up: function(element, expression, index) {
     element = $(element);
     if (arguments.length == 1) return $(element.parentNode);
-    var ancestors = element.ancestors();
+    var ancestors = Element.ancestors(element);
     return Object.isNumber(expression) ? ancestors[expression] :
       Selector.findElement(ancestors, expression, index);
   },
 
   down: function(element, expression, index) {
     element = $(element);
-    if (arguments.length == 1) return element.firstDescendant();
-    return Object.isNumber(expression) ? element.descendants()[expression] :
+    if (arguments.length == 1) return Element.firstDescendant(element);
+    return Object.isNumber(expression) ? Element.descendants(element)[expression] :
       Element.select(element, expression)[index || 0];
   },
 
   previous: function(element, expression, index) {
     element = $(element);
     if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element));
-    var previousSiblings = element.previousSiblings();
+    var previousSiblings = Element.previousSiblings(element);
     return Object.isNumber(expression) ? previousSiblings[expression] :
       Selector.findElement(previousSiblings, expression, index);
   },
@@ -2065,28 +2071,28 @@
   next: function(element, expression, index) {
     element = $(element);
     if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element));
-    var nextSiblings = element.nextSiblings();
+    var nextSiblings = Element.nextSiblings(element);
     return Object.isNumber(expression) ? nextSiblings[expression] :
       Selector.findElement(nextSiblings, expression, index);
   },
 
 
-  select: function() {
-    var args = $A(arguments), element = $(args.shift());
+  select: function(element) {
+    var args = Array.prototype.slice.call(arguments, 1);
     return Selector.findChildElements(element, args);
   },
 
-  adjacent: function() {
-    var args = $A(arguments), element = $(args.shift());
+  adjacent: function(element) {
+    var args = Array.prototype.slice.call(arguments, 1);
     return Selector.findChildElements(element.parentNode, args).without(element);
   },
 
   identify: function(element) {
     element = $(element);
-    var id = element.readAttribute('id');
+    var id = Element.readAttribute(element, 'id');
     if (id) return id;
     do { id = 'anonymous_element_' + Element.idCounter++ } while ($(id));
-    element.writeAttribute('id', id);
+    Element.writeAttribute(element, 'id', id);
     return id;
   },
 
@@ -2148,11 +2154,11 @@
   },
 
   getHeight: function(element) {
-    return $(element).getDimensions().height;
+    return Element.getDimensions(element).height;
   },
 
   getWidth: function(element) {
-    return $(element).getDimensions().width;
+    return Element.getDimensions(element).width;
   },
 
   classNames: function(element) {
@@ -2168,7 +2174,7 @@
 
   addClassName: function(element, className) {
     if (!(element = $(element))) return;
-    if (!element.hasClassName(className))
+    if (!Element.hasClassName(element, className))
       element.className += (element.className ? ' ' : '') + className;
     return element;
   },
@@ -2182,8 +2188,8 @@
 
   toggleClassName: function(element, className) {
     if (!(element = $(element))) return;
-    return element[element.hasClassName(className) ?
-      'removeClassName' : 'addClassName'](className);
+    return Element[Element.hasClassName(element, className) ?
+      'removeClassName' : 'addClassName'](element, className);
   },
 
   cleanWhitespace: function(element) {
@@ -2219,7 +2225,7 @@
 
   scrollTo: function(element) {
     element = $(element);
-    var pos = element.cumulativeOffset();
+    var pos = Element.cumulativeOffset(element);
     window.scrollTo(pos[0], pos[1]);
     return element;
   },
@@ -2267,7 +2273,7 @@
 
   getDimensions: function(element) {
     element = $(element);
-    var display = element.getStyle('display');
+    var display = Element.getStyle(element, 'display');
     if (display != 'none' && display != null) // Safari bug
       return {width: element.offsetWidth, height: element.offsetHeight};
 
@@ -2358,9 +2364,9 @@
 
   absolutize: function(element) {
     element = $(element);
-    if (element.getStyle('position') == 'absolute') return element;
+    if (Element.getStyle(element, 'position') == 'absolute') return element;
 
-    var offsets = element.positionedOffset();
+    var offsets = Element.positionedOffset(element);
     var top     = offsets[1];
     var left    = offsets[0];
     var width   = element.clientWidth;
@@ -2381,7 +2387,7 @@
 
   relativize: function(element) {
     element = $(element);
-    if (element.getStyle('position') == 'relative') return element;
+    if (Element.getStyle(element, 'position') == 'relative') return element;
 
     element.style.position = 'relative';
     var top  = parseFloat(element.style.top  || 0) - (element._originalTop || 0);
@@ -2450,14 +2456,14 @@
     }, arguments[2] || { });
 
     source = $(source);
-    var p = source.viewportOffset();
+    var p = Element.viewportOffset(source);
 
     element = $(element);
     var delta = [0, 0];
     var parent = null;
     if (Element.getStyle(element, 'position') == 'absolute') {
-      parent = element.getOffsetParent();
-      delta = parent.viewportOffset();
+      parent = Element.getOffsetParent(element);
+      delta = Element.viewportOffset(parent);
     }
 
     if (parent == document.body) {
@@ -2882,12 +2888,13 @@
 };
 
 (function() {
-  Object.extend(this.tags, {
-    THEAD: this.tags.TBODY,
-    TFOOT: this.tags.TBODY,
-    TH:    this.tags.TD
+  var tags = Element._insertionTranslations.tags;
+  Object.extend(tags, {
+    THEAD: tags.TBODY,
+    TFOOT: tags.TBODY,
+    TH:    tags.TD
   });
-}).call(Element._insertionTranslations);
+})();
 
 Element.Methods.Simulated = {
   hasAttribute: function(element, attribute) {
@@ -2946,16 +2953,12 @@
     if (HTMLOBJECTELEMENT_PROTOTYPE_BUGGY &&
         HTMLAPPLETELEMENT_PROTOTYPE_BUGGY) {
       return function(element) {
-        if (element && element.tagName) {
-          var tagName = element.tagName.toUpperCase();
-          if (tagName === 'OBJECT' || tagName === 'APPLET') {
+        if (element && typeof element._extendedByPrototype == 'undefined') {
+          var t = element.tagName;
+          if (t && (/^(?:object|applet|embed)$/i.test(t))) {
             extendElementWith(element, Element.Methods);
-            if (tagName === 'OBJECT') {
-              extendElementWith(element, Element.Methods.ByTag.OBJECT)
-            }
-            else if (tagName === 'APPLET') {
-              extendElementWith(element, Element.Methods.ByTag.APPLET)
-            }
+            extendElementWith(element, Element.Methods.Simulated);
+            extendElementWith(element, Element.Methods.ByTag[t.toUpperCase()]);
           }
         }
         return element;
@@ -3158,9 +3161,9 @@
     if (!(element = $(element))) return;
 
     if (arguments.length === 2) {
-      element.getStorage().update(key);
+      Element.getStorage(element).update(key);
     } else {
-      element.getStorage().set(key, value);
+      Element.getStorage(element).set(key, value);
     }
 
     return element;
@@ -3580,11 +3583,31 @@
       return nodes;
     },
 
-    unmark: function(nodes) {
-      for (var i = 0, node; node = nodes[i]; i++)
-        node._countedByPrototype = undefined;
-      return nodes;
-    },
+    unmark: (function(){
+
+      var PROPERTIES_ATTRIBUTES_MAP = (function(){
+        var el = document.createElement('div'),
+            isBuggy = false,
+            propName = '_countedByPrototype',
+            value = 'x'
+        el[propName] = value;
+        isBuggy = (el.getAttribute(propName) === value);
+        el = null;
+        return isBuggy;
+      })();
+
+      return PROPERTIES_ATTRIBUTES_MAP ?
+        function(nodes) {
+          for (var i = 0, node; node = nodes[i]; i++)
+            node.removeAttribute('_countedByPrototype');
+          return nodes;
+        } :
+        function(nodes) {
+          for (var i = 0, node; node = nodes[i]; i++)
+            node._countedByPrototype = void 0;
+          return nodes;
+        }
+    })(),
 
     index: function(parentNode, reverse, ofType) {
       parentNode._countedByPrototype = Prototype.emptyFunction;
@@ -3926,12 +3949,6 @@
       for (var i = 0, node; node = b[i]; i++)
         if (node.tagName !== "!") a.push(node);
       return a;
-    },
-
-    unmark: function(nodes) {
-      for (var i = 0, node; node = nodes[i]; i++)
-        node.removeAttribute('_countedByPrototype');
-      return nodes;
     }
   });
 }
@@ -4028,7 +4045,7 @@
     }).sortBy(function(element) { return element.tabIndex }).first();
 
     return firstByIndex ? firstByIndex : elements.find(function(element) {
-      return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase());
+      return /^(?:input|select|textarea)$/i.test(element.tagName);
     });
   },
 
@@ -4114,7 +4131,7 @@
     try {
       element.focus();
       if (element.select && (element.tagName.toLowerCase() != 'input' ||
-          !['button', 'reset', 'submit'].include(element.type)))
+          !(/^(?:button|reset|submit)$/i.test(element.type))))
         element.select();
     } catch (e) { }
     return element;
@@ -4308,6 +4325,10 @@
     cache: {}
   };
 
+  var docEl = document.documentElement;
+  var MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED = 'onmouseenter' in docEl
+    && 'onmouseleave' in docEl;
+
   var _isButton;
   if (Prototype.Browser.IE) {
     var buttonMap = { 0: 1, 1: 4, 2: 2 };
@@ -4460,7 +4481,7 @@
     }
 
     var respondersForEvent = registry.get(eventName);
-    if (Object.isUndefined()) {
+    if (Object.isUndefined(respondersForEvent)) {
       respondersForEvent = [];
       registry.set(eventName, respondersForEvent);
     }
@@ -4480,7 +4501,7 @@
         handler.call(element, event);
       };
     } else {
-      if (!Prototype.Browser.IE &&
+      if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED &&
        (eventName === "mouseenter" || eventName === "mouseleave")) {
         if (eventName === "mouseenter" || eventName === "mouseleave") {
           responder = function(event) {
@@ -4528,7 +4549,7 @@
 
   var _getDOMEventName = Prototype.K;
 
-  if (!Prototype.Browser.IE) {
+  if (!MOUSEENTER_MOUSELEAVE_EVENTS_SUPPORTED) {
     _getDOMEventName = function(eventName) {
       var translations = { mouseenter: "mouseover", mouseleave: "mouseout" };
       return eventName in translations ? translations[eventName] : eventName;



Mime
View raw message