Ticket #3645: scriptacproto.diff

File scriptacproto.diff, 204.2 KB (added by ryan, 5 years ago)

Prototype 1.5.0 and scriptaculous 1.7.0 patch

  • wp-includes/js/prototype.js

     
    1 /*  Prototype JavaScript framework, version 1.5.0_rc0 
    2  *  (c) 2005 Sam Stephenson <sam@conio.net> 
     1/*  Prototype JavaScript framework, version 1.5.0 
     2 *  (c) 2005-2007 Sam Stephenson 
    33 * 
    44 *  Prototype is freely distributable under the terms of an MIT-style license. 
    55 *  For details, see the Prototype web site: http://prototype.conio.net/ 
     
    77/*--------------------------------------------------------------------------*/ 
    88 
    99var Prototype = { 
    10   Version: '1.5.0_rc0', 
     10  Version: '1.5.0', 
     11  BrowserFeatures: { 
     12    XPath: !!document.evaluate 
     13  }, 
     14 
    1115  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 
    12  
    1316  emptyFunction: function() {}, 
    14   K: function(x) {return x} 
     17  K: function(x) { return x } 
    1518} 
    1619 
    1720var Class = { 
     
    3134  return destination; 
    3235} 
    3336 
    34 Object.inspect = function(object) { 
    35   try { 
    36     if (object == undefined) return 'undefined'; 
    37     if (object == null) return 'null'; 
    38     return object.inspect ? object.inspect() : object.toString(); 
    39   } catch (e) { 
    40     if (e instanceof RangeError) return '...'; 
    41     throw e; 
     37Object.extend(Object, { 
     38  inspect: function(object) { 
     39    try { 
     40      if (object === undefined) return 'undefined'; 
     41      if (object === null) return 'null'; 
     42      return object.inspect ? object.inspect() : object.toString(); 
     43    } catch (e) { 
     44      if (e instanceof RangeError) return '...'; 
     45      throw e; 
     46    } 
     47  }, 
     48 
     49  keys: function(object) { 
     50    var keys = []; 
     51    for (var property in object) 
     52      keys.push(property); 
     53    return keys; 
     54  }, 
     55 
     56  values: function(object) { 
     57    var values = []; 
     58    for (var property in object) 
     59      values.push(object[property]); 
     60    return values; 
     61  }, 
     62 
     63  clone: function(object) { 
     64    return Object.extend({}, object); 
    4265  } 
    43 } 
     66}); 
    4467 
    4568Function.prototype.bind = function() { 
    4669  var __method = this, args = $A(arguments), object = args.shift(); 
     
    5073} 
    5174 
    5275Function.prototype.bindAsEventListener = function(object) { 
    53   var __method = this; 
     76  var __method = this, args = $A(arguments), object = args.shift(); 
    5477  return function(event) { 
    55     return __method.call(object, event || window.event); 
     78    return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 
    5679  } 
    5780} 
    5881 
     
    77100  these: function() { 
    78101    var returnValue; 
    79102 
    80     for (var i = 0; i < arguments.length; i++) { 
     103    for (var i = 0, length = arguments.length; i < length; i++) { 
    81104      var lambda = arguments[i]; 
    82105      try { 
    83106        returnValue = lambda(); 
     
    102125  }, 
    103126 
    104127  registerCallback: function() { 
    105     setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 
     128    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 
    106129  }, 
    107130 
     131  stop: function() { 
     132    if (!this.timer) return; 
     133    clearInterval(this.timer); 
     134    this.timer = null; 
     135  }, 
     136 
    108137  onTimerEvent: function() { 
    109138    if (!this.currentlyExecuting) { 
    110139      try { 
    111140        this.currentlyExecuting = true; 
    112         this.callback(); 
     141        this.callback(this); 
    113142      } finally { 
    114143        this.currentlyExecuting = false; 
    115144      } 
    116145    } 
    117146  } 
    118147} 
     148String.interpret = function(value){ 
     149  return value == null ? '' : String(value); 
     150} 
     151 
    119152Object.extend(String.prototype, { 
    120153  gsub: function(pattern, replacement) { 
    121154    var result = '', source = this, match; 
     
    124157    while (source.length > 0) { 
    125158      if (match = source.match(pattern)) { 
    126159        result += source.slice(0, match.index); 
    127         result += (replacement(match) || '').toString(); 
     160        result += String.interpret(replacement(match)); 
    128161        source  = source.slice(match.index + match[0].length); 
    129162      } else { 
    130163        result += source, source = ''; 
     
    189222  unescapeHTML: function() { 
    190223    var div = document.createElement('div'); 
    191224    div.innerHTML = this.stripTags(); 
    192     return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; 
     225    return div.childNodes[0] ? (div.childNodes.length > 1 ? 
     226      $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 
     227      div.childNodes[0].nodeValue) : ''; 
    193228  }, 
    194229 
    195   toQueryParams: function() { 
    196     var pairs = this.match(/^\??(.*)$/)[1].split('&'); 
    197     return pairs.inject({}, function(params, pairString) { 
    198       var pair = pairString.split('='); 
    199       params[pair[0]] = pair[1]; 
    200       return params; 
     230  toQueryParams: function(separator) { 
     231    var match = this.strip().match(/([^?#]*)(#.*)?$/); 
     232    if (!match) return {}; 
     233 
     234    return match[1].split(separator || '&').inject({}, function(hash, pair) { 
     235      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); 
     243        } 
     244        else hash[name] = value; 
     245      } 
     246      return hash; 
    201247    }); 
    202248  }, 
    203249 
     
    205251    return this.split(''); 
    206252  }, 
    207253 
     254  succ: function() { 
     255    return this.slice(0, this.length - 1) + 
     256      String.fromCharCode(this.charCodeAt(this.length - 1) + 1); 
     257  }, 
     258 
    208259  camelize: function() { 
    209     var oStringList = this.split('-'); 
    210     if (oStringList.length == 1) return oStringList[0]; 
     260    var parts = this.split('-'), len = parts.length; 
     261    if (len == 1) return parts[0]; 
    211262 
    212     var camelizedString = this.indexOf('-') == 0 
    213       ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) 
    214       : oStringList[0]; 
     263    var camelized = this.charAt(0) == '-' 
     264      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) 
     265      : parts[0]; 
    215266 
    216     for (var i = 1, len = oStringList.length; i < len; i++) { 
    217       var s = oStringList[i]; 
    218       camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 
    219     } 
     267    for (var i = 1; i < len; i++) 
     268      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); 
    220269 
    221     return camelizedString; 
     270    return camelized; 
    222271  }, 
    223272 
    224   inspect: function() { 
    225     return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'"; 
     273  capitalize: function(){ 
     274    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 
     275  }, 
     276 
     277  underscore: function() { 
     278    return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); 
     279  }, 
     280 
     281  dasherize: function() { 
     282    return this.gsub(/_/,'-'); 
     283  }, 
     284 
     285  inspect: function(useDoubleQuotes) { 
     286    var escapedString = this.replace(/\\/g, '\\\\'); 
     287    if (useDoubleQuotes) 
     288      return '"' + escapedString.replace(/"/g, '\\"') + '"'; 
     289    else 
     290      return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 
    226291  } 
    227292}); 
    228293 
     
    246311    return this.template.gsub(this.pattern, function(match) { 
    247312      var before = match[1]; 
    248313      if (before == '\\') return match[2]; 
    249       return before + (object[match[3]] || '').toString(); 
     314      return before + String.interpret(object[match[3]]); 
    250315    }); 
    251316  } 
    252317} 
     
    268333    } catch (e) { 
    269334      if (e != $break) throw e; 
    270335    } 
     336    return this; 
    271337  }, 
    272338 
     339  eachSlice: function(number, iterator) { 
     340    var index = -number, slices = [], array = this.toArray(); 
     341    while ((index += number) < array.length) 
     342      slices.push(array.slice(index, index+number)); 
     343    return slices.map(iterator); 
     344  }, 
     345 
    273346  all: function(iterator) { 
    274347    var result = true; 
    275348    this.each(function(value, index) { 
     
    280353  }, 
    281354 
    282355  any: function(iterator) { 
    283     var result = true; 
     356    var result = false; 
    284357    this.each(function(value, index) { 
    285358      if (result = !!(iterator || Prototype.K)(value, index)) 
    286359        throw $break; 
     
    291364  collect: function(iterator) { 
    292365    var results = []; 
    293366    this.each(function(value, index) { 
    294       results.push(iterator(value, index)); 
     367      results.push((iterator || Prototype.K)(value, index)); 
    295368    }); 
    296369    return results; 
    297370  }, 
    298371 
    299   detect: function (iterator) { 
     372  detect: function(iterator) { 
    300373    var result; 
    301374    this.each(function(value, index) { 
    302375      if (iterator(value, index)) { 
     
    337410    return found; 
    338411  }, 
    339412 
     413  inGroupsOf: function(number, fillWith) { 
     414    fillWith = fillWith === undefined ? null : fillWith; 
     415    return this.eachSlice(number, function(slice) { 
     416      while(slice.length < number) slice.push(fillWith); 
     417      return slice; 
     418    }); 
     419  }, 
     420 
    340421  inject: function(memo, iterator) { 
    341422    this.each(function(value, index) { 
    342423      memo = iterator(memo, value, index); 
     
    346427 
    347428  invoke: function(method) { 
    348429    var args = $A(arguments).slice(1); 
    349     return this.collect(function(value) { 
     430    return this.map(function(value) { 
    350431      return value[method].apply(value, args); 
    351432    }); 
    352433  }, 
     
    398479  }, 
    399480 
    400481  sortBy: function(iterator) { 
    401     return this.collect(function(value, index) { 
     482    return this.map(function(value, index) { 
    402483      return {value: value, criteria: iterator(value, index)}; 
    403484    }).sort(function(left, right) { 
    404485      var a = left.criteria, b = right.criteria; 
     
    407488  }, 
    408489 
    409490  toArray: function() { 
    410     return this.collect(Prototype.K); 
     491    return this.map(); 
    411492  }, 
    412493 
    413494  zip: function() { 
     
    421502    }); 
    422503  }, 
    423504 
     505  size: function() { 
     506    return this.toArray().length; 
     507  }, 
     508 
    424509  inspect: function() { 
    425510    return '#<Enumerable:' + this.toArray().inspect() + '>'; 
    426511  } 
     
    439524    return iterable.toArray(); 
    440525  } else { 
    441526    var results = []; 
    442     for (var i = 0; i < iterable.length; i++) 
     527    for (var i = 0, length = iterable.length; i < length; i++) 
    443528      results.push(iterable[i]); 
    444529    return results; 
    445530  } 
     
    452537 
    453538Object.extend(Array.prototype, { 
    454539  _each: function(iterator) { 
    455     for (var i = 0; i < this.length; i++) 
     540    for (var i = 0, length = this.length; i < length; i++) 
    456541      iterator(this[i]); 
    457542  }, 
    458543 
     
    471556 
    472557  compact: function() { 
    473558    return this.select(function(value) { 
    474       return value != undefined || value != null; 
     559      return value != null; 
    475560    }); 
    476561  }, 
    477562 
     
    490575  }, 
    491576 
    492577  indexOf: function(object) { 
    493     for (var i = 0; i < this.length; i++) 
     578    for (var i = 0, length = this.length; i < length; i++) 
    494579      if (this[i] == object) return i; 
    495580    return -1; 
    496581  }, 
     
    499584    return (inline !== false ? this : this.toArray())._reverse(); 
    500585  }, 
    501586 
     587  reduce: function() { 
     588    return this.length > 1 ? this : this[0]; 
     589  }, 
     590 
     591  uniq: function() { 
     592    return this.inject([], function(array, value) { 
     593      return array.include(value) ? array : array.concat([value]); 
     594    }); 
     595  }, 
     596 
     597  clone: function() { 
     598    return [].concat(this); 
     599  }, 
     600 
     601  size: function() { 
     602    return this.length; 
     603  }, 
     604 
    502605  inspect: function() { 
    503606    return '[' + this.map(Object.inspect).join(', ') + ']'; 
    504607  } 
    505608}); 
    506 var Hash = { 
     609 
     610Array.prototype.toArray = Array.prototype.clone; 
     611 
     612function $w(string){ 
     613  string = string.strip(); 
     614  return string ? string.split(/\s+/) : []; 
     615} 
     616 
     617if(window.opera){ 
     618  Array.prototype.concat = function(){ 
     619    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++) 
     624          array.push(arguments[i][j]); 
     625      } else { 
     626        array.push(arguments[i]); 
     627      } 
     628    } 
     629    return array; 
     630  } 
     631} 
     632var Hash = function(obj) { 
     633  Object.extend(this, obj || {}); 
     634}; 
     635 
     636Object.extend(Hash, { 
     637  toQueryString: function(obj) { 
     638    var parts = []; 
     639 
     640          this.prototype._each.call(obj, function(pair) { 
     641      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        } 
     654      } 
     655      if (pair.value == undefined) pair[1] = ''; 
     656      parts.push(pair.map(encodeURIComponent).join('=')); 
     657          }); 
     658 
     659    return parts.join('&'); 
     660  } 
     661}); 
     662 
     663Object.extend(Hash.prototype, Enumerable); 
     664Object.extend(Hash.prototype, { 
    507665  _each: function(iterator) { 
    508666    for (var key in this) { 
    509667      var value = this[key]; 
    510       if (typeof value == 'function') continue; 
     668      if (value && value == Hash.prototype[key]) continue; 
    511669 
    512670      var pair = [key, value]; 
    513671      pair.key = key; 
     
    525683  }, 
    526684 
    527685  merge: function(hash) { 
    528     return $H(hash).inject($H(this), function(mergedHash, pair) { 
     686    return $H(hash).inject(this, function(mergedHash, pair) { 
    529687      mergedHash[pair.key] = pair.value; 
    530688      return mergedHash; 
    531689    }); 
    532690  }, 
    533691 
     692  remove: function() { 
     693    var result; 
     694    for(var i = 0, length = arguments.length; i < length; i++) { 
     695      var value = this[arguments[i]]; 
     696      if (value !== undefined){ 
     697        if (result === undefined) result = value; 
     698        else { 
     699          if (result.constructor != Array) result = [result]; 
     700          result.push(value) 
     701        } 
     702      } 
     703      delete this[arguments[i]]; 
     704    } 
     705    return result; 
     706  }, 
     707 
    534708  toQueryString: function() { 
    535     return this.map(function(pair) { 
    536       return pair.map(encodeURIComponent).join('='); 
    537     }).join('&'); 
     709    return Hash.toQueryString(this); 
    538710  }, 
    539711 
    540712  inspect: function() { 
     
    542714      return pair.map(Object.inspect).join(': '); 
    543715    }).join(', ') + '}>'; 
    544716  } 
    545 } 
     717}); 
    546718 
    547719function $H(object) { 
    548   var hash = Object.extend({}, object || {}); 
    549   Object.extend(hash, Enumerable); 
    550   Object.extend(hash, Hash); 
    551   return hash; 
    552 } 
     720  if (object && object.constructor == Hash) return object; 
     721  return new Hash(object); 
     722}; 
    553723ObjectRange = Class.create(); 
    554724Object.extend(ObjectRange.prototype, Enumerable); 
    555725Object.extend(ObjectRange.prototype, { 
     
    561731 
    562732  _each: function(iterator) { 
    563733    var value = this.start; 
    564     do { 
     734    while (this.include(value)) { 
    565735      iterator(value); 
    566736      value = value.succ(); 
    567     } while (this.include(value)); 
     737    } 
    568738  }, 
    569739 
    570740  include: function(value) { 
     
    599769    this.responders._each(iterator); 
    600770  }, 
    601771 
    602   register: function(responderToAdd) { 
    603     if (!this.include(responderToAdd)) 
    604       this.responders.push(responderToAdd); 
     772  register: function(responder) { 
     773    if (!this.include(responder)) 
     774      this.responders.push(responder); 
    605775  }, 
    606776 
    607   unregister: function(responderToRemove) { 
    608     this.responders = this.responders.without(responderToRemove); 
     777  unregister: function(responder) { 
     778    this.responders = this.responders.without(responder); 
    609779  }, 
    610780 
    611781  dispatch: function(callback, request, transport, json) { 
    612782    this.each(function(responder) { 
    613       if (responder[callback] && typeof responder[callback] == 'function') { 
     783      if (typeof responder[callback] == 'function') { 
    614784        try { 
    615785          responder[callback].apply(responder, [request, transport, json]); 
    616786        } catch (e) {} 
     
    625795  onCreate: function() { 
    626796    Ajax.activeRequestCount++; 
    627797  }, 
    628  
    629798  onComplete: function() { 
    630799    Ajax.activeRequestCount--; 
    631800  } 
     
    638807      method:       'post', 
    639808      asynchronous: true, 
    640809      contentType:  'application/x-www-form-urlencoded', 
     810      encoding:     'UTF-8', 
    641811      parameters:   '' 
    642812    } 
    643813    Object.extend(this.options, options || {}); 
    644   }, 
    645814 
    646   responseIsSuccess: function() { 
    647     return this.transport.status == undefined 
    648         || this.transport.status == 0 
    649         || (this.transport.status >= 200 && this.transport.status < 300); 
    650   }, 
    651  
    652   responseIsFailure: function() { 
    653     return !this.responseIsSuccess(); 
     815    this.options.method = this.options.method.toLowerCase(); 
     816    if (typeof this.options.parameters == 'string') 
     817      this.options.parameters = this.options.parameters.toQueryParams(); 
    654818  } 
    655819} 
    656820 
     
    659823  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; 
    660824 
    661825Ajax.Request.prototype = Object.extend(new Ajax.Base(), { 
     826  _complete: false, 
     827 
    662828  initialize: function(url, options) { 
    663829    this.transport = Ajax.getTransport(); 
    664830    this.setOptions(options); 
     
    666832  }, 
    667833 
    668834  request: function(url) { 
    669     var parameters = this.options.parameters || ''; 
    670     if (parameters.length > 0) parameters += '&_='; 
     835    this.url = url; 
     836    this.method = this.options.method; 
     837    var params = this.options.parameters; 
    671838 
     839    if (!['get', 'post'].include(this.method)) { 
     840      // simulate other verbs over post 
     841      params['_method'] = this.method; 
     842      this.method = 'post'; 
     843    } 
     844 
     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; 
     851 
    672852    try { 
    673       this.url = url; 
    674       if (this.options.method == 'get' && parameters.length > 0) 
    675         this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; 
    676  
    677853      Ajax.Responders.dispatch('onCreate', this, this.transport); 
    678854 
    679       this.transport.open(this.options.method, this.url, 
     855      this.transport.open(this.method.toUpperCase(), this.url, 
    680856        this.options.asynchronous); 
    681857 
    682       if (this.options.asynchronous) { 
    683         this.transport.onreadystatechange = this.onStateChange.bind(this); 
    684         setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); 
    685       } 
     858      if (this.options.asynchronous) 
     859        setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); 
    686860 
     861      this.transport.onreadystatechange = this.onStateChange.bind(this); 
    687862      this.setRequestHeaders(); 
    688863 
    689       var body = this.options.postBody ? this.options.postBody : parameters; 
    690       this.transport.send(this.options.method == 'post' ? body : null); 
     864      var body = this.method == 'post' ? (this.options.postBody || params) : null; 
    691865 
    692     } catch (e) { 
     866      this.transport.send(body); 
     867 
     868      /* Force Firefox to handle ready state 4 for synchronous requests */ 
     869      if (!this.options.asynchronous && this.transport.overrideMimeType) 
     870        this.onStateChange(); 
     871 
     872    } 
     873    catch (e) { 
    693874      this.dispatchException(e); 
    694875    } 
    695876  }, 
    696877 
     878  onStateChange: function() { 
     879    var readyState = this.transport.readyState; 
     880    if (readyState > 1 && !((readyState == 4) && this._complete)) 
     881      this.respondToReadyState(this.transport.readyState); 
     882  }, 
     883 
    697884  setRequestHeaders: function() { 
    698     var requestHeaders = 
    699       ['X-Requested-With', 'XMLHttpRequest', 
    700        'X-Prototype-Version', Prototype.Version, 
    701        'Accept', 'text/javascript, text/html, application/xml, text/xml, */*']; 
     885    var headers = { 
     886      'X-Requested-With': 'XMLHttpRequest', 
     887      'X-Prototype-Version': Prototype.Version, 
     888      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 
     889    }; 
    702890 
    703     if (this.options.method == 'post') { 
    704       requestHeaders.push('Content-type', this.options.contentType); 
     891    if (this.method == 'post') { 
     892      headers['Content-type'] = this.options.contentType + 
     893        (this.options.encoding ? '; charset=' + this.options.encoding : ''); 
    705894 
    706       /* Force "Connection: close" for Mozilla browsers to work around 
    707        * a bug where XMLHttpReqeuest sends an incorrect Content-length 
    708        * header. See Mozilla Bugzilla #246651. 
     895      /* Force "Connection: close" for older Mozilla browsers to work 
     896       * around a bug where XMLHttpRequest sends an incorrect 
     897       * Content-length header. See Mozilla Bugzilla #246651. 
    709898       */ 
    710       if (this.transport.overrideMimeType) 
    711         requestHeaders.push('Connection', 'close'); 
     899      if (this.transport.overrideMimeType && 
     900          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) 
     901            headers['Connection'] = 'close'; 
    712902    } 
    713903 
    714     if (this.options.requestHeaders) 
    715       requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); 
     904    // user-defined headers 
     905    if (typeof this.options.requestHeaders == 'object') { 
     906      var extras = this.options.requestHeaders; 
    716907 
    717     for (var i = 0; i < requestHeaders.length; i += 2) 
    718       this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); 
    719   }, 
     908      if (typeof extras.push == 'function') 
     909        for (var i = 0, length = extras.length; i < length; i += 2) 
     910          headers[extras[i]] = extras[i+1]; 
     911      else 
     912        $H(extras).each(function(pair) { headers[pair.key] = pair.value }); 
     913    } 
    720914 
    721   onStateChange: function() { 
    722     var readyState = this.transport.readyState; 
    723     if (readyState != 1) 
    724       this.respondToReadyState(this.transport.readyState); 
     915    for (var name in headers) 
     916      this.transport.setRequestHeader(name, headers[name]); 
    725917  }, 
    726918 
    727   header: function(name) { 
    728     try { 
    729       return this.transport.getResponseHeader(name); 
    730     } catch (e) {} 
     919  success: function() { 
     920    return !this.transport.status 
     921        || (this.transport.status >= 200 && this.transport.status < 300); 
    731922  }, 
    732923 
    733   evalJSON: function() { 
    734     try { 
    735       return eval('(' + this.header('X-JSON') + ')'); 
    736     } catch (e) {} 
    737   }, 
    738  
    739   evalResponse: function() { 
    740     try { 
    741       return eval(this.transport.responseText); 
    742     } catch (e) { 
    743       this.dispatchException(e); 
    744     } 
    745   }, 
    746  
    747924  respondToReadyState: function(readyState) { 
    748     var event = Ajax.Request.Events[readyState]; 
     925    var state = Ajax.Request.Events[readyState]; 
    749926    var transport = this.transport, json = this.evalJSON(); 
    750927 
    751     if (event == 'Complete') { 
     928    if (state == 'Complete') { 
    752929      try { 
     930        this._complete = true; 
    753931        (this.options['on' + this.transport.status] 
    754          || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] 
     932         || this.options['on' + (this.success() ? 'Success' : 'Failure')] 
    755933         || Prototype.emptyFunction)(transport, json); 
    756934      } catch (e) { 
    757935        this.dispatchException(e); 
    758936      } 
    759937 
    760       if ((this.header('Content-type') || '').match(/^text\/javascript/i)) 
    761         this.evalResponse(); 
     938      if ((this.getHeader('Content-type') || 'text/javascript').strip(). 
     939        match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 
     940          this.evalResponse(); 
    762941    } 
    763942 
    764943    try { 
    765       (this.options['on' + event] || Prototype.emptyFunction)(transport, json); 
    766       Ajax.Responders.dispatch('on' + event, this, transport, json); 
     944      (this.options['on' + state] || Prototype.emptyFunction)(transport, json); 
     945      Ajax.Responders.dispatch('on' + state, this, transport, json); 
    767946    } catch (e) { 
    768947      this.dispatchException(e); 
    769948    } 
    770949 
    771     /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ 
    772     if (event == 'Complete') 
     950    if (state == 'Complete') { 
     951      // avoid memory leak in MSIE: clean up 
    773952      this.transport.onreadystatechange = Prototype.emptyFunction; 
     953    } 
    774954  }, 
    775955 
     956  getHeader: function(name) { 
     957    try { 
     958      return this.transport.getResponseHeader(name); 
     959    } catch (e) { return null } 
     960  }, 
     961 
     962  evalJSON: function() { 
     963    try { 
     964      var json = this.getHeader('X-JSON'); 
     965      return json ? eval('(' + json + ')') : null; 
     966    } catch (e) { return null } 
     967  }, 
     968 
     969  evalResponse: function() { 
     970    try { 
     971      return eval(this.transport.responseText); 
     972    } catch (e) { 
     973      this.dispatchException(e); 
     974    } 
     975  }, 
     976 
    776977  dispatchException: function(exception) { 
    777978    (this.options.onException || Prototype.emptyFunction)(this, exception); 
    778979    Ajax.Responders.dispatch('onException', this, exception); 
     
    783984 
    784985Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { 
    785986  initialize: function(container, url, options) { 
    786     this.containers = { 
    787       success: container.success ? $(container.success) : $(container), 
    788       failure: container.failure ? $(container.failure) : 
    789         (container.success ? null : $(container)) 
     987    this.container = { 
     988      success: (container.success || container), 
     989      failure: (container.failure || (container.success ? null : container)) 
    790990    } 
    791991 
    792992    this.transport = Ajax.getTransport(); 
    793993    this.setOptions(options); 
    794994 
    795995    var onComplete = this.options.onComplete || Prototype.emptyFunction; 
    796     this.options.onComplete = (function(transport, object) { 
     996    this.options.onComplete = (function(transport, param) { 
    797997      this.updateContent(); 
    798       onComplete(transport, object); 
     998      onComplete(transport, param); 
    799999    }).bind(this); 
    8001000 
    8011001    this.request(url); 
    8021002  }, 
    8031003 
    8041004  updateContent: function() { 
    805     var receiver = this.responseIsSuccess() ? 
    806       this.containers.success : this.containers.failure; 
     1005    var receiver = this.container[this.success() ? 'success' : 'failure']; 
    8071006    var response = this.transport.responseText; 
    8081007 
    809     if (!this.options.evalScripts) 
    810       response = response.stripScripts(); 
     1008    if (!this.options.evalScripts) response = response.stripScripts(); 
    8111009 
    812     if (receiver) { 
    813       if (this.options.insertion) { 
     1010    if (receiver = $(receiver)) { 
     1011      if (this.options.insertion) 
    8141012        new this.options.insertion(receiver, response); 
    815       } else { 
    816         Element.update(receiver, response); 
    817       } 
     1013      else 
     1014        receiver.update(response); 
    8181015    } 
    8191016 
    820     if (this.responseIsSuccess()) { 
     1017    if (this.success()) { 
    8211018      if (this.onComplete) 
    8221019        setTimeout(this.onComplete.bind(this), 10); 
    8231020    } 
     
    8461043  }, 
    8471044 
    8481045  stop: function() { 
    849     this.updater.onComplete = undefined; 
     1046    this.updater.options.onComplete = undefined; 
    8501047    clearTimeout(this.timer); 
    8511048    (this.onComplete || Prototype.emptyFunction).apply(this, arguments); 
    8521049  }, 
     
    8661063    this.updater = new Ajax.Updater(this.container, this.url, this.options); 
    8671064  } 
    8681065}); 
    869 function $() { 
    870   var results = [], element; 
    871   for (var i = 0; i < arguments.length; i++) { 
    872     element = arguments[i]; 
    873     if (typeof element == 'string') 
    874       element = document.getElementById(element); 
    875     results.push(Element.extend(element)); 
     1066function $(element) { 
     1067  if (arguments.length > 1) { 
     1068    for (var i = 0, elements = [], length = arguments.length; i < length; i++) 
     1069      elements.push($(arguments[i])); 
     1070    return elements; 
    8761071  } 
    877   return results.length < 2 ? results[0] : results; 
     1072  if (typeof element == 'string') 
     1073    element = document.getElementById(element); 
     1074  return Element.extend(element); 
    8781075} 
    8791076 
     1077if (Prototype.BrowserFeatures.XPath) { 
     1078  document._getElementsByXPath = function(expression, parentElement) { 
     1079    var results = []; 
     1080    var query = document.evaluate(expression, $(parentElement) || document, 
     1081      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
     1082    for (var i = 0, length = query.snapshotLength; i < length; i++) 
     1083      results.push(query.snapshotItem(i)); 
     1084    return results; 
     1085  }; 
     1086} 
     1087 
    8801088document.getElementsByClassName = function(className, parentElement) { 
    881   var children = ($(parentElement) || document.body).getElementsByTagName('*'); 
    882   return $A(children).inject([], function(elements, child) { 
    883     if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
    884       elements.push(Element.extend(child)); 
     1089  if (Prototype.BrowserFeatures.XPath) { 
     1090    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 
     1091    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    } 
    8851100    return elements; 
    886   }); 
    887 } 
     1101  } 
     1102}; 
    8881103 
    8891104/*--------------------------------------------------------------------------*/ 
    8901105 
     
    8921107  var Element = new Object(); 
    8931108 
    8941109Element.extend = function(element) { 
    895   if (!element) return; 
    896   if (_nativeExtensions) return element; 
     1110  if (!element || _nativeExtensions || element.nodeType == 3) return element; 
    8971111 
    8981112  if (!element._extended && element.tagName && element != window) { 
    899     var methods = Element.Methods, cache = Element.extend.cache; 
    900     for (property in methods) { 
     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 
     1120    Object.extend(methods, Element.Methods.Simulated); 
     1121 
     1122    for (var property in methods) { 
    9011123      var value = methods[property]; 
    902       if (typeof value == 'function') 
     1124      if (typeof value == 'function' && !(property in element)) 
    9031125        element[property] = cache.findOrStore(value); 
    9041126    } 
    9051127  } 
    9061128 
    9071129  element._extended = true; 
    9081130  return element; 
    909 } 
     1131}; 
    9101132 
    9111133Element.extend.cache = { 
    9121134  findOrStore: function(value) { 
     
    9141136      return value.apply(null, [this].concat($A(arguments))); 
    9151137    } 
    9161138  } 
    917 } 
     1139}; 
    9181140 
    9191141Element.Methods = { 
    9201142  visible: function(element) { 
    9211143    return $(element).style.display != 'none'; 
    9221144  }, 
    9231145 
    924   toggle: function() { 
    925     for (var i = 0; i < arguments.length; i++) { 
    926       var element = $(arguments[i]); 
    927       Element[Element.visible(element) ? 'hide' : 'show'](element); 
    928     } 
     1146  toggle: function(element) { 
     1147    element = $(element); 
     1148    Element[Element.visible(element) ? 'hide' : 'show'](element); 
     1149    return element; 
    9291150  }, 
    9301151 
    931   hide: function() { 
    932     for (var i = 0; i < arguments.length; i++) { 
    933       var element = $(arguments[i]); 
    934       element.style.display = 'none'; 
    935     } 
     1152  hide: function(element) { 
     1153    $(element).style.display = 'none'; 
     1154    return element; 
    9361155  }, 
    9371156 
    938   show: function() { 
    939     for (var i = 0; i < arguments.length; i++) { 
    940       var element = $(arguments[i]); 
    941       element.style.display = ''; 
    942     } 
     1157  show: function(element) { 
     1158    $(element).style.display = ''; 
     1159    return element; 
    9431160  }, 
    9441161 
    9451162  remove: function(element) { 
    9461163    element = $(element); 
    9471164    element.parentNode.removeChild(element); 
     1165    return element; 
    9481166  }, 
    9491167 
    9501168  update: function(element, html) { 
     1169    html = typeof html == 'undefined' ? '' : html.toString(); 
    9511170    $(element).innerHTML = html.stripScripts(); 
    9521171    setTimeout(function() {html.evalScripts()}, 10); 
     1172    return element; 
    9531173  }, 
    9541174 
    9551175  replace: function(element, html) { 
    9561176    element = $(element); 
     1177    html = typeof html == 'undefined' ? '' : html.toString(); 
    9571178    if (element.outerHTML) { 
    9581179      element.outerHTML = html.stripScripts(); 
    9591180    } else { 
     
    9631184        range.createContextualFragment(html.stripScripts()), element); 
    9641185    } 
    9651186    setTimeout(function() {html.evalScripts()}, 10); 
     1187    return element; 
    9661188  }, 
    9671189 
    968   getHeight: function(element) { 
     1190  inspect: function(element) { 
    9691191    element = $(element); 
    970     return element.offsetHeight; 
     1192    var result = '<' + element.tagName.toLowerCase(); 
     1193    $H({'id': 'id', 'className': 'class'}).each(function(pair) { 
     1194      var property = pair.first(), attribute = pair.last(); 
     1195      var value = (element[property] || '').toString(); 
     1196      if (value) result += ' ' + attribute + '=' + value.inspect(true); 
     1197    }); 
     1198    return result + '>'; 
    9711199  }, 
    9721200 
     1201  recursivelyCollect: function(element, property) { 
     1202    element = $(element); 
     1203    var elements = []; 
     1204    while (element = element[property]) 
     1205      if (element.nodeType == 1) 
     1206        elements.push(Element.extend(element)); 
     1207    return elements; 
     1208  }, 
     1209 
     1210  ancestors: function(element) { 
     1211    return $(element).recursivelyCollect('parentNode'); 
     1212  }, 
     1213 
     1214  descendants: function(element) { 
     1215    return $A($(element).getElementsByTagName('*')); 
     1216  }, 
     1217 
     1218  immediateDescendants: function(element) { 
     1219    if (!(element = $(element).firstChild)) return []; 
     1220    while (element && element.nodeType != 1) element = element.nextSibling; 
     1221    if (element) return [element].concat($(element).nextSiblings()); 
     1222    return []; 
     1223  }, 
     1224 
     1225  previousSiblings: function(element) { 
     1226    return $(element).recursivelyCollect('previousSibling'); 
     1227  }, 
     1228 
     1229  nextSiblings: function(element) { 
     1230    return $(element).recursivelyCollect('nextSibling'); 
     1231  }, 
     1232 
     1233  siblings: function(element) { 
     1234    element = $(element); 
     1235    return element.previousSiblings().reverse().concat(element.nextSiblings()); 
     1236  }, 
     1237 
     1238  match: function(element, selector) { 
     1239    if (typeof selector == 'string') 
     1240      selector = new Selector(selector); 
     1241    return selector.match($(element)); 
     1242  }, 
     1243 
     1244  up: function(element, expression, index) { 
     1245    return Selector.findElement($(element).ancestors(), expression, index); 
     1246  }, 
     1247 
     1248  down: function(element, expression, index) { 
     1249    return Selector.findElement($(element).descendants(), expression, index); 
     1250  }, 
     1251 
     1252  previous: function(element, expression, index) { 
     1253    return Selector.findElement($(element).previousSiblings(), expression, index); 
     1254  }, 
     1255 
     1256  next: function(element, expression, index) { 
     1257    return Selector.findElement($(element).nextSiblings(), expression, index); 
     1258  }, 
     1259 
     1260  getElementsBySelector: function() { 
     1261    var args = $A(arguments), element = $(args.shift()); 
     1262    return Selector.findChildElements(element, args); 
     1263  }, 
     1264 
     1265  getElementsByClassName: function(element, className) { 
     1266    return document.getElementsByClassName(className, element); 
     1267  }, 
     1268 
     1269  readAttribute: function(element, name) { 
     1270    element = $(element); 
     1271    if (document.all && !window.opera) { 
     1272      var t = Element._attributeTranslations; 
     1273      if (t.values[name]) return t.values[name](element, name); 
     1274      if (t.names[name])  name = t.names[name]; 
     1275      var attribute = element.attributes[name]; 
     1276      if(attribute) return attribute.nodeValue; 
     1277    } 
     1278    return element.getAttribute(name); 
     1279  }, 
     1280 
     1281  getHeight: function(element) { 
     1282    return $(element).getDimensions().height; 
     1283  }, 
     1284 
     1285  getWidth: function(element) { 
     1286    return $(element).getDimensions().width; 
     1287  }, 
     1288 
    9731289  classNames: function(element) { 
    9741290    return new Element.ClassNames(element); 
    9751291  }, 
    9761292 
    9771293  hasClassName: function(element, className) { 
    9781294    if (!(element = $(element))) return; 
    979     return Element.classNames(element).include(className); 
     1295    var elementClassName = element.className; 
     1296    if (elementClassName.length == 0) return false; 
     1297    if (elementClassName == className || 
     1298        elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
     1299      return true; 
     1300    return false; 
    9801301  }, 
    9811302 
    9821303  addClassName: function(element, className) { 
    9831304    if (!(element = $(element))) return; 
    984     return Element.classNames(element).add(className); 
     1305    Element.classNames(element).add(className); 
     1306    return element; 
    9851307  }, 
    9861308 
    9871309  removeClassName: function(element, className) { 
    9881310    if (!(element = $(element))) return; 
    989     return Element.classNames(element).remove(className); 
     1311    Element.classNames(element).remove(className); 
     1312    return element; 
    9901313  }, 
    9911314 
     1315  toggleClassName: function(element, className) { 
     1316    if (!(element = $(element))) return; 
     1317    Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); 
     1318    return element; 
     1319  }, 
     1320 
     1321  observe: function() { 
     1322    Event.observe.apply(Event, arguments); 
     1323    return $A(arguments).first(); 
     1324  }, 
     1325 
     1326  stopObserving: function() { 
     1327    Event.stopObserving.apply(Event, arguments); 
     1328    return $A(arguments).first(); 
     1329  }, 
     1330 
    9921331  // removes whitespace-only text node children 
    9931332  cleanWhitespace: function(element) { 
    9941333    element = $(element); 
    995     for (var i = 0; i < element.childNodes.length; i++) { 
    996       var node = element.childNodes[i]; 
     1334    var node = element.firstChild; 
     1335    while (node) { 
     1336      var nextNode = node.nextSibling; 
    9971337      if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
    998         Element.remove(node); 
     1338        element.removeChild(node); 
     1339      node = nextNode; 
    9991340    } 
     1341    return element; 
    10001342  }, 
    10011343 
    10021344  empty: function(element) { 
    10031345    return $(element).innerHTML.match(/^\s*$/); 
    10041346  }, 
    10051347 
    1006   childOf: function(element, ancestor) { 
     1348  descendantOf: function(element, ancestor) { 
    10071349    element = $(element), ancestor = $(ancestor); 
    10081350    while (element = element.parentNode) 
    10091351      if (element == ancestor) return true; 
     
    10121354 
    10131355  scrollTo: function(element) { 
    10141356    element = $(element); 
    1015     var x = element.x ? element.x : element.offsetLeft, 
    1016         y = element.y ? element.y : element.offsetTop; 
    1017     window.scrollTo(x, y); 
     1357    var pos = Position.cumulativeOffset(element); 
     1358    window.scrollTo(pos[0], pos[1]); 
     1359    return element; 
    10181360  }, 
    10191361 
    10201362  getStyle: function(element, style) { 
    10211363    element = $(element); 
    1022     var value = element.style[style.camelize()]; 
     1364    if (['float','cssFloat'].include(style)) 
     1365      style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 
     1366    style = style.camelize(); 
     1367    var value = element.style[style]; 
    10231368    if (!value) { 
    10241369      if (document.defaultView && document.defaultView.getComputedStyle) { 
    10251370        var css = document.defaultView.getComputedStyle(element, null); 
    1026         value = css ? css.getPropertyValue(style) : null; 
     1371        value = css ? css[style] : null; 
    10271372      } else if (element.currentStyle) { 
    1028         value = element.currentStyle[style.camelize()]; 
     1373        value = element.currentStyle[style]; 
    10291374      } 
    10301375    } 
    10311376 
     1377    if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) 
     1378      value = element['offset'+style.capitalize()] + 'px'; 
     1379 
    10321380    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 
    10331381      if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 
    1034  
     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    } 
    10351388    return value == 'auto' ? null : value; 
    10361389  }, 
    10371390 
    10381391  setStyle: function(element, style) { 
    10391392    element = $(element); 
    1040     for (var name in style) 
    1041       element.style[name.camelize()] = style[name]; 
     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    } 
     1413    return element; 
    10421414  }, 
    10431415 
    10441416  getDimensions: function(element) { 
    10451417    element = $(element); 
    1046     if (Element.getStyle(element, 'display') != 'none') 
     1418    var display = $(element).getStyle('display'); 
     1419    if (display != 'none' && display != null) // Safari bug 
    10471420      return {width: element.offsetWidth, height: element.offsetHeight}; 
    10481421 
    10491422    // All *Width and *Height properties give 0 on elements with display none, 
     
    10511424    var els = element.style; 
    10521425    var originalVisibility = els.visibility; 
    10531426    var originalPosition = els.position; 
     1427    var originalDisplay = els.display; 
    10541428    els.visibility = 'hidden'; 
    10551429    els.position = 'absolute'; 
    1056     els.display = ''; 
     1430    els.display = 'block'; 
    10571431    var originalWidth = element.clientWidth; 
    10581432    var originalHeight = element.clientHeight; 
    1059     els.display = 'none'; 
     1433    els.display = originalDisplay; 
    10601434    els.position = originalPosition; 
    10611435    els.visibility = originalVisibility; 
    10621436    return {width: originalWidth, height: originalHeight}; 
     
    10751449        element.style.left = 0; 
    10761450      } 
    10771451    } 
     1452    return element; 
    10781453  }, 
    10791454 
    10801455  undoPositioned: function(element) { 
     
    10871462        element.style.bottom = 
    10881463        element.style.right = ''; 
    10891464    } 
     1465    return element; 
    10901466  }, 
    10911467 
    10921468  makeClipping: function(element) { 
    10931469    element = $(element); 
    1094     if (element._overflow) return; 
    1095     element._overflow = element.style.overflow; 
     1470    if (element._overflow) return element; 
     1471    element._overflow = element.style.overflow || 'auto'; 
    10961472    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') 
    10971473      element.style.overflow = 'hidden'; 
     1474    return element; 
    10981475  }, 
    10991476 
    11001477  undoClipping: function(element) { 
    11011478    element = $(element); 
    1102     if (element._overflow) return; 
    1103     element.style.overflow = element._overflow; 
    1104     element._overflow = undefined; 
     1479    if (!element._overflow) return element; 
     1480    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; 
     1481    element._overflow = null; 
     1482    return element; 
    11051483  } 
    1106 } 
     1484}; 
    11071485 
     1486Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); 
     1487 
     1488Element._attributeTranslations = {}; 
     1489 
     1490Element._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 
     1503Element._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 
     1522Object.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 
     1529}); 
     1530 
     1531Element.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 
     1540if (document.all && !window.opera){ 
     1541  Element.Methods.update = function(element, html) { 
     1542    element = $(element); 
     1543    html = typeof html == 'undefined' ? '' : html.toString(); 
     1544    var tagName = element.tagName.toUpperCase(); 
     1545    if (['THEAD','TBODY','TR','TD'].include(tagName)) { 
     1546      var div = document.createElement('div'); 
     1547      switch (tagName) { 
     1548        case 'THEAD': 
     1549        case 'TBODY': 
     1550          div.innerHTML = '<table><tbody>' +  html.stripScripts() + '</tbody></table>'; 
     1551          depth = 2; 
     1552          break; 
     1553        case 'TR': 
     1554          div.innerHTML = '<table><tbody><tr>' +  html.stripScripts() + '</tr></tbody></table>'; 
     1555          depth = 3; 
     1556          break; 
     1557        case 'TD': 
     1558          div.innerHTML = '<table><tbody><tr><td>' +  html.stripScripts() + '</td></tr></tbody></table>'; 
     1559          depth = 4; 
     1560      } 
     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) }); 
     1568    } else { 
     1569      element.innerHTML = html.stripScripts(); 
     1570    } 
     1571    setTimeout(function() {html.evalScripts()}, 10); 
     1572    return element; 
     1573  } 
     1574}; 
     1575 
    11081576Object.extend(Element, Element.Methods); 
    11091577 
    11101578var _nativeExtensions = false; 
    11111579 
    1112 if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 
    1113   var HTMLElement = {} 
    1114   HTMLElement.prototype = document.createElement('div').__proto__; 
    1115 } 
     1580if(/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  }); 
    11161587 
    11171588Element.addMethods = function(methods) { 
    11181589  Object.extend(Element.Methods, methods || {}); 
    11191590 
    1120   if(typeof HTMLElement != 'undefined') { 
    1121     var methods = Element.Methods, cache = Element.extend.cache; 
    1122     for (property in methods) { 
     1591  function copy(methods, destination, onlyIfAbsent) { 
     1592    onlyIfAbsent = onlyIfAbsent || false; 
     1593    var cache = Element.extend.cache; 
     1594    for (var property in methods) { 
    11231595      var value = methods[property]; 
    1124       if (typeof value == 'function') 
    1125         HTMLElement.prototype[property] = cache.findOrStore(value); 
     1596      if (!onlyIfAbsent || !(property in destination)) 
     1597        destination[property] = cache.findOrStore(value); 
    11261598    } 
     1599  } 
     1600 
     1601  if (typeof HTMLElement != 'undefined') { 
     1602    copy(Element.Methods, HTMLElement.prototype); 
     1603    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    }); 
    11271608    _nativeExtensions = true; 
    11281609  } 
    11291610} 
    11301611 
    1131 Element.addMethods(); 
    1132  
    11331612var Toggle = new Object(); 
    11341613Toggle.display = Element.toggle; 
    11351614 
     
    11481627      try { 
    11491628        this.element.insertAdjacentHTML(this.adjacency, this.content); 
    11501629      } catch (e) { 
    1151         var tagName = this.element.tagName.toLowerCase(); 
    1152         if (tagName == 'tbody' || tagName == 'tr') { 
     1630        var tagName = this.element.tagName.toUpperCase(); 
     1631        if (['TBODY', 'TR'].include(tagName)) { 
    11531632          this.insertContent(this.contentFromAnonymousTable()); 
    11541633        } else { 
    11551634          throw e; 
     
    12481727 
    12491728  add: function(classNameToAdd) { 
    12501729    if (this.include(classNameToAdd)) return; 
    1251     this.set(this.toArray().concat(classNameToAdd).join(' ')); 
     1730    this.set($A(this).concat(classNameToAdd).join(' ')); 
    12521731  }, 
    12531732 
    12541733  remove: function(classNameToRemove) { 
    12551734    if (!this.include(classNameToRemove)) return; 
    1256     this.set(this.select(function(className) { 
    1257       return className != classNameToRemove; 
    1258     }).join(' ')); 
     1735    this.set($A(this).without(classNameToRemove).join(' ')); 
    12591736  }, 
    12601737 
    12611738  toString: function() { 
    1262     return this.toArray().join(' '); 
     1739    return $A(this).join(' '); 
    12631740  } 
    1264 } 
     1741}; 
    12651742 
    12661743Object.extend(Element.ClassNames.prototype, Enumerable); 
    12671744var Selector = Class.create(); 
     
    13081785    if (params.wildcard) 
    13091786      conditions.push('true'); 
    13101787    if (clause = params.id) 
    1311       conditions.push('element.id == ' + clause.inspect()); 
     1788      conditions.push('element.readAttribute("id") == ' + clause.inspect()); 
    13121789    if (clause = params.tagName) 
    13131790      conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 
    13141791    if ((clause = params.classNames).length > 0) 
    1315       for (var i = 0; i < clause.length; i++) 
    1316         conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')'); 
     1792      for (var i = 0, length = clause.length; i < length; i++) 
     1793        conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 
    13171794    if (clause = params.attributes) { 
    13181795      clause.each(function(attribute) { 
    1319         var value = 'element.getAttribute(' + attribute.name.inspect() + ')'; 
     1796        var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 
    13201797        var splitValueBy = function(delimiter) { 
    13211798          return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; 
    13221799        } 
     
    13291806                          ); break; 
    13301807          case '!=':      conditions.push(value + ' != ' + attribute.value.inspect()); break; 
    13311808          case '': 
    1332           case undefined: conditions.push(value + ' != null'); break; 
     1809          case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 
    13331810          default:        throw 'Unknown operator ' + attribute.operator + ' in selector'; 
    13341811        } 
    13351812      }); 
     
    13401817 
    13411818  compileMatcher: function() { 
    13421819    this.match = new Function('element', 'if (!element.tagName) return false; \ 
     1820      element = $(element); \ 
    13431821      return ' + this.buildMatchExpression()); 
    13441822  }, 
    13451823 
     
    13541832    scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); 
    13551833 
    13561834    var results = []; 
    1357     for (var i = 0; i < scope.length; i++) 
     1835    for (var i = 0, length = scope.length; i < length; i++) 
    13581836      if (this.match(element = scope[i])) 
    13591837        results.push(Element.extend(element)); 
    13601838 
     
    13661844  } 
    13671845} 
    13681846 
    1369 function $$() { 
    1370   return $A(arguments).map(function(expression) { 
    1371     return expression.strip().split(/\s+/).inject([null], function(results, expr) { 
    1372       var selector = new Selector(expr); 
    1373       return results.map(selector.findElements.bind(selector)).flatten(); 
    1374     }); 
    1375   }).flatten(); 
    1376 } 
    1377 var Field = { 
    1378   clear: function() { 
    1379     for (var i = 0; i < arguments.length; i++) 
    1380       $(arguments[i]).value = ''; 
     1847Object.extend(Selector, { 
     1848  matchElements: function(elements, expression) { 
     1849    var selector = new Selector(expression); 
     1850    return elements.select(selector.match.bind(selector)).map(Element.extend); 
    13811851  }, 
    13821852 
    1383   focus: function(element) { 
    1384     $(element).focus(); 
     1853  findElement: function(elements, expression, index) { 
     1854    if (typeof expression == 'number') index = expression, expression = false; 
     1855    return Selector.matchElements(elements, expression || '*')[index || 0]; 
    13851856  }, 
    13861857 
    1387   present: function() { 
    1388     for (var i = 0; i < arguments.length; i++) 
    1389       if ($(arguments[i]).value == '') return false; 
    1390     return true; 
    1391   }, 
     1858  findChildElements: function(element, expressions) { 
     1859    return expressions.map(function(expression) { 
     1860      return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { 
     1861        var selector = new Selector(expr); 
     1862        return results.inject([], function(elements, result) { 
     1863          return elements.concat(selector.findElements(result || element)); 
     1864        }); 
     1865      }); 
     1866    }).flatten(); 
     1867  } 
     1868}); 
    13921869 
    1393   select: function(element) { 
    1394     $(element).select(); 
     1870function $$() { 
     1871  return Selector.findChildElements(document, $A(arguments)); 
     1872} 
     1873var Form = { 
     1874  reset: function(form) { 
     1875    $(form).reset(); 
     1876    return form; 
    13951877  }, 
    13961878 
    1397   activate: function(element) { 
    1398     element = $(element); 
    1399     element.focus(); 
    1400     if (element.select) 
    1401       element.select(); 
     1879  serializeElements: function(elements, getHash) { 
     1880    var data = elements.inject({}, function(result, element) { 
     1881      if (!element.disabled && element.name) { 
     1882        var key = element.name, value = $(element).getValue(); 
     1883        if (value != undefined) { 
     1884          if (result[key]) { 
     1885            if (result[key].constructor != Array) result[key] = [result[key]]; 
     1886            result[key].push(value); 
     1887          } 
     1888          else result[key] = value; 
     1889        } 
     1890      } 
     1891      return result; 
     1892    }); 
     1893 
     1894    return getHash ? data : Hash.toQueryString(data); 
    14021895  } 
    1403 } 
     1896}; 
    14041897 
    1405 /*--------------------------------------------------------------------------*/ 
    1406  
    1407 var Form = { 
    1408   serialize: function(form) { 
    1409     var elements = Form.getElements($(form)); 
    1410     var queryComponents = new Array(); 
    1411  
    1412     for (var i = 0; i < elements.length; i++) { 
    1413       var queryComponent = Form.Element.serialize(elements[i]); 
    1414       if (queryComponent) 
    1415         queryComponents.push(queryComponent); 
    1416     } 
    1417  
    1418     return queryComponents.join('&'); 
     1898Form.Methods = { 
     1899  serialize: function(form, getHash) { 
     1900    return Form.serializeElements(Form.getElements(form), getHash); 
    14191901  }, 
    14201902 
    14211903  getElements: function(form) { 
    1422     form = $(form); 
    1423     var elements = new Array(); 
    1424  
    1425     for (var tagName in Form.Element.Serializers) { 
    1426       var tagElements = form.getElementsByTagName(tagName); 
    1427       for (var j = 0; j < tagElements.length; j++) 
    1428         elements.push(tagElements[j]); 
    1429     } 
    1430     return elements; 
     1904    return $A($(form).getElementsByTagName('*')).inject([], 
     1905      function(elements, child) { 
     1906        if (Form.Element.Serializers[child.tagName.toLowerCase()]) 
     1907          elements.push(Element.extend(child)); 
     1908        return elements; 
     1909      } 
     1910    ); 
    14311911  }, 
    14321912 
    14331913  getInputs: function(form, typeName, name) { 
    14341914    form = $(form); 
    14351915    var inputs = form.getElementsByTagName('input'); 
    14361916 
    1437     if (!typeName && !name) 
    1438       return inputs; 
     1917    if (!typeName && !name) return $A(inputs).map(Element.extend); 
    14391918 
    1440     var matchingInputs = new Array(); 
    1441     for (var i = 0; i < inputs.length; i++) { 
     1919    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { 
    14421920      var input = inputs[i]; 
    1443       if ((typeName && input.type != typeName) || 
    1444           (name && input.name != name)) 
     1921      if ((typeName && input.type != typeName) || (name && input.name != name)) 
    14451922        continue; 
    1446       matchingInputs.push(input); 
     1923      matchingInputs.push(Element.extend(input)); 
    14471924    } 
    14481925 
    14491926    return matchingInputs; 
    14501927  }, 
    14511928 
    14521929  disable: function(form) { 
    1453     var elements = Form.getElements(form); 
    1454     for (var i = 0; i < elements.length; i++) { 
    1455       var element = elements[i]; 
     1930    form = $(form); 
     1931    form.getElements().each(function(element) { 
    14561932      element.blur(); 
    14571933      element.disabled = 'true'; 
    1458     } 
     1934    }); 
     1935    return form; 
    14591936  }, 
    14601937 
    14611938  enable: function(form) { 
    1462     var elements = Form.getElements(form); 
    1463     for (var i = 0; i < elements.length; i++) { 
    1464       var element = elements[i]; 
     1939    form = $(form); 
     1940    form.getElements().each(function(element) { 
    14651941      element.disabled = ''; 
    1466     } 
     1942    }); 
     1943    return form; 
    14671944  }, 
    14681945 
    14691946  findFirstElement: function(form) { 
    1470     return Form.getElements(form).find(function(element) { 
     1947    return $(form).getElements().find(function(element) { 
    14711948      return element.type != 'hidden' && !element.disabled && 
    14721949        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); 
    14731950    }); 
    14741951  }, 
    14751952 
    14761953  focusFirstElement: function(form) { 
    1477     Field.activate(Form.findFirstElement(form)); 
     1954    form = $(form); 
     1955    form.findFirstElement().activate(); 
     1956    return form; 
     1957  } 
     1958} 
     1959 
     1960Object.extend(Form, Form.Methods); 
     1961 
     1962/*--------------------------------------------------------------------------*/ 
     1963 
     1964Form.Element = { 
     1965  focus: function(element) { 
     1966    $(element).focus(); 
     1967    return element; 
    14781968  }, 
    14791969 
    1480   reset: function(form) { 
    1481     $(form).reset(); 
     1970  select: function(element) { 
     1971    $(element).select(); 
     1972    return element; 
    14821973  } 
    14831974} 
    14841975 
    1485 Form.Element = { 
     1976Form.Element.Methods = { 
    14861977  serialize: function(element) { 
    14871978    element = $(element); 
     1979    if (!element.disabled && element.name) { 
     1980      var value = element.getValue(); 
     1981      if (value != undefined) { 
     1982        var pair = {}; 
     1983        pair[element.name] = value; 
     1984        return Hash.toQueryString(pair); 
     1985      } 
     1986    } 
     1987    return ''; 
     1988  }, 
     1989 
     1990  getValue: function(element) { 
     1991    element = $(element); 
    14881992    var method = element.tagName.toLowerCase(); 
    1489     var parameter = Form.Element.Serializers[method](element); 
     1993    return Form.Element.Serializers[method](element); 
     1994  }, 
    14901995 
    1491     if (parameter) { 
    1492       var key = encodeURIComponent(parameter[0]); 
    1493       if (key.length == 0) return; 
     1996  clear: function(element) { 
     1997    $(element).value = ''; 
     1998    return element; 
     1999  }, 
    14942000 
    1495       if (parameter[1].constructor != Array) 
    1496         parameter[1] = [parameter[1]]; 
     2001  present: function(element) { 
     2002    return $(element).value != ''; 
     2003  }, 
    14972004 
    1498       return parameter[1].map(function(value) { 
    1499         return key + '=' + encodeURIComponent(value); 
    1500       }).join('&'); 
    1501     } 
     2005  activate: function(element) { 
     2006    element = $(element); 
     2007    element.focus(); 
     2008    if (element.select && ( element.tagName.toLowerCase() != 'input' || 
     2009      !['button', 'reset', 'submit'].include(element.type) ) ) 
     2010      element.select(); 
     2011    return element; 
    15022012  }, 
    15032013 
    1504   getValue: function(element) { 
     2014  disable: function(element) { 
    15052015    element = $(element); 
    1506     var method = element.tagName.toLowerCase(); 
    1507     var parameter = Form.Element.Serializers[method](element); 
     2016    element.disabled = true; 
     2017    return element; 
     2018  }, 
    15082019 
    1509     if (parameter) 
    1510       return parameter[1]; 
     2020  enable: function(element) { 
     2021    element = $(element); 
     2022    element.blur(); 
     2023    element.disabled = false; 
     2024    return element; 
    15112025  } 
    15122026} 
    15132027 
     2028Object.extend(Form.Element, Form.Element.Methods); 
     2029var Field = Form.Element; 
     2030var $F = Form.Element.getValue; 
     2031 
     2032/*--------------------------------------------------------------------------*/ 
     2033 
    15142034Form.Element.Serializers = { 
    15152035  input: function(element) { 
    15162036    switch (element.type.toLowerCase()) { 
    1517       case 'submit': 
    1518       case 'hidden': 
    1519       case 'password': 
    1520       case 'text': 
    1521         return Form.Element.Serializers.textarea(element); 
    15222037      case 'checkbox': 
    15232038      case 'radio': 
    15242039        return Form.Element.Serializers.inputSelector(element); 
     2040      default: 
     2041        return Form.Element.Serializers.textarea(element); 
    15252042    } 
    1526     return false; 
    15272043  }, 
    15282044 
    15292045  inputSelector: function(element) { 
    1530     if (element.checked) 
    1531       return [element.name, element.value]; 
     2046    return element.checked ? element.value : null; 
    15322047  }, 
    15332048 
    15342049  textarea: function(element) { 
    1535     return [element.name, element.value]; 
     2050    return element.value; 
    15362051  }, 
    15372052 
    15382053  select: function(element) { 
    1539     return Form.Element.Serializers[element.type == 'select-one' ? 
     2054    return this[element.type == 'select-one' ? 
    15402055      'selectOne' : 'selectMany'](element); 
    15412056  }, 
    15422057 
    15432058  selectOne: function(element) { 
    1544     var value = '', opt, index = element.selectedIndex; 
    1545     if (index >= 0) { 
    1546       opt = element.options[index]; 
    1547       value = opt.value || opt.text; 
    1548     } 
    1549     return [element.name, value]; 
     2059    var index = element.selectedIndex; 
     2060    return index >= 0 ? this.optionValue(element.options[index]) : null; 
    15502061  }, 
    15512062 
    15522063  selectMany: function(element) { 
    1553     var value = []; 
    1554     for (var i = 0; i < element.length; i++) { 
     2064    var values, length = element.length; 
     2065    if (!length) return null; 
     2066 
     2067    for (var i = 0, values = []; i < length; i++) { 
    15552068      var opt = element.options[i]; 
    1556       if (opt.selected) 
    1557         value.push(opt.value || opt.text); 
     2069      if (opt.selected) values.push(this.optionValue(opt)); 
    15582070    } 
    1559     return [element.name, value]; 
     2071    return values; 
     2072  }, 
     2073 
     2074  optionValue: function(opt) { 
     2075    // extend element because hasAttribute may not be native 
     2076    return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; 
    15602077  } 
    15612078} 
    15622079 
    15632080/*--------------------------------------------------------------------------*/ 
    15642081 
    1565 var $F = Form.Element.getValue; 
    1566  
    1567 /*--------------------------------------------------------------------------*/ 
    1568  
    15692082Abstract.TimedObserver = function() {} 
    15702083Abstract.TimedObserver.prototype = { 
    15712084  initialize: function(element, frequency, callback) { 
     
    15832096 
    15842097  onTimerEvent: function() { 
    15852098    var value = this.getValue(); 
    1586     if (this.lastValue != value) { 
     2099    var changed = ('string' == typeof this.lastValue && 'string' == typeof value 
     2100      ? this.lastValue != value : String(this.lastValue) != String(value)); 
     2101    if (changed) { 
    15872102      this.callback(this.element, value); 
    15882103      this.lastValue = value; 
    15892104    } 
     
    16282143  }, 
    16292144 
    16302145  registerFormCallbacks: function() { 
    1631     var elements = Form.getElements(this.element); 
    1632     for (var i = 0; i < elements.length; i++) 
    1633       this.registerCallback(elements[i]); 
     2146    Form.getElements(this.element).each(this.registerCallback.bind(this)); 
    16342147  }, 
    16352148 
    16362149  registerCallback: function(element) { 
     
    16402153        case 'radio': 
    16412154          Event.observe(element, 'click', this.onElementEvent.bind(this)); 
    16422155          break; 
    1643         case 'password': 
    1644         case 'text': 
    1645         case 'textarea': 
    1646         case 'select-one': 
    1647         case 'select-multiple': 
     2156        default: 
    16482157          Event.observe(element, 'change', this.onElementEvent.bind(this)); 
    16492158          break; 
    16502159      } 
     
    16792188  KEY_RIGHT:    39, 
    16802189  KEY_DOWN:     40, 
    16812190  KEY_DELETE:   46, 
     2191  KEY_HOME:     36, 
     2192  KEY_END:      35, 
     2193  KEY_PAGEUP:   33, 
     2194  KEY_PAGEDOWN: 34, 
    16822195 
    16832196  element: function(event) { 
    16842197    return event.target || event.srcElement; 
     
    17342247 
    17352248  unloadCache: function() { 
    17362249    if (!Event.observers) return; 
    1737     for (var i = 0; i < Event.observers.length; i++) { 
     2250    for (var i = 0, length = Event.observers.length; i < length; i++) { 
    17382251      Event.stopObserving.apply(this, Event.observers[i]); 
    17392252      Event.observers[i][0] = null; 
    17402253    } 
     
    17422255  }, 
    17432256 
    17442257  observe: function(element, name, observer, useCapture) { 
    1745     var element = $(element); 
     2258    element = $(element); 
    17462259    useCapture = useCapture || false; 
    17472260 
    17482261    if (name == 'keypress' && 
     
    17502263        || element.attachEvent)) 
    17512264      name = 'keydown'; 
    17522265 
    1753     this._observeAndCache(element, name, observer, useCapture); 
     2266    Event._observeAndCache(element, name, observer, useCapture); 
    17542267  }, 
    17552268 
    17562269  stopObserving: function(element, name, observer, useCapture) { 
    1757     var element = $(element); 
     2270    element = $(element); 
    17582271    useCapture = useCapture || false; 
    17592272 
    17602273    if (name == 'keypress' && 
     
    18212334      valueL += element.offsetLeft || 0; 
    18222335      element = element.offsetParent; 
    18232336      if (element) { 
    1824         p = Element.getStyle(element, 'position'); 
     2337        if(element.tagName=='BODY') break; 
     2338        var p = Element.getStyle(element, 'position'); 
    18252339        if (p == 'relative' || p == 'absolute') break; 
    18262340      } 
    18272341    } while (element); 
     
    18772391        element.offsetWidth; 
    18782392  }, 
    18792393 
    1880   clone: function(source, target) { 
    1881     source = $(source); 
    1882     target = $(target); 
    1883     target.style.position = 'absolute'; 
    1884     var offsets = this.cumulativeOffset(source); 
    1885     target.style.top    = offsets[1] + 'px'; 
    1886     target.style.left   = offsets[0] + 'px'; 
    1887     target.style.width  = source.offsetWidth + 'px'; 
    1888     target.style.height = source.offsetHeight + 'px'; 
    1889   }, 
    1890  
    18912394  page: function(forElement) { 
    18922395    var valueT = 0, valueL = 0; 
    18932396 
     
    19042407 
    19052408    element = forElement; 
    19062409    do { 
    1907       valueT -= element.scrollTop  || 0; 
    1908       valueL -= element.scrollLeft || 0; 
     2410      if (!window.opera || element.tagName=='BODY') { 
     2411        valueT -= element.scrollTop  || 0; 
     2412        valueL -= element.scrollLeft || 0; 
     2413      } 
    19092414    } while (element = element.parentNode); 
    19102415 
    19112416    return [valueL, valueT]; 
     
    19662471    element._originalHeight = element.style.height; 
    19672472 
    19682473    element.style.position = 'absolute'; 
    1969     element.style.top    = top + 'px';; 
    1970     element.style.left   = left + 'px';; 
    1971     element.style.width  = width + 'px';; 
    1972     element.style.height = height + 'px';; 
     2474    element.style.top    = top + 'px'; 
     2475    element.style.left   = left + 'px'; 
     2476    element.style.width  = width + 'px'; 
     2477    element.style.height = height + 'px'; 
    19732478  }, 
    19742479 
    19752480  relativize: function(element) { 
     
    20052510 
    20062511    return [valueL, valueT]; 
    20072512  } 
    2008 } 
    2009  No newline at end of file 
     2513} 
     2514 
     2515Element.addMethods(); 
     2516 No newline at end of file 
  • wp-includes/js/scriptaculous/prototype.js

     
    1 /*  Prototype JavaScript framework, version 1.5.0_rc0 
    2  *  (c) 2005 Sam Stephenson <sam@conio.net> 
     1/*  Prototype JavaScript framework, version 1.5.0 
     2 *  (c) 2005-2007 Sam Stephenson 
    33 * 
    44 *  Prototype is freely distributable under the terms of an MIT-style license. 
    55 *  For details, see the Prototype web site: http://prototype.conio.net/ 
     
    77/*--------------------------------------------------------------------------*/ 
    88 
    99var Prototype = { 
    10   Version: '1.5.0_rc0', 
     10  Version: '1.5.0', 
     11  BrowserFeatures: { 
     12    XPath: !!document.evaluate 
     13  }, 
     14 
    1115  ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', 
    12  
    1316  emptyFunction: function() {}, 
    14   K: function(x) {return x} 
     17  K: function(x) { return x } 
    1518} 
    1619 
    1720var Class = { 
     
    3134  return destination; 
    3235} 
    3336 
    34 Object.inspect = function(object) { 
    35   try { 
    36     if (object == undefined) return 'undefined'; 
    37     if (object == null) return 'null'; 
    38     return object.inspect ? object.inspect() : object.toString(); 
    39   } catch (e) { 
    40     if (e instanceof RangeError) return '...'; 
    41     throw e; 
     37Object.extend(Object, { 
     38  inspect: function(object) { 
     39    try { 
     40      if (object === undefined) return 'undefined'; 
     41      if (object === null) return 'null'; 
     42      return object.inspect ? object.inspect() : object.toString(); 
     43    } catch (e) { 
     44      if (e instanceof RangeError) return '...'; 
     45      throw e; 
     46    } 
     47  }, 
     48 
     49  keys: function(object) { 
     50    var keys = []; 
     51    for (var property in object) 
     52      keys.push(property); 
     53    return keys; 
     54  }, 
     55 
     56  values: function(object) { 
     57    var values = []; 
     58    for (var property in object) 
     59      values.push(object[property]); 
     60    return values; 
     61  }, 
     62 
     63  clone: function(object) { 
     64    return Object.extend({}, object); 
    4265  } 
    43 } 
     66}); 
    4467 
    4568Function.prototype.bind = function() { 
    4669  var __method = this, args = $A(arguments), object = args.shift(); 
     
    5073} 
    5174 
    5275Function.prototype.bindAsEventListener = function(object) { 
    53   var __method = this; 
     76  var __method = this, args = $A(arguments), object = args.shift(); 
    5477  return function(event) { 
    55     return __method.call(object, event || window.event); 
     78    return __method.apply(object, [( event || window.event)].concat(args).concat($A(arguments))); 
    5679  } 
    5780} 
    5881 
     
    77100  these: function() { 
    78101    var returnValue; 
    79102 
    80     for (var i = 0; i < arguments.length; i++) { 
     103    for (var i = 0, length = arguments.length; i < length; i++) { 
    81104      var lambda = arguments[i]; 
    82105      try { 
    83106        returnValue = lambda(); 
     
    102125  }, 
    103126 
    104127  registerCallback: function() { 
    105     setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 
     128    this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); 
    106129  }, 
    107130 
     131  stop: function() { 
     132    if (!this.timer) return; 
     133    clearInterval(this.timer); 
     134    this.timer = null; 
     135  }, 
     136 
    108137  onTimerEvent: function() { 
    109138    if (!this.currentlyExecuting) { 
    110139      try { 
    111140        this.currentlyExecuting = true; 
    112         this.callback(); 
     141        this.callback(this); 
    113142      } finally { 
    114143        this.currentlyExecuting = false; 
    115144      } 
    116145    } 
    117146  } 
    118147} 
     148String.interpret = function(value){ 
     149  return value == null ? '' : String(value); 
     150} 
     151 
    119152Object.extend(String.prototype, { 
    120153  gsub: function(pattern, replacement) { 
    121154    var result = '', source = this, match; 
     
    124157    while (source.length > 0) { 
    125158      if (match = source.match(pattern)) { 
    126159        result += source.slice(0, match.index); 
    127         result += (replacement(match) || '').toString(); 
     160        result += String.interpret(replacement(match)); 
    128161        source  = source.slice(match.index + match[0].length); 
    129162      } else { 
    130163        result += source, source = ''; 
     
    189222  unescapeHTML: function() { 
    190223    var div = document.createElement('div'); 
    191224    div.innerHTML = this.stripTags(); 
    192     return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; 
     225    return div.childNodes[0] ? (div.childNodes.length > 1 ? 
     226      $A(div.childNodes).inject('',function(memo,node){ return memo+node.nodeValue }) : 
     227      div.childNodes[0].nodeValue) : ''; 
    193228  }, 
    194229 
    195   toQueryParams: function() { 
    196     var pairs = this.match(/^\??(.*)$/)[1].split('&'); 
    197     return pairs.inject({}, function(params, pairString) { 
    198       var pair = pairString.split('='); 
    199       params[pair[0]] = pair[1]; 
    200       return params; 
     230  toQueryParams: function(separator) { 
     231    var match = this.strip().match(/([^?#]*)(#.*)?$/); 
     232    if (!match) return {}; 
     233 
     234    return match[1].split(separator || '&').inject({}, function(hash, pair) { 
     235      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); 
     243        } 
     244        else hash[name] = value; 
     245      } 
     246      return hash; 
    201247    }); 
    202248  }, 
    203249 
     
    205251    return this.split(''); 
    206252  }, 
    207253 
     254  succ: function() { 
     255    return this.slice(0, this.length - 1) + 
     256      String.fromCharCode(this.charCodeAt(this.length - 1) + 1); 
     257  }, 
     258 
    208259  camelize: function() { 
    209     var oStringList = this.split('-'); 
    210     if (oStringList.length == 1) return oStringList[0]; 
     260    var parts = this.split('-'), len = parts.length; 
     261    if (len == 1) return parts[0]; 
    211262 
    212     var camelizedString = this.indexOf('-') == 0 
    213       ? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) 
    214       : oStringList[0]; 
     263    var camelized = this.charAt(0) == '-' 
     264      ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) 
     265      : parts[0]; 
    215266 
    216     for (var i = 1, len = oStringList.length; i < len; i++) { 
    217       var s = oStringList[i]; 
    218       camelizedString += s.charAt(0).toUpperCase() + s.substring(1); 
    219     } 
     267    for (var i = 1; i < len; i++) 
     268      camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); 
    220269 
    221     return camelizedString; 
     270    return camelized; 
    222271  }, 
    223272 
    224   inspect: function() { 
    225     return "'" + this.replace(/\\/g, '\\\\').replace(/'/g, '\\\'') + "'"; 
     273  capitalize: function(){ 
     274    return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); 
     275  }, 
     276 
     277  underscore: function() { 
     278    return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); 
     279  }, 
     280 
     281  dasherize: function() { 
     282    return this.gsub(/_/,'-'); 
     283  }, 
     284 
     285  inspect: function(useDoubleQuotes) { 
     286    var escapedString = this.replace(/\\/g, '\\\\'); 
     287    if (useDoubleQuotes) 
     288      return '"' + escapedString.replace(/"/g, '\\"') + '"'; 
     289    else 
     290      return "'" + escapedString.replace(/'/g, '\\\'') + "'"; 
    226291  } 
    227292}); 
    228293 
     
    246311    return this.template.gsub(this.pattern, function(match) { 
    247312      var before = match[1]; 
    248313      if (before == '\\') return match[2]; 
    249       return before + (object[match[3]] || '').toString(); 
     314      return before + String.interpret(object[match[3]]); 
    250315    }); 
    251316  } 
    252317} 
     
    268333    } catch (e) { 
    269334      if (e != $break) throw e; 
    270335    } 
     336    return this; 
    271337  }, 
    272338 
     339  eachSlice: function(number, iterator) { 
     340    var index = -number, slices = [], array = this.toArray(); 
     341    while ((index += number) < array.length) 
     342      slices.push(array.slice(index, index+number)); 
     343    return slices.map(iterator); 
     344  }, 
     345 
    273346  all: function(iterator) { 
    274347    var result = true; 
    275348    this.each(function(value, index) { 
     
    280353  }, 
    281354 
    282355  any: function(iterator) { 
    283     var result = true; 
     356    var result = false; 
    284357    this.each(function(value, index) { 
    285358      if (result = !!(iterator || Prototype.K)(value, index)) 
    286359        throw $break; 
     
    291364  collect: function(iterator) { 
    292365    var results = []; 
    293366    this.each(function(value, index) { 
    294       results.push(iterator(value, index)); 
     367      results.push((iterator || Prototype.K)(value, index)); 
    295368    }); 
    296369    return results; 
    297370  }, 
    298371 
    299   detect: function (iterator) { 
     372  detect: function(iterator) { 
    300373    var result; 
    301374    this.each(function(value, index) { 
    302375      if (iterator(value, index)) { 
     
    337410    return found; 
    338411  }, 
    339412 
     413  inGroupsOf: function(number, fillWith) { 
     414    fillWith = fillWith === undefined ? null : fillWith; 
     415    return this.eachSlice(number, function(slice) { 
     416      while(slice.length < number) slice.push(fillWith); 
     417      return slice; 
     418    }); 
     419  }, 
     420 
    340421  inject: function(memo, iterator) { 
    341422    this.each(function(value, index) { 
    342423      memo = iterator(memo, value, index); 
     
    346427 
    347428  invoke: function(method) { 
    348429    var args = $A(arguments).slice(1); 
    349     return this.collect(function(value) { 
     430    return this.map(function(value) { 
    350431      return value[method].apply(value, args); 
    351432    }); 
    352433  }, 
     
    398479  }, 
    399480 
    400481  sortBy: function(iterator) { 
    401     return this.collect(function(value, index) { 
     482    return this.map(function(value, index) { 
    402483      return {value: value, criteria: iterator(value, index)}; 
    403484    }).sort(function(left, right) { 
    404485      var a = left.criteria, b = right.criteria; 
     
    407488  }, 
    408489 
    409490  toArray: function() { 
    410     return this.collect(Prototype.K); 
     491    return this.map(); 
    411492  }, 
    412493 
    413494  zip: function() { 
     
    421502    }); 
    422503  }, 
    423504 
     505  size: function() { 
     506    return this.toArray().length; 
     507  }, 
     508 
    424509  inspect: function() { 
    425510    return '#<Enumerable:' + this.toArray().inspect() + '>'; 
    426511  } 
     
    439524    return iterable.toArray(); 
    440525  } else { 
    441526    var results = []; 
    442     for (var i = 0; i < iterable.length; i++) 
     527    for (var i = 0, length = iterable.length; i < length; i++) 
    443528      results.push(iterable[i]); 
    444529    return results; 
    445530  } 
     
    452537 
    453538Object.extend(Array.prototype, { 
    454539  _each: function(iterator) { 
    455     for (var i = 0; i < this.length; i++) 
     540    for (var i = 0, length = this.length; i < length; i++) 
    456541      iterator(this[i]); 
    457542  }, 
    458543 
     
    471556 
    472557  compact: function() { 
    473558    return this.select(function(value) { 
    474       return value != undefined || value != null; 
     559      return value != null; 
    475560    }); 
    476561  }, 
    477562 
     
    490575  }, 
    491576 
    492577  indexOf: function(object) { 
    493     for (var i = 0; i < this.length; i++) 
     578    for (var i = 0, length = this.length; i < length; i++) 
    494579      if (this[i] == object) return i; 
    495580    return -1; 
    496581  }, 
     
    499584    return (inline !== false ? this : this.toArray())._reverse(); 
    500585  }, 
    501586 
     587  reduce: function() { 
     588    return this.length > 1 ? this : this[0]; 
     589  }, 
     590 
     591  uniq: function() { 
     592    return this.inject([], function(array, value) { 
     593      return array.include(value) ? array : array.concat([value]); 
     594    }); 
     595  }, 
     596 
     597  clone: function() { 
     598    return [].concat(this); 
     599  }, 
     600 
     601  size: function() { 
     602    return this.length; 
     603  }, 
     604 
    502605  inspect: function() { 
    503606    return '[' + this.map(Object.inspect).join(', ') + ']'; 
    504607  } 
    505608}); 
    506 var Hash = { 
     609 
     610Array.prototype.toArray = Array.prototype.clone; 
     611 
     612function $w(string){ 
     613  string = string.strip(); 
     614  return string ? string.split(/\s+/) : []; 
     615} 
     616 
     617if(window.opera){ 
     618  Array.prototype.concat = function(){ 
     619    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++) 
     624          array.push(arguments[i][j]); 
     625      } else { 
     626        array.push(arguments[i]); 
     627      } 
     628    } 
     629    return array; 
     630  } 
     631} 
     632var Hash = function(obj) { 
     633  Object.extend(this, obj || {}); 
     634}; 
     635 
     636Object.extend(Hash, { 
     637  toQueryString: function(obj) { 
     638    var parts = []; 
     639 
     640          this.prototype._each.call(obj, function(pair) { 
     641      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        } 
     654      } 
     655      if (pair.value == undefined) pair[1] = ''; 
     656      parts.push(pair.map(encodeURIComponent).join('=')); 
     657          }); 
     658 
     659    return parts.join('&'); 
     660  } 
     661}); 
     662 
     663Object.extend(Hash.prototype, Enumerable); 
     664Object.extend(Hash.prototype, { 
    507665  _each: function(iterator) { 
    508666    for (var key in this) { 
    509667      var value = this[key]; 
    510       if (typeof value == 'function') continue; 
     668      if (value && value == Hash.prototype[key]) continue; 
    511669 
    512670      var pair = [key, value]; 
    513671      pair.key = key; 
     
    525683  }, 
    526684 
    527685  merge: function(hash) { 
    528     return $H(hash).inject($H(this), function(mergedHash, pair) { 
     686    return $H(hash).inject(this, function(mergedHash, pair) { 
    529687      mergedHash[pair.key] = pair.value; 
    530688      return mergedHash; 
    531689    }); 
    532690  }, 
    533691 
     692  remove: function() { 
     693    var result; 
     694    for(var i = 0, length = arguments.length; i < length; i++) { 
     695      var value = this[arguments[i]]; 
     696      if (value !== undefined){ 
     697        if (result === undefined) result = value; 
     698        else { 
     699          if (result.constructor != Array) result = [result]; 
     700          result.push(value) 
     701        } 
     702      } 
     703      delete this[arguments[i]]; 
     704    } 
     705    return result; 
     706  }, 
     707 
    534708  toQueryString: function() { 
    535     return this.map(function(pair) { 
    536       return pair.map(encodeURIComponent).join('='); 
    537     }).join('&'); 
     709    return Hash.toQueryString(this); 
    538710  }, 
    539711 
    540712  inspect: function() { 
     
    542714      return pair.map(Object.inspect).join(': '); 
    543715    }).join(', ') + '}>'; 
    544716  } 
    545 } 
     717}); 
    546718 
    547719function $H(object) { 
    548   var hash = Object.extend({}, object || {}); 
    549   Object.extend(hash, Enumerable); 
    550   Object.extend(hash, Hash); 
    551   return hash; 
    552 } 
     720  if (object && object.constructor == Hash) return object; 
     721  return new Hash(object); 
     722}; 
    553723ObjectRange = Class.create(); 
    554724Object.extend(ObjectRange.prototype, Enumerable); 
    555725Object.extend(ObjectRange.prototype, { 
     
    561731 
    562732  _each: function(iterator) { 
    563733    var value = this.start; 
    564     do { 
     734    while (this.include(value)) { 
    565735      iterator(value); 
    566736      value = value.succ(); 
    567     } while (this.include(value)); 
     737    } 
    568738  }, 
    569739 
    570740  include: function(value) { 
     
    599769    this.responders._each(iterator); 
    600770  }, 
    601771 
    602   register: function(responderToAdd) { 
    603     if (!this.include(responderToAdd)) 
    604       this.responders.push(responderToAdd); 
     772  register: function(responder) { 
     773    if (!this.include(responder)) 
     774      this.responders.push(responder); 
    605775  }, 
    606776 
    607   unregister: function(responderToRemove) { 
    608     this.responders = this.responders.without(responderToRemove); 
     777  unregister: function(responder) { 
     778    this.responders = this.responders.without(responder); 
    609779  }, 
    610780 
    611781  dispatch: function(callback, request, transport, json) { 
    612782    this.each(function(responder) { 
    613       if (responder[callback] && typeof responder[callback] == 'function') { 
     783      if (typeof responder[callback] == 'function') { 
    614784        try { 
    615785          responder[callback].apply(responder, [request, transport, json]); 
    616786        } catch (e) {} 
     
    625795  onCreate: function() { 
    626796    Ajax.activeRequestCount++; 
    627797  }, 
    628  
    629798  onComplete: function() { 
    630799    Ajax.activeRequestCount--; 
    631800  } 
     
    638807      method:       'post', 
    639808      asynchronous: true, 
    640809      contentType:  'application/x-www-form-urlencoded', 
     810      encoding:     'UTF-8', 
    641811      parameters:   '' 
    642812    } 
    643813    Object.extend(this.options, options || {}); 
    644   }, 
    645814 
    646   responseIsSuccess: function() { 
    647     return this.transport.status == undefined 
    648         || this.transport.status == 0 
    649         || (this.transport.status >= 200 && this.transport.status < 300); 
    650   }, 
    651  
    652   responseIsFailure: function() { 
    653     return !this.responseIsSuccess(); 
     815    this.options.method = this.options.method.toLowerCase(); 
     816    if (typeof this.options.parameters == 'string') 
     817      this.options.parameters = this.options.parameters.toQueryParams(); 
    654818  } 
    655819} 
    656820 
     
    659823  ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; 
    660824 
    661825Ajax.Request.prototype = Object.extend(new Ajax.Base(), { 
     826  _complete: false, 
     827 
    662828  initialize: function(url, options) { 
    663829    this.transport = Ajax.getTransport(); 
    664830    this.setOptions(options); 
     
    666832  }, 
    667833 
    668834  request: function(url) { 
    669     var parameters = this.options.parameters || ''; 
    670     if (parameters.length > 0) parameters += '&_='; 
     835    this.url = url; 
     836    this.method = this.options.method; 
     837    var params = this.options.parameters; 
    671838 
     839    if (!['get', 'post'].include(this.method)) { 
     840      // simulate other verbs over post 
     841      params['_method'] = this.method; 
     842      this.method = 'post'; 
     843    } 
     844 
     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; 
     851 
    672852    try { 
    673       this.url = url; 
    674       if (this.options.method == 'get' && parameters.length > 0) 
    675         this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; 
    676  
    677853      Ajax.Responders.dispatch('onCreate', this, this.transport); 
    678854 
    679       this.transport.open(this.options.method, this.url, 
     855      this.transport.open(this.method.toUpperCase(), this.url, 
    680856        this.options.asynchronous); 
    681857 
    682       if (this.options.asynchronous) { 
    683         this.transport.onreadystatechange = this.onStateChange.bind(this); 
    684         setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); 
    685       } 
     858      if (this.options.asynchronous) 
     859        setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); 
    686860 
     861      this.transport.onreadystatechange = this.onStateChange.bind(this); 
    687862      this.setRequestHeaders(); 
    688863 
    689       var body = this.options.postBody ? this.options.postBody : parameters; 
    690       this.transport.send(this.options.method == 'post' ? body : null); 
     864      var body = this.method == 'post' ? (this.options.postBody || params) : null; 
    691865 
    692     } catch (e) { 
     866      this.transport.send(body); 
     867 
     868      /* Force Firefox to handle ready state 4 for synchronous requests */ 
     869      if (!this.options.asynchronous && this.transport.overrideMimeType) 
     870        this.onStateChange(); 
     871 
     872    } 
     873    catch (e) { 
    693874      this.dispatchException(e); 
    694875    } 
    695876  }, 
    696877 
     878  onStateChange: function() { 
     879    var readyState = this.transport.readyState; 
     880    if (readyState > 1 && !((readyState == 4) && this._complete)) 
     881      this.respondToReadyState(this.transport.readyState); 
     882  }, 
     883 
    697884  setRequestHeaders: function() { 
    698     var requestHeaders = 
    699       ['X-Requested-With', 'XMLHttpRequest', 
    700        'X-Prototype-Version', Prototype.Version, 
    701        'Accept', 'text/javascript, text/html, application/xml, text/xml, */*']; 
     885    var headers = { 
     886      'X-Requested-With': 'XMLHttpRequest', 
     887      'X-Prototype-Version': Prototype.Version, 
     888      'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' 
     889    }; 
    702890 
    703     if (this.options.method == 'post') { 
    704       requestHeaders.push('Content-type', this.options.contentType); 
     891    if (this.method == 'post') { 
     892      headers['Content-type'] = this.options.contentType + 
     893        (this.options.encoding ? '; charset=' + this.options.encoding : ''); 
    705894 
    706       /* Force "Connection: close" for Mozilla browsers to work around 
    707        * a bug where XMLHttpReqeuest sends an incorrect Content-length 
    708        * header. See Mozilla Bugzilla #246651. 
     895      /* Force "Connection: close" for older Mozilla browsers to work 
     896       * around a bug where XMLHttpRequest sends an incorrect 
     897       * Content-length header. See Mozilla Bugzilla #246651. 
    709898       */ 
    710       if (this.transport.overrideMimeType) 
    711         requestHeaders.push('Connection', 'close'); 
     899      if (this.transport.overrideMimeType && 
     900          (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) 
     901            headers['Connection'] = 'close'; 
    712902    } 
    713903 
    714     if (this.options.requestHeaders) 
    715       requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); 
     904    // user-defined headers 
     905    if (typeof this.options.requestHeaders == 'object') { 
     906      var extras = this.options.requestHeaders; 
    716907 
    717     for (var i = 0; i < requestHeaders.length; i += 2) 
    718       this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); 
    719   }, 
     908      if (typeof extras.push == 'function') 
     909        for (var i = 0, length = extras.length; i < length; i += 2) 
     910          headers[extras[i]] = extras[i+1]; 
     911      else 
     912        $H(extras).each(function(pair) { headers[pair.key] = pair.value }); 
     913    } 
    720914 
    721   onStateChange: function() { 
    722     var readyState = this.transport.readyState; 
    723     if (readyState != 1) 
    724       this.respondToReadyState(this.transport.readyState); 
     915    for (var name in headers) 
     916      this.transport.setRequestHeader(name, headers[name]); 
    725917  }, 
    726918 
    727   header: function(name) { 
    728     try { 
    729       return this.transport.getResponseHeader(name); 
    730     } catch (e) {} 
     919  success: function() { 
     920    return !this.transport.status 
     921        || (this.transport.status >= 200 && this.transport.status < 300); 
    731922  }, 
    732923 
    733   evalJSON: function() { 
    734     try { 
    735       return eval('(' + this.header('X-JSON') + ')'); 
    736     } catch (e) {} 
    737   }, 
    738  
    739   evalResponse: function() { 
    740     try { 
    741       return eval(this.transport.responseText); 
    742     } catch (e) { 
    743       this.dispatchException(e); 
    744     } 
    745   }, 
    746  
    747924  respondToReadyState: function(readyState) { 
    748     var event = Ajax.Request.Events[readyState]; 
     925    var state = Ajax.Request.Events[readyState]; 
    749926    var transport = this.transport, json = this.evalJSON(); 
    750927 
    751     if (event == 'Complete') { 
     928    if (state == 'Complete') { 
    752929      try { 
     930        this._complete = true; 
    753931        (this.options['on' + this.transport.status] 
    754          || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] 
     932         || this.options['on' + (this.success() ? 'Success' : 'Failure')] 
    755933         || Prototype.emptyFunction)(transport, json); 
    756934      } catch (e) { 
    757935        this.dispatchException(e); 
    758936      } 
    759937 
    760       if ((this.header('Content-type') || '').match(/^text\/javascript/i)) 
    761         this.evalResponse(); 
     938      if ((this.getHeader('Content-type') || 'text/javascript').strip(). 
     939        match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) 
     940          this.evalResponse(); 
    762941    } 
    763942 
    764943    try { 
    765       (this.options['on' + event] || Prototype.emptyFunction)(transport, json); 
    766       Ajax.Responders.dispatch('on' + event, this, transport, json); 
     944      (this.options['on' + state] || Prototype.emptyFunction)(transport, json); 
     945      Ajax.Responders.dispatch('on' + state, this, transport, json); 
    767946    } catch (e) { 
    768947      this.dispatchException(e); 
    769948    } 
    770949 
    771     /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ 
    772     if (event == 'Complete') 
     950    if (state == 'Complete') { 
     951      // avoid memory leak in MSIE: clean up 
    773952      this.transport.onreadystatechange = Prototype.emptyFunction; 
     953    } 
    774954  }, 
    775955 
     956  getHeader: function(name) { 
     957    try { 
     958      return this.transport.getResponseHeader(name); 
     959    } catch (e) { return null } 
     960  }, 
     961 
     962  evalJSON: function() { 
     963    try { 
     964      var json = this.getHeader('X-JSON'); 
     965      return json ? eval('(' + json + ')') : null; 
     966    } catch (e) { return null } 
     967  }, 
     968 
     969  evalResponse: function() { 
     970    try { 
     971      return eval(this.transport.responseText); 
     972    } catch (e) { 
     973      this.dispatchException(e); 
     974    } 
     975  }, 
     976 
    776977  dispatchException: function(exception) { 
    777978    (this.options.onException || Prototype.emptyFunction)(this, exception); 
    778979    Ajax.Responders.dispatch('onException', this, exception); 
     
    783984 
    784985Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { 
    785986  initialize: function(container, url, options) { 
    786     this.containers = { 
    787       success: container.success ? $(container.success) : $(container), 
    788       failure: container.failure ? $(container.failure) : 
    789         (container.success ? null : $(container)) 
     987    this.container = { 
     988      success: (container.success || container), 
     989      failure: (container.failure || (container.success ? null : container)) 
    790990    } 
    791991 
    792992    this.transport = Ajax.getTransport(); 
    793993    this.setOptions(options); 
    794994 
    795995    var onComplete = this.options.onComplete || Prototype.emptyFunction; 
    796     this.options.onComplete = (function(transport, object) { 
     996    this.options.onComplete = (function(transport, param) { 
    797997      this.updateContent(); 
    798       onComplete(transport, object); 
     998      onComplete(transport, param); 
    799999    }).bind(this); 
    8001000 
    8011001    this.request(url); 
    8021002  }, 
    8031003 
    8041004  updateContent: function() { 
    805     var receiver = this.responseIsSuccess() ? 
    806       this.containers.success : this.containers.failure; 
     1005    var receiver = this.container[this.success() ? 'success' : 'failure']; 
    8071006    var response = this.transport.responseText; 
    8081007 
    809     if (!this.options.evalScripts) 
    810       response = response.stripScripts(); 
     1008    if (!this.options.evalScripts) response = response.stripScripts(); 
    8111009 
    812     if (receiver) { 
    813       if (this.options.insertion) { 
     1010    if (receiver = $(receiver)) { 
     1011      if (this.options.insertion) 
    8141012        new this.options.insertion(receiver, response); 
    815       } else { 
    816         Element.update(receiver, response); 
    817       } 
     1013      else 
     1014        receiver.update(response); 
    8181015    } 
    8191016 
    820     if (this.responseIsSuccess()) { 
     1017    if (this.success()) { 
    8211018      if (this.onComplete) 
    8221019        setTimeout(this.onComplete.bind(this), 10); 
    8231020    } 
     
    8461043  }, 
    8471044 
    8481045  stop: function() { 
    849     this.updater.onComplete = undefined; 
     1046    this.updater.options.onComplete = undefined; 
    8501047    clearTimeout(this.timer); 
    8511048    (this.onComplete || Prototype.emptyFunction).apply(this, arguments); 
    8521049  }, 
     
    8661063    this.updater = new Ajax.Updater(this.container, this.url, this.options); 
    8671064  } 
    8681065}); 
    869 function $() { 
    870   var results = [], element; 
    871   for (var i = 0; i < arguments.length; i++) { 
    872     element = arguments[i]; 
    873     if (typeof element == 'string') 
    874       element = document.getElementById(element); 
    875     results.push(Element.extend(element)); 
     1066function $(element) { 
     1067  if (arguments.length > 1) { 
     1068    for (var i = 0, elements = [], length = arguments.length; i < length; i++) 
     1069      elements.push($(arguments[i])); 
     1070    return elements; 
    8761071  } 
    877   return results.length < 2 ? results[0] : results; 
     1072  if (typeof element == 'string') 
     1073    element = document.getElementById(element); 
     1074  return Element.extend(element); 
    8781075} 
    8791076 
     1077if (Prototype.BrowserFeatures.XPath) { 
     1078  document._getElementsByXPath = function(expression, parentElement) { 
     1079    var results = []; 
     1080    var query = document.evaluate(expression, $(parentElement) || document, 
     1081      null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); 
     1082    for (var i = 0, length = query.snapshotLength; i < length; i++) 
     1083      results.push(query.snapshotItem(i)); 
     1084    return results; 
     1085  }; 
     1086} 
     1087 
    8801088document.getElementsByClassName = function(className, parentElement) { 
    881   var children = ($(parentElement) || document.body).getElementsByTagName('*'); 
    882   return $A(children).inject([], function(elements, child) { 
    883     if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
    884       elements.push(Element.extend(child)); 
     1089  if (Prototype.BrowserFeatures.XPath) { 
     1090    var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; 
     1091    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    } 
    8851100    return elements; 
    886   }); 
    887 } 
     1101  } 
     1102}; 
    8881103 
    8891104/*--------------------------------------------------------------------------*/ 
    8901105 
     
    8921107  var Element = new Object(); 
    8931108 
    8941109Element.extend = function(element) { 
    895   if (!element) return; 
    896   if (_nativeExtensions) return element; 
     1110  if (!element || _nativeExtensions || element.nodeType == 3) return element; 
    8971111 
    8981112  if (!element._extended && element.tagName && element != window) { 
    899     var methods = Element.Methods, cache = Element.extend.cache; 
    900     for (property in methods) { 
     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 
     1120    Object.extend(methods, Element.Methods.Simulated); 
     1121 
     1122    for (var property in methods) { 
    9011123      var value = methods[property]; 
    902       if (typeof value == 'function') 
     1124      if (typeof value == 'function' && !(property in element)) 
    9031125        element[property] = cache.findOrStore(value); 
    9041126    } 
    9051127  } 
    9061128 
    9071129  element._extended = true; 
    9081130  return element; 
    909 } 
     1131}; 
    9101132 
    9111133Element.extend.cache = { 
    9121134  findOrStore: function(value) { 
     
    9141136      return value.apply(null, [this].concat($A(arguments))); 
    9151137    } 
    9161138  } 
    917 } 
     1139}; 
    9181140 
    9191141Element.Methods = { 
    9201142  visible: function(element) { 
    9211143    return $(element).style.display != 'none'; 
    9221144  }, 
    9231145 
    924   toggle: function() { 
    925     for (var i = 0; i < arguments.length; i++) { 
    926       var element = $(arguments[i]); 
    927       Element[Element.visible(element) ? 'hide' : 'show'](element); 
    928     } 
     1146  toggle: function(element) { 
     1147    element = $(element); 
     1148    Element[Element.visible(element) ? 'hide' : 'show'](element); 
     1149    return element; 
    9291150  }, 
    9301151 
    931   hide: function() { 
    932     for (var i = 0; i < arguments.length; i++) { 
    933       var element = $(arguments[i]); 
    934       element.style.display = 'none'; 
    935     } 
     1152  hide: function(element) { 
     1153    $(element).style.display = 'none'; 
     1154    return element; 
    9361155  }, 
    9371156 
    938   show: function() { 
    939     for (var i = 0; i < arguments.length; i++) { 
    940       var element = $(arguments[i]); 
    941       element.style.display = ''; 
    942     } 
     1157  show: function(element) { 
     1158    $(element).style.display = ''; 
     1159    return element; 
    9431160  }, 
    9441161 
    9451162  remove: function(element) { 
    9461163    element = $(element); 
    9471164    element.parentNode.removeChild(element); 
     1165    return element; 
    9481166  }, 
    9491167 
    9501168  update: function(element, html) { 
     1169    html = typeof html == 'undefined' ? '' : html.toString(); 
    9511170    $(element).innerHTML = html.stripScripts(); 
    9521171    setTimeout(function() {html.evalScripts()}, 10); 
     1172    return element; 
    9531173  }, 
    9541174 
    9551175  replace: function(element, html) { 
    9561176    element = $(element); 
     1177    html = typeof html == 'undefined' ? '' : html.toString(); 
    9571178    if (element.outerHTML) { 
    9581179      element.outerHTML = html.stripScripts(); 
    9591180    } else { 
     
    9631184        range.createContextualFragment(html.stripScripts()), element); 
    9641185    } 
    9651186    setTimeout(function() {html.evalScripts()}, 10); 
     1187    return element; 
    9661188  }, 
    9671189 
    968   getHeight: function(element) { 
     1190  inspect: function(element) { 
    9691191    element = $(element); 
    970     return element.offsetHeight; 
     1192    var result = '<' + element.tagName.toLowerCase(); 
     1193    $H({'id': 'id', 'className': 'class'}).each(function(pair) { 
     1194      var property = pair.first(), attribute = pair.last(); 
     1195      var value = (element[property] || '').toString(); 
     1196      if (value) result += ' ' + attribute + '=' + value.inspect(true); 
     1197    }); 
     1198    return result + '>'; 
    9711199  }, 
    9721200 
     1201  recursivelyCollect: function(element, property) { 
     1202    element = $(element); 
     1203    var elements = []; 
     1204    while (element = element[property]) 
     1205      if (element.nodeType == 1) 
     1206        elements.push(Element.extend(element)); 
     1207    return elements; 
     1208  }, 
     1209 
     1210  ancestors: function(element) { 
     1211    return $(element).recursivelyCollect('parentNode'); 
     1212  }, 
     1213 
     1214  descendants: function(element) { 
     1215    return $A($(element).getElementsByTagName('*')); 
     1216  }, 
     1217 
     1218  immediateDescendants: function(element) { 
     1219    if (!(element = $(element).firstChild)) return []; 
     1220    while (element && element.nodeType != 1) element = element.nextSibling; 
     1221    if (element) return [element].concat($(element).nextSiblings()); 
     1222    return []; 
     1223  }, 
     1224 
     1225  previousSiblings: function(element) { 
     1226    return $(element).recursivelyCollect('previousSibling'); 
     1227  }, 
     1228 
     1229  nextSiblings: function(element) { 
     1230    return $(element).recursivelyCollect('nextSibling'); 
     1231  }, 
     1232 
     1233  siblings: function(element) { 
     1234    element = $(element); 
     1235    return element.previousSiblings().reverse().concat(element.nextSiblings()); 
     1236  }, 
     1237 
     1238  match: function(element, selector) { 
     1239    if (typeof selector == 'string') 
     1240      selector = new Selector(selector); 
     1241    return selector.match($(element)); 
     1242  }, 
     1243 
     1244  up: function(element, expression, index) { 
     1245    return Selector.findElement($(element).ancestors(), expression, index); 
     1246  }, 
     1247 
     1248  down: function(element, expression, index) { 
     1249    return Selector.findElement($(element).descendants(), expression, index); 
     1250  }, 
     1251 
     1252  previous: function(element, expression, index) { 
     1253    return Selector.findElement($(element).previousSiblings(), expression, index); 
     1254  }, 
     1255 
     1256  next: function(element, expression, index) { 
     1257    return Selector.findElement($(element).nextSiblings(), expression, index); 
     1258  }, 
     1259 
     1260  getElementsBySelector: function() { 
     1261    var args = $A(arguments), element = $(args.shift()); 
     1262    return Selector.findChildElements(element, args); 
     1263  }, 
     1264 
     1265  getElementsByClassName: function(element, className) { 
     1266    return document.getElementsByClassName(className, element); 
     1267  }, 
     1268 
     1269  readAttribute: function(element, name) { 
     1270    element = $(element); 
     1271    if (document.all && !window.opera) { 
     1272      var t = Element._attributeTranslations; 
     1273      if (t.values[name]) return t.values[name](element, name); 
     1274      if (t.names[name])  name = t.names[name]; 
     1275      var attribute = element.attributes[name]; 
     1276      if(attribute) return attribute.nodeValue; 
     1277    } 
     1278    return element.getAttribute(name); 
     1279  }, 
     1280 
     1281  getHeight: function(element) { 
     1282    return $(element).getDimensions().height; 
     1283  }, 
     1284 
     1285  getWidth: function(element) { 
     1286    return $(element).getDimensions().width; 
     1287  }, 
     1288 
    9731289  classNames: function(element) { 
    9741290    return new Element.ClassNames(element); 
    9751291  }, 
    9761292 
    9771293  hasClassName: function(element, className) { 
    9781294    if (!(element = $(element))) return; 
    979     return Element.classNames(element).include(className); 
     1295    var elementClassName = element.className; 
     1296    if (elementClassName.length == 0) return false; 
     1297    if (elementClassName == className || 
     1298        elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) 
     1299      return true; 
     1300    return false; 
    9801301  }, 
    9811302 
    9821303  addClassName: function(element, className) { 
    9831304    if (!(element = $(element))) return; 
    984     return Element.classNames(element).add(className); 
     1305    Element.classNames(element).add(className); 
     1306    return element; 
    9851307  }, 
    9861308 
    9871309  removeClassName: function(element, className) { 
    9881310    if (!(element = $(element))) return; 
    989     return Element.classNames(element).remove(className); 
     1311    Element.classNames(element).remove(className); 
     1312    return element; 
    9901313  }, 
    9911314 
     1315  toggleClassName: function(element, className) { 
     1316    if (!(element = $(element))) return; 
     1317    Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); 
     1318    return element; 
     1319  }, 
     1320 
     1321  observe: function() { 
     1322    Event.observe.apply(Event, arguments); 
     1323    return $A(arguments).first(); 
     1324  }, 
     1325 
     1326  stopObserving: function() { 
     1327    Event.stopObserving.apply(Event, arguments); 
     1328    return $A(arguments).first(); 
     1329  }, 
     1330 
    9921331  // removes whitespace-only text node children 
    9931332  cleanWhitespace: function(element) { 
    9941333    element = $(element); 
    995     for (var i = 0; i < element.childNodes.length; i++) { 
    996       var node = element.childNodes[i]; 
     1334    var node = element.firstChild; 
     1335    while (node) { 
     1336      var nextNode = node.nextSibling; 
    9971337      if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) 
    998         Element.remove(node); 
     1338        element.removeChild(node); 
     1339      node = nextNode; 
    9991340    } 
     1341    return element; 
    10001342  }, 
    10011343 
    10021344  empty: function(element) { 
    10031345    return $(element).innerHTML.match(/^\s*$/); 
    10041346  }, 
    10051347 
    1006   childOf: function(element, ancestor) { 
     1348  descendantOf: function(element, ancestor) { 
    10071349    element = $(element), ancestor = $(ancestor); 
    10081350    while (element = element.parentNode) 
    10091351      if (element == ancestor) return true; 
     
    10121354 
    10131355  scrollTo: function(element) { 
    10141356    element = $(element); 
    1015     var x = element.x ? element.x : element.offsetLeft, 
    1016         y = element.y ? element.y : element.offsetTop; 
    1017     window.scrollTo(x, y); 
     1357    var pos = Position.cumulativeOffset(element); 
     1358    window.scrollTo(pos[0], pos[1]); 
     1359    return element; 
    10181360  }, 
    10191361 
    10201362  getStyle: function(element, style) { 
    10211363    element = $(element); 
    1022     var value = element.style[style.camelize()]; 
     1364    if (['float','cssFloat'].include(style)) 
     1365      style = (typeof element.style.styleFloat != 'undefined' ? 'styleFloat' : 'cssFloat'); 
     1366    style = style.camelize(); 
     1367    var value = element.style[style]; 
    10231368    if (!value) { 
    10241369      if (document.defaultView && document.defaultView.getComputedStyle) { 
    10251370        var css = document.defaultView.getComputedStyle(element, null); 
    1026         value = css ? css.getPropertyValue(style) : null; 
     1371        value = css ? css[style] : null; 
    10271372      } else if (element.currentStyle) { 
    1028         value = element.currentStyle[style.camelize()]; 
     1373        value = element.currentStyle[style]; 
    10291374      } 
    10301375    } 
    10311376 
     1377    if((value == 'auto') && ['width','height'].include(style) && (element.getStyle('display') != 'none')) 
     1378      value = element['offset'+style.capitalize()] + 'px'; 
     1379 
    10321380    if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) 
    10331381      if (Element.getStyle(element, 'position') == 'static') value = 'auto'; 
    1034  
     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    } 
    10351388    return value == 'auto' ? null : value; 
    10361389  }, 
    10371390 
    10381391  setStyle: function(element, style) { 
    10391392    element = $(element); 
    1040     for (var name in style) 
    1041       element.style[name.camelize()] = style[name]; 
     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    } 
     1413    return element; 
    10421414  }, 
    10431415 
    10441416  getDimensions: function(element) { 
    10451417    element = $(element); 
    1046     if (Element.getStyle(element, 'display') != 'none') 
     1418    var display = $(element).getStyle('display'); 
     1419    if (display != 'none' && display != null) // Safari bug 
    10471420      return {width: element.offsetWidth, height: element.offsetHeight}; 
    10481421 
    10491422    // All *Width and *Height properties give 0 on elements with display none, 
     
    10511424    var els = element.style; 
    10521425    var originalVisibility = els.visibility; 
    10531426    var originalPosition = els.position; 
     1427    var originalDisplay = els.display; 
    10541428    els.visibility = 'hidden'; 
    10551429    els.position = 'absolute'; 
    1056     els.display = ''; 
     1430    els.display = 'block'; 
    10571431    var originalWidth = element.clientWidth; 
    10581432    var originalHeight = element.clientHeight; 
    1059     els.display = 'none'; 
     1433    els.display = originalDisplay; 
    10601434    els.position = originalPosition; 
    10611435    els.visibility = originalVisibility; 
    10621436    return {width: originalWidth, height: originalHeight}; 
     
    10751449        element.style.left = 0; 
    10761450      } 
    10771451    } 
     1452    return element; 
    10781453  }, 
    10791454 
    10801455  undoPositioned: function(element) { 
     
    10871462        element.style.bottom = 
    10881463        element.style.right = ''; 
    10891464    } 
     1465    return element; 
    10901466  }, 
    10911467 
    10921468  makeClipping: function(element) { 
    10931469    element = $(element); 
    1094     if (element._overflow) return; 
    1095     element._overflow = element.style.overflow; 
     1470    if (element._overflow) return element; 
     1471    element._overflow = element.style.overflow || 'auto'; 
    10961472    if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') 
    10971473      element.style.overflow = 'hidden'; 
     1474    return element; 
    10981475  }, 
    10991476 
    11001477  undoClipping: function(element) { 
    11011478    element = $(element); 
    1102     if (element._overflow) return; 
    1103     element.style.overflow = element._overflow; 
    1104     element._overflow = undefined; 
     1479    if (!element._overflow) return element; 
     1480    element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; 
     1481    element._overflow = null; 
     1482    return element; 
    11051483  } 
    1106 } 
     1484}; 
    11071485 
     1486Object.extend(Element.Methods, {childOf: Element.Methods.descendantOf}); 
     1487 
     1488Element._attributeTranslations = {}; 
     1489 
     1490Element._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 
     1503Element._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 
     1522Object.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 
     1529}); 
     1530 
     1531Element.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 
     1540if (document.all && !window.opera){ 
     1541  Element.Methods.update = function(element, html) { 
     1542    element = $(element); 
     1543    html = typeof html == 'undefined' ? '' : html.toString(); 
     1544    var tagName = element.tagName.toUpperCase(); 
     1545    if (['THEAD','TBODY','TR','TD'].include(tagName)) { 
     1546      var div = document.createElement('div'); 
     1547      switch (tagName) { 
     1548        case 'THEAD': 
     1549        case 'TBODY': 
     1550          div.innerHTML = '<table><tbody>' +  html.stripScripts() + '</tbody></table>'; 
     1551          depth = 2; 
     1552          break; 
     1553        case 'TR': 
     1554          div.innerHTML = '<table><tbody><tr>' +  html.stripScripts() + '</tr></tbody></table>'; 
     1555          depth = 3; 
     1556          break; 
     1557        case 'TD': 
     1558          div.innerHTML = '<table><tbody><tr><td>' +  html.stripScripts() + '</td></tr></tbody></table>'; 
     1559          depth = 4; 
     1560      } 
     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) }); 
     1568    } else { 
     1569      element.innerHTML = html.stripScripts(); 
     1570    } 
     1571    setTimeout(function() {html.evalScripts()}, 10); 
     1572    return element; 
     1573  } 
     1574}; 
     1575 
    11081576Object.extend(Element, Element.Methods); 
    11091577 
    11101578var _nativeExtensions = false; 
    11111579 
    1112 if(!HTMLElement && /Konqueror|Safari|KHTML/.test(navigator.userAgent)) { 
    1113   var HTMLElement = {} 
    1114   HTMLElement.prototype = document.createElement('div').__proto__; 
    1115 } 
     1580if(/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  }); 
    11161587 
    11171588Element.addMethods = function(methods) { 
    11181589  Object.extend(Element.Methods, methods || {}); 
    11191590 
    1120   if(typeof HTMLElement != 'undefined') { 
    1121     var methods = Element.Methods, cache = Element.extend.cache; 
    1122     for (property in methods) { 
     1591  function copy(methods, destination, onlyIfAbsent) { 
     1592    onlyIfAbsent = onlyIfAbsent || false; 
     1593    var cache = Element.extend.cache; 
     1594    for (var property in methods) { 
    11231595      var value = methods[property]; 
    1124       if (typeof value == 'function') 
    1125         HTMLElement.prototype[property] = cache.findOrStore(value); 
     1596      if (!onlyIfAbsent || !(property in destination)) 
     1597        destination[property] = cache.findOrStore(value); 
    11261598    } 
     1599  } 
     1600 
     1601  if (typeof HTMLElement != 'undefined') { 
     1602    copy(Element.Methods, HTMLElement.prototype); 
     1603    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    }); 
    11271608    _nativeExtensions = true; 
    11281609  } 
    11291610} 
    11301611 
    1131 Element.addMethods(); 
    1132  
    11331612var Toggle = new Object(); 
    11341613Toggle.display = Element.toggle; 
    11351614 
     
    11481627      try { 
    11491628        this.element.insertAdjacentHTML(this.adjacency, this.content); 
    11501629      } catch (e) { 
    1151         var tagName = this.element.tagName.toLowerCase(); 
    1152         if (tagName == 'tbody' || tagName == 'tr') { 
     1630        var tagName = this.element.tagName.toUpperCase(); 
     1631        if (['TBODY', 'TR'].include(tagName)) { 
    11531632          this.insertContent(this.contentFromAnonymousTable()); 
    11541633        } else { 
    11551634          throw e; 
     
    12481727 
    12491728  add: function(classNameToAdd) { 
    12501729    if (this.include(classNameToAdd)) return; 
    1251     this.set(this.toArray().concat(classNameToAdd).join(' ')); 
     1730    this.set($A(this).concat(classNameToAdd).join(' ')); 
    12521731  }, 
    12531732 
    12541733  remove: function(classNameToRemove) { 
    12551734    if (!this.include(classNameToRemove)) return; 
    1256     this.set(this.select(function(className) { 
    1257       return className != classNameToRemove; 
    1258     }).join(' ')); 
     1735    this.set($A(this).without(classNameToRemove).join(' ')); 
    12591736  }, 
    12601737 
    12611738  toString: function() { 
    1262     return this.toArray().join(' '); 
     1739    return $A(this).join(' '); 
    12631740  } 
    1264 } 
     1741}; 
    12651742 
    12661743Object.extend(Element.ClassNames.prototype, Enumerable); 
    12671744var Selector = Class.create(); 
     
    13081785    if (params.wildcard) 
    13091786      conditions.push('true'); 
    13101787    if (clause = params.id) 
    1311       conditions.push('element.id == ' + clause.inspect()); 
     1788      conditions.push('element.readAttribute("id") == ' + clause.inspect()); 
    13121789    if (clause = params.tagName) 
    13131790      conditions.push('element.tagName.toUpperCase() == ' + clause.inspect()); 
    13141791    if ((clause = params.classNames).length > 0) 
    1315       for (var i = 0; i < clause.length; i++) 
    1316         conditions.push('Element.hasClassName(element, ' + clause[i].inspect() + ')'); 
     1792      for (var i = 0, length = clause.length; i < length; i++) 
     1793        conditions.push('element.hasClassName(' + clause[i].inspect() + ')'); 
    13171794    if (clause = params.attributes) { 
    13181795      clause.each(function(attribute) { 
    1319         var value = 'element.getAttribute(' + attribute.name.inspect() + ')'; 
     1796        var value = 'element.readAttribute(' + attribute.name.inspect() + ')'; 
    13201797        var splitValueBy = function(delimiter) { 
    13211798          return value + ' && ' + value + '.split(' + delimiter.inspect() + ')'; 
    13221799        } 
     
    13291806                          ); break; 
    13301807          case '!=':      conditions.push(value + ' != ' + attribute.value.inspect()); break; 
    13311808          case '': 
    1332           case undefined: conditions.push(value + ' != null'); break; 
     1809          case undefined: conditions.push('element.hasAttribute(' + attribute.name.inspect() + ')'); break; 
    13331810          default:        throw 'Unknown operator ' + attribute.operator + ' in selector'; 
    13341811        } 
    13351812      }); 
     
    13401817 
    13411818  compileMatcher: function() { 
    13421819    this.match = new Function('element', 'if (!element.tagName) return false; \ 
     1820      element = $(element); \ 
    13431821      return ' + this.buildMatchExpression()); 
    13441822  }, 
    13451823 
     
    13541832    scope = (scope || document).getElementsByTagName(this.params.tagName || '*'); 
    13551833 
    13561834    var results = []; 
    1357     for (var i = 0; i < scope.length; i++) 
     1835    for (var i = 0, length = scope.length; i < length; i++) 
    13581836      if (this.match(element = scope[i])) 
    13591837        results.push(Element.extend(element)); 
    13601838 
     
    13661844  } 
    13671845} 
    13681846 
    1369 function $$() { 
    1370   return $A(arguments).map(function(expression) { 
    1371     return expression.strip().split(/\s+/).inject([null], function(results, expr) { 
    1372       var selector = new Selector(expr); 
    1373       return results.map(selector.findElements.bind(selector)).flatten(); 
    1374     }); 
    1375   }).flatten(); 
    1376 } 
    1377 var Field = { 
    1378   clear: function() { 
    1379     for (var i = 0; i < arguments.length; i++) 
    1380       $(arguments[i]).value = ''; 
     1847Object.extend(Selector, { 
     1848  matchElements: function(elements, expression) { 
     1849    var selector = new Selector(expression); 
     1850    return elements.select(selector.match.bind(selector)).map(Element.extend); 
    13811851  }, 
    13821852 
    1383   focus: function(element) { 
    1384     $(element).focus(); 
     1853  findElement: function(elements, expression, index) { 
     1854    if (typeof expression == 'number') index = expression, expression = false; 
     1855    return Selector.matchElements(elements, expression || '*')[index || 0]; 
    13851856  }, 
    13861857 
    1387   present: function() { 
    1388     for (var i = 0; i < arguments.length; i++) 
    1389       if ($(arguments[i]).value == '') return false; 
    1390     return true; 
    1391   }, 
     1858  findChildElements: function(element, expressions) { 
     1859    return expressions.map(function(expression) { 
     1860      return expression.match(/[^\s"]+(?:"[^"]*"[^\s"]+)*/g).inject([null], function(results, expr) { 
     1861        var selector = new Selector(expr); 
     1862        return results.inject([], function(elements, result) { 
     1863          return elements.concat(selector.findElements(result || element)); 
     1864        }); 
     1865      }); 
     1866    }).flatten(); 
     1867  } 
     1868}); 
    13921869 
    1393   select: function(element) { 
    1394     $(element).select(); 
     1870function $$() { 
     1871  return Selector.findChildElements(document, $A(arguments)); 
     1872} 
     1873var Form = { 
     1874  reset: function(form) { 
     1875    $(form).reset(); 
     1876    return form; 
    13951877  }, 
    13961878 
    1397   activate: function(element) { 
    1398     element = $(element); 
    1399     element.focus(); 
    1400     if (element.select) 
    1401       element.select(); 
     1879  serializeElements: function(elements, getHash) { 
     1880    var data = elements.inject({}, function(result, element) { 
     1881      if (!element.disabled && element.name) { 
     1882        var key = element.name, value = $(element).getValue(); 
     1883        if (value != undefined) { 
     1884          if (result[key]) { 
     1885            if (result[key].constructor != Array) result[key] = [result[key]]; 
     1886            result[key].push(value); 
     1887          } 
     1888          else result[key] = value; 
     1889        } 
     1890      } 
     1891      return result; 
     1892    }); 
     1893 
     1894    return getHash ? data : Hash.toQueryString(data); 
    14021895  } 
    1403 } 
     1896}; 
    14041897 
    1405 /*--------------------------------------------------------------------------*/ 
    1406  
    1407 var Form = { 
    1408   serialize: function(form) { 
    1409     var elements = Form.getElements($(form)); 
    1410     var queryComponents = new Array(); 
    1411  
    1412     for (var i = 0; i < elements.length; i++) { 
    1413       var queryComponent = Form.Element.serialize(elements[i]); 
    1414       if (queryComponent) 
    1415         queryComponents.push(queryComponent); 
    1416     } 
    1417  
    1418     return queryComponents.join('&'); 
     1898Form.Methods = { 
     1899  serialize: function(form, getHash) { 
     1900    return Form.serializeElements(Form.getElements(form), getHash); 
    14191901  }, 
    14201902 
    14211903  getElements: function(form) { 
    1422     form = $(form); 
    1423     var elements = new Array(); 
    1424  
    1425     for (var tagName in Form.Element.Serializers) { 
    1426       var tagElements = form.getElementsByTagName(tagName); 
    1427       for (var j = 0; j < tagElements.length; j++) 
    1428         elements.push(tagElements[j]); 
    1429     } 
    1430     return elements; 
     1904    return $A($(form).getElementsByTagName('*')).inject([], 
     1905      function(elements, child) { 
     1906        if (Form.Element.Serializers[child.tagName.toLowerCase()]) 
     1907          elements.push(Element.extend(child)); 
     1908        return elements; 
     1909      } 
     1910    ); 
    14311911  }, 
    14321912 
    14331913  getInputs: function(form, typeName, name) { 
    14341914    form = $(form); 
    14351915    var inputs = form.getElementsByTagName('input'); 
    14361916 
    1437     if (!typeName && !name) 
    1438       return inputs; 
     1917    if (!typeName && !name) return $A(inputs).map(Element.extend); 
    14391918 
    1440     var matchingInputs = new Array(); 
    1441     for (var i = 0; i < inputs.length; i++) { 
     1919    for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { 
    14421920      var input = inputs[i]; 
    1443       if ((typeName && input.type != typeName) || 
    1444           (name && input.name != name)) 
     1921      if ((typeName && input.type != typeName) || (name && input.name != name)) 
    14451922        continue; 
    1446       matchingInputs.push(input); 
     1923      matchingInputs.push(Element.extend(input)); 
    14471924    } 
    14481925 
    14491926    return matchingInputs; 
    14501927  }, 
    14511928 
    14521929  disable: function(form) { 
    1453     var elements = Form.getElements(form); 
    1454     for (var i = 0; i < elements.length; i++) { 
    1455       var element = elements[i]; 
     1930    form = $(form); 
     1931    form.getElements().each(function(element) { 
    14561932      element.blur(); 
    14571933      element.disabled = 'true'; 
    1458     } 
     1934    }); 
     1935    return form; 
    14591936  }, 
    14601937 
    14611938  enable: function(form) { 
    1462     var elements = Form.getElements(form); 
    1463     for (var i = 0; i < elements.length; i++) { 
    1464       var element = elements[i]; 
     1939    form = $(form); 
     1940    form.getElements().each(function(element) { 
    14651941      element.disabled = ''; 
    1466     } 
     1942    }); 
     1943    return form; 
    14671944  }, 
    14681945 
    14691946  findFirstElement: function(form) { 
    1470     return Form.getElements(form).find(function(element) { 
     1947    return $(form).getElements().find(function(element) { 
    14711948      return element.type != 'hidden' && !element.disabled && 
    14721949        ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); 
    14731950    }); 
    14741951  }, 
    14751952 
    14761953  focusFirstElement: function(form) { 
    1477     Field.activate(Form.findFirstElement(form)); 
     1954    form = $(form); 
     1955    form.findFirstElement().activate(); 
     1956    return form; 
     1957  } 
     1958} 
     1959 
     1960Object.extend(Form, Form.Methods); 
     1961 
     1962/*--------------------------------------------------------------------------*/ 
     1963 
     1964Form.Element = { 
     1965  focus: function(element) { 
     1966    $(element).focus(); 
     1967    return element; 
    14781968  }, 
    14791969 
    1480   reset: function(form) { 
    1481     $(form).reset(); 
     1970  select: function(element) { 
     1971    $(element).select(); 
     1972    return element; 
    14821973  } 
    14831974} 
    14841975 
    1485 Form.Element = { 
     1976Form.Element.Methods = { 
    14861977  serialize: function(element) { 
    14871978    element = $(element); 
     1979    if (!element.disabled && element.name) { 
     1980      var value = element.getValue(); 
     1981      if (value != undefined) { 
     1982        var pair = {}; 
     1983        pair[element.name] = value; 
     1984        return Hash.toQueryString(pair); 
     1985      } 
     1986    } 
     1987    return ''; 
     1988  }, 
     1989 
     1990  getValue: function(element) { 
     1991    element = $(element); 
    14881992    var method = element.tagName.toLowerCase(); 
    1489     var parameter = Form.Element.Serializers[method](element); 
     1993    return Form.Element.Serializers[method](element); 
     1994  }, 
    14901995 
    1491     if (parameter) { 
    1492       var key = encodeURIComponent(parameter[0]); 
    1493       if (key.length == 0) return; 
     1996  clear: function(element) { 
     1997    $(element).value = ''; 
     1998    return element; 
     1999  }, 
    14942000 
    1495       if (parameter[1].constructor != Array) 
    1496         parameter[1] = [parameter[1]]; 
     2001  present: function(element) { 
     2002    return $(element).value != ''; 
     2003  }, 
    14972004 
    1498       return parameter[1].map(function(value) { 
    1499         return key + '=' + encodeURIComponent(value); 
    1500       }).join('&'); 
    1501     } 
     2005  activate: function(element) { 
     2006    element = $(element); 
     2007    element.focus(); 
     2008    if (element.select && ( element.tagName.toLowerCase() != 'input' || 
     2009      !['button', 'reset', 'submit'].include(element.type) ) ) 
     2010      element.select(); 
     2011    return element; 
    15022012  }, 
    15032013 
    1504   getValue: function(element) { 
     2014  disable: function(element) { 
    15052015    element = $(element); 
    1506     var method = element.tagName.toLowerCase(); 
    1507     var parameter = Form.Element.Serializers[method](element); 
     2016    element.disabled = true; 
     2017    return element; 
     2018  }, 
    15082019 
    1509     if (parameter) 
    1510       return parameter[1]; 
     2020  enable: function(element) { 
     2021    element = $(element); 
     2022    element.blur(); 
     2023    element.disabled = false; 
     2024    return element; 
    15112025  } 
    15122026} 
    15132027 
     2028Object.extend(Form.Element, Form.Element.Methods); 
     2029var Field = Form.Element; 
     2030var $F = Form.Element.getValue; 
     2031 
     2032/*--------------------------------------------------------------------------*/ 
     2033 
    15142034Form.Element.Serializers = { 
    15152035  input: function(element) { 
    15162036    switch (element.type.toLowerCase()) { 
    1517       case 'submit': 
    1518       case 'hidden': 
    1519       case 'password': 
    1520       case 'text': 
    1521         return Form.Element.Serializers.textarea(element); 
    15222037      case 'checkbox': 
    15232038      case 'radio': 
    15242039        return Form.Element.Serializers.inputSelector(element); 
     2040      default: 
     2041        return Form.Element.Serializers.textarea(element); 
    15252042    } 
    1526     return false; 
    15272043  }, 
    15282044 
    15292045  inputSelector: function(element) { 
    1530     if (element.checked) 
    1531       return [element.name, element.value]; 
     2046    return element.checked ? element.value : null; 
    15322047  }, 
    15332048 
    15342049  textarea: function(element) { 
    1535     return [element.name, element.value]; 
     2050    return element.value; 
    15362051  }, 
    15372052 
    15382053  select: function(element) { 
    1539     return Form.Element.Serializers[element.type == 'select-one' ? 
     2054    return this[element.type == 'select-one' ? 
    15402055      'selectOne' : 'selectMany'](element); 
    15412056  }, 
    15422057 
    15432058  selectOne: function(element) { 
    1544     var value = '', opt, index = element.selectedIndex; 
    1545     if (index >= 0) { 
    1546       opt = element.options[index]; 
    1547       value = opt.value || opt.text; 
    1548     } 
    1549     return [element.name, value]; 
     2059    var index = element.selectedIndex; 
     2060    return index >= 0 ? this.optionValue(element.options[index]) : null; 
    15502061  }, 
    15512062 
    15522063  selectMany: function(element) { 
    1553     var value = []; 
    1554     for (var i = 0; i < element.length; i++) { 
     2064    var values, length = element.length; 
     2065    if (!length) return null; 
     2066 
     2067    for (var i = 0, values = []; i < length; i++) { 
    15552068      var opt = element.options[i]; 
    1556       if (opt.selected) 
    1557         value.push(opt.value || opt.text); 
     2069      if (opt.selected) values.push(this.optionValue(opt)); 
    15582070    } 
    1559     return [element.name, value]; 
     2071    return values; 
     2072  }, 
     2073 
     2074  optionValue: function(opt) { 
     2075    // extend element because hasAttribute may not be native 
     2076    return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; 
    15602077  } 
    15612078} 
    15622079 
    15632080/*--------------------------------------------------------------------------*/ 
    15642081 
    1565 var $F = Form.Element.getValue; 
    1566  
    1567 /*--------------------------------------------------------------------------*/ 
    1568  
    15692082Abstract.TimedObserver = function() {} 
    15702083Abstract.TimedObserver.prototype = { 
    15712084  initialize: function(element, frequency, callback) { 
     
    15832096 
    15842097  onTimerEvent: function() { 
    15852098    var value = this.getValue(); 
    1586     if (this.lastValue != value) { 
     2099    var changed = ('string' == typeof this.lastValue && 'string' == typeof value 
     2100      ? this.lastValue != value : String(this.lastValue) != String(value)); 
     2101    if (changed) { 
    15872102      this.callback(this.element, value); 
    15882103      this.lastValue = value; 
    15892104    } 
     
    16282143  }, 
    16292144 
    16302145  registerFormCallbacks: function() { 
    1631     var elements = Form.getElements(this.element); 
    1632     for (var i = 0; i < elements.length; i++) 
    1633       this.registerCallback(elements[i]); 
     2146    Form.getElements(this.element).each(this.registerCallback.bind(this)); 
    16342147  }, 
    16352148 
    16362149  registerCallback: function(element) { 
     
    16402153        case 'radio': 
    16412154          Event.observe(element, 'click', this.onElementEvent.bind(this)); 
    16422155          break; 
    1643         case 'password': 
    1644         case 'text': 
    1645         case 'textarea': 
    1646         case 'select-one': 
    1647         case 'select-multiple': 
     2156        default: 
    16482157          Event.observe(element, 'change', this.onElementEvent.bind(this)); 
    16492158          break; 
    16502159      } 
     
    16792188  KEY_RIGHT:    39, 
    16802189  KEY_DOWN:     40, 
    16812190  KEY_DELETE:   46, 
     2191  KEY_HOME:     36, 
     2192  KEY_END:      35, 
     2193  KEY_PAGEUP:   33, 
     2194  KEY_PAGEDOWN: 34, 
    16822195 
    16832196  element: function(event) { 
    16842197    return event.target || event.srcElement; 
     
    17342247 
    17352248  unloadCache: function() { 
    17362249    if (!Event.observers) return; 
    1737     for (var i = 0; i < Event.observers.length; i++) { 
     2250    for (var i = 0, length = Event.observers.length; i < length; i++) { 
    17382251      Event.stopObserving.apply(this, Event.observers[i]); 
    17392252      Event.observers[i][0] = null; 
    17402253    } 
     
    17422255  }, 
    17432256 
    17442257  observe: function(element, name, observer, useCapture) { 
    1745     var element = $(element); 
     2258    element = $(element); 
    17462259    useCapture = useCapture || false; 
    17472260 
    17482261    if (name == 'keypress' && 
     
    17502263        || element.attachEvent)) 
    17512264      name = 'keydown'; 
    17522265 
    1753     this._observeAndCache(element, name, observer, useCapture); 
     2266    Event._observeAndCache(element, name, observer, useCapture); 
    17542267  }, 
    17552268 
    17562269  stopObserving: function(element, name, observer, useCapture) { 
    1757     var element = $(element); 
     2270    element = $(element); 
    17582271    useCapture = useCapture || false; 
    17592272 
    17602273    if (name == 'keypress' && 
     
    18212334      valueL += element.offsetLeft || 0; 
    18222335      element = element.offsetParent; 
    18232336      if (element) { 
    1824         p = Element.getStyle(element, 'position'); 
     2337        if(element.tagName=='BODY') break; 
     2338        var p = Element.getStyle(element, 'position'); 
    18252339        if (p == 'relative' || p == 'absolute') break; 
    18262340      } 
    18272341    } while (element); 
     
    18772391        element.offsetWidth; 
    18782392  }, 
    18792393 
    1880   clone: function(source, target) { 
    1881     source = $(source); 
    1882     target = $(target); 
    1883     target.style.position = 'absolute'; 
    1884     var offsets = this.cumulativeOffset(source); 
    1885     target.style.top    = offsets[1] + 'px'; 
    1886     target.style.left   = offsets[0] + 'px'; 
    1887     target.style.width  = source.offsetWidth + 'px'; 
    1888     target.style.height = source.offsetHeight + 'px'; 
    1889   }, 
    1890  
    18912394  page: function(forElement) { 
    18922395    var valueT = 0, valueL = 0; 
    18932396 
     
    19042407 
    19052408    element = forElement; 
    19062409    do { 
    1907       valueT -= element.scrollTop  || 0; 
    1908       valueL -= element.scrollLeft || 0; 
     2410      if (!window.opera || element.tagName=='BODY') { 
     2411        valueT -= element.scrollTop  || 0; 
     2412        valueL -= element.scrollLeft || 0; 
     2413      } 
    19092414    } while (element = element.parentNode); 
    19102415 
    19112416    return [valueL, valueT]; 
     
    19662471    element._originalHeight = element.style.height; 
    19672472 
    19682473    element.style.position = 'absolute'; 
    1969     element.style.top    = top + 'px';; 
    1970     element.style.left   = left + 'px';; 
    1971     element.style.width  = width + 'px';; 
    1972     element.style.height = height + 'px';; 
     2474    element.style.top    = top + 'px'; 
     2475    element.style.left   = left + 'px'; 
     2476    element.style.width  = width + 'px'; 
     2477    element.style.height = height + 'px'; 
    19732478  }, 
    19742479 
    19752480  relativize: function(element) { 
     
    20052510 
    20062511    return [valueL, valueT]; 
    20072512  } 
    2008 } 
    2009  No newline at end of file 
     2513} 
     2514 
     2515Element.addMethods(); 
     2516 No newline at end of file 
  • wp-includes/js/scriptaculous/builder.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    24// 
    3 // See scriptaculous.js for full license. 
     5// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     6// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    47 
    58var Builder = { 
    69  NODEMAP: { 
     
    3336    var element = parentElement.firstChild || null; 
    3437       
    3538    // see if browser added wrapping tags 
    36     if(element && (element.tagName != elementName)) 
     39    if(element && (element.tagName.toUpperCase() != elementName)) 
    3740      element = element.getElementsByTagName(elementName)[0]; 
    3841     
    3942    // fallback to createElement approach 
     
    6164              for(attr in arguments[1])  
    6265                element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; 
    6366            } 
    64             if(element.tagName != elementName) 
     67            if(element.tagName.toUpperCase() != elementName) 
    6568              element = parentElement.getElementsByTagName(elementName)[0]; 
    6669            } 
    6770        }  
     
    7578  _text: function(text) { 
    7679     return document.createTextNode(text); 
    7780  }, 
     81 
     82  ATTR_MAP: { 
     83    'className': 'class', 
     84    'htmlFor': 'for' 
     85  }, 
     86 
    7887  _attributes: function(attributes) { 
    7988    var attrs = []; 
    8089    for(attribute in attributes) 
    81       attrs.push((attribute=='className' ? 'class' : attribute) + 
     90      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + 
    8291          '="' + attributes[attribute].toString().escapeHTML() + '"'); 
    8392    return attrs.join(" "); 
    8493  }, 
     
    97106  }, 
    98107  _isStringOrNumber: function(param) { 
    99108    return(typeof param=='string' || typeof param=='number'); 
     109  }, 
     110  build: function(html) { 
     111    var element = this.node('div'); 
     112    $(element).update(html.strip()); 
     113    return element.down(); 
     114  }, 
     115  dump: function(scope) {  
     116    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope  
     117   
     118    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + 
     119      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + 
     120      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ 
     121      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ 
     122      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ 
     123      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); 
     124   
     125    tags.each( function(tag){  
     126      scope[tag] = function() {  
     127        return Builder.node.apply(Builder, [tag].concat($A(arguments)));   
     128      }  
     129    }); 
    100130  } 
    101 } 
    102  No newline at end of file 
     131} 
  • wp-includes/js/scriptaculous/MIT-LICENSE

     
    1 Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    22 
    33Permission is hereby granted, free of charge, to any person obtaining 
    44a copy of this software and associated documentation files (the 
  • wp-includes/js/scriptaculous/effects.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    24// Contributors: 
    35//  Justin Palmer (http://encytemedia.com/) 
    46//  Mark Pilgrim (http://diveintomark.org/) 
    57//  Martin Bialasinki 
    68//  
    7 // See scriptaculous.js for full license.   
     9// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     10// For details, see the script.aculo.us web site: http://script.aculo.us/  
    811 
    912// converts rgb() and #xxx to #xxxxxx format,   
    1013// returns self (or first argument) if not convertable   
    1114String.prototype.parseColor = function() {   
    12   var color = '#';   
     15  var color = '#'; 
    1316  if(this.slice(0,4) == 'rgb(') {   
    1417    var cols = this.slice(4,this.length-1).split(',');   
    1518    var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3);   
     
    4144 
    4245Element.setContentZoom = function(element, percent) { 
    4346  element = $(element);   
    44   Element.setStyle(element, {fontSize: (percent/100) + 'em'});    
     47  element.setStyle({fontSize: (percent/100) + 'em'});    
    4548  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 
     49  return element; 
    4650} 
    4751 
    48 Element.getOpacity = function(element){   
    49   var opacity; 
    50   if (opacity = Element.getStyle(element, 'opacity'))   
    51     return parseFloat(opacity);   
    52   if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))   
    53     if(opacity[1]) return parseFloat(opacity[1]) / 100;   
    54   return 1.0;   
     52Element.getOpacity = function(element){ 
     53  return $(element).getStyle('opacity'); 
    5554} 
    5655 
    57 Element.setOpacity = function(element, value){   
    58   element= $(element);   
    59   if (value == 1){ 
    60     Element.setStyle(element, { opacity:  
    61       (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?  
    62       0.999999 : null }); 
    63     if(/MSIE/.test(navigator.userAgent))   
    64       Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});   
    65   } else {   
    66     if(value < 0.00001) value = 0;   
    67     Element.setStyle(element, {opacity: value}); 
    68     if(/MSIE/.test(navigator.userAgent))   
    69      Element.setStyle(element,  
    70        { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 
    71                  'alpha(opacity='+value*100+')' });   
    72   } 
    73  
    74   
    75 Element.getInlineOpacity = function(element){   
     56Element.setOpacity = function(element, value){ 
     57  return $(element).setStyle({opacity:value}); 
     58} 
     59 
     60Element.getInlineOpacity = function(element){ 
    7661  return $(element).style.opacity || ''; 
    77  
    78  
    79 Element.childrenWithClassName = function(element, className, findFirst) { 
    80   var classNameRegExp = new RegExp("(^|\\s)" + className + "(\\s|$)"); 
    81   var results = $A($(element).getElementsByTagName('*'))[findFirst ? 'detect' : 'select']( function(c) {  
    82     return (c.className && c.className.match(classNameRegExp)); 
    83   }); 
    84   if(!results) results = []; 
    85   return results; 
    8662} 
    8763 
    8864Element.forceRerendering = function(element) { 
     
    10480/*--------------------------------------------------------------------------*/ 
    10581 
    10682var Effect = { 
     83  _elementDoesNotExistError: { 
     84    name: 'ElementDoesNotExistError', 
     85    message: 'The specified DOM element does not exist, but is required for this effect to operate' 
     86  }, 
    10787  tagifyText: function(element) { 
     88    if(typeof Builder == 'undefined') 
     89      throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); 
     90       
    10891    var tagifyStyle = 'position:relative'; 
    109     if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; 
     92    if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1'; 
     93     
    11094    element = $(element); 
    11195    $A(element.childNodes).each( function(child) { 
    11296      if(child.nodeType==3) { 
     
    159143 
    160144/* ------------- transitions ------------- */ 
    161145 
    162 Effect.Transitions = {} 
     146Effect.Transitions = { 
     147  linear: Prototype.K, 
     148  sinoidal: function(pos) { 
     149    return (-Math.cos(pos*Math.PI)/2) + 0.5; 
     150  }, 
     151  reverse: function(pos) { 
     152    return 1-pos; 
     153  }, 
     154  flicker: function(pos) { 
     155    return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 
     156  }, 
     157  wobble: function(pos) { 
     158    return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 
     159  }, 
     160  pulse: function(pos, pulses) {  
     161    pulses = pulses || 5;  
     162    return ( 
     163      Math.round((pos % (1/pulses)) * pulses) == 0 ?  
     164            ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :  
     165        1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) 
     166      ); 
     167  }, 
     168  none: function(pos) { 
     169    return 0; 
     170  }, 
     171  full: function(pos) { 
     172    return 1; 
     173  } 
     174}; 
    163175 
    164 Effect.Transitions.linear = function(pos) { 
    165   return pos; 
    166 } 
    167 Effect.Transitions.sinoidal = function(pos) { 
    168   return (-Math.cos(pos*Math.PI)/2) + 0.5; 
    169 } 
    170 Effect.Transitions.reverse  = function(pos) { 
    171   return 1-pos; 
    172 } 
    173 Effect.Transitions.flicker = function(pos) { 
    174   return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 
    175 } 
    176 Effect.Transitions.wobble = function(pos) { 
    177   return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 
    178 } 
    179 Effect.Transitions.pulse = function(pos) { 
    180   return (Math.floor(pos*10) % 2 == 0 ?  
    181     (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); 
    182 } 
    183 Effect.Transitions.none = function(pos) { 
    184   return 0; 
    185 } 
    186 Effect.Transitions.full = function(pos) { 
    187   return 1; 
    188 } 
    189  
    190176/* ------------- core effects ------------- */ 
    191177 
    192178Effect.ScopedQueue = Class.create(); 
     
    212198            e.finishOn += effect.finishOn; 
    213199          }); 
    214200        break; 
     201      case 'with-last': 
     202        timestamp = this.effects.pluck('startOn').max() || timestamp; 
     203        break; 
    215204      case 'end': 
    216205        // start effect after last queued effect has finished 
    217206        timestamp = this.effects.pluck('finishOn').max() || timestamp; 
     
    225214      this.effects.push(effect); 
    226215     
    227216    if(!this.interval)  
    228       this.interval = setInterval(this.loop.bind(this), 40); 
     217      this.interval = setInterval(this.loop.bind(this), 15); 
    229218  }, 
    230219  remove: function(effect) { 
    231220    this.effects = this.effects.reject(function(e) { return e==effect }); 
     
    236225  }, 
    237226  loop: function() { 
    238227    var timePos = new Date().getTime(); 
    239     this.effects.invoke('loop', timePos); 
     228    for(var i=0, len=this.effects.length;i<len;i++)  
     229      if(this.effects[i]) this.effects[i].loop(timePos); 
    240230  } 
    241231}); 
    242232 
     
    256246Effect.DefaultOptions = { 
    257247  transition: Effect.Transitions.sinoidal, 
    258248  duration:   1.0,   // seconds 
    259   fps:        25.0,  // max. 25fps due to Effect.Queue implementation 
     249  fps:        60.0,  // max. 60fps due to Effect.Queue implementation 
    260250  sync:       false, // true for combining 
    261251  from:       0.0, 
    262252  to:         1.0, 
     
    324314    if(this.options[eventName]) this.options[eventName](this); 
    325315  }, 
    326316  inspect: function() { 
    327     return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>'; 
     317    var data = $H(); 
     318    for(property in this) 
     319      if(typeof this[property] != 'function') data[property] = this[property]; 
     320    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; 
    328321  } 
    329322} 
    330323 
     
    348341  } 
    349342}); 
    350343 
     344Effect.Event = Class.create(); 
     345Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), { 
     346  initialize: function() { 
     347    var options = Object.extend({ 
     348      duration: 0 
     349    }, arguments[0] || {}); 
     350    this.start(options); 
     351  }, 
     352  update: Prototype.emptyFunction 
     353}); 
     354 
    351355Effect.Opacity = Class.create(); 
    352356Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { 
    353357  initialize: function(element) { 
    354358    this.element = $(element); 
     359    if(!this.element) throw(Effect._elementDoesNotExistError); 
    355360    // make this work on IE on elements without 'layout' 
    356     if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) 
     361    if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 
    357362      this.element.setStyle({zoom: 1}); 
    358363    var options = Object.extend({ 
    359364      from: this.element.getOpacity() || 0.0, 
     
    370375Object.extend(Object.extend(Effect.Move.prototype, Effect.Base.prototype), { 
    371376  initialize: function(element) { 
    372377    this.element = $(element); 
     378    if(!this.element) throw(Effect._elementDoesNotExistError); 
    373379    var options = Object.extend({ 
    374380      x:    0, 
    375381      y:    0, 
     
    393399  }, 
    394400  update: function(position) { 
    395401    this.element.setStyle({ 
    396       left: this.options.x  * position + this.originalLeft + 'px', 
    397       top:  this.options.y  * position + this.originalTop  + 'px' 
     402      left: Math.round(this.options.x  * position + this.originalLeft) + 'px', 
     403      top:  Math.round(this.options.y  * position + this.originalTop)  + 'px' 
    398404    }); 
    399405  } 
    400406}); 
     
    408414Effect.Scale = Class.create(); 
    409415Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { 
    410416  initialize: function(element, percent) { 
    411     this.element = $(element) 
     417    this.element = $(element); 
     418    if(!this.element) throw(Effect._elementDoesNotExistError); 
    412419    var options = Object.extend({ 
    413420      scaleX: true, 
    414421      scaleY: true, 
     
    433440    this.originalLeft = this.element.offsetLeft; 
    434441     
    435442    var fontSize = this.element.getStyle('font-size') || '100%'; 
    436     ['em','px','%'].each( function(fontSizeType) { 
     443    ['em','px','%','pt'].each( function(fontSizeType) { 
    437444      if(fontSize.indexOf(fontSizeType)>0) { 
    438445        this.fontSize     = parseFloat(fontSize); 
    439446        this.fontSizeType = fontSizeType; 
     
    458465    this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); 
    459466  }, 
    460467  finish: function(position) { 
    461     if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); 
     468    if(this.restoreAfterFinish) this.element.setStyle(this.originalStyle); 
    462469  }, 
    463470  setDimensions: function(height, width) { 
    464471    var d = {}; 
    465     if(this.options.scaleX) d.width = width + 'px'; 
    466     if(this.options.scaleY) d.height = height + 'px'; 
     472    if(this.options.scaleX) d.width = Math.round(width) + 'px'; 
     473    if(this.options.scaleY) d.height = Math.round(height) + 'px'; 
    467474    if(this.options.scaleFromCenter) { 
    468475      var topd  = (height - this.dims[0])/2; 
    469476      var leftd = (width  - this.dims[1])/2; 
     
    483490Object.extend(Object.extend(Effect.Highlight.prototype, Effect.Base.prototype), { 
    484491  initialize: function(element) { 
    485492    this.element = $(element); 
     493    if(!this.element) throw(Effect._elementDoesNotExistError); 
    486494    var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || {}); 
    487495    this.start(options); 
    488496  }, 
     
    490498    // Prevent executing on elements not in the layout flow 
    491499    if(this.element.getStyle('display')=='none') { this.cancel(); return; } 
    492500    // Disable background image during the effect 
    493     this.oldStyle = { 
    494       backgroundImage: this.element.getStyle('background-image') }; 
    495     this.element.setStyle({backgroundImage: 'none'}); 
     501    this.oldStyle = {}; 
     502    if (!this.options.keepBackgroundImage) { 
     503      this.oldStyle.backgroundImage = this.element.getStyle('background-image'); 
     504      this.element.setStyle({backgroundImage: 'none'}); 
     505    } 
    496506    if(!this.options.endcolor) 
    497507      this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); 
    498508    if(!this.options.restorecolor) 
     
    547557  to:   0.0, 
    548558  afterFinishInternal: function(effect) {  
    549559    if(effect.options.to!=0) return; 
    550     effect.element.hide(); 
    551     effect.element.setStyle({opacity: oldOpacity});  
     560    effect.element.hide().setStyle({opacity: oldOpacity});  
    552561  }}, arguments[1] || {}); 
    553562  return new Effect.Opacity(element,options); 
    554563} 
     
    563572    effect.element.forceRerendering(); 
    564573  }, 
    565574  beforeSetup: function(effect) { 
    566     effect.element.setOpacity(effect.options.from); 
    567     effect.element.show();  
     575    effect.element.setOpacity(effect.options.from).show();  
    568576  }}, arguments[1] || {}); 
    569577  return new Effect.Opacity(element,options); 
    570578} 
    571579 
    572580Effect.Puff = function(element) { 
    573581  element = $(element); 
    574   var oldStyle = { opacity: element.getInlineOpacity(), position: element.getStyle('position') }; 
     582  var oldStyle = {  
     583    opacity: element.getInlineOpacity(),  
     584    position: element.getStyle('position'), 
     585    top:  element.style.top, 
     586    left: element.style.left, 
     587    width: element.style.width, 
     588    height: element.style.height 
     589  }; 
    575590  return new Effect.Parallel( 
    576591   [ new Effect.Scale(element, 200,  
    577592      { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }),  
    578593     new Effect.Opacity(element, { sync: true, to: 0.0 } ) ],  
    579594     Object.extend({ duration: 1.0,  
    580595      beforeSetupInternal: function(effect) { 
    581         effect.effects[0].element.setStyle({position: 'absolute'}); }, 
     596        Position.absolutize(effect.effects[0].element) 
     597      }, 
    582598      afterFinishInternal: function(effect) { 
    583          effect.effects[0].element.hide(); 
    584          effect.effects[0].element.setStyle(oldStyle); } 
     599         effect.effects[0].element.hide().setStyle(oldStyle); } 
    585600     }, arguments[1] || {}) 
    586601   ); 
    587602} 
     
    589604Effect.BlindUp = function(element) { 
    590605  element = $(element); 
    591606  element.makeClipping(); 
    592   return new Effect.Scale(element, 0,  
     607  return new Effect.Scale(element, 0, 
    593608    Object.extend({ scaleContent: false,  
    594609      scaleX: false,  
    595610      restoreAfterFinish: true, 
    596611      afterFinishInternal: function(effect) { 
    597         effect.element.hide(); 
    598         effect.element.undoClipping(); 
     612        effect.element.hide().undoClipping(); 
    599613      }  
    600614    }, arguments[1] || {}) 
    601615  ); 
     
    604618Effect.BlindDown = function(element) { 
    605619  element = $(element); 
    606620  var elementDimensions = element.getDimensions(); 
    607   return new Effect.Scale(element, 100,  
    608     Object.extend({ scaleContent: false,  
    609       scaleX: false, 
    610       scaleFrom: 0, 
    611       scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, 
    612       restoreAfterFinish: true, 
    613       afterSetup: function(effect) { 
    614         effect.element.makeClipping(); 
    615         effect.element.setStyle({height: '0px'}); 
    616         effect.element.show();  
    617       },   
    618       afterFinishInternal: function(effect) { 
    619         effect.element.undoClipping(); 
    620       } 
    621     }, arguments[1] || {}) 
    622   ); 
     621  return new Effect.Scale(element, 100, Object.extend({  
     622    scaleContent: false,  
     623    scaleX: false, 
     624    scaleFrom: 0, 
     625    scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, 
     626    restoreAfterFinish: true, 
     627    afterSetup: function(effect) { 
     628      effect.element.makeClipping().setStyle({height: '0px'}).show();  
     629    },   
     630    afterFinishInternal: function(effect) { 
     631      effect.element.undoClipping(); 
     632    } 
     633  }, arguments[1] || {})); 
    623634} 
    624635 
    625636Effect.SwitchOff = function(element) { 
    626637  element = $(element); 
    627638  var oldOpacity = element.getInlineOpacity(); 
    628   return new Effect.Appear(element, {  
     639  return new Effect.Appear(element, Object.extend({ 
    629640    duration: 0.4, 
    630641    from: 0, 
    631642    transition: Effect.Transitions.flicker, 
     
    634645        duration: 0.3, scaleFromCenter: true, 
    635646        scaleX: false, scaleContent: false, restoreAfterFinish: true, 
    636647        beforeSetup: function(effect) {  
    637           effect.element.makePositioned(); 
    638           effect.element.makeClipping(); 
     648          effect.element.makePositioned().makeClipping(); 
    639649        }, 
    640650        afterFinishInternal: function(effect) { 
    641           effect.element.hide(); 
    642           effect.element.undoClipping(); 
    643           effect.element.undoPositioned(); 
    644           effect.element.setStyle({opacity: oldOpacity}); 
     651          effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); 
    645652        } 
    646653      }) 
    647654    } 
    648   }); 
     655  }, arguments[1] || {})); 
    649656} 
    650657 
    651658Effect.DropOut = function(element) { 
     
    663670          effect.effects[0].element.makePositioned();  
    664671        }, 
    665672        afterFinishInternal: function(effect) { 
    666           effect.effects[0].element.hide(); 
    667           effect.effects[0].element.undoPositioned(); 
    668           effect.effects[0].element.setStyle(oldStyle); 
     673          effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); 
    669674        }  
    670675      }, arguments[1] || {})); 
    671676} 
     
    687692      { x:  40, y: 0, duration: 0.1,  afterFinishInternal: function(effect) { 
    688693    new Effect.Move(effect.element, 
    689694      { x: -20, y: 0, duration: 0.05, afterFinishInternal: function(effect) { 
    690         effect.element.undoPositioned(); 
    691         effect.element.setStyle(oldStyle); 
     695        effect.element.undoPositioned().setStyle(oldStyle); 
    692696  }}) }}) }}) }}) }}) }}); 
    693697} 
    694698 
    695699Effect.SlideDown = function(element) { 
    696   element = $(element); 
    697   element.cleanWhitespace(); 
     700  element = $(element).cleanWhitespace(); 
    698701  // SlideDown need to have the content of the element wrapped in a container element with fixed height! 
    699   var oldInnerBottom = $(element.firstChild).getStyle('bottom'); 
     702  var oldInnerBottom = element.down().getStyle('bottom'); 
    700703  var elementDimensions = element.getDimensions(); 
    701704  return new Effect.Scale(element, 100, Object.extend({  
    702705    scaleContent: false,  
     
    706709    restoreAfterFinish: true, 
    707710    afterSetup: function(effect) { 
    708711      effect.element.makePositioned(); 
    709       effect.element.firstChild.makePositioned(); 
     712      effect.element.down().makePositioned(); 
    710713      if(window.opera) effect.element.setStyle({top: ''}); 
    711       effect.element.makeClipping(); 
    712       effect.element.setStyle({height: '0px'}); 
    713       effect.element.show(); }, 
     714      effect.element.makeClipping().setStyle({height: '0px'}).show();  
     715    }, 
    714716    afterUpdateInternal: function(effect) { 
    715       effect.element.firstChild.setStyle({bottom: 
     717      effect.element.down().setStyle({bottom: 
    716718        (effect.dims[0] - effect.element.clientHeight) + 'px' });  
    717719    }, 
    718720    afterFinishInternal: function(effect) { 
    719       effect.element.undoClipping();  
    720       // IE will crash if child is undoPositioned first 
    721       if(/MSIE/.test(navigator.userAgent)){ 
    722         effect.element.undoPositioned(); 
    723         effect.element.firstChild.undoPositioned(); 
    724       }else{ 
    725         effect.element.firstChild.undoPositioned(); 
    726         effect.element.undoPositioned(); 
    727       } 
    728       effect.element.firstChild.setStyle({bottom: oldInnerBottom}); } 
     721      effect.element.undoClipping().undoPositioned(); 
     722      effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } 
    729723    }, arguments[1] || {}) 
    730724  ); 
    731725} 
    732    
     726 
    733727Effect.SlideUp = function(element) { 
    734   element = $(element); 
    735   element.cleanWhitespace(); 
    736   var oldInnerBottom = $(element.firstChild).getStyle('bottom'); 
     728  element = $(element).cleanWhitespace(); 
     729  var oldInnerBottom = element.down().getStyle('bottom'); 
    737730  return new Effect.Scale(element, window.opera ? 0 : 1, 
    738731   Object.extend({ scaleContent: false,  
    739732    scaleX: false,  
     
    742735    restoreAfterFinish: true, 
    743736    beforeStartInternal: function(effect) { 
    744737      effect.element.makePositioned(); 
    745       effect.element.firstChild.makePositioned(); 
     738      effect.element.down().makePositioned(); 
    746739      if(window.opera) effect.element.setStyle({top: ''}); 
    747       effect.element.makeClipping(); 
    748       effect.element.show(); },   
     740      effect.element.makeClipping().show(); 
     741    },   
    749742    afterUpdateInternal: function(effect) { 
    750       effect.element.firstChild.setStyle({bottom: 
    751         (effect.dims[0] - effect.element.clientHeight) + 'px' }); }, 
     743      effect.element.down().setStyle({bottom: 
     744        (effect.dims[0] - effect.element.clientHeight) + 'px' }); 
     745    }, 
    752746    afterFinishInternal: function(effect) { 
    753       effect.element.hide(); 
    754       effect.element.undoClipping(); 
    755       effect.element.firstChild.undoPositioned(); 
    756       effect.element.undoPositioned(); 
    757       effect.element.setStyle({bottom: oldInnerBottom}); } 
     747      effect.element.hide().undoClipping().undoPositioned().setStyle({bottom: oldInnerBottom}); 
     748      effect.element.down().undoPositioned(); 
     749    } 
    758750   }, arguments[1] || {}) 
    759751  ); 
    760752} 
    761753 
    762754// Bug in opera makes the TD containing this element expand for a instance after finish  
    763755Effect.Squish = function(element) { 
    764   return new Effect.Scale(element, window.opera ? 1 : 0,  
    765     { restoreAfterFinish: true, 
    766       beforeSetup: function(effect) { 
    767         effect.element.makeClipping(effect.element); },   
    768       afterFinishInternal: function(effect) { 
    769         effect.element.hide(effect.element);  
    770         effect.element.undoClipping(effect.element); } 
     756  return new Effect.Scale(element, window.opera ? 1 : 0, {  
     757    restoreAfterFinish: true, 
     758    beforeSetup: function(effect) { 
     759      effect.element.makeClipping();  
     760    },   
     761    afterFinishInternal: function(effect) { 
     762      effect.element.hide().undoClipping();  
     763    } 
    771764  }); 
    772765} 
    773766 
     
    823816    y: initialMoveY, 
    824817    duration: 0.01,  
    825818    beforeSetup: function(effect) { 
    826       effect.element.hide(); 
    827       effect.element.makeClipping(); 
    828       effect.element.makePositioned(); 
     819      effect.element.hide().makeClipping().makePositioned(); 
    829820    }, 
    830821    afterFinishInternal: function(effect) { 
    831822      new Effect.Parallel( 
     
    836827            sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) 
    837828        ], Object.extend({ 
    838829             beforeSetup: function(effect) { 
    839                effect.effects[0].element.setStyle({height: '0px'}); 
    840                effect.effects[0].element.show();  
     830               effect.effects[0].element.setStyle({height: '0px'}).show();  
    841831             }, 
    842832             afterFinishInternal: function(effect) { 
    843                effect.effects[0].element.undoClipping(); 
    844                effect.effects[0].element.undoPositioned(); 
    845                effect.effects[0].element.setStyle(oldStyle);  
     833               effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle);  
    846834             } 
    847835           }, options) 
    848836      ) 
     
    896884      new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) 
    897885    ], Object.extend({             
    898886         beforeStartInternal: function(effect) { 
    899            effect.effects[0].element.makePositioned(); 
    900            effect.effects[0].element.makeClipping(); }, 
     887           effect.effects[0].element.makePositioned().makeClipping();  
     888         }, 
    901889         afterFinishInternal: function(effect) { 
    902            effect.effects[0].element.hide(); 
    903            effect.effects[0].element.undoClipping(); 
    904            effect.effects[0].element.undoPositioned(); 
    905            effect.effects[0].element.setStyle(oldStyle); } 
     890           effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } 
    906891       }, options) 
    907892  ); 
    908893} 
     
    912897  var options    = arguments[1] || {}; 
    913898  var oldOpacity = element.getInlineOpacity(); 
    914899  var transition = options.transition || Effect.Transitions.sinoidal; 
    915   var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos)) }; 
     900  var reverser   = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; 
    916901  reverser.bind(transition); 
    917902  return new Effect.Opacity(element,  
    918     Object.extend(Object.extend({  duration: 3.0, from: 0, 
     903    Object.extend(Object.extend({  duration: 2.0, from: 0, 
    919904      afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } 
    920905    }, options), {transition: reverser})); 
    921906} 
     
    927912    left: element.style.left, 
    928913    width: element.style.width, 
    929914    height: element.style.height }; 
    930   Element.makeClipping(element); 
     915  element.makeClipping(); 
    931916  return new Effect.Scale(element, 5, Object.extend({    
    932917    scaleContent: false, 
    933918    scaleX: false, 
     
    936921      scaleContent: false,  
    937922      scaleY: false, 
    938923      afterFinishInternal: function(effect) { 
    939         effect.element.hide(); 
    940         effect.element.undoClipping();  
    941         effect.element.setStyle(oldStyle); 
     924        effect.element.hide().undoClipping().setStyle(oldStyle); 
    942925      } }); 
    943926  }}, arguments[1] || {})); 
    944927}; 
    945928 
     929Effect.Morph = Class.create(); 
     930Object.extend(Object.extend(Effect.Morph.prototype, Effect.Base.prototype), { 
     931  initialize: function(element) { 
     932    this.element = $(element); 
     933    if(!this.element) throw(Effect._elementDoesNotExistError); 
     934    var options = Object.extend({ 
     935      style: {} 
     936    }, arguments[1] || {}); 
     937    if (typeof options.style == 'string') { 
     938      if(options.style.indexOf(':') == -1) { 
     939        var cssText = '', selector = '.' + options.style; 
     940        $A(document.styleSheets).reverse().each(function(styleSheet) { 
     941          if (styleSheet.cssRules) cssRules = styleSheet.cssRules; 
     942          else if (styleSheet.rules) cssRules = styleSheet.rules; 
     943          $A(cssRules).reverse().each(function(rule) { 
     944            if (selector == rule.selectorText) { 
     945              cssText = rule.style.cssText; 
     946              throw $break; 
     947            } 
     948          }); 
     949          if (cssText) throw $break; 
     950        }); 
     951        this.style = cssText.parseStyle(); 
     952        options.afterFinishInternal = function(effect){ 
     953          effect.element.addClassName(effect.options.style); 
     954          effect.transforms.each(function(transform) { 
     955            if(transform.style != 'opacity') 
     956              effect.element.style[transform.style.camelize()] = ''; 
     957          }); 
     958        } 
     959      } else this.style = options.style.parseStyle(); 
     960    } else this.style = $H(options.style) 
     961    this.start(options); 
     962  }, 
     963  setup: function(){ 
     964    function parseColor(color){ 
     965      if(!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; 
     966      color = color.parseColor(); 
     967      return $R(0,2).map(function(i){ 
     968        return parseInt( color.slice(i*2+1,i*2+3), 16 )  
     969      }); 
     970    } 
     971    this.transforms = this.style.map(function(pair){ 
     972      var property = pair[0].underscore().dasherize(), value = pair[1], unit = null; 
     973 
     974      if(value.parseColor('#zzzzzz') != '#zzzzzz') { 
     975        value = value.parseColor(); 
     976        unit  = 'color'; 
     977      } else if(property == 'opacity') { 
     978        value = parseFloat(value); 
     979        if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 
     980          this.element.setStyle({zoom: 1}); 
     981      } else if(Element.CSS_LENGTH.test(value))  
     982        var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/), 
     983          value = parseFloat(components[1]), unit = (components.length == 3) ? components[2] : null; 
     984 
     985      var originalValue = this.element.getStyle(property); 
     986      return $H({  
     987        style: property,  
     988        originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0),  
     989        targetValue: unit=='color' ? parseColor(value) : value, 
     990        unit: unit 
     991      }); 
     992    }.bind(this)).reject(function(transform){ 
     993      return ( 
     994        (transform.originalValue == transform.targetValue) || 
     995        ( 
     996          transform.unit != 'color' && 
     997          (isNaN(transform.originalValue) || isNaN(transform.targetValue)) 
     998        ) 
     999      ) 
     1000    }); 
     1001  }, 
     1002  update: function(position) { 
     1003    var style = $H(), value = null; 
     1004    this.transforms.each(function(transform){ 
     1005      value = transform.unit=='color' ? 
     1006        $R(0,2).inject('#',function(m,v,i){ 
     1007          return m+(Math.round(transform.originalValue[i]+ 
     1008            (transform.targetValue[i] - transform.originalValue[i])*position)).toColorPart() }) :  
     1009        transform.originalValue + Math.round( 
     1010          ((transform.targetValue - transform.originalValue) * position) * 1000)/1000 + transform.unit; 
     1011      style[transform.style] = value; 
     1012    }); 
     1013    this.element.setStyle(style); 
     1014  } 
     1015}); 
     1016 
     1017Effect.Transform = Class.create(); 
     1018Object.extend(Effect.Transform.prototype, { 
     1019  initialize: function(tracks){ 
     1020    this.tracks  = []; 
     1021    this.options = arguments[1] || {}; 
     1022    this.addTracks(tracks); 
     1023  }, 
     1024  addTracks: function(tracks){ 
     1025    tracks.each(function(track){ 
     1026      var data = $H(track).values().first(); 
     1027      this.tracks.push($H({ 
     1028        ids:     $H(track).keys().first(), 
     1029        effect:  Effect.Morph, 
     1030        options: { style: data } 
     1031      })); 
     1032    }.bind(this)); 
     1033    return this; 
     1034  }, 
     1035  play: function(){ 
     1036    return new Effect.Parallel( 
     1037      this.tracks.map(function(track){ 
     1038        var elements = [$(track.ids) || $$(track.ids)].flatten(); 
     1039        return elements.map(function(e){ return new track.effect(e, Object.extend({ sync:true }, track.options)) }); 
     1040      }).flatten(), 
     1041      this.options 
     1042    ); 
     1043  } 
     1044}); 
     1045 
     1046Element.CSS_PROPERTIES = $w( 
     1047  'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' +  
     1048  'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + 
     1049  'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + 
     1050  'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + 
     1051  'fontSize fontWeight height left letterSpacing lineHeight ' + 
     1052  'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ 
     1053  'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + 
     1054  'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + 
     1055  'right textIndent top width wordSpacing zIndex'); 
     1056   
     1057Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; 
     1058 
     1059String.prototype.parseStyle = function(){ 
     1060  var element = Element.extend(document.createElement('div')); 
     1061  element.innerHTML = '<div style="' + this + '"></div>'; 
     1062  var style = element.down().style, styleRules = $H(); 
     1063   
     1064  Element.CSS_PROPERTIES.each(function(property){ 
     1065    if(style[property]) styleRules[property] = style[property];  
     1066  }); 
     1067  if(/MSIE/.test(navigator.userAgent) && !window.opera && this.indexOf('opacity') > -1) { 
     1068    styleRules.opacity = this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]; 
     1069  } 
     1070  return styleRules; 
     1071}; 
     1072 
     1073Element.morph = function(element, style) { 
     1074  new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || {})); 
     1075  return element; 
     1076}; 
     1077 
    9461078['setOpacity','getOpacity','getInlineOpacity','forceRerendering','setContentZoom', 
    947  'collectTextNodes','collectTextNodesIgnoreClass','childrenWithClassName'].each(  
     1079 'collectTextNodes','collectTextNodesIgnoreClass','morph'].each(  
    9481080  function(f) { Element.Methods[f] = Element[f]; } 
    9491081); 
    9501082 
  • wp-includes/js/scriptaculous/unittest.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    2 //           (c) 2005 Jon Tirsen (http://www.tirsen.com) 
    3 //           (c) 2005 Michael Schuerig (http://www.schuerig.de/michael/) 
     1// script.aculo.us unittest.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     4//           (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) 
     5//           (c) 2005, 2006 Michael Schuerig (http://www.schuerig.de/michael/) 
    46// 
    5 // Permission is hereby granted, free of charge, to any person obtaining 
    6 // a copy of this software and associated documentation files (the 
    7 // "Software"), to deal in the Software without restriction, including 
    8 // without limitation the rights to use, copy, modify, merge, publish, 
    9 // distribute, sublicense, and/or sell copies of the Software, and to 
    10 // permit persons to whom the Software is furnished to do so, subject to 
    11 // the following conditions: 
    12 //  
    13 // The above copyright notice and this permission notice shall be 
    14 // included in all copies or substantial portions of the Software. 
    15 //  
    16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     7// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     8// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    239 
    24  
    2510// experimental, Firefox-only 
    2611Event.simulateMouse = function(element, eventName) { 
    2712  var options = Object.extend({ 
    2813    pointerX: 0, 
    2914    pointerY: 0, 
    30     buttons: 0 
     15    buttons:  0, 
     16    ctrlKey:  false, 
     17    altKey:   false, 
     18    shiftKey: false, 
     19    metaKey:  false 
    3120  }, arguments[2] || {}); 
    3221  var oEvent = document.createEvent("MouseEvents"); 
    3322  oEvent.initMouseEvent(eventName, true, true, document.defaultView,  
    3423    options.buttons, options.pointerX, options.pointerY, options.pointerX, options.pointerY,  
    35     false, false, false, false, 0, $(element)); 
     24    options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, 0, $(element)); 
    3625   
    3726  if(this.mark) Element.remove(this.mark); 
    3827  this.mark = document.createElement('div'); 
     
    9887    this.lastLogLine = document.createElement('tr'); 
    9988    this.statusCell = document.createElement('td'); 
    10089    this.nameCell = document.createElement('td'); 
     90    this.nameCell.className = "nameCell"; 
    10191    this.nameCell.appendChild(document.createTextNode(testName)); 
    10292    this.messageCell = document.createElement('td'); 
    10393    this.lastLogLine.appendChild(this.statusCell); 
     
    110100    this.lastLogLine.className = status; 
    111101    this.statusCell.innerHTML = status; 
    112102    this.messageCell.innerHTML = this._toHTML(summary); 
     103    this.addLinksToResults(); 
    113104  }, 
    114105  message: function(message) { 
    115106    if (!this.log) return; 
     
    131122  }, 
    132123  _toHTML: function(txt) { 
    133124    return txt.escapeHTML().replace(/\n/g,"<br/>"); 
     125  }, 
     126  addLinksToResults: function(){  
     127    $$("tr.failed .nameCell").each( function(td){ // todo: limit to children of this.log 
     128      td.title = "Run only this test" 
     129      Event.observe(td, 'click', function(){ window.location.search = "?tests=" + td.innerHTML;}); 
     130    }); 
     131    $$("tr.passed .nameCell").each( function(td){ // todo: limit to children of this.log 
     132      td.title = "Run all tests" 
     133      Event.observe(td, 'click', function(){ window.location.search = "";}); 
     134    }); 
    134135  } 
    135136} 
    136137 
     
    141142      testLog: 'testlog' 
    142143    }, arguments[1] || {}); 
    143144    this.options.resultsURL = this.parseResultsURLQueryParameter(); 
     145    this.options.tests      = this.parseTestsQueryParameter(); 
    144146    if (this.options.testLog) { 
    145147      this.options.testLog = $(this.options.testLog) || null; 
    146148    } 
     
    158160        this.tests = []; 
    159161        for(var testcase in testcases) { 
    160162          if(/^test/.test(testcase)) { 
    161             this.tests.push(new Test.Unit.Testcase(testcase, testcases[testcase], testcases["setup"], testcases["teardown"])); 
     163            this.tests.push( 
     164               new Test.Unit.Testcase( 
     165                 this.options.context ? ' -> ' + this.options.titles[testcase] : testcase,  
     166                 testcases[testcase], testcases["setup"], testcases["teardown"] 
     167               )); 
    162168          } 
    163169        } 
    164170      } 
     
    170176  parseResultsURLQueryParameter: function() { 
    171177    return window.location.search.parseQuery()["resultsURL"]; 
    172178  }, 
     179  parseTestsQueryParameter: function(){ 
     180    if (window.location.search.parseQuery()["tests"]){ 
     181        return window.location.search.parseQuery()["tests"].split(','); 
     182    }; 
     183  }, 
    173184  // Returns: 
    174185  //  "ERROR" if there was an error, 
    175186  //  "FAILURE" if there was a failure, or 
     
    229240      errors     +=   this.tests[i].errors; 
    230241    } 
    231242    return ( 
     243      (this.options.context ? this.options.context + ': ': '') +  
    232244      this.tests.length + " tests, " +  
    233245      assertions + " assertions, " +  
    234246      failures   + " failures, " + 
     
    283295        '", actual "' + Test.Unit.inspect(actual) + '"'); } 
    284296    catch(e) { this.error(e); } 
    285297  }, 
     298  assertInspect: function(expected, actual) { 
     299    var message = arguments[2] || "assertInspect"; 
     300    try { (expected == actual.inspect()) ? this.pass() : 
     301      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +  
     302        '", actual "' + Test.Unit.inspect(actual) + '"'); } 
     303    catch(e) { this.error(e); } 
     304  }, 
    286305  assertEnumEqual: function(expected, actual) { 
    287306    var message = arguments[2] || "assertEnumEqual"; 
    288307    try { $A(expected).length == $A(actual).length &&  
     
    297316      this.fail(message + ': got "' + Test.Unit.inspect(actual) + '"'); } 
    298317    catch(e) { this.error(e); } 
    299318  }, 
     319  assertIdentical: function(expected, actual) {  
     320    var message = arguments[2] || "assertIdentical";  
     321    try { (expected === actual) ? this.pass() :  
     322      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +   
     323        '", actual "' + Test.Unit.inspect(actual) + '"'); }  
     324    catch(e) { this.error(e); }  
     325  }, 
     326  assertNotIdentical: function(expected, actual) {  
     327    var message = arguments[2] || "assertNotIdentical";  
     328    try { !(expected === actual) ? this.pass() :  
     329      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +   
     330        '", actual "' + Test.Unit.inspect(actual) + '"'); }  
     331    catch(e) { this.error(e); }  
     332  }, 
    300333  assertNull: function(obj) { 
    301334    var message = arguments[1] || 'assertNull' 
    302335    try { (obj==null) ? this.pass() :  
    303336      this.fail(message + ': got "' + Test.Unit.inspect(obj) + '"'); } 
    304337    catch(e) { this.error(e); } 
    305338  }, 
     339  assertMatch: function(expected, actual) { 
     340    var message = arguments[2] || 'assertMatch'; 
     341    var regex = new RegExp(expected); 
     342    try { (regex.exec(actual)) ? this.pass() : 
     343      this.fail(message + ' : regex: "' +  Test.Unit.inspect(expected) + ' did not match: ' + Test.Unit.inspect(actual) + '"'); } 
     344    catch(e) { this.error(e); } 
     345  }, 
    306346  assertHidden: function(element) { 
    307347    var message = arguments[1] || 'assertHidden'; 
    308348    this.assertEqual("none", element.style.display, message); 
     
    311351    var message = arguments[1] || 'assertNotNull'; 
    312352    this.assert(object != null, message); 
    313353  }, 
     354  assertType: function(expected, actual) { 
     355    var message = arguments[2] || 'assertType'; 
     356    try {  
     357      (actual.constructor == expected) ? this.pass() :  
     358      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +   
     359        '", actual "' + (actual.constructor) + '"'); } 
     360    catch(e) { this.error(e); } 
     361  }, 
     362  assertNotOfType: function(expected, actual) { 
     363    var message = arguments[2] || 'assertNotOfType'; 
     364    try {  
     365      (actual.constructor != expected) ? this.pass() :  
     366      this.fail(message + ': expected "' + Test.Unit.inspect(expected) +   
     367        '", actual "' + (actual.constructor) + '"'); } 
     368    catch(e) { this.error(e); } 
     369  }, 
    314370  assertInstanceOf: function(expected, actual) { 
    315371    var message = arguments[2] || 'assertInstanceOf'; 
    316372    try {  
     
    325381      this.fail(message + ": object was an instance of the not expected type"); } 
    326382    catch(e) { this.error(e); }  
    327383  }, 
     384  assertRespondsTo: function(method, obj) { 
     385    var message = arguments[2] || 'assertRespondsTo'; 
     386    try { 
     387      (obj[method] && typeof obj[method] == 'function') ? this.pass() :  
     388      this.fail(message + ": object doesn't respond to [" + method + "]"); } 
     389    catch(e) { this.error(e); } 
     390  }, 
     391  assertReturnsTrue: function(method, obj) { 
     392    var message = arguments[2] || 'assertReturnsTrue'; 
     393    try { 
     394      var m = obj[method]; 
     395      if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; 
     396      m() ? this.pass() :  
     397      this.fail(message + ": method returned false"); } 
     398    catch(e) { this.error(e); } 
     399  }, 
     400  assertReturnsFalse: function(method, obj) { 
     401    var message = arguments[2] || 'assertReturnsFalse'; 
     402    try { 
     403      var m = obj[method]; 
     404      if(!m) m = obj['is'+method.charAt(0).toUpperCase()+method.slice(1)]; 
     405      !m() ? this.pass() :  
     406      this.fail(message + ": method returned true"); } 
     407    catch(e) { this.error(e); } 
     408  }, 
     409  assertRaise: function(exceptionName, method) { 
     410    var message = arguments[2] || 'assertRaise'; 
     411    try {  
     412      method(); 
     413      this.fail(message + ": exception expected but none was raised"); } 
     414    catch(e) { 
     415      ((exceptionName == null) || (e.name==exceptionName)) ? this.pass() : this.error(e);  
     416    } 
     417  }, 
     418  assertElementsMatch: function() { 
     419    var expressions = $A(arguments), elements = $A(expressions.shift()); 
     420    if (elements.length != expressions.length) { 
     421      this.fail('assertElementsMatch: size mismatch: ' + elements.length + ' elements, ' + expressions.length + ' expressions'); 
     422      return false; 
     423    } 
     424    elements.zip(expressions).all(function(pair, index) { 
     425      var element = $(pair.first()), expression = pair.last(); 
     426      if (element.match(expression)) return true; 
     427      this.fail('assertElementsMatch: (in index ' + index + ') expected ' + expression.inspect() + ' but got ' + element.inspect()); 
     428    }.bind(this)) && this.pass(); 
     429  }, 
     430  assertElementMatches: function(element, expression) { 
     431    this.assertElementsMatch([element], expression); 
     432  }, 
     433  benchmark: function(operation, iterations) { 
     434    var startAt = new Date(); 
     435    (iterations || 1).times(operation); 
     436    var timeTaken = ((new Date())-startAt); 
     437    this.info((arguments[2] || 'Operation') + ' finished ' +  
     438       iterations + ' iterations in ' + (timeTaken/1000)+'s' ); 
     439    return timeTaken; 
     440  }, 
    328441  _isVisible: function(element) { 
    329442    element = $(element); 
    330443    if(!element.parentNode) return true; 
     
    355468  initialize: function(name, test, setup, teardown) { 
    356469    Test.Unit.Assertions.prototype.initialize.bind(this)(); 
    357470    this.name           = name; 
    358     this.test           = test || function() {}; 
     471     
     472    if(typeof test == 'string') { 
     473      test = test.gsub(/(\.should[^\(]+\()/,'#{0}this,'); 
     474      test = test.gsub(/(\.should[^\(]+)\(this,\)/,'#{1}(this)'); 
     475      this.test = function() { 
     476        eval('with(this){'+test+'}'); 
     477      } 
     478    } else { 
     479      this.test = test || function() {}; 
     480    } 
     481     
    359482    this.setup          = setup || function() {}; 
    360483    this.teardown       = teardown || function() {}; 
    361484    this.isWaiting      = false; 
     
    381504    catch(e) { this.error(e); } 
    382505  } 
    383506}); 
     507 
     508// *EXPERIMENTAL* BDD-style testing to please non-technical folk 
     509// This draws many ideas from RSpec http://rspec.rubyforge.org/ 
     510 
     511Test.setupBDDExtensionMethods = function(){ 
     512  var METHODMAP = { 
     513    shouldEqual:     'assertEqual', 
     514    shouldNotEqual:  'assertNotEqual', 
     515    shouldEqualEnum: 'assertEnumEqual', 
     516    shouldBeA:       'assertType', 
     517    shouldNotBeA:    'assertNotOfType', 
     518    shouldBeAn:      'assertType', 
     519    shouldNotBeAn:   'assertNotOfType', 
     520    shouldBeNull:    'assertNull', 
     521    shouldNotBeNull: 'assertNotNull', 
     522     
     523    shouldBe:        'assertReturnsTrue', 
     524    shouldNotBe:     'assertReturnsFalse', 
     525    shouldRespondTo: 'assertRespondsTo' 
     526  }; 
     527  Test.BDDMethods = {}; 
     528  for(m in METHODMAP) { 
     529    Test.BDDMethods[m] = eval( 
     530      'function(){'+ 
     531      'var args = $A(arguments);'+ 
     532      'var scope = args.shift();'+ 
     533      'scope.'+METHODMAP[m]+'.apply(scope,(args || []).concat([this])); }'); 
     534  } 
     535  [Array.prototype, String.prototype, Number.prototype].each( 
     536    function(p){ Object.extend(p, Test.BDDMethods) } 
     537  ); 
     538} 
     539 
     540Test.context = function(name, spec, log){ 
     541  Test.setupBDDExtensionMethods(); 
     542   
     543  var compiledSpec = {}; 
     544  var titles = {}; 
     545  for(specName in spec) { 
     546    switch(specName){ 
     547      case "setup": 
     548      case "teardown": 
     549        compiledSpec[specName] = spec[specName]; 
     550        break; 
     551      default: 
     552        var testName = 'test'+specName.gsub(/\s+/,'-').camelize(); 
     553        var body = spec[specName].toString().split('\n').slice(1); 
     554        if(/^\{/.test(body[0])) body = body.slice(1); 
     555        body.pop(); 
     556        body = body.map(function(statement){  
     557          return statement.strip() 
     558        }); 
     559        compiledSpec[testName] = body.join('\n'); 
     560        titles[testName] = specName; 
     561    } 
     562  } 
     563  new Test.Unit.Runner(compiledSpec, { titles: titles, testLog: log || 'testlog', context: name }); 
     564}; 
     565 No newline at end of file 
  • wp-includes/js/scriptaculous/scriptaculous.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// script.aculo.us scriptaculous.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    24//  
    35// Permission is hereby granted, free of charge, to any person obtaining 
    46// a copy of this software and associated documentation files (the 
     
    1820// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    1921// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    2022// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     23// 
     24// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    2125 
    2226var Scriptaculous = { 
    23   Version: '1.6.1', 
     27  Version: '1.7.0', 
    2428  require: function(libraryName) { 
    2529    // inserting via DOM fails in Safari 2.0, so brute force approach 
    2630    document.write('<script type="text/javascript" src="'+libraryName+'"></script>'); 
  • wp-includes/js/scriptaculous/dragdrop.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    2 //           (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 
     1// script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     4//           (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 
    35//  
    4 // See scriptaculous.js for full license. 
     6// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     7// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    58 
    6 /*--------------------------------------------------------------------------*/ 
     9if(typeof Effect == 'undefined') 
     10  throw("dragdrop.js requires including script.aculo.us' effects.js library"); 
    711 
    812var Droppables = { 
    913  drops: [], 
     
    145149  }, 
    146150   
    147151  activate: function(draggable) { 
    148     window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 
    149     this.activeDraggable = draggable; 
     152    if(draggable.options.delay) {  
     153      this._timeout = setTimeout(function() {  
     154        Draggables._timeout = null;  
     155        window.focus();  
     156        Draggables.activeDraggable = draggable;  
     157      }.bind(this), draggable.options.delay);  
     158    } else { 
     159      window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 
     160      this.activeDraggable = draggable; 
     161    } 
    150162  }, 
    151163   
    152164  deactivate: function() { 
     
    160172    // the same coordinates, prevent needless redrawing (moz bug?) 
    161173    if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; 
    162174    this._lastPointer = pointer; 
     175     
    163176    this.activeDraggable.updateDrag(event, pointer); 
    164177  }, 
    165178   
    166179  endDrag: function(event) { 
     180    if(this._timeout) {  
     181      clearTimeout(this._timeout);  
     182      this._timeout = null;  
     183    } 
    167184    if(!this.activeDraggable) return; 
    168185    this._lastPointer = null; 
    169186    this.activeDraggable.endDrag(event); 
     
    190207      this.observers.each( function(o) { 
    191208        if(o[eventName]) o[eventName](eventName, draggable, event); 
    192209      }); 
     210    if(draggable.options[eventName]) draggable.options[eventName](draggable, event); 
    193211  }, 
    194212   
    195213  _cacheObserverCallbacks: function() { 
     
    204222/*--------------------------------------------------------------------------*/ 
    205223 
    206224var Draggable = Class.create(); 
     225Draggable._dragging    = {}; 
     226 
    207227Draggable.prototype = { 
    208228  initialize: function(element) { 
    209     var options = Object.extend({ 
     229    var defaults = { 
    210230      handle: false, 
    211       starteffect: function(element) { 
    212         element._opacity = Element.getOpacity(element);  
    213         new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});  
    214       }, 
    215231      reverteffect: function(element, top_offset, left_offset) { 
    216232        var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; 
    217         element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); 
     233        new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, 
     234          queue: {scope:'_draggable', position:'end'} 
     235        }); 
    218236      }, 
    219237      endeffect: function(element) { 
    220         var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 
    221         new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity});  
     238        var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; 
     239        new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,  
     240          queue: {scope:'_draggable', position:'end'}, 
     241          afterFinish: function(){  
     242            Draggable._dragging[element] = false  
     243          } 
     244        });  
    222245      }, 
    223246      zindex: 1000, 
    224247      revert: false, 
    225248      scroll: false, 
    226249      scrollSensitivity: 20, 
    227250      scrollSpeed: 15, 
    228       snap: false   // false, or xy or [x,y] or function(x,y){ return [x,y] } 
    229     }, arguments[1] || {}); 
     251      snap: false,  // false, or xy or [x,y] or function(x,y){ return [x,y] } 
     252      delay: 0 
     253    }; 
     254     
     255    if(!arguments[1] || typeof arguments[1].endeffect == 'undefined') 
     256      Object.extend(defaults, { 
     257        starteffect: function(element) { 
     258          element._opacity = Element.getOpacity(element); 
     259          Draggable._dragging[element] = true; 
     260          new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});  
     261        } 
     262      }); 
     263     
     264    var options = Object.extend(defaults, arguments[1] || {}); 
    230265 
    231266    this.element = $(element); 
    232267     
    233     if(options.handle && (typeof options.handle == 'string')) { 
    234       var h = Element.childrenWithClassName(this.element, options.handle, true); 
    235       if(h.length>0) this.handle = h[0]; 
    236     } 
     268    if(options.handle && (typeof options.handle == 'string')) 
     269      this.handle = this.element.down('.'+options.handle, 0); 
     270     
    237271    if(!this.handle) this.handle = $(options.handle); 
    238272    if(!this.handle) this.handle = this.element; 
    239273     
    240     if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) 
     274    if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 
    241275      options.scroll = $(options.scroll); 
     276      this._isScrollChild = Element.childOf(this.element, options.scroll); 
     277    } 
    242278 
    243279    Element.makePositioned(this.element); // fix IE     
    244280 
     
    264300  }, 
    265301   
    266302  initDrag: function(event) { 
     303    if(typeof Draggable._dragging[this.element] != 'undefined' && 
     304      Draggable._dragging[this.element]) return; 
    267305    if(Event.isLeftClick(event)) {     
    268306      // abort on form elements, fixes a Firefox issue 
    269307      var src = Event.element(event); 
    270       if(src.tagName && ( 
    271         src.tagName=='INPUT' || 
    272         src.tagName=='SELECT' || 
    273         src.tagName=='OPTION' || 
    274         src.tagName=='BUTTON' || 
    275         src.tagName=='TEXTAREA')) return; 
     308      if((tag_name = src.tagName.toUpperCase()) && ( 
     309        tag_name=='INPUT' || 
     310        tag_name=='SELECT' || 
     311        tag_name=='OPTION' || 
     312        tag_name=='BUTTON' || 
     313        tag_name=='TEXTAREA')) return; 
    276314         
    277       if(this.element._revert) { 
    278         this.element._revert.cancel(); 
    279         this.element._revert = null; 
    280       } 
    281        
    282315      var pointer = [Event.pointerX(event), Event.pointerY(event)]; 
    283316      var pos     = Position.cumulativeOffset(this.element); 
    284317      this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); 
     
    314347    } 
    315348     
    316349    Draggables.notify('onStart', this, event); 
     350         
    317351    if(this.options.starteffect) this.options.starteffect(this.element); 
    318352  }, 
    319353   
     
    322356    Position.prepare(); 
    323357    Droppables.show(pointer, this.element); 
    324358    Draggables.notify('onDrag', this, event); 
     359     
    325360    this.draw(pointer); 
    326361    if(this.options.change) this.options.change(this); 
    327362     
     
    333368        with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } 
    334369      } else { 
    335370        p = Position.page(this.options.scroll); 
    336         p[0] += this.options.scroll.scrollLeft; 
    337         p[1] += this.options.scroll.scrollTop; 
     371        p[0] += this.options.scroll.scrollLeft + Position.deltaX; 
     372        p[1] += this.options.scroll.scrollTop + Position.deltaY; 
    338373        p.push(p[0]+this.options.scroll.offsetWidth); 
    339374        p.push(p[1]+this.options.scroll.offsetHeight); 
    340375      } 
     
    380415 
    381416    if(this.options.endeffect)  
    382417      this.options.endeffect(this.element); 
    383  
     418       
    384419    Draggables.deactivate(this); 
    385420    Droppables.reset(); 
    386421  }, 
     
    400435   
    401436  draw: function(point) { 
    402437    var pos = Position.cumulativeOffset(this.element); 
     438    if(this.options.ghosting) { 
     439      var r   = Position.realOffset(this.element); 
     440      pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; 
     441    } 
     442     
    403443    var d = this.currentDelta(); 
    404444    pos[0] -= d[0]; pos[1] -= d[1]; 
    405445     
    406     if(this.options.scroll && (this.options.scroll != window)) { 
     446    if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 
    407447      pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; 
    408448      pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; 
    409449    } 
     
    430470      style.left = p[0] + "px"; 
    431471    if((!this.options.constraint) || (this.options.constraint=='vertical')) 
    432472      style.top  = p[1] + "px"; 
     473     
    433474    if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering 
    434475  }, 
    435476   
     
    442483  }, 
    443484   
    444485  startScrolling: function(speed) { 
     486    if(!(speed[0] || speed[1])) return; 
    445487    this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; 
    446488    this.lastScrolled = new Date(); 
    447489    this.scrollInterval = setInterval(this.scroll.bind(this), 10); 
     
    466508    Position.prepare(); 
    467509    Droppables.show(Draggables._lastPointer, this.element); 
    468510    Draggables.notify('onDrag', this); 
    469     Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
    470     Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
    471     Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
    472     if (Draggables._lastScrollPointer[0] < 0) 
    473       Draggables._lastScrollPointer[0] = 0; 
    474     if (Draggables._lastScrollPointer[1] < 0) 
    475       Draggables._lastScrollPointer[1] = 0; 
    476     this.draw(Draggables._lastScrollPointer); 
     511    if (this._isScrollChild) { 
     512      Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
     513      Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
     514      Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
     515      if (Draggables._lastScrollPointer[0] < 0) 
     516        Draggables._lastScrollPointer[0] = 0; 
     517      if (Draggables._lastScrollPointer[1] < 0) 
     518        Draggables._lastScrollPointer[1] = 0; 
     519      this.draw(Draggables._lastScrollPointer); 
     520    } 
    477521     
    478522    if(this.options.change) this.options.change(this); 
    479523  }, 
     
    525569} 
    526570 
    527571var Sortable = { 
     572  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, 
     573   
    528574  sortables: {}, 
    529575   
    530576  _findRootElement: function(element) { 
    531     while (element.tagName != "BODY") {   
     577    while (element.tagName.toUpperCase() != "BODY") {   
    532578      if(element.id && Sortable.sortables[element.id]) return element; 
    533579      element = element.parentNode; 
    534580    } 
     
    565611      containment: element,    // also takes array of elements (or id's); or false 
    566612      handle:      false,      // or a CSS class 
    567613      only:        false, 
     614      delay:       0, 
    568615      hoverclass:  null, 
    569616      ghosting:    false, 
    570617      scroll:      false, 
    571618      scrollSensitivity: 20, 
    572619      scrollSpeed: 15, 
    573       format:      /^[^_]*_(.*)$/, 
     620      format:      this.SERIALIZE_RULE, 
    574621      onChange:    Prototype.emptyFunction, 
    575622      onUpdate:    Prototype.emptyFunction 
    576623    }, arguments[1] || {}); 
     
    584631      scroll:      options.scroll, 
    585632      scrollSpeed: options.scrollSpeed, 
    586633      scrollSensitivity: options.scrollSensitivity, 
     634      delay:       options.delay, 
    587635      ghosting:    options.ghosting, 
    588636      constraint:  options.constraint, 
    589637      handle:      options.handle }; 
     
    612660      tree:        options.tree, 
    613661      hoverclass:  options.hoverclass, 
    614662      onHover:     Sortable.onHover 
    615       //greedy:      !options.dropOnEmpty 
    616663    } 
    617664     
    618665    var options_for_tree = { 
     
    637684    (this.findElements(element, options) || []).each( function(e) { 
    638685      // handles are per-draggable 
    639686      var handle = options.handle ?  
    640         Element.childrenWithClassName(e, options.handle)[0] : e;     
     687        $(e).down('.'+options.handle,0) : e;     
    641688      options.draggables.push( 
    642689        new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); 
    643690      Droppables.add(e, options_for_droppable); 
     
    708755    if(!Element.isParent(dropon, element)) { 
    709756      var index; 
    710757       
    711       var children = Sortable.findElements(dropon, {tag: droponOptions.tag}); 
     758      var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); 
    712759      var child = null; 
    713760             
    714761      if(children) { 
     
    735782  }, 
    736783 
    737784  unmark: function() { 
    738     if(Sortable._marker) Element.hide(Sortable._marker); 
     785    if(Sortable._marker) Sortable._marker.hide(); 
    739786  }, 
    740787 
    741788  mark: function(dropon, position) { 
     
    744791    if(sortable && !sortable.ghosting) return;  
    745792 
    746793    if(!Sortable._marker) { 
    747       Sortable._marker = $('dropmarker') || document.createElement('DIV'); 
    748       Element.hide(Sortable._marker); 
    749       Element.addClassName(Sortable._marker, 'dropmarker'); 
    750       Sortable._marker.style.position = 'absolute'; 
     794      Sortable._marker =  
     795        ($('dropmarker') || Element.extend(document.createElement('DIV'))). 
     796          hide().addClassName('dropmarker').setStyle({position:'absolute'}); 
    751797      document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); 
    752798    }     
    753799    var offsets = Position.cumulativeOffset(dropon); 
    754     Sortable._marker.style.left = offsets[0] + 'px'; 
    755     Sortable._marker.style.top = offsets[1] + 'px'; 
     800    Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); 
    756801     
    757802    if(position=='after') 
    758803      if(sortable.overlap == 'horizontal')  
    759         Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px'; 
     804        Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); 
    760805      else 
    761         Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px'; 
     806        Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); 
    762807     
    763     Element.show(Sortable._marker); 
     808    Sortable._marker.show(); 
    764809  }, 
    765810   
    766811  _tree: function(element, options, parent) { 
     
    775820        id: encodeURIComponent(match ? match[1] : null), 
    776821        element: element, 
    777822        parent: parent, 
    778         children: new Array, 
     823        children: [], 
    779824        position: parent.children.length, 
    780         container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase()) 
     825        container: $(children[i]).down(options.treeTag) 
    781826      } 
    782827       
    783828      /* Get the element containing the children and recurse over it */ 
     
    790835    return parent;  
    791836  }, 
    792837 
    793   /* Finds the first element of the given tag type within a parent element. 
    794     Used for finding the first LI[ST] within a L[IST]I[TEM].*/ 
    795   _findChildrenElement: function (element, containerTag) { 
    796     if (element && element.hasChildNodes) 
    797       for (var i = 0; i < element.childNodes.length; ++i) 
    798         if (element.childNodes[i].tagName == containerTag) 
    799           return element.childNodes[i]; 
    800    
    801     return null; 
    802   }, 
    803  
    804838  tree: function(element) { 
    805839    element = $(element); 
    806840    var sortableOptions = this.options(element); 
     
    815849    var root = { 
    816850      id: null, 
    817851      parent: null, 
    818       children: new Array, 
     852      children: [], 
    819853      container: element, 
    820854      position: 0 
    821855    } 
    822856     
    823     return Sortable._tree (element, options, root); 
     857    return Sortable._tree(element, options, root); 
    824858  }, 
    825859 
    826860  /* Construct a [i] index for a particular node */ 
     
    869903     
    870904    if (options.tree) { 
    871905      return Sortable.tree(element, arguments[1]).children.map( function (item) { 
    872         return [name + Sortable._constructIndex(item) + "=" +  
     906        return [name + Sortable._constructIndex(item) + "[id]=" +  
    873907                encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); 
    874908      }).flatten().join('&'); 
    875909    } else { 
     
    880914  } 
    881915} 
    882916 
    883 /* Returns true if child is contained within element */ 
     917// Returns true if child is contained within element 
    884918Element.isParent = function(child, element) { 
    885919  if (!child.parentNode || child == element) return false; 
    886  
    887920  if (child.parentNode == element) return true; 
    888  
    889921  return Element.isParent(child.parentNode, element); 
    890922} 
    891923 
     
    908940} 
    909941 
    910942Element.offsetSize = function (element, type) { 
    911   if (type == 'vertical' || type == 'height') 
    912     return element.offsetHeight; 
    913   else 
    914     return element.offsetWidth; 
    915 } 
    916  No newline at end of file 
     943  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; 
     944} 
  • wp-includes/js/scriptaculous/slider.js

     
    1 // Copyright (c) 2005 Marty Haught, Thomas Fuchs  
     1// script.aculo.us slider.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Marty Haught, Thomas Fuchs  
    24// 
    3 // See http://script.aculo.us for more info 
    4 //  
    5 // Permission is hereby granted, free of charge, to any person obtaining 
    6 // a copy of this software and associated documentation files (the 
    7 // "Software"), to deal in the Software without restriction, including 
    8 // without limitation the rights to use, copy, modify, merge, publish, 
    9 // distribute, sublicense, and/or sell copies of the Software, and to 
    10 // permit persons to whom the Software is furnished to do so, subject to 
    11 // the following conditions: 
    12 //  
    13 // The above copyright notice and this permission notice shall be 
    14 // included in all copies or substantial portions of the Software. 
    15 // 
    16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 
    17 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 
    18 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 
    19 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 
    20 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 
    21 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 
    22 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 
     5// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     6// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    237 
    248if(!Control) var Control = {}; 
    259Control.Slider = Class.create(); 
     
    6448    this.alignY = parseInt(this.options.alignY || '0'); 
    6549     
    6650    this.trackLength = this.maximumOffset() - this.minimumOffset(); 
    67     this.handleLength = this.isVertical() ? this.handles[0].offsetHeight : this.handles[0].offsetWidth; 
    6851 
     52    this.handleLength = this.isVertical() ?  
     53      (this.handles[0].offsetHeight != 0 ?  
     54        this.handles[0].offsetHeight : this.handles[0].style.height.replace(/px$/,"")) :  
     55      (this.handles[0].offsetWidth != 0 ? this.handles[0].offsetWidth :  
     56        this.handles[0].style.width.replace(/px$/,"")); 
     57 
    6958    this.active   = false; 
    7059    this.dragging = false; 
    7160    this.disabled = false; 
     
    137126  }, 
    138127  setValue: function(sliderValue, handleIdx){ 
    139128    if(!this.active) { 
    140       this.activeHandle    = this.handles[handleIdx]; 
    141       this.activeHandleIdx = handleIdx; 
     129      this.activeHandleIdx = handleIdx || 0; 
     130      this.activeHandle    = this.handles[this.activeHandleIdx]; 
    142131      this.updateStyles(); 
    143132    } 
    144133    handleIdx = handleIdx || this.activeHandleIdx || 0; 
     
    180169    return(this.isVertical() ? this.alignY : this.alignX); 
    181170  }, 
    182171  maximumOffset: function(){ 
    183     return(this.isVertical() ? 
    184       this.track.offsetHeight - this.alignY : this.track.offsetWidth - this.alignX); 
     172    return(this.isVertical() ?  
     173      (this.track.offsetHeight != 0 ? this.track.offsetHeight : 
     174        this.track.style.height.replace(/px$/,"")) - this.alignY :  
     175      (this.track.offsetWidth != 0 ? this.track.offsetWidth :  
     176        this.track.style.width.replace(/px$/,"")) - this.alignY); 
    185177  },   
    186178  isVertical:  function(){ 
    187179    return (this.axis == 'vertical'); 
     
    217209         
    218210        var handle = Event.element(event); 
    219211        var pointer  = [Event.pointerX(event), Event.pointerY(event)]; 
    220         if(handle==this.track) { 
     212        var track = handle; 
     213        if(track==this.track) { 
    221214          var offsets  = Position.cumulativeOffset(this.track);  
    222215          this.event = event; 
    223216          this.setValue(this.translateToValue(  
     
    230223          // find the handle (prevents issues with Safari) 
    231224          while((this.handles.indexOf(handle) == -1) && handle.parentNode)  
    232225            handle = handle.parentNode; 
    233          
    234           this.activeHandle    = handle; 
    235           this.activeHandleIdx = this.handles.indexOf(this.activeHandle); 
    236           this.updateStyles(); 
    237          
    238           var offsets  = Position.cumulativeOffset(this.activeHandle); 
    239           this.offsetX = (pointer[0] - offsets[0]); 
    240           this.offsetY = (pointer[1] - offsets[1]); 
     226             
     227          if(this.handles.indexOf(handle)!=-1) { 
     228            this.activeHandle    = handle; 
     229            this.activeHandleIdx = this.handles.indexOf(this.activeHandle); 
     230            this.updateStyles(); 
     231             
     232            var offsets  = Position.cumulativeOffset(this.activeHandle); 
     233            this.offsetX = (pointer[0] - offsets[0]); 
     234            this.offsetY = (pointer[1] - offsets[1]); 
     235          } 
    241236        } 
    242237      } 
    243238      Event.stop(event); 
  • wp-includes/js/scriptaculous/controls.js

     
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    2 //           (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 
    3 //           (c) 2005 Jon Tirsen (http://www.tirsen.com) 
     1// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     4//           (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 
     5//           (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) 
    46// Contributors: 
    57//  Richard Livsey 
    68//  Rahul Bhargava 
    79//  Rob Wills 
    810//  
    9 // See scriptaculous.js for full license. 
     11// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     12// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    1013 
    1114// Autocompleter.Base handles all the autocompletion functionality  
    1215// that's independent of the data source for autocompletion. This 
     
    3336// useful when one of the tokens is \n (a newline), as it  
    3437// allows smart autocompletion after linebreaks. 
    3538 
     39if(typeof Effect == 'undefined') 
     40  throw("controls.js requires including script.aculo.us' effects.js library"); 
     41 
    3642var Autocompleter = {} 
    3743Autocompleter.Base = function() {}; 
    3844Autocompleter.Base.prototype = { 
     
    4551    this.index       = 0;      
    4652    this.entryCount  = 0; 
    4753 
    48     if (this.setOptions) 
     54    if(this.setOptions) 
    4955      this.setOptions(options); 
    5056    else 
    5157      this.options = options || {}; 
     
    5561    this.options.frequency    = this.options.frequency || 0.4; 
    5662    this.options.minChars     = this.options.minChars || 1; 
    5763    this.options.onShow       = this.options.onShow ||  
    58     function(element, update){  
    59       if(!update.style.position || update.style.position=='absolute') { 
    60         update.style.position = 'absolute'; 
    61         Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); 
    62       } 
    63       Effect.Appear(update,{duration:0.15}); 
    64     }; 
     64      function(element, update){  
     65        if(!update.style.position || update.style.position=='absolute') { 
     66          update.style.position = 'absolute'; 
     67          Position.clone(element, update, { 
     68            setHeight: false,  
     69            offsetTop: element.offsetHeight 
     70          }); 
     71        } 
     72        Effect.Appear(update,{duration:0.15}); 
     73      }; 
    6574    this.options.onHide = this.options.onHide ||  
    66     function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 
     75      function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 
    6776 
    68     if (typeof(this.options.tokens) == 'string')  
     77    if(typeof(this.options.tokens) == 'string')  
    6978      this.options.tokens = new Array(this.options.tokens); 
    7079 
    7180    this.observer = null; 
     
    94103  }, 
    95104   
    96105  fixIEOverlapping: function() { 
    97     Position.clone(this.update, this.iefix); 
     106    Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); 
    98107    this.iefix.style.zIndex = 1; 
    99108    this.update.style.zIndex = 2; 
    100109    Element.show(this.iefix); 
     
    202211  markPrevious: function() { 
    203212    if(this.index > 0) this.index-- 
    204213      else this.index = this.entryCount-1; 
     214    this.getEntry(this.index).scrollIntoView(true); 
    205215  }, 
    206216   
    207217  markNext: function() { 
    208218    if(this.index < this.entryCount-1) this.index++ 
    209219      else this.index = 0; 
     220    this.getEntry(this.index).scrollIntoView(false); 
    210221  }, 
    211222   
    212223  getEntry: function(index) { 
     
    254265    if(!this.changed && this.hasFocus) { 
    255266      this.update.innerHTML = choices; 
    256267      Element.cleanWhitespace(this.update); 
    257       Element.cleanWhitespace(this.update.firstChild); 
     268      Element.cleanWhitespace(this.update.down()); 
    258269 
    259       if(this.update.firstChild && this.update.firstChild.childNodes) { 
     270      if(this.update.firstChild && this.update.down().childNodes) { 
    260271        this.entryCount =  
    261           this.update.firstChild.childNodes.length; 
     272          this.update.down().childNodes.length; 
    262273        for (var i = 0; i < this.entryCount; i++) { 
    263274          var entry = this.getEntry(i); 
    264275          entry.autocompleteIndex = i; 
     
    269280      } 
    270281 
    271282      this.stopIndicator(); 
    272  
    273283      this.index = 0; 
    274       this.render(); 
     284       
     285      if(this.entryCount==1 && this.options.autoSelect) { 
     286        this.selectEntry(); 
     287        this.hide(); 
     288      } else { 
     289        this.render(); 
     290      } 
    275291    } 
    276292  }, 
    277293 
     
    459475    this.element = $(element); 
    460476 
    461477    this.options = Object.extend({ 
     478      paramName: "value", 
    462479      okButton: true, 
    463480      okText: "ok", 
    464481      cancelLink: true, 
     
    531548    Element.hide(this.element); 
    532549    this.createForm(); 
    533550    this.element.parentNode.insertBefore(this.form, this.element); 
    534     Field.scrollFreeActivate(this.editField); 
     551    if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); 
    535552    // stop the event to avoid a page refresh in Safari 
    536553    if (evt) { 
    537554      Event.stop(evt); 
     
    590607      var textField = document.createElement("input"); 
    591608      textField.obj = this; 
    592609      textField.type = "text"; 
    593       textField.name = "value"; 
     610      textField.name = this.options.paramName; 
    594611      textField.value = text; 
    595612      textField.style.backgroundColor = this.options.highlightcolor; 
    596613      textField.className = 'editor_field'; 
     
    603620      this.options.textarea = true; 
    604621      var textArea = document.createElement("textarea"); 
    605622      textArea.obj = this; 
    606       textArea.name = "value"; 
     623      textArea.name = this.options.paramName; 
    607624      textArea.value = this.convertHTMLLineBreaks(text); 
    608625      textArea.rows = this.options.rows; 
    609626      textArea.cols = this.options.cols || 40; 
     
    636653    Element.removeClassName(this.form, this.options.loadingClassName); 
    637654    this.editField.disabled = false; 
    638655    this.editField.value = transport.responseText.stripTags(); 
     656    Field.scrollFreeActivate(this.editField); 
    639657  }, 
    640658  onclickCancel: function() { 
    641659    this.onComplete(); 
     
    772790      collection.each(function(e,i) { 
    773791        optionTag = document.createElement("option"); 
    774792        optionTag.value = (e instanceof Array) ? e[0] : e; 
     793        if((typeof this.options.value == 'undefined') &&  
     794          ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; 
    775795        if(this.options.value==optionTag.value) optionTag.selected = true; 
    776796        optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); 
    777797        selectTag.appendChild(optionTag); 
  • wp-includes/script-loader.php

     
    1818                $this->add( 'tiny_mce', '/wp-includes/js/tinymce/tiny_mce_gzip.php', false, '20070124' ); 
    1919                $mce_config = apply_filters('tiny_mce_config_url', '/wp-includes/js/tinymce/tiny_mce_config.php'); 
    2020                $this->add( 'wp_tiny_mce', $mce_config, array('tiny_mce'), '20070124' ); 
    21                 $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0'); 
     21                $this->add( 'prototype', '/wp-includes/js/prototype.js', false, '1.5.0-0'); 
    2222                $this->add( 'autosave', '/wp-includes/js/autosave-js.php', array('prototype', 'sack'), '20070116'); 
    2323                $this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '20070118'); 
    2424                $this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '20070118'); 
    25                 $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.6.1'); 
    26                 $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.6.1'); 
    27                 $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder'), '1.6.1'); 
    28                 $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.6.1'); 
    29                 $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.6.1'); 
    30                 $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.6.1'); 
    31                 $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.6.1'); 
     25                $this->add( 'scriptaculous-root', '/wp-includes/js/scriptaculous/wp-scriptaculous.js', array('prototype'), '1.7.0'); 
     26                $this->add( 'scriptaculous-builder', '/wp-includes/js/scriptaculous/builder.js', array('scriptaculous-root'), '1.7.0'); 
     27                $this->add( 'scriptaculous-dragdrop', '/wp-includes/js/scriptaculous/dragdrop.js', array('scriptaculous-builder'), '1.7.0'); 
     28                $this->add( 'scriptaculous-effects', '/wp-includes/js/scriptaculous/effects.js', array('scriptaculous-root'), '1.7.0'); 
     29                $this->add( 'scriptaculous-slider', '/wp-includes/js/scriptaculous/slider.js', array('scriptaculous-effects'), '1.7.0'); 
     30                $this->add( 'scriptaculous-controls', '/wp-includes/js/scriptaculous/controls.js', array('scriptaculous-root'), '1.7.0'); 
     31                $this->add( 'scriptaculous', '', array('scriptaculous-dragdrop', 'scriptaculous-slider', 'scriptaculous-controls'), '1.7.0'); 
    3232                $this->add( 'cropper', '/wp-includes/js/crop/cropper.js', array('scriptaculous-dragdrop'), '20070118'); 
    3333                if ( is_admin() ) { 
    3434                        $this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );