Changeset 5482

Show
Ignore:
Timestamp:
05/16/07 03:27:07 (1 year ago)
Author:
rob1n
Message:

Update Prototype to 1.5.1 and script.aculo.us to 1.7.1-b2. Props zamoose. fixes #4265

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/js/prototype.js

    r5391 r5482  
    1 /*  Prototype JavaScript framework, version 1.5.0 
     1/*  Prototype JavaScript framework, version 1.5.1 
    22 *  (c) 2005-2007 Sam Stephenson 
    33 * 
    44 *  Prototype is freely distributable under the terms of an MIT-style license. 
    5  *  For details, see the Prototype web site: http://prototype.conio.net
     5 *  For details, see the Prototype web site: http://www.prototypejs.org
    66 * 
    77/*--------------------------------------------------------------------------*/ 
    88 
    99var Prototype = { 
    10   Version: '1.5.0', 
     10  Version: '1.5.1', 
     11 
     12  Browser: { 
     13    IE:     !!(window.attachEvent && !window.opera), 
     14    Opera:  !!window.opera, 
     15    WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, 
     16    Gecko:  navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 
     17  }, 
     18 
    1119  BrowserFeatures: { 
    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() { }, 
    1731  K: function(x) { return x } 
    1832} 
     
    4761  }, 
    4862 
     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 
    4983  keys: function(object) { 
    5084    var keys = []; 
     
    76110  var __method = this, args = $A(arguments), object = args.shift(); 
    77111  return function(event) { 
    78     return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 
     112    return __method.apply(object, [event || window.event].concat(args)); 
    79113  } 
    80114} 
     
    82116Object.extend(Number.prototype, { 
    83117  toColorPart: function() { 
    84     var digits = this.toString(16); 
    85     if (this < 16) return '0' + digits; 
    86     return digits; 
     118    return this.toPaddedString(2, 16); 
    87119  }, 
    88120 
     
    94126    $R(0, this, true).each(iterator); 
    95127    return this; 
     128  }, 
     129 
     130  toPaddedString: function(length, radix) { 
     131    var string = this.toString(radix || 10); 
     132    return '0'.times(length - string.length) + string; 
     133  }, 
     134 
     135  toJSON: function() { 
     136    return isFinite(this) ? this.toString() : 'null'; 
    96137  } 
    97138}); 
     139 
     140Date.prototype.toJSON = function() { 
     141  return '"' + this.getFullYear() + '-' + 
     142    (this.getMonth() + 1).toPaddedString(2) + '-' + 
     143    this.getDate().toPaddedString(2) + 'T' + 
     144    this.getHours().toPaddedString(2) + ':' + 
     145    this.getMinutes().toPaddedString(2) + ':' + 
     146    this.getSeconds().toPaddedString(2) + '"'; 
     147}; 
    98148 
    99149var Try = { 
     
    146196  } 
    147197} 
    148 String.interpret = function(value){ 
    149   return value == null ? '' : String(value); 
    150 
     198Object.extend(String, { 
     199  interpret: function(value) { 
     200    return value == null ? '' : String(value); 
     201  }, 
     202  specialChar: { 
     203    '\b': '\\b', 
     204    '\t': '\\t', 
     205    '\n': '\\n', 
     206    '\f': '\\f', 
     207    '\r': '\\r', 
     208    '\\': '\\\\' 
     209  } 
     210}); 
    151211 
    152212Object.extend(String.prototype, { 
     
    214274 
    215275  escapeHTML: function() { 
    216     var div = document.createElement('div'); 
    217     var text = document.createTextNode(this); 
    218     div.appendChild(text); 
    219     return div.innerHTML; 
     276    var self = arguments.callee; 
     277    self.text.data = this; 
     278    return self.div.innerHTML; 
    220279  }, 
    221280 
     
    224283    div.innerHTML = this.stripTags(); 
    225284    return div.childNodes[0] ? (div.childNodes.length > 1 ? 
    226       $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 
     285      $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : 
    227286      div.childNodes[0].nodeValue) : ''; 
    228287  }, 
     
    234293    return match[1].split(separator || '&').inject({}, function(hash, pair) { 
    235294      if ((pair = pair.split('='))[0]) { 
    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); 
    243302        } 
    244         else hash[name] = value; 
     303        else hash[key] = value; 
    245304      } 
    246305      return hash; 
     
    257316  }, 
    258317 
     318  times: function(count) { 
     319    var result = ''; 
     320    for (var i = 0; i < count; i++) result += this; 
     321    return result; 
     322  }, 
     323 
    259324  camelize: function() { 
    260325    var parts = this.split('-'), len = parts.length; 
     
    271336  }, 
    272337 
    273   capitalize: function()
     338  capitalize: function()
    274339    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 
    275340  }, 
     
    284349 
    285350  inspect: function(useDoubleQuotes) { 
    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 
     398if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { 
     399  escapeHTML: function() { 
     400    return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;'); 
     401  }, 
     402  unescapeHTML: function() { 
     403    return this.replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>'); 
    291404  } 
    292405}); 
     
    299412 
    300413String.prototype.parseQuery = String.prototype.toQueryParams; 
     414 
     415Object.extend(String.prototype.escapeHTML, { 
     416  div:  document.createElement('div'), 
     417  text: document.createTextNode('') 
     418}); 
     419 
     420with (String.prototype.escapeHTML) div.appendChild(text); 
    301421 
    302422var Template = Class.create(); 
     
    317437} 
    318438 
    319 var $break    = new Object(); 
    320 var $continue = new Object(); 
     439var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead'); 
    321440 
    322441var Enumerable = { 
     
    325444    try { 
    326445      this._each(function(value) { 
    327         try { 
    328           iterator(value, index++); 
    329         } catch (e) { 
    330           if (e != $continue) throw e; 
    331         } 
     446        iterator(value, index++); 
    332447      }); 
    333448    } catch (e) { 
     
    531646} 
    532647 
     648if (Prototype.Browser.WebKit) { 
     649  $A = Array.from = function(iterable) { 
     650    if (!iterable) return []; 
     651    if (!(typeof iterable == 'function' && iterable == '[object NodeList]') && 
     652      iterable.toArray) { 
     653      return iterable.toArray(); 
     654    } else { 
     655      var results = []; 
     656      for (var i = 0, length = iterable.length; i < length; i++) 
     657        results.push(iterable[i]); 
     658      return results; 
     659    } 
     660  } 
     661} 
     662 
    533663Object.extend(Array.prototype, Enumerable); 
    534664 
     
    589719  }, 
    590720 
    591   uniq: function() { 
    592     return this.inject([], function(array, value) { 
    593       return array.include(value) ? array : array.concat([value]); 
     721  uniq: function(sorted) { 
     722    return this.inject([], function(array, value, index) { 
     723      if (0 == index || (sorted ? array.last() != value : !array.include(value))) 
     724        array.push(value); 
     725      return array; 
    594726    }); 
    595727  }, 
     
    605737  inspect: function() { 
    606738    return '[' + this.map(Object.inspect).join(', ') + ']'; 
     739  }, 
     740 
     741  toJSON: function() { 
     742    var results = []; 
     743    this.each(function(object) { 
     744      var value = Object.toJSON(object); 
     745      if (value !== undefined) results.push(value); 
     746    }); 
     747    return '[' + results.join(', ') + ']'; 
    607748  } 
    608749}); 
     
    610751Array.prototype.toArray = Array.prototype.clone; 
    611752 
    612 function $w(string)
     753function $w(string)
    613754  string = string.strip(); 
    614755  return string ? string.split(/\s+/) : []; 
    615756} 
    616757 
    617 if(window.opera){ 
    618   Array.prototype.concat = function()
     758if (Prototype.Browser.Opera){ 
     759  Array.prototype.concat = function()
    619760    var array = []; 
    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++) 
    624765          array.push(arguments[i][j]); 
    625766      } else { 
     
    630771  } 
    631772} 
    632 var Hash = function(obj) { 
    633   Object.extend(this, obj || {}); 
     773var Hash = function(object) { 
     774  if (object instanceof Hash) this.merge(object); 
     775  else Object.extend(this, object || {}); 
    634776}; 
    635777 
     
    637779  toQueryString: function(obj) { 
    638780    var parts = []; 
    639  
    640       this.prototype._each.call(obj, function(pair) { 
     781    parts.add = arguments.callee.addPair; 
     782 
     783    this.prototype._each.call(obj, function(pair) { 
    641784      if (!pair.key) return; 
    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; 
    654792      } 
    655       if (pair.value == undefined) pair[1] = ''; 
    656       parts.push(pair.map(encodeURIComponent).join('=')); 
    657       }); 
     793      parts.add(pair.key, value); 
     794    }); 
    658795 
    659796    return parts.join('&'); 
     797  }, 
     798 
     799  toJSON: function(object) { 
     800    var results = []; 
     801    this.prototype._each.call(object, function(pair) { 
     802      var value = Object.toJSON(pair.value); 
     803      if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value); 
     804    }); 
     805    return '{' + results.join(', ') + '}'; 
    660806  } 
    661807}); 
     808 
     809Hash.toQueryString.addPair = function(key, value, prefix) { 
     810  key = encodeURIComponent(key); 
     811  if (value === undefined) this.push(key); 
     812  else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value))); 
     813} 
    662814 
    663815Object.extend(Hash.prototype, Enumerable); 
     
    714866      return pair.map(Object.inspect).join(': '); 
    715867    }).join(', ') + '}>'; 
     868  }, 
     869 
     870  toJSON: function() { 
     871    return Hash.toJSON(this); 
    716872  } 
    717873}); 
    718874 
    719875function $H(object) { 
    720   if (object && object.constructor == Hash) return object; 
     876  if (object instanceof Hash) return object; 
    721877  return new Hash(object); 
     878}; 
     879 
     880// Safari iterates over shadowed properties 
     881if (function() { 
     882  var i = 0, Test = function(value) { this.key = value }; 
     883  Test.prototype.key = 'foo'; 
     884  for (var property in new Test('bar')) i++; 
     885  return i > 1; 
     886}()) Hash.prototype._each = function(iterator) { 
     887  var cache = []; 
     888  for (var key in this) { 
     889    var value = this[key]; 
     890    if ((value && value == Hash.prototype[key]) || cache.include(key)) continue; 
     891    cache.push(key); 
     892    var pair = [key, value]; 
     893    pair.key = key; 
     894    pair.value = value; 
     895    iterator(pair); 
     896  } 
    722897}; 
    723898ObjectRange = Class.create(); 
     
    8351010    this.url = url; 
    8361011    this.method = this.options.method; 
    837     var params = this.options.parameters
     1012    var params = Object.clone(this.options.parameters)
    8381013 
    8391014    if (!['get', 'post'].include(this.method)) { 
     
    8431018    } 
    8441019 
    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    } 
    8511029 
    8521030    try { 
     1031      if (this.options.onCreate) this.options.onCreate(this.transport); 
    8531032      Ajax.Responders.dispatch('onCreate', this, this.transport); 
    8541033 
     
    8621041      this.setRequestHeaders(); 
    8631042 
    864       var body = this.method == 'post' ? (this.options.postBody || params) : null; 
    865  
    866       this.transport.send(body); 
     1043      this.body = this.method == 'post' ? (this.options.postBody || params) : null; 
     1044      this.transport.send(this.body); 
    8671045 
    8681046      /* Force Firefox to handle ready state 4 for synchronous requests */ 
     
    9361114      } 
    9371115 
    938       if ((this.getHeader('Content-type') || 'text/javascript').strip(). 
     1116      var contentType = this.getHeader('Content-type'); 
     1117      if (contentType && contentType.strip(). 
    9391118        match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 
    9401119          this.evalResponse(); 
     
    9631142    try { 
    9641143      var json = this.getHeader('X-JSON'); 
    965       return json ? eval('(' + json + ')') : null; 
     1144      return json ? json.evalJSON() : null; 
    9661145    } catch (e) { return null } 
    9671146  }, 
     
    9691148  evalResponse: function() { 
    9701149    try { 
    971       return eval(this.transport.responseText); 
     1150      return eval((this.transport.responseText || '').unfilterJSON()); 
    9721151    } catch (e) { 
    9731152      this.dispatchException(e); 
     
    10841263    return results; 
    10851264  }; 
    1086 
    1087  
    1088 document.getElementsByClassName = function(className, parentElement) { 
    1089   if (Prototype.BrowserFeatures.XPath) { 
     1265 
     1266  document.getElementsByClassName = function(className, parentElement) { 
    10901267    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 
    10911268    return document._getElementsByXPath(q, parentElement); 
    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; 
    11021280}; 
    11031281 
    11041282/*--------------------------------------------------------------------------*/ 
    11051283 
    1106 if (!window.Element) 
    1107   var Element = new Object(); 
     1284if (!window.Element) var Element = {}; 
    11081285 
    11091286Element.extend = function(element) { 
    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), 
    11201298    Object.extend(methods, Element.Methods.Simulated); 
    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; 
    11301311  return element; 
    11311312}; 
     
    12131394 
    12141395  descendants: function(element) { 
    1215     return $A($(element).getElementsByTagName('*')); 
     1396    return $A($(element).getElementsByTagName('*')).each(Element.extend); 
     1397  }, 
     1398 
     1399  firstDescendant: function(element) { 
     1400    element = $(element).firstChild; 
     1401    while (element && element.nodeType != 1) element = element.nextSibling; 
     1402    return $(element); 
    12161403  }, 
    12171404 
     
    12431430 
    12441431  up: function(element, expression, index) { 
    1245     return Selector.findElement($(element).ancestors(), expression, index); 
     1432    element = $(element); 
     1433    if (arguments.length == 1) return $(element.parentNode); 
     1434    var ancestors = element.ancestors(); 
     1435    return expression ? Selector.findElement(ancestors, expression, index) : 
     1436      ancestors[index || 0]; 
    12461437  }, 
    12471438 
    12481439  down: function(element, expression, index) { 
    1249     return Selector.findElement($(element).descendants(), expression, index); 
     1440    element = $(element); 
     1441    if (arguments.length == 1) return element.firstDescendant(); 
     1442    var descendants = element.descendants(); 
     1443    return expression ? Selector.findElement(descendants, expression, index) : 
     1444      descendants[index || 0]; 
    12501445  }, 
    12511446 
    12521447  previous: function(element, expression, index) { 
    1253     return Selector.findElement($(element).previousSiblings(), expression, index); 
     1448    element = $(element); 
     1449    if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); 
     1450    var previousSiblings = element.previousSiblings(); 
     1451    return expression ? Selector.findElement(previousSiblings, expression, index) : 
     1452      previousSiblings[index || 0]; 
    12541453  }, 
    12551454 
    12561455  next: function(element, expression, index) { 
    1257     return Selector.findElement($(element).nextSiblings(), expression, index); 
     1456    element = $(element); 
     1457    if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); 
     1458    var nextSiblings = element.nextSiblings(); 
     1459    return expression ? Selector.findElement(nextSiblings, expression, index) : 
     1460      nextSiblings[index || 0]; 
    12581461  }, 
    12591462 
     
    12691472  readAttribute: function(element, name) { 
    12701473    element = $(element); 
    1271     if (document.all && !window.opera) { 
     1474    if (Prototype.Browser.IE) { 
     1475      if (!element.attributes) return null; 
    12721476      var t = Element._attributeTranslations; 
    12731477      if (t.values[name]) return t.values[name](element, name); 
    12741478      if (t.names[name])  name = t.names[name]; 
    12751479      var attribute = element.attributes[name]; 
    1276       if(attribute) return attribute.nodeValue
     1480      return attribute ? attribute.nodeValue : null
    12771481    } 
    12781482    return element.getAttribute(name); 
     
    13431547 
    13441548  empty: function(element) { 
    1345     return $(element).innerHTML.match(/^\s*$/); 
     1549    return $(element).innerHTML.blank(); 
    13461550  }, 
    13471551 
     
    13621566  getStyle: function(element, style) { 
    13631567    element = $(element); 
    1364     if (['float','cssFloat'].include(style)) 
    1365       style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 
    1366     style = style.camelize(); 
     1568    style = style == 'float' ? 'cssFloat' : style.camelize(); 
    13671569    var value = element.style[style]; 
    13681570    if (!value) { 
    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; 
    13881575    return value == 'auto' ? null : value; 
    13891576  }, 
    13901577 
    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; 
    14131600    return element; 
    14141601  }, 
     
    14841671}; 
    14851672 
    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 
     1673Object.extend(Element.Methods, { 
     1674  childOf: Element.Methods.descendantOf, 
     1675  childElements: Element.Methods.immediateDescendants 
    15291676}); 
    15301677 
    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){ 
     1678if (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
     1691else 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 
    15411725  Element.Methods.update = function(element, html) { 
    15421726    element = $(element); 
     
    15591743          depth = 4; 
    15601744      } 
    1561       $A(element.childNodes).each(function(node){ 
    1562         element.removeChild(node) 
    1563       }); 
    1564       depth.times(function(){ div = div.firstChild }); 
    1565  
    1566       $A(div.childNodes).each( 
    1567         function(node){ element.appendChild(node) }); 
     1745      $A(element.childNodes).each(function(node) { element.removeChild(node) }); 
     1746      depth.times(function() { div = div.firstChild }); 
     1747      $A(div.childNodes).each(function(node) { element.appendChild(node) }); 
    15681748    } else { 
    15691749      element.innerHTML = html.stripScripts(); 
    15701750    } 
    1571     setTimeout(function() {html.evalScripts()}, 10); 
     1751    setTimeout(function() { html.evalScripts() }, 10); 
    15721752    return element; 
    15731753  } 
     1754} 
     1755else 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 
     1764Element._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  } 
    15741792}; 
    15751793 
     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 
     1806Element.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 
     1815Element.Methods.ByTag = {}; 
     1816 
    15761817Object.extend(Element, Element.Methods); 
    15771818 
    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   }); 
     1819if (!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 
     1826Element.hasAttribute = function(element, attribute) { 
     1827  if (element.hasAttribute) return element.hasAttribute(attribute); 
     1828  return Element.Methods.Simulated.hasAttribute(element, attribute); 
     1829}; 
    15871830 
    15881831Element.addMethods = function(methods) { 
    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  } 
    15901862 
    15911863  function copy(methods, destination, onlyIfAbsent) { 
     
    15991871  } 
    16001872 
    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) { 
    16021899    copy(Element.Methods, HTMLElement.prototype); 
    16031900    copy(Element.Methods.Simulated, HTMLElement.prototype, true); 
    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 
     1915var Toggle = { display: Element.toggle }; 
    16141916 
    16151917/*--------------------------------------------------------------------------*/ 
     
    17422044 
    17432045Object.extend(Element.ClassNames.prototype, Enumerable); 
     2046/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, 
     2047 * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style 
     2048 * license.  Please see http://www.yui-ext.com/ for more information. */ 
     2049 
    17442050var Selector = Class.create(); 
     2051 
    17452052Selector.prototype = { 
    17462053  initialize: function(expression) { 
    1747     this.params = {classNames: []}; 
    1748     this.expression = expression.toString().strip(); 
    1749     this.parseExpression(); 
     2054    this.expression = expression.strip(); 
    17502055    this.compileMatcher(); 
    17512056  }, 
    17522057 
    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