public
Description: script.aculo.us is an open-source JavaScript framework for visual effects and interface behaviours.
Homepage: http://script.aculo.us/
Clone URL: git://github.com/madrobby/scriptaculous.git
Search Repo:
Click here to lend your support to: scriptaculous and make a donation at www.pledgie.com !
script.aculo.us: bump Prototype to 1.6.0.2

git-svn-id: http://svn.rubyonrails.org/rails/spinoffs/scriptaculous@8736 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
madrobby (author)
Sat Jan 26 00:17:42 -0800 2008
commit  261d3076bb18aa0c7f4e5196f2e1d21ddcf81e0d
tree    49a3d285e74c5a9b10a3e2f079bf7d393614a931
parent  115b86defe984a47e9fe61e4bdccd870b54edb82
...
 
 
1
2
3
...
1
2
3
4
5
0
@@ -1,3 +1,5 @@
0
+* Update to Prototype 1.6.0.2 final
0
+
0
 * Fix an issue with Effect.ScrollTo that caused Firefox to scroll to the wrong offset in some situations. Closes #10245. [nik.wakelin]
0
 
0
 * Fixes an issue with IE ghosting on non-absolute elements. Closes #10423. [Tanrikut, tdd]
...
1
 
2
3
4
...
7
8
9
10
 
11
12
13
...
110
111
112
113
 
114
115
116
...
171
172
173
174
 
 
175
176
177
...
578
579
580
581
 
582
583
584
...
812
813
814
815
 
816
817
818
819
820
821
822
 
823
824
825
...
1298
1299
1300
1301
 
1302
1303
1304
...
1316
1317
1318
 
 
 
 
 
 
 
 
 
1319
1320
1321
...
1391
1392
1393
1394
 
 
1395
1396
1397
...
1404
1405
1406
1407
 
 
1408
1409
1410
...
1610
1611
1612
1613
 
1614
1615
1616
...
1674
1675
1676
1677
 
1678
1679
1680
...
1863
1864
1865
1866
 
 
1867
1868
1869
...
2007
2008
2009
2010
 
2011
2012
2013
...
2200
2201
2202
2203
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2204
2205
2206
2207
2208
 
 
 
 
 
 
2209
2210
2211
...
2287
2288
2289
2290
 
 
 
 
2291
2292
2293
...
2407
2408
2409
2410
 
2411
2412
2413
...
2901
2902
2903
2904
2905
2906
2907
 
 
 
 
2908
2909
2910
 
2911
2912
2913
...
2957
2958
2959
2960
 
2961
2962
2963
...
2972
2973
2974
 
2975
2976
 
2977
2978
2979
2980
2981
2982
 
2983
2984
2985
...
2987
2988
2989
2990
 
2991
2992
2993
2994
 
2995
2996
2997
2998
 
2999
3000
3001
...
3004
3005
3006
3007
3008
 
 
3009
3010
3011
...
3117
3118
3119
3120
 
3121
 
3122
3123
3124
3125
3126
3127
3128
 
3129
 
3130
3131
3132
...
3205
3206
3207
3208
 
3209
3210
3211
...
3243
3244
3245
3246
 
3247
3248
3249
...
3277
3278
3279
 
 
 
 
 
 
 
 
3280
3281
 
3282
3283
3284
 
3285
3286
3287
...
3294
3295
3296
3297
3298
3299
3300
3301
 
3302
3303
3304
...
3309
3310
3311
3312
3313
3314
3315
3316
3317
3318
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3319
3320
3321
...
3793
3794
3795
3796
 
3797
3798
 
3799
3800
3801
...
 
1
2
3
4
...
7
8
9
 
10
11
12
13
...
110
111
112
 
113
114
115
116
...
171
172
173
 
174
175
176
177
178
...
579
580
581
 
582
583
584
585
...
813
814
815
 
816
817
818
819
820
821
822
 
823
824
825
826
...
1299
1300
1301
 
1302
1303
1304
1305
...
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
...
1401
1402
1403
 
1404
1405
1406
1407
1408
...
1415
1416
1417
 
1418
1419
1420
1421
1422
...
1622
1623
1624
 
1625
1626
1627
1628
...
1686
1687
1688
 
1689
1690
1691
1692
...
1875
1876
1877
 
1878
1879
1880
1881
1882
...
2020
2021
2022
 
