Commit 0f63ee794a315a3ad48349c5bf3ab2cbc0c24a12
1 parent
37a3c256
Exists in
master
and in
28 other branches
ActionItem1178: upgrading rails files
with `rake rails:update`
Showing
7 changed files
with
160 additions
and
158 deletions
Show diff stats
.gitignore
config/boot.rb
... | ... | @@ -24,9 +24,8 @@ module Rails |
24 | 24 | File.exist?("#{RAILS_ROOT}/vendor/rails") |
25 | 25 | end |
26 | 26 | |
27 | - # FIXME : Ruby 1.9 | |
28 | 27 | def preinitialize |
29 | - load(preinitializer_path) if File.exists?(preinitializer_path) | |
28 | + load(preinitializer_path) if File.exist?(preinitializer_path) | |
30 | 29 | end |
31 | 30 | |
32 | 31 | def preinitializer_path |
... | ... | @@ -44,6 +43,7 @@ module Rails |
44 | 43 | class VendorBoot < Boot |
45 | 44 | def load_initializer |
46 | 45 | require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" |
46 | + Rails::Initializer.run(:install_gem_spec_stubs) | |
47 | 47 | end |
48 | 48 | end |
49 | 49 | ... | ... |
public/javascripts/controls.js
1 | -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
1 | +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
2 | 2 | // (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) |
3 | 3 | // (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) |
4 | 4 | // Contributors: | ... | ... |
public/javascripts/dragdrop.js
1 | -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
1 | +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
2 | 2 | // (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) |
3 | 3 | // |
4 | 4 | // script.aculo.us is freely distributable under the terms of an MIT-style license. | ... | ... |
public/javascripts/effects.js
1 | -// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
1 | +// Copyright (c) 2005-2008 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) | |
2 | 2 | // Contributors: |
3 | 3 | // Justin Palmer (http://encytemedia.com/) |
4 | 4 | // Mark Pilgrim (http://diveintomark.org/) | ... | ... |
public/javascripts/prototype.js
1 | -/* Prototype JavaScript framework, version 1.6.0.1 | |
2 | - * (c) 2005-2007 Sam Stephenson | |
1 | +/* Prototype JavaScript framework, version 1.6.0.2 | |
2 | + * (c) 2005-2008 Sam Stephenson | |
3 | 3 | * |
4 | 4 | * Prototype is freely distributable under the terms of an MIT-style license. |
5 | 5 | * For details, see the Prototype web site: http://www.prototypejs.org/ |
... | ... | @@ -7,7 +7,7 @@ |
7 | 7 | *--------------------------------------------------------------------------*/ |
8 | 8 | |
9 | 9 | var Prototype = { |
10 | - Version: '1.6.0.1', | |
10 | + Version: '1.6.0.2', | |
11 | 11 | |
12 | 12 | Browser: { |
13 | 13 | IE: !!(window.attachEvent && !window.opera), |
... | ... | @@ -110,7 +110,7 @@ Object.extend(Object, { |
110 | 110 | try { |
111 | 111 | if (Object.isUndefined(object)) return 'undefined'; |
112 | 112 | if (object === null) return 'null'; |
113 | - return object.inspect ? object.inspect() : object.toString(); | |
113 | + return object.inspect ? object.inspect() : String(object); | |
114 | 114 | } catch (e) { |
115 | 115 | if (e instanceof RangeError) return '...'; |
116 | 116 | throw e; |
... | ... | @@ -171,7 +171,8 @@ Object.extend(Object, { |
171 | 171 | }, |
172 | 172 | |
173 | 173 | isArray: function(object) { |
174 | - return object && object.constructor === Array; | |
174 | + return object != null && typeof object == "object" && | |
175 | + 'splice' in object && 'join' in object; | |
175 | 176 | }, |
176 | 177 | |
177 | 178 | isHash: function(object) { |
... | ... | @@ -578,7 +579,7 @@ var Template = Class.create({ |
578 | 579 | } |
579 | 580 | |
580 | 581 | return before + String.interpret(ctx); |
581 | - }.bind(this)); | |
582 | + }); | |
582 | 583 | } |
583 | 584 | }); |
584 | 585 | Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; |
... | ... | @@ -806,20 +807,20 @@ Object.extend(Enumerable, { |
806 | 807 | function $A(iterable) { |
807 | 808 | if (!iterable) return []; |
808 | 809 | if (iterable.toArray) return iterable.toArray(); |
809 | - var length = iterable.length, results = new Array(length); | |
810 | + var length = iterable.length || 0, results = new Array(length); | |
810 | 811 | while (length--) results[length] = iterable[length]; |
811 | 812 | return results; |
812 | 813 | } |
813 | 814 | |
814 | 815 | if (Prototype.Browser.WebKit) { |
815 | - function $A(iterable) { | |
816 | + $A = function(iterable) { | |
816 | 817 | if (!iterable) return []; |
817 | 818 | if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && |
818 | 819 | iterable.toArray) return iterable.toArray(); |
819 | - var length = iterable.length, results = new Array(length); | |
820 | + var length = iterable.length || 0, results = new Array(length); | |
820 | 821 | while (length--) results[length] = iterable[length]; |
821 | 822 | return results; |
822 | - } | |
823 | + }; | |
823 | 824 | } |
824 | 825 | |
825 | 826 | Array.from = $A; |
... | ... | @@ -1298,7 +1299,7 @@ Ajax.Request = Class.create(Ajax.Base, { |
1298 | 1299 | |
1299 | 1300 | var contentType = response.getHeader('Content-type'); |
1300 | 1301 | if (this.options.evalJS == 'force' |
1301 | - || (this.options.evalJS && contentType | |
1302 | + || (this.options.evalJS && this.isSameOrigin() && contentType | |
1302 | 1303 | && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) |
1303 | 1304 | this.evalResponse(); |
1304 | 1305 | } |
... | ... | @@ -1316,9 +1317,18 @@ Ajax.Request = Class.create(Ajax.Base, { |
1316 | 1317 | } |
1317 | 1318 | }, |
1318 | 1319 | |
1320 | + isSameOrigin: function() { | |
1321 | + var m = this.url.match(/^\s*https?:\/\/[^\/]*/); | |
1322 | + return !m || (m[0] == '#{protocol}//#{domain}#{port}'.interpolate({ | |
1323 | + protocol: location.protocol, | |
1324 | + domain: document.domain, | |
1325 | + port: location.port ? ':' + location.port : '' | |
1326 | + })); | |
1327 | + }, | |
1328 | + | |
1319 | 1329 | getHeader: function(name) { |
1320 | 1330 | try { |
1321 | - return this.transport.getResponseHeader(name); | |
1331 | + return this.transport.getResponseHeader(name) || null; | |
1322 | 1332 | } catch (e) { return null } |
1323 | 1333 | }, |
1324 | 1334 | |
... | ... | @@ -1391,7 +1401,8 @@ Ajax.Response = Class.create({ |
1391 | 1401 | if (!json) return null; |
1392 | 1402 | json = decodeURIComponent(escape(json)); |
1393 | 1403 | try { |
1394 | - return json.evalJSON(this.request.options.sanitizeJSON); | |
1404 | + return json.evalJSON(this.request.options.sanitizeJSON || | |
1405 | + !this.request.isSameOrigin()); | |
1395 | 1406 | } catch (e) { |
1396 | 1407 | this.request.dispatchException(e); |
1397 | 1408 | } |
... | ... | @@ -1404,7 +1415,8 @@ Ajax.Response = Class.create({ |
1404 | 1415 | this.responseText.blank()) |
1405 | 1416 | return null; |
1406 | 1417 | try { |
1407 | - return this.responseText.evalJSON(options.sanitizeJSON); | |
1418 | + return this.responseText.evalJSON(options.sanitizeJSON || | |
1419 | + !this.request.isSameOrigin()); | |
1408 | 1420 | } catch (e) { |
1409 | 1421 | this.request.dispatchException(e); |
1410 | 1422 | } |
... | ... | @@ -1608,24 +1620,28 @@ Element.Methods = { |
1608 | 1620 | Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) |
1609 | 1621 | insertions = {bottom:insertions}; |
1610 | 1622 | |
1611 | - var content, t, range; | |
1623 | + var content, insert, tagName, childNodes; | |
1612 | 1624 | |
1613 | - for (position in insertions) { | |
1625 | + for (var position in insertions) { | |
1614 | 1626 | content = insertions[position]; |
1615 | 1627 | position = position.toLowerCase(); |
1616 | - t = Element._insertionTranslations[position]; | |
1628 | + insert = Element._insertionTranslations[position]; | |
1617 | 1629 | |
1618 | 1630 | if (content && content.toElement) content = content.toElement(); |
1619 | 1631 | if (Object.isElement(content)) { |
1620 | - t.insert(element, content); | |
1632 | + insert(element, content); | |
1621 | 1633 | continue; |
1622 | 1634 | } |
1623 | 1635 | |
1624 | 1636 | content = Object.toHTML(content); |
1625 | 1637 | |
1626 | - range = element.ownerDocument.createRange(); | |
1627 | - t.initializeRange(element, range); | |
1628 | - t.insert(element, range.createContextualFragment(content.stripScripts())); | |
1638 | + tagName = ((position == 'before' || position == 'after') | |
1639 | + ? element.parentNode : element).tagName.toUpperCase(); | |
1640 | + | |
1641 | + childNodes = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); | |
1642 | + | |
1643 | + if (position == 'top' || position == 'after') childNodes.reverse(); | |
1644 | + childNodes.each(insert.curry(element)); | |
1629 | 1645 | |
1630 | 1646 | content.evalScripts.bind(content).defer(); |
1631 | 1647 | } |
... | ... | @@ -1670,7 +1686,7 @@ Element.Methods = { |
1670 | 1686 | }, |
1671 | 1687 | |
1672 | 1688 | descendants: function(element) { |
1673 | - return $(element).getElementsBySelector("*"); | |
1689 | + return $(element).select("*"); | |
1674 | 1690 | }, |
1675 | 1691 | |
1676 | 1692 | firstDescendant: function(element) { |
... | ... | @@ -1709,32 +1725,31 @@ Element.Methods = { |
1709 | 1725 | element = $(element); |
1710 | 1726 | if (arguments.length == 1) return $(element.parentNode); |
1711 | 1727 | var ancestors = element.ancestors(); |
1712 | - return expression ? Selector.findElement(ancestors, expression, index) : | |
1713 | - ancestors[index || 0]; | |
1728 | + return Object.isNumber(expression) ? ancestors[expression] : | |
1729 | + Selector.findElement(ancestors, expression, index); | |
1714 | 1730 | }, |
1715 | 1731 | |
1716 | 1732 | down: function(element, expression, index) { |
1717 | 1733 | element = $(element); |
1718 | 1734 | if (arguments.length == 1) return element.firstDescendant(); |
1719 | - var descendants = element.descendants(); | |
1720 | - return expression ? Selector.findElement(descendants, expression, index) : | |
1721 | - descendants[index || 0]; | |
1735 | + return Object.isNumber(expression) ? element.descendants()[expression] : | |
1736 | + element.select(expression)[index || 0]; | |
1722 | 1737 | }, |
1723 | 1738 | |
1724 | 1739 | previous: function(element, expression, index) { |
1725 | 1740 | element = $(element); |
1726 | 1741 | if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); |
1727 | 1742 | var previousSiblings = element.previousSiblings(); |
1728 | - return expression ? Selector.findElement(previousSiblings, expression, index) : | |
1729 | - previousSiblings[index || 0]; | |
1743 | + return Object.isNumber(expression) ? previousSiblings[expression] : | |
1744 | + Selector.findElement(previousSiblings, expression, index); | |
1730 | 1745 | }, |
1731 | 1746 | |
1732 | 1747 | next: function(element, expression, index) { |
1733 | 1748 | element = $(element); |
1734 | 1749 | if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); |
1735 | 1750 | var nextSiblings = element.nextSiblings(); |
1736 | - return expression ? Selector.findElement(nextSiblings, expression, index) : | |
1737 | - nextSiblings[index || 0]; | |
1751 | + return Object.isNumber(expression) ? nextSiblings[expression] : | |
1752 | + Selector.findElement(nextSiblings, expression, index); | |
1738 | 1753 | }, |
1739 | 1754 | |
1740 | 1755 | select: function() { |
... | ... | @@ -1860,7 +1875,8 @@ Element.Methods = { |
1860 | 1875 | do { ancestor = ancestor.parentNode; } |
1861 | 1876 | while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); |
1862 | 1877 | } |
1863 | - if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex); | |
1878 | + if (nextAncestor && nextAncestor.sourceIndex) | |
1879 | + return (e > a && e < nextAncestor.sourceIndex); | |
1864 | 1880 | } |
1865 | 1881 | |
1866 | 1882 | while (element = element.parentNode) |
... | ... | @@ -2004,7 +2020,7 @@ Element.Methods = { |
2004 | 2020 | if (element) { |
2005 | 2021 | if (element.tagName == 'BODY') break; |
2006 | 2022 | var p = Element.getStyle(element, 'position'); |
2007 | - if (p == 'relative' || p == 'absolute') break; | |
2023 | + if (p !== 'static') break; | |
2008 | 2024 | } |
2009 | 2025 | } while (element); |
2010 | 2026 | return Element._returnOffset(valueL, valueT); |
... | ... | @@ -2153,46 +2169,6 @@ Element._attributeTranslations = { |
2153 | 2169 | } |
2154 | 2170 | }; |
2155 | 2171 | |
2156 | - | |
2157 | -if (!document.createRange || Prototype.Browser.Opera) { | |
2158 | - Element.Methods.insert = function(element, insertions) { | |
2159 | - element = $(element); | |
2160 | - | |
2161 | - if (Object.isString(insertions) || Object.isNumber(insertions) || | |
2162 | - Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) | |
2163 | - insertions = { bottom: insertions }; | |
2164 | - | |
2165 | - var t = Element._insertionTranslations, content, position, pos, tagName; | |
2166 | - | |
2167 | - for (position in insertions) { | |
2168 | - content = insertions[position]; | |
2169 | - position = position.toLowerCase(); | |
2170 | - pos = t[position]; | |
2171 | - | |
2172 | - if (content && content.toElement) content = content.toElement(); | |
2173 | - if (Object.isElement(content)) { | |
2174 | - pos.insert(element, content); | |
2175 | - continue; | |
2176 | - } | |
2177 | - | |
2178 | - content = Object.toHTML(content); | |
2179 | - tagName = ((position == 'before' || position == 'after') | |
2180 | - ? element.parentNode : element).tagName.toUpperCase(); | |
2181 | - | |
2182 | - if (t.tags[tagName]) { | |
2183 | - var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); | |
2184 | - if (position == 'top' || position == 'after') fragments.reverse(); | |
2185 | - fragments.each(pos.insert.curry(element)); | |
2186 | - } | |
2187 | - else element.insertAdjacentHTML(pos.adjacency, content.stripScripts()); | |
2188 | - | |
2189 | - content.evalScripts.bind(content).defer(); | |
2190 | - } | |
2191 | - | |
2192 | - return element; | |
2193 | - }; | |
2194 | -} | |
2195 | - | |
2196 | 2172 | if (Prototype.Browser.Opera) { |
2197 | 2173 | Element.Methods.getStyle = Element.Methods.getStyle.wrap( |
2198 | 2174 | function(proceed, element, style) { |
... | ... | @@ -2237,12 +2213,31 @@ if (Prototype.Browser.Opera) { |
2237 | 2213 | } |
2238 | 2214 | |
2239 | 2215 | else if (Prototype.Browser.IE) { |
2240 | - $w('positionedOffset getOffsetParent viewportOffset').each(function(method) { | |
2216 | + // IE doesn't report offsets correctly for static elements, so we change them | |
2217 | + // to "relative" to get the values, then change them back. | |
2218 | + Element.Methods.getOffsetParent = Element.Methods.getOffsetParent.wrap( | |
2219 | + function(proceed, element) { | |
2220 | + element = $(element); | |
2221 | + var position = element.getStyle('position'); | |
2222 | + if (position !== 'static') return proceed(element); | |
2223 | + element.setStyle({ position: 'relative' }); | |
2224 | + var value = proceed(element); | |
2225 | + element.setStyle({ position: position }); | |
2226 | + return value; | |
2227 | + } | |
2228 | + ); | |
2229 | + | |
2230 | + $w('positionedOffset viewportOffset').each(function(method) { | |
2241 | 2231 | Element.Methods[method] = Element.Methods[method].wrap( |
2242 | 2232 | function(proceed, element) { |
2243 | 2233 | element = $(element); |
2244 | 2234 | var position = element.getStyle('position'); |
2245 | - if (position != 'static') return proceed(element); | |
2235 | + if (position !== 'static') return proceed(element); | |
2236 | + // Trigger hasLayout on the offset parent so that IE6 reports | |
2237 | + // accurate offsetTop and offsetLeft values for position: fixed. | |
2238 | + var offsetParent = element.getOffsetParent(); | |
2239 | + if (offsetParent && offsetParent.getStyle('position') === 'fixed') | |
2240 | + offsetParent.setStyle({ zoom: 1 }); | |
2246 | 2241 | element.setStyle({ position: 'relative' }); |
2247 | 2242 | var value = proceed(element); |
2248 | 2243 | element.setStyle({ position: position }); |
... | ... | @@ -2324,7 +2319,10 @@ else if (Prototype.Browser.IE) { |
2324 | 2319 | }; |
2325 | 2320 | |
2326 | 2321 | Element._attributeTranslations.write = { |
2327 | - names: Object.clone(Element._attributeTranslations.read.names), | |
2322 | + names: Object.extend({ | |
2323 | + cellpadding: 'cellPadding', | |
2324 | + cellspacing: 'cellSpacing' | |
2325 | + }, Element._attributeTranslations.read.names), | |
2328 | 2326 | values: { |
2329 | 2327 | checked: function(element, value) { |
2330 | 2328 | element.checked = !!value; |
... | ... | @@ -2444,7 +2442,7 @@ if (Prototype.Browser.IE || Prototype.Browser.Opera) { |
2444 | 2442 | }; |
2445 | 2443 | } |
2446 | 2444 | |
2447 | -if (document.createElement('div').outerHTML) { | |
2445 | +if ('outerHTML' in document.createElement('div')) { | |
2448 | 2446 | Element.Methods.replace = function(element, content) { |
2449 | 2447 | element = $(element); |
2450 | 2448 | |
... | ... | @@ -2482,45 +2480,25 @@ Element._returnOffset = function(l, t) { |
2482 | 2480 | |
2483 | 2481 | Element._getContentFromAnonymousElement = function(tagName, html) { |
2484 | 2482 | var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; |
2485 | - div.innerHTML = t[0] + html + t[1]; | |
2486 | - t[2].times(function() { div = div.firstChild }); | |
2483 | + if (t) { | |
2484 | + div.innerHTML = t[0] + html + t[1]; | |
2485 | + t[2].times(function() { div = div.firstChild }); | |
2486 | + } else div.innerHTML = html; | |
2487 | 2487 | return $A(div.childNodes); |
2488 | 2488 | }; |
2489 | 2489 | |
2490 | 2490 | Element._insertionTranslations = { |
2491 | - before: { | |
2492 | - adjacency: 'beforeBegin', | |
2493 | - insert: function(element, node) { | |
2494 | - element.parentNode.insertBefore(node, element); | |
2495 | - }, | |
2496 | - initializeRange: function(element, range) { | |
2497 | - range.setStartBefore(element); | |
2498 | - } | |
2491 | + before: function(element, node) { | |
2492 | + element.parentNode.insertBefore(node, element); | |
2499 | 2493 | }, |
2500 | - top: { | |
2501 | - adjacency: 'afterBegin', | |
2502 | - insert: function(element, node) { | |
2503 | - element.insertBefore(node, element.firstChild); | |
2504 | - }, | |
2505 | - initializeRange: function(element, range) { | |
2506 | - range.selectNodeContents(element); | |
2507 | - range.collapse(true); | |
2508 | - } | |
2494 | + top: function(element, node) { | |
2495 | + element.insertBefore(node, element.firstChild); | |
2509 | 2496 | }, |
2510 | - bottom: { | |
2511 | - adjacency: 'beforeEnd', | |
2512 | - insert: function(element, node) { | |
2513 | - element.appendChild(node); | |
2514 | - } | |
2497 | + bottom: function(element, node) { | |
2498 | + element.appendChild(node); | |
2515 | 2499 | }, |
2516 | - after: { | |
2517 | - adjacency: 'afterEnd', | |
2518 | - insert: function(element, node) { | |
2519 | - element.parentNode.insertBefore(node, element.nextSibling); | |
2520 | - }, | |
2521 | - initializeRange: function(element, range) { | |
2522 | - range.setStartAfter(element); | |
2523 | - } | |
2500 | + after: function(element, node) { | |
2501 | + element.parentNode.insertBefore(node, element.nextSibling); | |
2524 | 2502 | }, |
2525 | 2503 | tags: { |
2526 | 2504 | TABLE: ['<table>', '</table>', 1], |
... | ... | @@ -2532,7 +2510,6 @@ Element._insertionTranslations = { |
2532 | 2510 | }; |
2533 | 2511 | |
2534 | 2512 | (function() { |
2535 | - this.bottom.initializeRange = this.top.initializeRange; | |
2536 | 2513 | Object.extend(this.tags, { |
2537 | 2514 | THEAD: this.tags.TBODY, |
2538 | 2515 | TFOOT: this.tags.TBODY, |
... | ... | @@ -2959,13 +2936,13 @@ Object.extend(Selector, { |
2959 | 2936 | }, |
2960 | 2937 | |
2961 | 2938 | criteria: { |
2962 | - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', | |
2963 | - className: 'n = h.className(n, r, "#{1}", c); c = false;', | |
2964 | - id: 'n = h.id(n, r, "#{1}", c); c = false;', | |
2965 | - attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', | |
2939 | + tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', | |
2940 | + className: 'n = h.className(n, r, "#{1}", c); c = false;', | |
2941 | + id: 'n = h.id(n, r, "#{1}", c); c = false;', | |
2942 | + attrPresence: 'n = h.attrPresence(n, r, "#{1}", c); c = false;', | |
2966 | 2943 | attr: function(m) { |
2967 | 2944 | m[3] = (m[5] || m[6]); |
2968 | - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); | |
2945 | + return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); c = false;').evaluate(m); | |
2969 | 2946 | }, |
2970 | 2947 | pseudo: function(m) { |
2971 | 2948 | if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); |
... | ... | @@ -2989,7 +2966,8 @@ Object.extend(Selector, { |
2989 | 2966 | tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, |
2990 | 2967 | id: /^#([\w\-\*]+)(\b|$)/, |
2991 | 2968 | className: /^\.([\w\-\*]+)(\b|$)/, |
2992 | - pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/, | |
2969 | + pseudo: | |
2970 | +/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s|[:+~>]))/, | |
2993 | 2971 | attrPresence: /^\[([\w]+)\]/, |
2994 | 2972 | attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ |
2995 | 2973 | }, |
... | ... | @@ -3014,7 +2992,7 @@ Object.extend(Selector, { |
3014 | 2992 | |
3015 | 2993 | attr: function(element, matches) { |
3016 | 2994 | var nodeValue = Element.readAttribute(element, matches[1]); |
3017 | - return Selector.operators[matches[2]](nodeValue, matches[3]); | |
2995 | + return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); | |
3018 | 2996 | } |
3019 | 2997 | }, |
3020 | 2998 | |
... | ... | @@ -3029,14 +3007,15 @@ Object.extend(Selector, { |
3029 | 3007 | |
3030 | 3008 | // marks an array of nodes for counting |
3031 | 3009 | mark: function(nodes) { |
3010 | + var _true = Prototype.emptyFunction; | |
3032 | 3011 | for (var i = 0, node; node = nodes[i]; i++) |
3033 | - node._counted = true; | |
3012 | + node._countedByPrototype = _true; | |
3034 | 3013 | return nodes; |
3035 | 3014 | }, |
3036 | 3015 | |
3037 | 3016 | unmark: function(nodes) { |
3038 | 3017 | for (var i = 0, node; node = nodes[i]; i++) |
3039 | - node._counted = undefined; | |
3018 | + node._countedByPrototype = undefined; | |
3040 | 3019 | return nodes; |
3041 | 3020 | }, |
3042 | 3021 | |
... | ... | @@ -3044,15 +3023,15 @@ Object.extend(Selector, { |
3044 | 3023 | // "ofType" flag indicates whether we're indexing for nth-of-type |
3045 | 3024 | // rather than nth-child |
3046 | 3025 | index: function(parentNode, reverse, ofType) { |
3047 | - parentNode._counted = true; | |
3026 | + parentNode._countedByPrototype = Prototype.emptyFunction; | |
3048 | 3027 | if (reverse) { |
3049 | 3028 | for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { |
3050 | 3029 | var node = nodes[i]; |
3051 | - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; | |
3030 | + if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; | |
3052 | 3031 | } |
3053 | 3032 | } else { |
3054 | 3033 | for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) |
3055 | - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; | |
3034 | + if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; | |
3056 | 3035 | } |
3057 | 3036 | }, |
3058 | 3037 | |
... | ... | @@ -3061,8 +3040,8 @@ Object.extend(Selector, { |
3061 | 3040 | if (nodes.length == 0) return nodes; |
3062 | 3041 | var results = [], n; |
3063 | 3042 | for (var i = 0, l = nodes.length; i < l; i++) |
3064 | - if (!(n = nodes[i])._counted) { | |
3065 | - n._counted = true; | |
3043 | + if (!(n = nodes[i])._countedByPrototype) { | |
3044 | + n._countedByPrototype = Prototype.emptyFunction; | |
3066 | 3045 | results.push(Element.extend(n)); |
3067 | 3046 | } |
3068 | 3047 | return Selector.handlers.unmark(results); |
... | ... | @@ -3114,7 +3093,7 @@ Object.extend(Selector, { |
3114 | 3093 | |
3115 | 3094 | // TOKEN FUNCTIONS |
3116 | 3095 | tagName: function(nodes, root, tagName, combinator) { |
3117 | - tagName = tagName.toUpperCase(); | |
3096 | + var uTagName = tagName.toUpperCase(); | |
3118 | 3097 | var results = [], h = Selector.handlers; |
3119 | 3098 | if (nodes) { |
3120 | 3099 | if (combinator) { |
... | ... | @@ -3127,7 +3106,7 @@ Object.extend(Selector, { |
3127 | 3106 | if (tagName == "*") return nodes; |
3128 | 3107 | } |
3129 | 3108 | for (var i = 0, node; node = nodes[i]; i++) |
3130 | - if (node.tagName.toUpperCase() == tagName) results.push(node); | |
3109 | + if (node.tagName.toUpperCase() === uTagName) results.push(node); | |
3131 | 3110 | return results; |
3132 | 3111 | } else return root.getElementsByTagName(tagName); |
3133 | 3112 | }, |
... | ... | @@ -3174,16 +3153,18 @@ Object.extend(Selector, { |
3174 | 3153 | return results; |
3175 | 3154 | }, |
3176 | 3155 | |
3177 | - attrPresence: function(nodes, root, attr) { | |
3156 | + attrPresence: function(nodes, root, attr, combinator) { | |
3178 | 3157 | if (!nodes) nodes = root.getElementsByTagName("*"); |
3158 | + if (nodes && combinator) nodes = this[combinator](nodes); | |
3179 | 3159 | var results = []; |
3180 | 3160 | for (var i = 0, node; node = nodes[i]; i++) |
3181 | 3161 | if (Element.hasAttribute(node, attr)) results.push(node); |
3182 | 3162 | return results; |
3183 | 3163 | }, |
3184 | 3164 | |
3185 | - attr: function(nodes, root, attr, value, operator) { | |
3165 | + attr: function(nodes, root, attr, value, operator, combinator) { | |
3186 | 3166 | if (!nodes) nodes = root.getElementsByTagName("*"); |
3167 | + if (nodes && combinator) nodes = this[combinator](nodes); | |
3187 | 3168 | var handler = Selector.operators[operator], results = []; |
3188 | 3169 | for (var i = 0, node; node = nodes[i]; i++) { |
3189 | 3170 | var nodeValue = Element.readAttribute(node, attr); |
... | ... | @@ -3262,7 +3243,7 @@ Object.extend(Selector, { |
3262 | 3243 | var h = Selector.handlers, results = [], indexed = [], m; |
3263 | 3244 | h.mark(nodes); |
3264 | 3245 | for (var i = 0, node; node = nodes[i]; i++) { |
3265 | - if (!node.parentNode._counted) { | |
3246 | + if (!node.parentNode._countedByPrototype) { | |
3266 | 3247 | h.index(node.parentNode, reverse, ofType); |
3267 | 3248 | indexed.push(node.parentNode); |
3268 | 3249 | } |
... | ... | @@ -3300,7 +3281,7 @@ Object.extend(Selector, { |
3300 | 3281 | var exclusions = new Selector(selector).findElements(root); |
3301 | 3282 | h.mark(exclusions); |
3302 | 3283 | for (var i = 0, results = [], node; node = nodes[i]; i++) |
3303 | - if (!node._counted) results.push(node); | |
3284 | + if (!node._countedByPrototype) results.push(node); | |
3304 | 3285 | h.unmark(exclusions); |
3305 | 3286 | return results; |
3306 | 3287 | }, |
... | ... | @@ -3334,11 +3315,19 @@ Object.extend(Selector, { |
3334 | 3315 | '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } |
3335 | 3316 | }, |
3336 | 3317 | |
3318 | + split: function(expression) { | |
3319 | + var expressions = []; | |
3320 | + expression.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { | |
3321 | + expressions.push(m[1].strip()); | |
3322 | + }); | |
3323 | + return expressions; | |
3324 | + }, | |
3325 | + | |
3337 | 3326 | matchElements: function(elements, expression) { |
3338 | - var matches = new Selector(expression).findElements(), h = Selector.handlers; | |
3327 | + var matches = $$(expression), h = Selector.handlers; | |
3339 | 3328 | h.mark(matches); |
3340 | 3329 | for (var i = 0, results = [], element; element = elements[i]; i++) |
3341 | - if (element._counted) results.push(element); | |
3330 | + if (element._countedByPrototype) results.push(element); | |
3342 | 3331 | h.unmark(matches); |
3343 | 3332 | return results; |
3344 | 3333 | }, |
... | ... | @@ -3351,11 +3340,7 @@ Object.extend(Selector, { |
3351 | 3340 | }, |
3352 | 3341 | |
3353 | 3342 | findChildElements: function(element, expressions) { |
3354 | - var exprs = expressions.join(','); | |
3355 | - expressions = []; | |
3356 | - exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { | |
3357 | - expressions.push(m[1].strip()); | |
3358 | - }); | |
3343 | + expressions = Selector.split(expressions.join(',')); | |
3359 | 3344 | var results = [], h = Selector.handlers; |
3360 | 3345 | for (var i = 0, l = expressions.length, selector; i < l; i++) { |
3361 | 3346 | selector = new Selector(expressions[i].strip()); |
... | ... | @@ -3366,13 +3351,22 @@ Object.extend(Selector, { |
3366 | 3351 | }); |
3367 | 3352 | |
3368 | 3353 | if (Prototype.Browser.IE) { |
3369 | - // IE returns comment nodes on getElementsByTagName("*"). | |
3370 | - // Filter them out. | |
3371 | - Selector.handlers.concat = function(a, b) { | |
3372 | - for (var i = 0, node; node = b[i]; i++) | |
3373 | - if (node.tagName !== "!") a.push(node); | |
3374 | - return a; | |
3375 | - }; | |
3354 | + Object.extend(Selector.handlers, { | |
3355 | + // IE returns comment nodes on getElementsByTagName("*"). | |
3356 | + // Filter them out. | |
3357 | + concat: function(a, b) { | |
3358 | + for (var i = 0, node; node = b[i]; i++) | |
3359 | + if (node.tagName !== "!") a.push(node); | |
3360 | + return a; | |
3361 | + }, | |
3362 | + | |
3363 | + // IE improperly serializes _countedByPrototype in (inner|outer)HTML. | |
3364 | + unmark: function(nodes) { | |
3365 | + for (var i = 0, node; node = nodes[i]; i++) | |
3366 | + node.removeAttribute('_countedByPrototype'); | |
3367 | + return nodes; | |
3368 | + } | |
3369 | + }); | |
3376 | 3370 | } |
3377 | 3371 | |
3378 | 3372 | function $$() { |
... | ... | @@ -3850,9 +3844,9 @@ Object.extend(Event, (function() { |
3850 | 3844 | var cache = Event.cache; |
3851 | 3845 | |
3852 | 3846 | function getEventID(element) { |
3853 | - if (element._eventID) return element._eventID; | |
3847 | + if (element._prototypeEventID) return element._prototypeEventID[0]; | |
3854 | 3848 | arguments.callee.id = arguments.callee.id || 1; |
3855 | - return element._eventID = ++arguments.callee.id; | |
3849 | + return element._prototypeEventID = [++arguments.callee.id]; | |
3856 | 3850 | } |
3857 | 3851 | |
3858 | 3852 | function getDOMEventName(eventName) { |
... | ... | @@ -3880,7 +3874,7 @@ Object.extend(Event, (function() { |
3880 | 3874 | return false; |
3881 | 3875 | |
3882 | 3876 | Event.extend(event); |
3883 | - handler.call(element, event) | |
3877 | + handler.call(element, event); | |
3884 | 3878 | }; |
3885 | 3879 | |
3886 | 3880 | wrapper.handler = handler; |
... | ... | @@ -3962,11 +3956,12 @@ Object.extend(Event, (function() { |
3962 | 3956 | if (element == document && document.createEvent && !element.dispatchEvent) |
3963 | 3957 | element = document.documentElement; |
3964 | 3958 | |
3959 | + var event; | |
3965 | 3960 | if (document.createEvent) { |
3966 | - var event = document.createEvent("HTMLEvents"); | |
3961 | + event = document.createEvent("HTMLEvents"); | |
3967 | 3962 | event.initEvent("dataavailable", true, true); |
3968 | 3963 | } else { |
3969 | - var event = document.createEventObject(); | |
3964 | + event = document.createEventObject(); | |
3970 | 3965 | event.eventType = "ondataavailable"; |
3971 | 3966 | } |
3972 | 3967 | |
... | ... | @@ -3995,20 +3990,21 @@ Element.addMethods({ |
3995 | 3990 | Object.extend(document, { |
3996 | 3991 | fire: Element.Methods.fire.methodize(), |
3997 | 3992 | observe: Element.Methods.observe.methodize(), |
3998 | - stopObserving: Element.Methods.stopObserving.methodize() | |
3993 | + stopObserving: Element.Methods.stopObserving.methodize(), | |
3994 | + loaded: false | |
3999 | 3995 | }); |
4000 | 3996 | |
4001 | 3997 | (function() { |
4002 | 3998 | /* Support for the DOMContentLoaded event is based on work by Dan Webb, |
4003 | 3999 | Matthias Miller, Dean Edwards and John Resig. */ |
4004 | 4000 | |
4005 | - var timer, fired = false; | |
4001 | + var timer; | |
4006 | 4002 | |
4007 | 4003 | function fireContentLoadedEvent() { |
4008 | - if (fired) return; | |
4004 | + if (document.loaded) return; | |
4009 | 4005 | if (timer) window.clearInterval(timer); |
4010 | 4006 | document.fire("dom:loaded"); |
4011 | - fired = true; | |
4007 | + document.loaded = true; | |
4012 | 4008 | } |
4013 | 4009 | |
4014 | 4010 | if (document.addEventListener) { | ... | ... |