| 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[^>]*>([\u0001-\uFFFF]*?)</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 | evalJSON: function(sanitize) { |
|---|
| | 368 | var json = this.unfilterJSON(); |
|---|
| | 369 | try { |
|---|
| | 370 | if (!sanitize || (/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/.test(json))) |
|---|
| | 371 | return eval('(' + json + ')'); |
|---|
| | 372 | } catch (e) { } |
|---|
| | 373 | throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); |
|---|
| | 374 | }, |
|---|
| | 375 | |
|---|
| | 376 | include: function(pattern) { |
|---|
| | 377 | return this.indexOf(pattern) > -1; |
|---|
| | 378 | }, |
|---|
| | 379 | |
|---|
| | 380 | startsWith: function(pattern) { |
|---|
| | 381 | return this.indexOf(pattern) === 0; |
|---|
| | 382 | }, |
|---|
| | 383 | |
|---|
| | 384 | endsWith: function(pattern) { |
|---|
| | 385 | var d = this.length - pattern.length; |
|---|
| | 386 | return d >= 0 && this.lastIndexOf(pattern) === d; |
|---|
| | 387 | }, |
|---|
| | 388 | |
|---|
| | 389 | empty: function() { |
|---|
| | 390 | return this == ''; |
|---|
| | 391 | }, |
|---|
| | 392 | |
|---|
| | 393 | blank: function() { |
|---|
| | 394 | return /^\s*$/.test(this); |
|---|
| | 395 | } |
|---|
| | 396 | }); |
|---|
| | 397 | |
|---|
| | 398 | if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { |
|---|
| | 399 | escapeHTML: function() { |
|---|
| | 400 | return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); |
|---|
| | 401 | }, |
|---|
| | 402 | unescapeHTML: function() { |
|---|
| | 403 | 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++) |
|---|
| | 761 | for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); |
|---|
| | 762 | for (var i = 0, length = arguments.length; i < length; i++) { |
|---|
| | 763 | if (arguments[i].constructor == Array) { |
|---|
| | 764 | 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 | | } |
|---|
| | 785 | var value = pair.value; |
|---|
| | 786 | |
|---|
| | 787 | if (value && typeof value == 'object') { |
|---|
| | 788 | if (value.constructor == Array) value.each(function(value) { |
|---|
| | 789 | parts.add(pair.key, value); |
|---|
| | 790 | }); |
|---|
| | 791 | 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; |
|---|
| | 1020 | this.parameters = params; |
|---|
| | 1021 | |
|---|
| | 1022 | if (params = Hash.toQueryString(params)) { |
|---|
| | 1023 | // when GET, append parameters to URL |
|---|
| | 1024 | if (this.method == 'get') |
|---|
| | 1025 | this.url += (this.url.include('?') ? '&' : '?') + params; |
|---|
| | 1026 | else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) |
|---|
| | 1027 | params += '&_='; |
|---|
| | 1028 | } |
|---|
| 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 | | } |
|---|
| | 1269 | } |
|---|
| | 1270 | |
|---|
| | 1271 | } else document.getElementsByClassName = function(className, parentElement) { |
|---|
| | 1272 | var children = ($(parentElement) || document.body).getElementsByTagName('*'); |
|---|
| | 1273 | var elements = [], child; |
|---|
| | 1274 | for (var i = 0, length = children.length; i < length; i++) { |
|---|
| | 1275 | child = children[i]; |
|---|
| | 1276 | if (Element.hasClassName(child, className)) |
|---|
| | 1277 | elements.push(Element.extend(child)); |
|---|
| | 1278 | } |
|---|
| | 1279 | 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 | | |
|---|
| | 1287 | var F = Prototype.BrowserFeatures; |
|---|
| | 1288 | if (!element || !element.tagName || element.nodeType == 3 || |
|---|
| | 1289 | element._extended || F.SpecificElementExtensions || element == window) |
|---|
| | 1290 | return element; |
|---|
| | 1291 | |
|---|
| | 1292 | var methods = {}, tagName = element.tagName, cache = Element.extend.cache, |
|---|
| | 1293 | T = Element.Methods.ByTag; |
|---|
| | 1294 | |
|---|
| | 1295 | // extend methods for all tags (Safari doesn't need this) |
|---|
| | 1296 | if (!F.ElementExtensions) { |
|---|
| | 1297 | 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; |
|---|
| | 1299 | } |
|---|
| | 1300 | |
|---|
| | 1301 | // extend methods for specific tags |
|---|
| | 1302 | if (T[tagName]) Object.extend(methods, T[tagName]); |
|---|
| | 1303 | |
|---|
| | 1304 | for (var property in methods) { |
|---|
| | 1305 | var value = methods[property]; |
|---|
| | 1306 | if (typeof value == 'function' && !(property in element)) |
|---|
| | 1307 | element[property] = cache.findOrStore(value); |
|---|
| | 1308 | } |
|---|
| | 1309 | |
|---|
| | 1310 | 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 | | } |
|---|
| | 1571 | var css = document.defaultView.getComputedStyle(element, null); |
|---|
| | 1572 | value = css ? css[style] : null; |
|---|
| | 1573 | } |
|---|
| | 1574 | 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 | | } |
|---|
| | 1578 | getOpacity: function(element) { |
|---|
| | 1579 | return $(element).getStyle('opacity'); |
|---|
| | 1580 | }, |
|---|
| | 1581 | |
|---|
| | 1582 | setStyle: function(element, styles, camelized) { |
|---|
| | 1583 | element = $(element); |
|---|
| | 1584 | var elementStyle = element.style; |
|---|
| | 1585 | |
|---|
| | 1586 | for (var property in styles) |
|---|
| | 1587 | if (property == 'opacity') element.setOpacity(styles[property]) |
|---|
| | 1588 | else |
|---|
| | 1589 | elementStyle[(property == 'float' || property == 'cssFloat') ? |
|---|
| | 1590 | (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : |
|---|
| | 1591 | (camelized ? property : property.camelize())] = styles[property]; |
|---|
| | 1592 | |
|---|
| | 1593 | return element; |
|---|
| | 1594 | }, |
|---|
| | 1595 | |
|---|
| | 1596 | setOpacity: function(element, value) { |
|---|
| | 1597 | element = $(element); |
|---|
| | 1598 | element.style.opacity = (value == 1 || value === '') ? '' : |
|---|
| | 1599 | (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 |
|---|
| | 1673 | Object.extend(Element.Methods, { |
|---|
| | 1674 | childOf: Element.Methods.descendantOf, |
|---|
| | 1675 | 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){ |
|---|
| | 1678 | if (Prototype.Browser.Opera) { |
|---|
| | 1679 | Element.Methods._getStyle = Element.Methods.getStyle; |
|---|
| | 1680 | Element.Methods.getStyle = function(element, style) { |
|---|
| | 1681 | switch(style) { |
|---|
| | 1682 | case 'left': |
|---|
| | 1683 | case 'top': |
|---|
| | 1684 | case 'right': |
|---|
| | 1685 | case 'bottom': |
|---|
| | 1686 | if (Element._getStyle(element, 'position') == 'static') return null; |
|---|
| | 1687 | default: return Element._getStyle(element, style); |
|---|
| | 1688 | } |
|---|
| | 1689 | }; |
|---|
| | 1690 | } |
|---|
| | 1691 | else if (Prototype.Browser.IE) { |
|---|
| | 1692 | Element.Methods.getStyle = function(element, style) { |
|---|
| | 1693 | element = $(element); |
|---|
| | 1694 | style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); |
|---|
| | 1695 | var value = element.style[style]; |
|---|
| | 1696 | if (!value && element.currentStyle) value = element.currentStyle[style]; |
|---|
| | 1697 | |
|---|
| | 1698 | if (style == 'opacity') { |
|---|
| | 1699 | if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) |
|---|
| | 1700 | if (value[1]) return parseFloat(value[1]) / 100; |
|---|
| | 1701 | return 1.0; |
|---|
| | 1702 | } |
|---|
| | 1703 | |
|---|
| | 1704 | if (value == 'auto') { |
|---|
| | 1705 | if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) |
|---|
| | 1706 | return element['offset'+style.capitalize()] + 'px'; |
|---|
| | 1707 | return null; |
|---|
| | 1708 | } |
|---|
| | 1709 | return value; |
|---|
| | 1710 | }; |
|---|
| | 1711 | |
|---|
| | 1712 | Element.Methods.setOpacity = function(element, value) { |
|---|
| | 1713 | element = $(element); |
|---|
| | 1714 | var filter = element.getStyle('filter'), style = element.style; |
|---|
| | 1715 | if (value == 1 || value === '') { |
|---|
| | 1716 | style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); |
|---|
| | 1717 | return element; |
|---|
| | 1718 | } else if (value < 0.00001) value = 0; |
|---|
| | 1719 | style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + |
|---|
| | 1720 | 'alpha(opacity=' + (value * 100) + ')'; |
|---|
| | 1721 | return element; |
|---|
| | 1722 | }; |
|---|
| | 1723 | |
|---|
| | 1724 | // IE is missing .innerHTML support for TABLE-related elements |
|---|
| | 1754 | } |
|---|
| | 1755 | else if (Prototype.Browser.Gecko) { |
|---|
| | 1756 | Element.Methods.setOpacity = function(element, value) { |
|---|
| | 1757 | element = $(element); |
|---|
| | 1758 | element.style.opacity = (value == 1) ? 0.999999 : |
|---|
| | 1759 | (value === '') ? '' : (value < 0.00001) ? 0 : value; |
|---|
| | 1760 | return element; |
|---|
| | 1761 | }; |
|---|
| | 1762 | } |
|---|
| | 1763 | |
|---|
| | 1764 | Element._attributeTranslations = { |
|---|
| | 1765 | names: { |
|---|
| | 1766 | colspan: "colSpan", |
|---|
| | 1767 | rowspan: "rowSpan", |
|---|
| | 1768 | valign: "vAlign", |
|---|
| | 1769 | datetime: "dateTime", |
|---|
| | 1770 | accesskey: "accessKey", |
|---|
| | 1771 | tabindex: "tabIndex", |
|---|
| | 1772 | enctype: "encType", |
|---|
| | 1773 | maxlength: "maxLength", |
|---|
| | 1774 | readonly: "readOnly", |
|---|
| | 1775 | longdesc: "longDesc" |
|---|
| | 1776 | }, |
|---|
| | 1777 | values: { |
|---|
| | 1778 | _getAttr: function(element, attribute) { |
|---|
| | 1779 | return element.getAttribute(attribute, 2); |
|---|
| | 1780 | }, |
|---|
| | 1781 | _flag: function(element, attribute) { |
|---|
| | 1782 | return $(element).hasAttribute(attribute) ? attribute : null; |
|---|
| | 1783 | }, |
|---|
| | 1784 | style: function(element) { |
|---|
| | 1785 | return element.style.cssText.toLowerCase(); |
|---|
| | 1786 | }, |
|---|
| | 1787 | title: function(element) { |
|---|
| | 1788 | var node = element.getAttributeNode('title'); |
|---|
| | 1789 | return node.specified ? node.nodeValue : null; |
|---|
| | 1790 | } |
|---|
| | 1791 | } |
|---|
| | 1794 | (function() { |
|---|
| | 1795 | Object.extend(this, { |
|---|
| | 1796 | href: this._getAttr, |
|---|
| | 1797 | src: this._getAttr, |
|---|
| | 1798 | type: this._getAttr, |
|---|
| | 1799 | disabled: this._flag, |
|---|
| | 1800 | checked: this._flag, |
|---|
| | 1801 | readonly: this._flag, |
|---|
| | 1802 | multiple: this._flag |
|---|
| | 1803 | }); |
|---|
| | 1804 | }).call(Element._attributeTranslations.values); |
|---|
| | 1805 | |
|---|
| | 1806 | Element.Methods.Simulated = { |
|---|
| | 1807 | hasAttribute: function(element, attribute) { |
|---|
| | 1808 | var t = Element._attributeTranslations, node; |
|---|
| | 1809 | attribute = t.names[attribute] || attribute; |
|---|
| | 1810 | node = $(element).getAttributeNode(attribute); |
|---|
| | 1811 | return node && node.specified; |
|---|
| | 1812 | } |
|---|
| | 1813 | }; |
|---|
| | 1814 | |
|---|
| | 1815 | Element.Methods.ByTag = {}; |
|---|
| | 1816 | |
|---|
| 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 | | }); |
|---|
| | 1819 | if (!Prototype.BrowserFeatures.ElementExtensions && |
|---|
| | 1820 | document.createElement('div').__proto__) { |
|---|
| | 1821 | window.HTMLElement = {}; |
|---|
| | 1822 | window.HTMLElement.prototype = document.createElement('div').__proto__; |
|---|
| | 1823 | Prototype.BrowserFeatures.ElementExtensions = true; |
|---|
| | 1824 | } |
|---|
| | 1825 | |
|---|
| | 1826 | Element.hasAttribute = function(element, attribute) { |
|---|
| | 1827 | if (element.hasAttribute) return element.hasAttribute(attribute); |
|---|
| | 1828 | return Element.Methods.Simulated.hasAttribute(element, attribute); |
|---|
| | 1829 | }; |
|---|
| 1589 | | Object.extend(Element.Methods, methods || {}); |
|---|
| | 1832 | var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; |
|---|
| | 1833 | |
|---|
| | 1834 | if (!methods) { |
|---|
| | 1835 | Object.extend(Form, Form.Methods); |
|---|
| | 1836 | Object.extend(Form.Element, Form.Element.Methods); |
|---|
| | 1837 | Object.extend(Element.Methods.ByTag, { |
|---|
| | 1838 | "FORM": Object.clone(Form.Methods), |
|---|
| | 1839 | "INPUT": Object.clone(Form.Element.Methods), |
|---|
| | 1840 | "SELECT": Object.clone(Form.Element.Methods), |
|---|
| | 1841 | "TEXTAREA": Object.clone(Form.Element.Methods) |
|---|
| | 1842 | }); |
|---|
| | 1843 | } |
|---|
| | 1844 | |
|---|
| | 1845 | if (arguments.length == 2) { |
|---|
| | 1846 | var tagName = methods; |
|---|
| | 1847 | methods = arguments[1]; |
|---|
| | 1848 | } |
|---|
| | 1849 | |
|---|
| | 1850 | if (!tagName) Object.extend(Element.Methods, methods || {}); |
|---|
| | 1851 | else { |
|---|
| | 1852 | if (tagName.constructor == Array) tagName.each(extend); |
|---|
| | 1853 | else extend(tagName); |
|---|
| | 1854 | } |
|---|
| | 1855 | |
|---|
| | 1856 | function extend(tagName) { |
|---|
| | 1857 | tagName = tagName.toUpperCase(); |
|---|
| | 1858 | if (!Element.Methods.ByTag[tagName]) |
|---|
| | 1859 | Element.Methods.ByTag[tagName] = {}; |
|---|
| | 1860 | Object.extend(Element.Methods.ByTag[tagName], methods); |
|---|
| | 1861 | } |
|---|
| 1601 | | if (typeof HTMLElement != 'undefined') { |
|---|
| | 1873 | function findDOMClass(tagName) { |
|---|
| | 1874 | var klass; |
|---|
| | 1875 | var trans = { |
|---|
| | 1876 | "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", |
|---|
| | 1877 | "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", |
|---|
| | 1878 | "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", |
|---|
| | 1879 | "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", |
|---|
| | 1880 | "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": |
|---|
| | 1881 | "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": |
|---|
| | 1882 | "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": |
|---|
| | 1883 | "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": |
|---|
| | 1884 | "FrameSet", "IFRAME": "IFrame" |
|---|
| | 1885 | }; |
|---|
| | 1886 | if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; |
|---|
| | 1887 | if (window[klass]) return window[klass]; |
|---|
| | 1888 | klass = 'HTML' + tagName + 'Element'; |
|---|
| | 1889 | if (window[klass]) return window[klass]; |
|---|
| | 1890 | klass = 'HTML' + tagName.capitalize() + 'Element'; |
|---|
| | 1891 | if (window[klass]) return window[klass]; |
|---|
| | 1892 | |
|---|
| | 1893 | window[klass] = {}; |
|---|
| | 1894 | window[klass].prototype = document.createElement(tagName).__proto__; |
|---|
| | 1895 | return window[klass]; |
|---|
| | 1896 | } |
|---|
| | 1897 | |
|---|
| | 1898 | 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; |
|---|
| | 1901 | } |
|---|
| | 1902 | |
|---|
| | 1903 | if (F.SpecificElementExtensions) { |
|---|
| | 1904 | for (var tag in Element.Methods.ByTag) { |
|---|
| | 1905 | var klass = findDOMClass(tag); |
|---|
| | 1906 | if (typeof klass == "undefined") continue; |
|---|
| | 1907 | copy(T[tag], klass.prototype); |
|---|
| | 1908 | } |
|---|
| | 1909 | } |
|---|
| | 1910 | |
|---|
| | 1911 | Object.extend(Element, Element.Methods); |
|---|
| | 1912 | delete Element.ByTag; |
|---|
| | 1913 | }; |
|---|
| | 1914 | |
|---|
| | 1915 | 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 | | i |
|---|