2023
2024
2025
2026
...
2213
2214
2215
 
2216
2217
2218
2219
2220
2221
2222
2223
2224
2225
2226
2227
2228
2229
2230
2231
2232
2233
2234
 
2235
2236
2237
2238
2239
2240
2241
2242
2243
...
2319
2320
2321
 
2322
2323
2324
2325
2326
2327
2328
...
2442
2443
2444
 
2445
2446
2447
2448
...
2936
2937
2938
 
 
 
 
2939
2940
2941
2942
2943
2944
 
2945
2946
2947
2948
...
2992
2993
2994
 
2995
2996
2997
2998
...
3007
3008
3009
3010
3011
 
3012
3013
3014
3015
3016
3017
 
3018
3019
3020
3021
...
3023
3024
3025
 
3026
3027
3028
3029
 
3030
3031
3032
3033
 
3034
3035
3036
3037
...
3040
3041
3042
 
 
3043
3044
3045
3046
3047
...
3153
3154
3155
 
3156
3157
3158
3159
3160
3161
3162
3163
3164
 
3165
3166
3167
3168
3169
3170
...
3243
3244
3245
 
3246
3247
3248
3249
...
3281
3282
3283
 
3284
3285
3286
3287
...
3315
3316
3317
3318
3319
3320
3321
3322
3323
3324
3325
3326
 
3327
3328
3329
 
3330
3331
3332
3333
...
3340
3341
3342
 
 
 
 
 
3343
3344
3345
3346
...
3351
3352
3353
 
 
 
 
 
 
 
3354
3355
3356
3357
3358
3359
3360
3361
3362
3363
3364
3365
3366
3367
3368
3369
3370
3371
3372
...
3844
3845
3846
 
3847
3848
 
3849
3850
3851
3852
0
@@ -1,4 +1,4 @@
0
-/* Prototype JavaScript framework, version 1.6.0.1
0
+/* Prototype JavaScript framework, version 1.6.0.2
0
  * (c) 2005-2007 Sam Stephenson
0
  *
0
  * Prototype is freely distributable under the terms of an MIT-style license.
0
@@ -7,7 +7,7 @@
0
  *--------------------------------------------------------------------------*/
0
 
0
 var Prototype = {
0
- Version: '1.6.0.1',
0
+ Version: '1.6.0.2',
0
 
0
   Browser: {
0
     IE: !!(window.attachEvent && !window.opera),
0
@@ -110,7 +110,7 @@ Object.extend(Object, {
0
     try {
0
       if (Object.isUndefined(object)) return 'undefined';
0
       if (object === null) return 'null';
0
- return object.inspect ? object.inspect() : object.toString();
0
+ return object.inspect ? object.inspect() : String(object);
0
     } catch (e) {
0
       if (e instanceof RangeError) return '...';
0
       throw e;
0
@@ -171,7 +171,8 @@ Object.extend(Object, {
0
   },
0
 
0
   isArray: function(object) {
0
- return object && object.constructor === Array;
0
+ return object != null && typeof object == "object" &&
0
+ 'splice' in object && 'join' in object;
0
   },
0
 
0
   isHash: function(object) {
0
@@ -578,7 +579,7 @@ var Template = Class.create({
0
       }
0
 
0
       return before + String.interpret(ctx);
0
- }.bind(this));
0
+ });
0
   }
0
 });
0
 Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
0
@@ -812,14 +813,14 @@ function $A(iterable) {
0
 }
0
 
0
 if (Prototype.Browser.WebKit) {
0
- function $A(iterable) {
0
+ $A = function(iterable) {
0
     if (!iterable) return [];
0
     if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') &&
0
         iterable.toArray) return iterable.toArray();
0
     var length = iterable.length || 0, results = new Array(length);
0
     while (length--) results[length] = iterable[length];
0
     return results;
0
- }
0
+ };
0
 }
0
 
0
 Array.from = $A;
