| 12 | | XPath: !!document.evaluate |
|---|
| 13 | | }, |
|---|
| 14 | | |
|---|
| 15 | | ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', |
|---|
| 16 | | emptyFunction: function() {}, |
|---|
| | 20 | XPath: !!document.evaluate, |
|---|
| | 21 | ElementExtensions: !!window.HTMLElement, |
|---|
| | 22 | SpecificElementExtensions: |
|---|
| | 23 | (document.createElement('div').__proto__ !== |
|---|
| | 24 | document.createElement('form').__proto__) |
|---|
| | 25 | }, |
|---|
| | 26 | |
|---|
| | 27 | ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', |
|---|
| | 28 | JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, |
|---|
| | 29 | |
|---|
| | 30 | emptyFunction: function() { }, |
|---|
| | 63 | toJSON: function(object) { |
|---|
| | 64 | var type = typeof object; |
|---|
| | 65 | switch(type) { |
|---|
| | 66 | case 'undefined': |
|---|
| | 67 | case 'function': |
|---|
| | 68 | case 'unknown': return; |
|---|
| | 69 | case 'boolean': return object.toString(); |
|---|
| | 70 | } |
|---|
| | 71 | if (object === null) return 'null'; |
|---|
| | 72 | if (object.toJSON) return object.toJSON(); |
|---|
| | 73 | if (object.ownerDocument === document) return; |
|---|
| | 74 | var results = []; |
|---|
| | 75 | for (var property in object) { |
|---|
| | 76 | var value = Object.toJSON(object[property]); |
|---|
| | 77 | if (value !== undefined) |
|---|
| | 78 | results.push(property.toJSON() + ': ' + value); |
|---|
| | 79 | } |
|---|
| | 80 | return '{' + results.join(', ') + '}'; |
|---|
| | 81 | }, |
|---|
| | 82 | |
|---|
| 236 | | var name = decodeURIComponent(pair[0]); |
|---|
| 237 | | var value = pair[1] ? decodeURIComponent(pair[1]) : undefined; |
|---|
| 238 | | |
|---|
| 239 | | if (hash[name] !== undefined) { |
|---|
| 240 | | if (hash[name].constructor != Array) |
|---|
| 241 | | hash[name] = [hash[name]]; |
|---|
| 242 | | if (value) hash[name].push(value); |
|---|
| | 295 | var key = decodeURIComponent(pair.shift()); |
|---|
| | 296 | var value = pair.length > 1 ? pair.join('=') : pair[0]; |
|---|
| | 297 | if (value != undefined) value = decodeURIComponent(value); |
|---|
| | 298 | |
|---|
| | 299 | if (key in hash) { |
|---|
| | 300 | if (hash[key].constructor != Array) hash[key] = [hash[key]]; |
|---|
| | 301 | hash[key].push(value); |
|---|
| 286 | | var escapedString = this.replace(/\\/g, '\\\\'); |
|---|
| 287 | | if (useDoubleQuotes) |
|---|
| 288 | | return '"' + escapedString.replace(/"/g, '\\"') + '"'; |
|---|
| 289 | | else |
|---|
| 290 | | return "'" + escapedString.replace(/'/g, '\\\'') + "'"; |
|---|
| | 351 | var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { |
|---|
| | 352 | var character = String.specialChar[match[0]]; |
|---|
| | 353 | return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); |
|---|
| | 354 | }); |
|---|
| | 355 | if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; |
|---|
| | 356 | return "'" + escapedString.replace(/'/g, '\\\'') + "'"; |
|---|
| | 357 | }, |
|---|
| | 358 | |
|---|
| | 359 | toJSON: function() { |
|---|
| | 360 | return this.inspect(true); |
|---|
| | 361 | }, |
|---|
| | 362 | |
|---|
| | 363 | unfilterJSON: function(filter) { |
|---|
| | 364 | return this.sub(filter || Prototype.JSONFilter, '#{1}'); |
|---|
| | 365 | }, |
|---|
| | 366 | |
|---|
| | 367 | isJSON: function() { |
|---|
| | 368 | var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); |
|---|
| | 369 | return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); |
|---|
| | 370 | }, |
|---|
| | 371 | |
|---|
| | 372 | evalJSON: function(sanitize) { |
|---|
| | 373 | var json = this.unfilterJSON(); |
|---|
| | 374 | try { |
|---|
| | 375 | if (!sanitize || json.isJSON()) return eval('(' + json + ')'); |
|---|
| | 376 | } catch (e) { } |
|---|
| | 377 | throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); |
|---|
| | 378 | }, |
|---|
| | 379 | |
|---|
| | 380 | include: function(pattern) { |
|---|
| | 381 | return this.indexOf(pattern) > -1; |
|---|
| | 382 | }, |
|---|
| | 383 | |
|---|
| | 384 | startsWith: function(pattern) { |
|---|
| | 385 | return this.indexOf(pattern) === 0; |
|---|
| | 386 | }, |
|---|
| | 387 | |
|---|
| | 388 | endsWith: function(pattern) { |
|---|
| | 389 | var d = this.length - pattern.length; |
|---|
| | 390 | return d >= 0 && this.lastIndexOf(pattern) === d; |
|---|
| | 391 | }, |
|---|
| | 392 | |
|---|
| | 393 | empty: function() { |
|---|
| | 394 | return this == ''; |
|---|
| | 395 | }, |
|---|
| | 396 | |
|---|
| | 397 | blank: function() { |
|---|
| | 398 | return /^\s*$/.test(this); |
|---|
| | 399 | } |
|---|
| | 400 | }); |
|---|
| | 401 | |
|---|
| | 402 | if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { |
|---|
| | 403 | escapeHTML: function() { |
|---|
| | 404 | return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
|---|
| | 405 | }, |
|---|
| | 406 | unescapeHTML: function() { |
|---|
| | 407 | return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
|---|
| 620 | | for(var i = 0, length = this.length; i < length; i++) array.push(this[i]); |
|---|
| 621 | | for(var i = 0, length = arguments.length; i < length; i++) { |
|---|
| 622 | | if(arguments[i].constructor == Array) { |
|---|
| 623 | | for(var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) |
|---|
| | 765 | for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); |
|---|
| | 766 | for (var i = 0, length = arguments.length; i < length; i++) { |
|---|
| | 767 | if (arguments[i].constructor == Array) { |
|---|
| | 768 | for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) |
|---|
| 642 | | |
|---|
| 643 | | if (pair.value && pair.value.constructor == Array) { |
|---|
| 644 | | var values = pair.value.compact(); |
|---|
| 645 | | if (values.length < 2) pair.value = values.reduce(); |
|---|
| 646 | | else { |
|---|
| 647 | | key = encodeURIComponent(pair.key); |
|---|
| 648 | | values.each(function(value) { |
|---|
| 649 | | value = value != undefined ? encodeURIComponent(value) : ''; |
|---|
| 650 | | parts.push(key + '=' + encodeURIComponent(value)); |
|---|
| 651 | | }); |
|---|
| 652 | | return; |
|---|
| 653 | | } |
|---|
| | 789 | var value = pair.value; |
|---|
| | 790 | |
|---|
| | 791 | if (value && typeof value == 'object') { |
|---|
| | 792 | if (value.constructor == Array) value.each(function(value) { |
|---|
| | 793 | parts.add(pair.key, value); |
|---|
| | 794 | }); |
|---|
| | 795 | return; |
|---|
| 845 | | params = Hash.toQueryString(params); |
|---|
| 846 | | if (params && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) params += '&_=' |
|---|
| 847 | | |
|---|
| 848 | | // when GET, append parameters to URL |
|---|
| 849 | | if (this.method == 'get' && params) |
|---|
| 850 | | this.url += (this.url.indexOf('?') > -1 ? '&' : '?') + params; |
|---|
| | 1024 | this.parameters = params; |
|---|
| | 1025 | |
|---|
| | 1026 | if (params = Hash.toQueryString(params)) { |
|---|
| | 1027 | // when GET, append parameters to URL |
|---|
| | 1028 | if (this.method == 'get') |
|---|
| | 1029 | this.url += (this.url.include('?') ? '&' : '?') + params; |
|---|
| | 1030 | else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) |
|---|
| | 1031 | params += '&_='; |
|---|
| | 1032 | } |
|---|
| 1092 | | } else { |
|---|
| 1093 | | var children = ($(parentElement) || document.body).getElementsByTagName('*'); |
|---|
| 1094 | | var elements = [], child; |
|---|
| 1095 | | for (var i = 0, length = children.length; i < length; i++) { |
|---|
| 1096 | | child = children[i]; |
|---|
| 1097 | | if (Element.hasClassName(child, className)) |
|---|
| 1098 | | elements.push(Element.extend(child)); |
|---|
| 1099 | | } |
|---|
| 1100 | | return elements; |
|---|
| 1101 | | } |
|---|
| | 1273 | } |
|---|
| | 1274 | |
|---|
| | 1275 | } else document.getElementsByClassName = function(className, parentElement) { |
|---|
| | 1276 | var children = ($(parentElement) || document.body).getElementsByTagName('*'); |
|---|
| | 1277 | var elements = [], child, pattern = new RegExp("(^|\\s)" + className + "(\\s|$)"); |
|---|
| | 1278 | for (var i = 0, length = children.length; i < length; i++) { |
|---|
| | 1279 | child = children[i]; |
|---|
| | 1280 | var elementClassName = child.className; |
|---|
| | 1281 | if (elementClassName.length == 0) continue; |
|---|
| | 1282 | if (elementClassName == className || elementClassName.match(pattern)) |
|---|
| | 1283 | elements.push(Element.extend(child)); |
|---|
| | 1284 | } |
|---|
| | 1285 | return elements; |
|---|
| 1110 | | if (!element || _nativeExtensions || element.nodeType == 3) return element; |
|---|
| 1111 | | |
|---|
| 1112 | | if (!element._extended && element.tagName && element != window) { |
|---|
| 1113 | | var methods = Object.clone(Element.Methods), cache = Element.extend.cache; |
|---|
| 1114 | | |
|---|
| 1115 | | if (element.tagName == 'FORM') |
|---|
| 1116 | | Object.extend(methods, Form.Methods); |
|---|
| 1117 | | if (['INPUT', 'TEXTAREA', 'SELECT'].include(element.tagName)) |
|---|
| 1118 | | Object.extend(methods, Form.Element.Methods); |
|---|
| 1119 | | |
|---|
| | 1293 | var F = Prototype.BrowserFeatures; |
|---|
| | 1294 | if (!element || !element.tagName || element.nodeType == 3 || |
|---|
| | 1295 | element._extended || F.SpecificElementExtensions || element == window) |
|---|
| | 1296 | return element; |
|---|
| | 1297 | |
|---|
| | 1298 | var methods = {}, tagName = element.tagName, cache = Element.extend.cache, |
|---|
| | 1299 | T = Element.Methods.ByTag; |
|---|
| | 1300 | |
|---|
| | 1301 | // extend methods for all tags (Safari doesn't need this) |
|---|
| | 1302 | if (!F.ElementExtensions) { |
|---|
| | 1303 | Object.extend(methods, Element.Methods), |
|---|
| 1121 | | |
|---|
| 1122 | | for (var property in methods) { |
|---|
| 1123 | | var value = methods[property]; |
|---|
| 1124 | | if (typeof value == 'function' && !(property in element)) |
|---|
| 1125 | | element[property] = cache.findOrStore(value); |
|---|
| 1126 | | } |
|---|
| 1127 | | } |
|---|
| 1128 | | |
|---|
| 1129 | | element._extended = true; |
|---|
| | 1305 | } |
|---|
| | 1306 | |
|---|
| | 1307 | // extend methods for specific tags |
|---|
| | 1308 | if (T[tagName]) Object.extend(methods, T[tagName]); |
|---|
| | 1309 | |
|---|
| | 1310 | for (var property in methods) { |
|---|
| | 1311 | var value = methods[property]; |
|---|
| | 1312 | if (typeof value == 'function' && !(property in element)) |
|---|
| | 1313 | element[property] = cache.findOrStore(value); |
|---|
| | 1314 | } |
|---|
| | 1315 | |
|---|
| | 1316 | element._extended = Prototype.emptyFunction; |
|---|
| 1369 | | if (document.defaultView && document.defaultView.getComputedStyle) { |
|---|
| 1370 | | var css = document.defaultView.getComputedStyle(element, null); |
|---|
| 1371 | | value = css ? css[style] : null; |
|---|
| 1372 | | } else if (element.currentStyle) { |
|---|
| 1373 | | value = element.currentStyle[style]; |
|---|
| 1374 | | } |
|---|
| 1375 | | } |
|---|
| 1376 | | |
|---|
| 1377 | | if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) |
|---|
| 1378 | | value = element['offset'+style.capitalize()] + 'px'; |
|---|
| 1379 | | |
|---|
| 1380 | | if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) |
|---|
| 1381 | | if (Element.getStyle(element, 'position') == 'static') value = 'auto'; |
|---|
| 1382 | | if(style == 'opacity') { |
|---|
| 1383 | | if(value) return parseFloat(value); |
|---|
| 1384 | | if(value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) |
|---|
| 1385 | | if(value[1]) return parseFloat(value[1]) / 100; |
|---|
| 1386 | | return 1.0; |
|---|
| 1387 | | } |
|---|
| | 1577 | var css = document.defaultView.getComputedStyle(element, null); |
|---|
| | 1578 | value = css ? css[style] : null; |
|---|
| | 1579 | } |
|---|
| | 1580 | if (style == 'opacity') return value ? parseFloat(value) : 1.0; |
|---|
| 1391 | | setStyle: function(element, style) { |
|---|
| 1392 | | element = $(element); |
|---|
| 1393 | | for (var name in style) { |
|---|
| 1394 | | var value = style[name]; |
|---|
| 1395 | | if(name == 'opacity') { |
|---|
| 1396 | | if (value == 1) { |
|---|
| 1397 | | value = (/Gecko/.test(navigator.userAgent) && |
|---|
| 1398 | | !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ? 0.999999 : 1.0; |
|---|
| 1399 | | if(/MSIE/.test(navigator.userAgent) && !window.opera) |
|---|
| 1400 | | element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); |
|---|
| 1401 | | } else if(value == '') { |
|---|
| 1402 | | if(/MSIE/.test(navigator.userAgent) && !window.opera) |
|---|
| 1403 | | element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,''); |
|---|
| 1404 | | } else { |
|---|
| 1405 | | if(value < 0.00001) value = 0; |
|---|
| 1406 | | if(/MSIE/.test(navigator.userAgent) && !window.opera) |
|---|
| 1407 | | element.style.filter = element.getStyle('filter').replace(/alpha\([^\)]*\)/gi,'') + |
|---|
| 1408 | | 'alpha(opacity='+value*100+')'; |
|---|
| 1409 | | } |
|---|
| 1410 | | } else if(['float','cssFloat'].include(name)) name = (typeof element.style.styleFloat != 'undefined') ? 'styleFloat' : 'cssFloat'; |
|---|
| 1411 | | element.style[name.camelize()] = value; |
|---|
| 1412 | | } |
|---|
| | 1584 | getOpacity: function(element) { |
|---|
| | 1585 | return $(element).getStyle('opacity'); |
|---|
| | 1586 | }, |
|---|
| | 1587 | |
|---|
| | 1588 | setStyle: function(element, styles, camelized) { |
|---|
| | 1589 | element = $(element); |
|---|
| | 1590 | var elementStyle = element.style; |
|---|
| | 1591 | |
|---|
| | 1592 | for (var property in styles) |
|---|
| | 1593 | if (property == 'opacity') element.setOpacity(styles[property]) |
|---|
| | 1594 | else |
|---|
| | 1595 | elementStyle[(property == 'float' || property == 'cssFloat') ? |
|---|
| | 1596 | (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : |
|---|
| | 1597 | (camelized ? property : property.camelize())] = styles[property]; |
|---|
| | 1598 | |
|---|
| | 1599 | return element; |
|---|
| | 1600 | }, |
|---|
| | 1601 | |
|---|
| | 1602 | setOpacity: function(element, value) { |
|---|
| | 1603 | element = $(element); |
|---|
| | 1604 | element.style.opacity = (value == 1 || value === '') ? '' : |
|---|
| | 1605 | (value < 0.00001) ? 0 : value; |
|---|
| 1486 | | Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); |
|---|
| 1487 | | |
|---|
| 1488 | | Element._attributeTranslations = {}; |
|---|
| 1489 | | |
|---|
| 1490 | | Element._attributeTranslations.names = { |
|---|
| 1491 | | colspan: "colSpan", |
|---|
| 1492 | | rowspan: "rowSpan", |
|---|
| 1493 | | valign: "vAlign", |
|---|
| 1494 | | datetime: "dateTime", |
|---|
| 1495 | | accesskey: "accessKey", |
|---|
| 1496 | | tabindex: "tabIndex", |
|---|
| 1497 | | enctype: "encType", |
|---|
| 1498 | | maxlength: "maxLength", |
|---|
| 1499 | | readonly: "readOnly", |
|---|
| 1500 | | longdesc: "longDesc" |
|---|
| 1501 | | }; |
|---|
| 1502 | | |
|---|
| 1503 | | Element._attributeTranslations.values = { |
|---|
| 1504 | | _getAttr: function(element, attribute) { |
|---|
| 1505 | | return element.getAttribute(attribute, 2); |
|---|
| 1506 | | }, |
|---|
| 1507 | | |
|---|
| 1508 | | _flag: function(element, attribute) { |
|---|
| 1509 | | return $(element).hasAttribute(attribute) ? attribute : null; |
|---|
| 1510 | | }, |
|---|
| 1511 | | |
|---|
| 1512 | | style: function(element) { |
|---|
| 1513 | | return element.style.cssText.toLowerCase(); |
|---|
| 1514 | | }, |
|---|
| 1515 | | |
|---|
| 1516 | | title: function(element) { |
|---|
| 1517 | | var node = element.getAttributeNode('title'); |
|---|
| 1518 | | return node.specified ? node.nodeValue : null; |
|---|
| 1519 | | } |
|---|
| 1520 | | }; |
|---|
| 1521 | | |
|---|
| 1522 | | Object.extend(Element._attributeTranslations.values, { |
|---|
| 1523 | | href: Element._attributeTranslations.values._getAttr, |
|---|
| 1524 | | src: Element._attributeTranslations.values._getAttr, |
|---|
| 1525 | | disabled: Element._attributeTranslations.values._flag, |
|---|
| 1526 | | checked: Element._attributeTranslations.values._flag, |
|---|
| 1527 | | readonly: Element._attributeTranslations.values._flag, |
|---|
| 1528 | | multiple: Element._attributeTranslations.values._flag |
|---|
| | 1679 | Object.extend(Element.Methods, { |
|---|
| | 1680 | childOf: Element.Methods.descendantOf, |
|---|
| | 1681 | childElements: Element.Methods.immediateDescendants |
|---|
| 1531 | | Element.Methods.Simulated = { |
|---|
| 1532 | | hasAttribute: function(element, attribute) { |
|---|
| 1533 | | var t = Element._attributeTranslations; |
|---|
| 1534 | | attribute = t.names[attribute] || attribute; |
|---|
| 1535 | | return $(element).getAttributeNode(attribute).specified; |
|---|
| 1536 | | } |
|---|
| 1537 | | }; |
|---|
| 1538 | | |
|---|
| 1539 | | // IE is missing .innerHTML support for TABLE-related elements |
|---|
| 1540 | | if (document.all && !window.opera){ |
|---|
| | 1684 | if (Prototype.Browser.Opera) { |
|---|
| | 1685 | Element.Methods._getStyle = Element.Methods.getStyle; |
|---|
| | 1686 | Element.Methods.getStyle = function(element, style) { |
|---|
| | 1687 | switch(style) { |
|---|
| | 1688 | case 'left': |
|---|
| | 1689 | case 'top': |
|---|
| | 1690 | case 'right': |
|---|
| | 1691 | case 'bottom': |
|---|
| | 1692 | if (Element._getStyle(element, 'position') == 'static') return null; |
|---|
| | 1693 | default: return Element._getStyle(element, style); |
|---|
| | 1694 | } |
|---|
| | 1695 | }; |
|---|
| | 1696 | } |
|---|
| | 1697 | else if (Prototype.Browser.IE) { |
|---|
| | 1698 | Element.Methods.getStyle = function(element, style) { |
|---|
| | 1699 | element = $(element); |
|---|
| | 1700 | style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); |
|---|
| | 1701 | var value = element.style[style]; |
|---|
| | 1702 | if (!value && element.currentStyle) value = element.currentStyle[style]; |
|---|
| | 1703 | |
|---|
| | 1704 | if (style == 'opacity') { |
|---|
| | 1705 | if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) |
|---|
| | 1706 | if (value[1]) return parseFloat(value[1]) / 100; |
|---|
| | 1707 | return 1.0; |
|---|
| | 1708 | } |
|---|
| | 1709 | |
|---|
| | 1710 | if (value == 'auto') { |
|---|
| | 1711 | if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) |
|---|
| | 1712 | return element['offset'+style.capitalize()] + 'px'; |
|---|
| | 1713 | return null; |
|---|
| | 1714 | } |
|---|
| | 1715 | return value; |
|---|
| | 1716 | }; |
|---|
| | 1717 | |
|---|
| | 1718 | Element.Methods.setOpacity = function(element, value) { |
|---|
| | 1719 | element = $(element); |
|---|
| | 1720 | var filter = element.getStyle('filter'), style = element.style; |
|---|
| | 1721 | if (value == 1 || value === '') { |
|---|
| | 1722 | style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); |
|---|
| | 1723 | return element; |
|---|
| | 1724 | } else if (value < 0.00001) value = 0; |
|---|
| | 1725 | style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + |
|---|
| | 1726 | 'alpha(opacity=' + (value * 100) + ')'; |
|---|
| | 1727 | return element; |
|---|
| | 1728 | }; |
|---|
| | 1729 | |
|---|
| | 1730 | // IE is missing .innerHTML support for TABLE-related elements |
|---|
| | 1760 | } |
|---|
| | 1761 | else if (Prototype.Browser.Gecko) { |
|---|
| | 1762 | Element.Methods.setOpacity = function(element, value) { |
|---|
| | 1763 | element = $(element); |
|---|
| | 1764 | element.style.opacity = (value == 1) ? 0.999999 : |
|---|
| | 1765 | (value === '') ? '' : (value < 0.00001) ? 0 : value; |
|---|
| | 1766 | return element; |
|---|
| | 1767 | }; |
|---|
| | 1768 | } |
|---|
| | 1769 | |
|---|
| | 1770 | Element._attributeTranslations = { |
|---|
| | 1771 | names: { |
|---|
| | 1772 | colspan: "colSpan", |
|---|
| | 1773 | rowspan: "rowSpan", |
|---|
| | 1774 | valign: "vAlign", |
|---|
| | 1775 | datetime: "dateTime", |
|---|
| | 1776 | accesskey: "accessKey", |
|---|
| | 1777 | tabindex: "tabIndex", |
|---|
| | 1778 | enctype: "encType", |
|---|
| | 1779 | maxlength: "maxLength", |
|---|
| | 1780 | readonly: "readOnly", |
|---|
| | 1781 | longdesc: "longDesc" |
|---|
| | 1782 | }, |
|---|
| | 1783 | values: { |
|---|
| | 1784 | _getAttr: function(element, attribute) { |
|---|
| | 1785 | return element.getAttribute(attribute, 2); |
|---|
| | 1786 | }, |
|---|
| | 1787 | _flag: function(element, attribute) { |
|---|
| | 1788 | return $(element).hasAttribute(attribute) ? attribute : null; |
|---|
| | 1789 | }, |
|---|
| | 1790 | style: function(element) { |
|---|
| | 1791 | return element.style.cssText.toLowerCase(); |
|---|
| | 1792 | }, |
|---|
| | 1793 | title: function(element) { |
|---|
| | 1794 | var node = element.getAttributeNode('title'); |
|---|
| | 1795 | return node.specified ? node.nodeValue : null; |
|---|
| | 1796 | } |
|---|
| | 1797 | } |
|---|
| | 1800 | (function() { |
|---|
| | 1801 | Object.extend(this, { |
|---|
| | 1802 | href: this._getAttr, |
|---|
| | 1803 | src: this._getAttr, |
|---|
| | 1804 | type: this._getAttr, |
|---|
| | 1805 | disabled: this._flag, |
|---|
| | 1806 | checked: this._flag, |
|---|
| | 1807 | readonly: this._flag, |
|---|
| | 1808 | multiple: this._flag |
|---|
| | 1809 | }); |
|---|
| | 1810 | }).call(Element._attributeTranslations.values); |
|---|
| | 1811 | |
|---|
| | 1812 | Element.Methods.Simulated = { |
|---|
| | 1813 | hasAttribute: function(element, attribute) { |
|---|
| | 1814 | var t = Element._attributeTranslations, node; |
|---|
| | 1815 | attribute = t.names[attribute] || attribute; |
|---|
| | 1816 | node = $(element).getAttributeNode(attribute); |
|---|
| | 1817 | return node && node.specified; |
|---|
| | 1818 | } |
|---|
| | 1819 | }; |
|---|
| | 1820 | |
|---|
| | 1821 | Element.Methods.ByTag = {}; |
|---|
| | 1822 | |
|---|
| 1578 | | var _nativeExtensions = false; |
|---|
| 1579 | | |
|---|
| 1580 | | if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)) |
|---|
| 1581 | | ['', 'Form', 'Input', 'TextArea', 'Select'].each(function(tag) { |
|---|
| 1582 | | var className = 'HTML' + tag + 'Element'; |
|---|
| 1583 | | if(window[className]) return; |
|---|
| 1584 | | var klass = window[className] = {}; |
|---|
| 1585 | | klass.prototype = document.createElement(tag ? tag.toLowerCase() : 'div').__proto__; |
|---|
| 1586 | | }); |
|---|
| | 1825 | if (!Prototype.BrowserFeatures.ElementExtensions && |
|---|
| | 1826 | document.createElement('div').__proto__) { |
|---|
| | 1827 | window.HTMLElement = {}; |
|---|
| | 1828 | window.HTMLElement.prototype = document.createElement('div').__proto__; |
|---|
| | 1829 | Prototype.BrowserFeatures.ElementExtensions = true; |
|---|
| | 1830 | } |
|---|
| | 1831 | |
|---|
| | 1832 | Element.hasAttribute = function(element, attribute) { |
|---|
| | 1833 | if (element.hasAttribute) return element.hasAttribute(attribute); |
|---|
| | 1834 | return Element.Methods.Simulated.hasAttribute(element, attribute); |
|---|
| | 1835 | }; |
|---|
| 1589 | | Object.extend(Element.Methods, methods || {}); |
|---|
| | 1838 | var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; |
|---|
| | 1839 | |
|---|
| | 1840 | if (!methods) { |
|---|
| | 1841 | Object.extend(Form, Form.Methods); |
|---|
| | 1842 | Object.extend(Form.Element, Form.Element.Methods); |
|---|
| | 1843 | Object.extend(Element.Methods.ByTag, { |
|---|
| | 1844 | "FORM": Object.clone(Form.Methods), |
|---|
| | 1845 | "INPUT": Object.clone(Form.Element.Methods), |
|---|
| | 1846 | "SELECT": Object.clone(Form.Element.Methods), |
|---|
| | 1847 | "TEXTAREA": Object.clone(Form.Element.Methods) |
|---|
| | 1848 | }); |
|---|
| | 1849 | } |
|---|
| | 1850 | |
|---|
| | 1851 | if (arguments.length == 2) { |
|---|
| | 1852 | var tagName = methods; |
|---|
| | 1853 | methods = arguments[1]; |
|---|
| | 1854 | } |
|---|
| | 1855 | |
|---|
| | 1856 | if (!tagName) Object.extend(Element.Methods, methods || {}); |
|---|
| | 1857 | else { |
|---|
| | 1858 | if (tagName.constructor == Array) tagName.each(extend); |
|---|
| | 1859 | else extend(tagName); |
|---|
| | 1860 | } |
|---|
| | 1861 | |
|---|
| | 1862 | function extend(tagName) { |
|---|
| | 1863 | tagName = tagName.toUpperCase(); |
|---|
| | 1864 | if (!Element.Methods.ByTag[tagName]) |
|---|
| | 1865 | Element.Methods.ByTag[tagName] = {}; |
|---|
| | 1866 | Object.extend(Element.Methods.ByTag[tagName], methods); |
|---|
| | 1867 | } |
|---|
| 1601 | | if (typeof HTMLElement != 'undefined') { |
|---|
| | 1879 | function findDOMClass(tagName) { |
|---|
| | 1880 | var klass; |
|---|
| | 1881 | var trans = { |
|---|
| | 1882 | "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", |
|---|
| | 1883 | "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", |
|---|
| | 1884 | "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", |
|---|
| | 1885 | "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", |
|---|
| | 1886 | "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": |
|---|
| | 1887 | "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": |
|---|
| | 1888 | "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": |
|---|
| | 1889 | "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": |
|---|
| | 1890 | "FrameSet", "IFRAME": "IFrame" |
|---|
| | 1891 | }; |
|---|
| | 1892 | if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; |
|---|
| | 1893 | if (window[klass]) return window[klass]; |
|---|
| | 1894 | klass = 'HTML' + tagName + 'Element'; |
|---|
| | 1895 | if (window[klass]) return window[klass]; |
|---|
| | 1896 | klass = 'HTML' + tagName.capitalize() + 'Element'; |
|---|
| | 1897 | if (window[klass]) return window[klass]; |
|---|
| | 1898 | |
|---|
| | 1899 | window[klass] = {}; |
|---|
| | 1900 | window[klass].prototype = document.createElement(tagName).__proto__; |
|---|
| | 1901 | return window[klass]; |
|---|
| | 1902 | } |
|---|
| | 1903 | |
|---|
| | 1904 | if (F.ElementExtensions) { |
|---|
| 1604 | | copy(Form.Methods, HTMLFormElement.prototype); |
|---|
| 1605 | | [HTMLInputElement, HTMLTextAreaElement, HTMLSelectElement].each(function(klass) { |
|---|
| 1606 | | copy(Form.Element.Methods, klass.prototype); |
|---|
| 1607 | | }); |
|---|
| 1608 | | _nativeExtensions = true; |
|---|
| 1609 | | } |
|---|
| 1610 | | } |
|---|
| 1611 | | |
|---|
| 1612 | | var Toggle = new Object(); |
|---|
| 1613 | | Toggle.display = Element.toggle; |
|---|
| | 1907 | } |
|---|
| | 1908 | |
|---|
| | 1909 | if (F.SpecificElementExtensions) { |
|---|
| | 1910 | for (var tag in Element.Methods.ByTag) { |
|---|
| | 1911 | var klass = findDOMClass(tag); |
|---|
| | 1912 | if (typeof klass == "undefined") continue; |
|---|
| | 1913 | copy(T[tag], klass.prototype); |
|---|
| | 1914 | } |
|---|
| | 1915 | } |
|---|
| | 1916 | |
|---|
| | 1917 | Object.extend(Element, Element.Methods); |
|---|
| | 1918 | delete Element.ByTag; |
|---|
| | 1919 | }; |
|---|
| | 1920 | |
|---|
| | 1921 | var Toggle = { display: Element.toggle }; |
|---|
| 1753 | | parseExpression: function() { |
|---|
| 1754 | | function abort(message) { throw 'Parse error in selector: ' + message; } |
|---|
| 1755 | | |
|---|
| 1756 | | if (this.expression == '') abort('empty expression'); |
|---|
| 1757 | | |
|---|
| 1758 | | var params = this.params, expr = this.expression, match, modifier, clause, rest; |
|---|
| 1759 | | while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { |
|---|
| 1760 | | params.attributes = params.attributes || []; |
|---|
| 1761 | | params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); |
|---|
| 1762 | | expr = match[1]; |
|---|
| 1763 | | } |
|---|
| 1764 | | |
|---|
| 1765 | | if (expr == '*') return this.params.wildcard = true; |
|---|
| 1766 | | |
|---|
| 1767 | | while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+)(.*)/i)) { |
|---|
| 1768 | | modifier = match[1], clause = match[2], rest = match[3]; |
|---|
| 1769 | | switch (modifier) { |
|---|
| 1770 | | case '#': params.id = clause; break; |
|---|
| 1771 | | case '.': params.classNames.push(clause); break; |
|---|
| 1772 | | case '': |
|---|
| 1773 | | case undefined: params.tagName = clause.toUpperCase(); break; |
|---|
| 1774 | | default: abort(expr.inspect()); |
|---|
| | 2064 | compileMatcher: function() { |
|---|
| | 2065 | // Selectors with namespaced attributes can't use the XPath version |
|---|
| | 2066 | if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression)) |
|---|
| | 2067 | return this.compileXPathMatcher(); |
|---|
| | 2068 | |
|---|