| r491 | r511 | |
| 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 | *--------------------------------------------------------------------------*/ |
| 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 | 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 | 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 | 579 | } |
| 579 | 580 | |
| 580 | 581 | return before + String.interpret(ctx); |
| 581 | | }.bind(this)); |
| 582 | }); |
| 582 | 583 | } |
| 583 | 584 | }); |
| 584 | 585 | Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; |
| --- | --- | |
| 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 | 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 | 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 | 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 | 1331 | return this.transport.getResponseHeader(name) || null; |
| --- | --- | |
| 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 | 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 | } |
| --- | --- | |
| 1610 | 1622 | |
| 1611 | 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 | 1628 | insert = Element._insertionTranslations[position]; |
| --- | --- | |
| 1863 | 1875 | do { ancestor = ancestor.parentNode; } |
| 1864 | 1876 | while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); |
| 1865 | 1877 | } |
| 1866 | | if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex); |
| 1878 | if (nextAncestor && nextAncestor.sourceIndex) |
| 1879 | return (e > a && e < nextAncestor.sourceIndex); |
| 1867 | 1880 | } |
| 1868 | 1881 | |
| 1869 | 1882 | while (element = element.parentNode) |
| --- | --- | |
| 2007 | 2020 | if (element) { |
| 2008 | 2021 | if (element.tagName == 'BODY') break; |
| 2009 | 2022 | var p = Element.getStyle(element, 'position'); |
| 2010 | | if (p == 'relative' || p == 'absolute') break; |
| 2023 | if (p !== 'static') break; |
| 2011 | 2024 | } |
| 2012 | 2025 | } while (element); |
| 2013 | 2026 | return Element._returnOffset(valueL, valueT); |
| --- | --- | |
| 2200 | 2213 | } |
| 2201 | 2214 | |
| 2202 | 2215 | else if (Prototype.Browser.IE) { |
| 2203 | | $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) { |
| 2204 | 2231 | Element.Methods[method] = Element.Methods[method].wrap( |
| 2205 | 2232 | function(proceed, element) { |
| 2206 | 2233 | element = $(element); |
| 2207 | 2234 | var position = element.getStyle('position'); |
| 2208 | | 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 }); |
| 2209 | 2241 | element.setStyle({ position: 'relative' }); |
| 2210 | 2242 | var value = proceed(element); |
| 2211 | 2243 | element.setStyle({ position: position }); |
| --- | --- | |
| 2287 | 2319 | }; |
| 2288 | 2320 | |
| 2289 | 2321 | Element._attributeTranslations.write = { |
| 2290 | | names: Object.clone(Element._attributeTranslations.read.names), |
| 2322 | names: Object.extend({ |
| 2323 | cellpadding: 'cellPadding', |
| 2324 | cellspacing: 'cellSpacing' |
| 2325 | }, Element._attributeTranslations.read.names), |
| 2291 | 2326 | values: { |
| 2292 | 2327 | checked: function(element, value) { |
| 2293 | 2328 | element.checked = !!value; |
| --- | --- | |
| 2638 | 2673 | var B = Prototype.Browser; |
| 2639 | 2674 | $w('width height').each(function(d) { |
| 2640 | 2675 | var D = d.capitalize(); |
| 2641 | | |
| 2642 | 2676 | dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : |
| 2643 | 2677 | (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; |
| 2644 | 2678 | }); |
| --- | --- | |
| 2902 | 2936 | }, |
| 2903 | 2937 | |
| 2904 | 2938 | criteria: { |
| 2905 | | tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', |
| 2906 | | className: 'n = h.className(n, r, "#{1}", c); c = false;', |
| 2907 | | id: 'n = h.id(n, r, "#{1}", c); c = false;', |
| 2908 | | 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;', |
| 2909 | 2943 | attr: function(m) { |
| 2910 | 2944 | m[3] = (m[5] || m[6]); |
| 2911 | | 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); |
| 2912 | 2946 | }, |
| 2913 | 2947 | pseudo: function(m) { |
| 2914 | 2948 | if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); |
| --- | --- | |
| 2958 | 2992 | |
| 2959 | 2993 | attr: function(element, matches) { |
| 2960 | 2994 | var nodeValue = Element.readAttribute(element, matches[1]); |
| 2961 | | return Selector.operators[matches[2]](nodeValue, matches[3]); |
| 2995 | return nodeValue && Selector.operators[matches[2]](nodeValue, matches[5] || matches[6]); |
| 2962 | 2996 | } |
| 2963 | 2997 | }, |
| 2964 | 2998 | |
| --- | --- | |
| 2973 | 3007 | |
| 2974 | 3008 | // marks an array of nodes for counting |
| 2975 | 3009 | mark: function(nodes) { |
| 3010 | var _true = Prototype.emptyFunction; |
| 2976 | 3011 | for (var i = 0, node; node = nodes[i]; i++) |
| 2977 | | node._counted = true; |
| 3012 | node._countedByPrototype = _true; |
| 2978 | 3013 | return nodes; |
| 2979 | 3014 | }, |
| 2980 | 3015 | |
| 2981 | 3016 | unmark: function(nodes) { |
| 2982 | 3017 | for (var i = 0, node; node = nodes[i]; i++) |
| 2983 | | node._counted = undefined; |
| 3018 | node._countedByPrototype = undefined; |
| 2984 | 3019 | return nodes; |
| 2985 | 3020 | }, |
| 2986 | 3021 | |
| --- | --- | |
| 2988 | 3023 | // "ofType" flag indicates whether we're indexing for nth-of-type |
| 2989 | 3024 | // rather than nth-child |
| 2990 | 3025 | index: function(parentNode, reverse, ofType) { |
| 2991 | | parentNode._counted = true; |
| 3026 | parentNode._countedByPrototype = Prototype.emptyFunction; |
| 2992 | 3027 | if (reverse) { |
| 2993 | 3028 | for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { |
| 2994 | 3029 | var node = nodes[i]; |
| 2995 | | if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; |
| 3030 | if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; |
| 2996 | 3031 | } |
| 2997 | 3032 | } else { |
| 2998 | 3033 | for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) |
| 2999 | | if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; |
| 3034 | if (node.nodeType == 1 && (!ofType || node._countedByPrototype)) node.nodeIndex = j++; |
| 3000 | 3035 | } |
| 3001 | 3036 | }, |
| 3002 | 3037 | |
| --- | --- | |
| 3005 | 3040 | if (nodes.length == 0) return nodes; |
| 3006 | 3041 | var results = [], n; |
| 3007 | 3042 | for (var i = 0, l = nodes.length; i < l; i++) |
| 3008 | | if (!(n = nodes[i])._counted) { |
| 3009 | | n._counted = true; |
| 3043 | if (!(n = nodes[i])._countedByPrototype) { |
| 3044 | n._countedByPrototype = Prototype.emptyFunction; |
| 3010 | 3045 | results.push(Element.extend(n)); |
| 3011 | 3046 | } |
| 3012 | 3047 | return Selector.handlers.unmark(results); |
| --- | --- | |
| 3118 | 3153 | return results; |
| 3119 | 3154 | }, |
| 3120 | 3155 | |
| 3121 | | attrPresence: function(nodes, root, attr) { |
| 3156 | attrPresence: function(nodes, root, attr, combinator) { |
| 3122 | 3157 | if (!nodes) nodes = root.getElementsByTagName("*"); |
| 3158 | if (nodes && combinator) nodes = this[combinator](nodes); |
| 3123 | 3159 | var results = []; |
| 3124 | 3160 | for (var i = 0, node; node = nodes[i]; i++) |
| 3125 | 3161 | if (Element.hasAttribute(node, attr)) results.push(node); |
| 3126 | 3162 | return results; |
| 3127 | 3163 | }, |
| 3128 | 3164 | |
| 3129 | | attr: function(nodes, root, attr, value, operator) { |
| 3165 | attr: function(nodes, root, attr, value, operator, combinator) { |
| 3130 | 3166 | if (!nodes) nodes = root.getElementsByTagName("*"); |
| 3167 | if (nodes && combinator) nodes = this[combinator](nodes); |
| 3131 | 3168 | var handler = Selector.operators[operator], results = []; |
| 3132 | 3169 | for (var i = 0, node; node = nodes[i]; i++) { |
| 3133 | 3170 | var nodeValue = Element.readAttribute(node, attr); |
| --- | --- | |
| 3206 | 3243 | var h = Selector.handlers, results = [], indexed = [], m; |
| 3207 | 3244 | h.mark(nodes); |
| 3208 | 3245 | for (var i = 0, node; node = nodes[i]; i++) { |
| 3209 | | if (!node.parentNode._counted) { |
| 3246 | if (!node.parentNode._countedByPrototype) { |
| 3210 | 3247 | h.index(node.parentNode, reverse, ofType); |
| 3211 | 3248 | indexed.push(node.parentNode); |
| 3212 | 3249 | } |
| --- | --- | |
| 3244 | 3281 | var exclusions = new Selector(selector).findElements(root); |
| 3245 | 3282 | h.mark(exclusions); |
| 3246 | 3283 | for (var i = 0, results = [], node; node = nodes[i]; i++) |
| 3247 | | if (!node._counted) results.push(node); |
| 3284 | if (!node._countedByPrototype) results.push(node); |
| 3248 | 3285 | h.unmark(exclusions); |
| 3249 | 3286 | return results; |
| 3250 | 3287 | }, |
| --- | --- | |
| 3278 | 3315 | '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } |
| 3279 | 3316 | }, |
| 3280 | 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 | |
| 3281 | 3326 | matchElements: function(elements, expression) { |
| 3282 | 3327 | var matches = $$(expression), h = Selector.handlers; |
| 3283 | 3328 | h.mark(matches); |
| 3284 | 3329 | for (var i = 0, results = [], element; element = elements[i]; i++) |
| 3285 | | if (element._counted) results.push(element); |
| 3330 | if (element._countedByPrototype) results.push(element); |
| 3286 | 3331 | h.unmark(matches); |
| 3287 | 3332 | return results; |
| 3288 | 3333 | }, |
| --- | --- | |
| 3295 | 3340 | }, |
| 3296 | 3341 | |
| 3297 | 3342 | findChildElements: function(element, expressions) { |
| 3298 | | var exprs = expressions.join(','); |
| 3299 | | expressions = []; |
| 3300 | | exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { |
| 3301 | | expressions.push(m[1].strip()); |
| 3302 | | }); |
| 3343 | expressions = Selector.split(expressions.join(',')); |
| 3303 | 3344 | var results = [], h = Selector.handlers; |
| 3304 | 3345 | for (var i = 0, l = expressions.length, selector; i < l; i++) { |
| 3305 | 3346 | selector = new Selector(expressions[i].strip()); |
| --- | --- | |
| 3310 | 3351 | }); |
| 3311 | 3352 | |
| 3312 | 3353 | if (Prototype.Browser.IE) { |
| 3313 | | // IE returns comment nodes on getElementsByTagName("*"). |
| 3314 | | // Filter them out. |
| 3315 | | Selector.handlers.concat = function(a, b) { |
| 3316 | | for (var i = 0, node; node = b[i]; i++) |
| 3317 | | if (node.tagName !== "!") a.push(node); |
| 3318 | | return a; |
| 3319 | | }; |
| 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 | }); |
| 3320 | 3370 | } |
| 3321 | 3371 | |
| 3322 | 3372 | function $$() { |
| --- | --- | |
| 3794 | 3844 | var cache = Event.cache; |
| 3795 | 3845 | |
| 3796 | 3846 | function getEventID(element) { |
| 3797 | | if (element._eventID) return element._eventID; |
| 3847 | if (element._prototypeEventID) return element._prototypeEventID[0]; |
| 3798 | 3848 | arguments.callee.id = arguments.callee.id || 1; |
| 3799 | | return element._eventID = ++arguments.callee.id; |
| 3849 | return element._prototypeEventID = [++arguments.callee.id]; |
| 3800 | 3850 | } |
| 3801 | 3851 | |
| 3802 | 3852 | function getDOMEventName(eventName) { |