[Jifty-commit] r4412 - jifty/branches/prototype-1.6/share/web/static/js

jifty-commit at lists.jifty.org jifty-commit at lists.jifty.org
Sat Nov 10 11:09:06 EST 2007


Author: sunnavy
Date: Sat Nov 10 11:09:05 2007
New Revision: 4412

Modified:
   jifty/branches/prototype-1.6/share/web/static/js/prototype.js

Log:
prototype 1.6.0 released

Modified: jifty/branches/prototype-1.6/share/web/static/js/prototype.js
==============================================================================
--- jifty/branches/prototype-1.6/share/web/static/js/prototype.js	(original)
+++ jifty/branches/prototype-1.6/share/web/static/js/prototype.js	Sat Nov 10 11:09:05 2007
@@ -1,4 +1,4 @@
-/*  Prototype JavaScript framework, version 1.6.0_rc1
+/*  Prototype JavaScript framework, version 1.6.0
  *  (c) 2005-2007 Sam Stephenson
  *
  *  Prototype is freely distributable under the terms of an MIT-style license.
@@ -7,7 +7,7 @@
  *--------------------------------------------------------------------------*/
 
 var Prototype = {
-  Version: '1.6.0_rc1',
+  Version: '1.6.0',
 
   Browser: {
     IE:     !!(window.attachEvent && !window.opera),
@@ -21,8 +21,9 @@
     XPath: !!document.evaluate,
     ElementExtensions: !!window.HTMLElement,
     SpecificElementExtensions:
+      document.createElement('div').__proto__ &&
       document.createElement('div').__proto__ !==
-       document.createElement('form').__proto__
+        document.createElement('form').__proto__
   },
 
   ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
@@ -74,10 +75,14 @@
 
 Class.Methods = {
   addMethods: function(source) {
-    var ancestor = this.superclass && this.superclass.prototype;
+    var ancestor   = this.superclass && this.superclass.prototype;
+    var properties = Object.keys(source);
 
-    for (var property in source) {
-      var value = source[property];
+    if (!Object.keys({ toString: true }).length)
+      properties.push("toString", "valueOf");
+
+    for (var i = 0, length = properties.length; i < length; i++) {
+      var property = properties[i], value = source[property];
       if (ancestor && Object.isFunction(value) &&
           value.argumentNames().first() == "$super") {
         var method = value, value = Object.extend((function(m) {
@@ -561,7 +566,7 @@
 
       var ctx = object, expr = match[3];
       var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/, match = pattern.exec(expr);
-      if (match == null) return '';
+      if (match == null) return before;
 
       while (match != null) {
         var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
@@ -1092,6 +1097,7 @@
   }
 })());
 
+Hash.prototype.toTemplateReplacements = Hash.prototype.toObject;
 Hash.from = $H;
 var ObjectRange = Class.create(Enumerable, {
   initialize: function(start, end, exclusive) {
@@ -1254,22 +1260,18 @@
       'X-Prototype-Version': Prototype.Version,
       'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'
     };
-    var headerNames = [ 'X-Requested-With', 'X-Prototype-Version', 'Accept' ];
 
     if (this.method == 'post') {
-          headers['Content-Type'] = this.options.contentType +
-            (this.options.encoding ? '; charset=' + this.options.encoding : '');
-          headerNames.push('Content-Type');
+      headers['Content-type'] = this.options.contentType +
+        (this.options.encoding ? '; charset=' + this.options.encoding : '');
 
       /* Force "Connection: close" for older Mozilla browsers to work
        * around a bug where XMLHttpRequest sends an incorrect
        * Content-length header. See Mozilla Bugzilla #246651.
        */
       if (this.transport.overrideMimeType &&
-          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) {
+          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005)
             headers['Connection'] = 'close';
-            headerNames.push('Connection');
-          }
     }
 
     // user-defined headers
@@ -1277,20 +1279,14 @@
       var extras = this.options.requestHeaders;
 
       if (Object.isFunction(extras.push))
-        for (var i = 0, length = extras.length; i < length; i += 2) {
+        for (var i = 0, length = extras.length; i < length; i += 2)
           headers[extras[i]] = extras[i+1];
-          headerNames.push(extras[i]);
-        }
       else
-        $H(extras).each(function(pair) {
-            headers[pair.key] = pair.value 
-            headerNames.push(pair.key);
-        });
+        $H(extras).each(function(pair) { headers[pair.key] = pair.value });
     }
 
-    for (var i=0; i<headerNames.length; i++) {
-        this.transport.setRequestHeader(headerNames[i], headers[headerNames[i]]);
-    }
+    for (var name in headers)
+      this.transport.setRequestHeader(name, headers[name]);
   },
 
   success: function() {
@@ -1409,8 +1405,10 @@
 
   _getHeaderJSON: function() {
     var json = this.getHeader('X-JSON');
+    if (!json) return null;
+    json = decodeURIComponent(escape(json));
     try {
-      return json ? json.evalJSON(this.request.options.sanitizeJSON) : null;
+      return json.evalJSON(this.request.options.sanitizeJSON);
     } catch (e) {
       this.request.dispatchException(e);
     }
@@ -1418,11 +1416,11 @@
 
   _getResponseJSON: function() {
     var options = this.request.options;
+    if (!options.evalJSON || (options.evalJSON != 'force' &&
+      !(this.getHeader('Content-type') || '').include('application/json')))
+        return null;
     try {
-      if (options.evalJSON == 'force' || (options.evalJSON &&
-          (this.getHeader('Content-type') || '').include('application/json')))
-        return this.transport.responseText.evalJSON(options.sanitizeJSON);
-      return null;
+      return this.transport.responseText.evalJSON(options.sanitizeJSON);
     } catch (e) {
       this.request.dispatchException(e);
     }
@@ -1633,7 +1631,6 @@
     var content, t, range;
 
     for (position in insertions) {
-      if ( position == 'extend' ) continue;
       content  = insertions[position];
       position = position.toLowerCase();
       t = Element._insertionTranslations[position];
@@ -1828,7 +1825,7 @@
     if (!(element = $(element))) return;
     var elementClassName = element.className;
     return (elementClassName.length > 0 && (elementClassName == className ||
-      elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))));
+      new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName)));
   },
 
   addClassName: function(element, className) {
@@ -1870,6 +1867,20 @@
 
   descendantOf: function(element, ancestor) {
     element = $(element), ancestor = $(ancestor);
+
+    if (element.compareDocumentPosition)
+      return (element.compareDocumentPosition(ancestor) & 8) === 8;
+
+    if (element.sourceIndex && !Prototype.Browser.Opera) {
+      var e = element.sourceIndex, a = ancestor.sourceIndex,
+       nextAncestor = ancestor.nextSibling;
+      if (!nextAncestor) {
+        do { ancestor = ancestor.parentNode; }
+        while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
+      }
+      if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
+    }
+
     while (element = element.parentNode)
       if (element == ancestor) return true;
     return false;
@@ -2259,7 +2270,11 @@
       return filter.replace(/alpha\([^\)]*\)/gi,'');
     }
     element = $(element);
-    if (!element.currentStyle.hasLayout) element.style.zoom = 1;
+    var currentStyle = element.currentStyle;
+    if ((currentStyle && !currentStyle.hasLayout) ||
+      (!currentStyle && element.style.zoom == 'normal'))
+        element.style.zoom = 1;
+
     var filter = element.getStyle('filter'), style = element.style;
     if (value == 1 || value === '') {
       (filter = stripAlpha(filter)) ?
@@ -2355,7 +2370,7 @@
   })(Element._attributeTranslations.read.values);
 }
 
-else if (Prototype.Browser.Gecko) {
+else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) {
   Element.Methods.setOpacity = function(element, value) {
     element = $(element);
     element.style.opacity = (value == 1) ? 0.999999 :
@@ -2618,8 +2633,7 @@
     onlyIfAbsent = onlyIfAbsent || false;
     for (var property in methods) {
       var value = methods[property];
-    // don't copy update, temporarily 
-      if (!Object.isFunction(value) || property == 'update') continue;
+      if (!Object.isFunction(value)) continue;
       if (!onlyIfAbsent || !(property in destination))
         destination[property] = value.methodize();
     }
@@ -3133,6 +3147,7 @@
     },
 
     attrPresence: function(nodes, root, attr) {
+      if (!nodes) nodes = root.getElementsByTagName("*");
       var results = [];
       for (var i = 0, node; node = nodes[i]; i++)
         if (Element.hasAttribute(node, attr)) results.push(node);
@@ -3696,24 +3711,27 @@
 });
 
 Event.Methods = (function() {
+  var isButton;
+
   if (Prototype.Browser.IE) {
-    function isButton(event, code) {
-      return event.button == ({ 0: 1, 1: 4, 2: 2 })[code];
-    }
+    var buttonMap = { 0: 1, 1: 4, 2: 2 };
+    isButton = function(event, code) {
+      return event.button == buttonMap[code];
+    };
 
   } else if (Prototype.Browser.WebKit) {
-    function isButton(event, code) {
+    isButton = function(event, code) {
       switch (code) {
         case 0: return event.which == 1 && !event.metaKey;
         case 1: return event.which == 1 && event.metaKey;
         default: return false;
       }
-    }
+    };
 
   } else {
-    function isButton(event, code) {
+    isButton = function(event, code) {
       return event.which ? (event.which === code + 1) : (event.button === code);
-    }
+    };
   }
 
   return {
@@ -3747,6 +3765,7 @@
       Event.extend(event);
       event.preventDefault();
       event.stopPropagation();
+      event.stopped = true;
     }
   };
 })();
@@ -3796,7 +3815,7 @@
   }
 
   function getDOMEventName(eventName) {
-    if (eventName && eventName.match(/:/)) return "dataavailable";
+    if (eventName && eventName.include(':')) return "dataavailable";
     return eventName;
   }
 
@@ -3815,8 +3834,9 @@
     if (c.pluck("handler").include(handler)) return false;
 
     var wrapper = function(event) {
-      if (event.eventName && event.eventName != eventName)
-        return false;
+      if (!Event || !Event.extend ||
+        (event.eventName && event.eventName != eventName))
+          return false;
 
       Event.extend(event);
       handler.call(element, event)
@@ -4161,4 +4181,4 @@
 
 /*--------------------------------------------------------------------------*/
 
-Element.addMethods();
+Element.addMethods();
\ No newline at end of file


More information about the Jifty-commit mailing list