0
@@ -1298,7 +1299,7 @@ Ajax.Request = Class.create(Ajax.Base, {
0
 
0
       var contentType = response.getHeader('Content-type');
0
       if (this.options.evalJS == 'force'
0
- || (this.options.evalJS && contentType
0
+ || (this.options.evalJS && this.isSameOrigin() && contentType
0
           && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))
0
         this.evalResponse();
0
     }
0
@@ -1316,6 +1317,15 @@ Ajax.Request = Class.create(Ajax.Base, {
0
     }
0
   },
0
 
0
+ isSameOrigin: function() {
0
+ var m = this.url.match(/^\s*https?:\/\/[^\/]*/);
0
+ return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({
0
+ protocol: location.protocol,
0
+ domain: document.domain,
0
+ port: location.port ? ':' + location.port : ''
0
+ }));
0
+ },
0
+
0
   getHeader: function(name) {
0
     try {
0
       return this.transport.getResponseHeader(name) || null;
0
@@ -1391,7 +1401,8 @@ Ajax.Response = Class.create({
0
     if (!json) return null;
0
     json = decodeURIComponent(escape(json));
0
     try {
0
- return json.evalJSON(this.request.options.sanitizeJSON);
0
+ return json.evalJSON(this.request.options.sanitizeJSON ||
0
+ !this.request.isSameOrigin());
0
     } catch (e) {
0
       this.request.dispatchException(e);
0
     }
0
@@ -1404,7 +1415,8 @@ Ajax.Response = Class.create({
0
         this.responseText.blank())
0
           return null;
0
     try {
0
- return this.responseText.evalJSON(options.sanitizeJSON);
0
+ return this.responseText.evalJSON(options.sanitizeJSON ||
0
+ !this.request.isSameOrigin());
0
     } catch (e) {
0
       this.request.dispatchException(e);
0
     }
0
@@ -1610,7 +1622,7 @@ Element.Methods = {
0
 
0
     var content, insert, tagName, childNodes;
0
 
0
- for (position in insertions) {
0
+ for (var position in insertions) {
0
       content = insertions[position];
0
       position = position.toLowerCase();
0
       insert = Element._insertionTranslations[position];
0
@@ -1674,7 +1686,7 @@ Element.Methods = {
0
   },
0
 
0
   descendants: function(element) {
0
- return $(element).getElementsBySelector("*");
0
+ return $(element).select("*");
0
   },
0
 
0
   firstDescendant: function(element) {
0
@@ -1863,7 +1875,8 @@ Element.Methods = {
0
         do { ancestor = ancestor.parentNode; }
0
         while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode);
0
       }
0
- if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex);
0
+ if (nextAncestor && nextAncestor.sourceIndex)
0
+ return (e > a && e < nextAncestor.sourceIndex);
0
     }
0
 
0
     while (element = element.parentNode)
0
@@ -2007,7 +2020,7 @@ Element.Methods = {
0
       if (element) {
0
         if (element.tagName == 'BODY') break;
0
         var p = Element.getStyle(element, 'position');
0
- if (p == 'relative' || p == 'absolute') break;
0
+ if (p !== 'static') break;
0
       }
0
     } while (element);
0
     return Element._returnOffset(valueL, valueT);
0
@@ -2200,12 +2213,31 @@ if (Prototype.Browser.Opera) {
0
 }
0
 
0
 else if (Prototype.Browser.IE) {
0
- $w('positionedOffset getOffsetParent viewportOffset').each(function(method) {
0
+ // IE doesn't report offsets correctly for static elements, so we change them
0
+ // to "relative" to get the values, then change them back.
0
+ Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap(
0
+ function(proceed, element) {
0
+ element = $(element);
0
+ var position = element.getStyle('position');
0
+ if (position !== 'static') return proceed(element);
0
+ element.setStyle({ position: 'relative' });
0
+ var value = proceed(element);
0
+ element.setStyle({ position: position });
0
+ return value;
0
+ }
0
+ );
0
+
0
+ $w('positionedOffset viewportOffset').each(function(method) {
0
     Element.Methods[method] = Element.Methods[method].wrap(
0
       function(proceed, element) {
0
         element = $(element);
0
         var position = element.getStyle('position');
0
- if (position != 'static') return proceed(element);
0
+ if (position !== 'static') return proceed(element);
0
+ // Trigger hasLayout on the offset parent so that IE6 reports
0
+ // accurate offsetTop and offsetLeft values for position: fixed.
0
+ var offsetParent = element.getOffsetParent();
0
+ if (offsetParent && offsetParent.getStyle('position') === 'fixed')
0
+ offsetParent.setStyle({ zoom: 1 });
0
         element.setStyle({ position: 'relative' });
0
         var value = proceed(element);
0
         element.setStyle({ position: position });
0
@@ -2287,7 +2319,10 @@ else if (Prototype.Browser.IE) {
0
   };
0
 
0
   Element._attributeTranslations.write = {
0
- names: Object.clone(Element._attributeTranslations.read.names),
0
+ names: Object.extend({
0
+ cellpadding: 'cellPadding',
0
+ cellspacing: 'cellSpacing'
0
+ }, Element._attributeTranslations.read.names),
0
     values: {
0
       checked: function(element, value) {
0
         element.checked = !!value;
0
@@ -2407,7 +2442,7 @@ if (Prototype.Browser.IE || Prototype.Browser.Opera) {
0
   };
0
 }
0
 
0
-if (document.createElement('div').outerHTML) {
0
+if ('outerHTML' in document.createElement('div')) {
0
   Element.Methods.replace = function(element, content) {
0
     element = $(element);
0
 
0
@@ -2901,13 +2936,13 @@ Object.extend(Selector, {
0
   },
0
 
0
   criteria: {
0
- tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
0
- className: 'n = h.className(n, r, "#{1}", c); c = false;',
0
- id: 'n = h.id(n, r, "#{1}", c); c = false;',
0
- attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;',
0
+ tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;',
0
+ className: 'n = h.className(n, r, "#{1}", c); c = false;',
0
+ id: 'n = h.id(n, r, "#{1}", c); c = false;',
0
+ attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;',
0
     attr: function(m) {
0
       m[3] = (m[5] || m[6]);
0
- return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m);
0
+ return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m);
0
     },
0
     pseudo: function(m) {
0
       if (m[6]) m[6] = m[6].replace(/"/g, '\\"');
0
@@ -2957,7 +2992,7 @@ Object.extend(Selector, {
0
 
0
     attr: function(element, matches) {
0
       var nodeValue = Element.readAttribute(element, matches[1]);
0
- return Selector.operators[matches[2]](nodeValue, matches[3]);
0
+ return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]);
0
     }
0
   },
0
 
0
@@ -2972,14 +3007,15 @@ Object.extend(Selector, {
0
 
0
     // marks an array of nodes for counting
0
     mark: function(nodes) {
0
+ var _true = Prototype.emptyFunction;
0
       for (var i = 0, node; node = nodes[i]; i++)
0
- node._counted = true;
0
+ node._countedByPrototype = _true;
0
       return nodes;
0
     },
0
 
0
     unmark: function(nodes) {
0
       for (var i = 0, node; node = nodes[i]; i++)
0
- node._counted = undefined;
0
+ node._countedByPrototype = undefined;
0
       return nodes;
0
     },
0
 
0
@@ -2987,15 +3023,15 @@ Object.extend(Selector, {
0
     // "ofType" flag indicates whether we're indexing for nth-of-type
0
     // rather than nth-child
0
     index: function(parentNode, reverse, ofType) {
0
- parentNode._counted = true;
0
+ parentNode._countedByPrototype = Prototype.emptyFunction;
0
       if (reverse) {
0
         for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) {
0
           var node = nodes[i];
0
- if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
0
+ if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
0
         }
0
       } else {
0
         for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++)
0
- if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++;
0
+ if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++;
0
       }
0
     },
0
 
0
@@ -3004,8 +3040,8 @@ Object.extend(Selector, {
0
       if (nodes.length == 0) return nodes;
0
       var results = [], n;
0
       for (var i = 0, l = nodes.length; i < l; i++)
0
- if (!(n = nodes[i])._counted) {
0
- n._counted = true;
0
+ if (!(n = nodes[i])._countedByPrototype) {
0
+ n._countedByPrototype = Prototype.emptyFunction;
0
           results.push(Element.extend(n));
0
         }
0
       return Selector.handlers.unmark(results);
0
@@ -3117,16 +3153,18 @@ Object.extend(Selector, {
0
       return results;
0
     },
0
 
0
- attrPresence: function(nodes, root, attr) {
0
+ attrPresence: function(nodes, root, attr, combinator) {
0
       if (!nodes) nodes = root.getElementsByTagName("*");
0
+ if (nodes && combinator) nodes = this[combinator](nodes);
0
       var results = [];
0
       for (var i = 0, node; node = nodes[i]; i++)
0
         if (Element.hasAttribute(node, attr)) results.push(node);
0
       return results;
0
     },
0
 
0
- attr: function(nodes, root, attr, value, operator) {
0
+ attr: function(nodes, root, attr, value, operator, combinator) {
0
       if (!nodes) nodes = root.getElementsByTagName("*");
0
+ if (nodes && combinator) nodes = this[combinator](nodes);
0
       var handler = Selector.operators[operator], results = [];
0
       for (var i = 0, node; node = nodes[i]; i++) {
0
         var nodeValue = Element.readAttribute(node, attr);
0
@@ -3205,7 +3243,7 @@ Object.extend(Selector, {
0
       var h = Selector.handlers, results = [], indexed = [], m;
0
       h.mark(nodes);
0
       for (var i = 0, node; node = nodes[i]; i++) {
0
- if (!node.parentNode._counted) {
0
+ if (!node.parentNode._countedByPrototype) {
0
           h.index(node.parentNode, reverse, ofType);
0
           indexed.push(node.parentNode);
0
         }
0
@@ -3243,7 +3281,7 @@ Object.extend(Selector, {
0
       var exclusions = new Selector(selector).findElements(root);
0
       h.mark(exclusions);
0
       for (var i = 0, results = [], node; node = nodes[i]; i++)
0
- if (!node._counted) results.push(node);
0
+ if (!node._countedByPrototype) results.push(node);
0
       h.unmark(exclusions);
0
       return results;
0
     },
0
@@ -3277,11 +3315,19 @@ Object.extend(Selector, {
0
     '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); }
0
   },
0
 
0
+ split: function(expression) {
0
+ var expressions = [];
0
+ expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
0
+ expressions.push(m[1].strip());
0
+ });
0
+ return expressions;
0
+ },
0
+
0
   matchElements: function(elements, expression) {
0
- var matches = new Selector(expression).findElements(), h = Selector.handlers;
0
+ var matches = $$(expression), h = Selector.handlers;
0
     h.mark(matches);
0
     for (var i = 0, results = [], element; element = elements[i]; i++)
0
- if (element._counted) results.push(element);
0
+ if (element._countedByPrototype) results.push(element);
0
     h.unmark(matches);
0
     return results;
0
   },
0
@@ -3294,11 +3340,7 @@ Object.extend(Selector, {
0
   },
0
 
0
   findChildElements: function(element, expressions) {
0
- var exprs = expressions.join(',');
0
- expressions = [];
0
- exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) {
0
- expressions.push(m[1].strip());
0
- });
0
+ expressions = Selector.split(expressions.join(','));
0
     var results = [], h = Selector.handlers;
0
     for (var i = 0, l = expressions.length, selector; i < l; i++) {
0
       selector = new Selector(expressions[i].strip());
0
@@ -3309,13 +3351,22 @@ Object.extend(Selector, {
0
 });
0
 
0
 if (Prototype.Browser.IE) {
0
- // IE returns comment nodes on getElementsByTagName("*").
0
- // Filter them out.
0
- Selector.handlers.concat = function(a, b) {
0
- for (var i = 0, node; node = b[i]; i++)
0
- if (node.tagName !== "!") a.push(node);
0
- return a;
0
- };
0
+ Object.extend(Selector.handlers, {
0
+ // IE returns comment nodes on getElementsByTagName("*").
0
+ // Filter them out.
0
+ concat: function(a, b) {
0
+ for (var i = 0, node; node = b[i]; i++)
0
+ if (node.tagName !== "!") a.push(node);
0
+ return a;
0
+ },
0
+
0
+ // IE improperly serializes _countedByPrototype in (inner|outer)HTML.
0
+ unmark: function(nodes) {
0
+ for (var i = 0, node; node = nodes[i]; i++)
0
+ node.removeAttribute('_countedByPrototype');
0
+ return nodes;
0
+ }
0
+ });
0
 }
0
 
0
 function $$() {
0
@@ -3793,9 +3844,9 @@ Object.extend(Event, (function() {
0
   var cache = Event.cache;
0
 
0
   function getEventID(element) {
0
- if (element._eventID) return element._eventID;
0
+ if (element._prototypeEventID) return element._prototypeEventID[0];
0
     arguments.callee.id = arguments.callee.id || 1;
0
- return element._eventID = ++arguments.callee.id;
0
+ return element._prototypeEventID = [++arguments.callee.id];
0
   }
0
 
0
   function getDOMEventName(eventName) {

Comments

    No one has commented yet.