http://2010.igem.org/wiki/index.php?title=Team:St_Andrews/mootools-1.2.4-core-nc.js&feed=atom&action=history
Team:St Andrews/mootools-1.2.4-core-nc.js - Revision history
2024-03-29T13:46:42Z
Revision history for this page on the wiki
MediaWiki 1.16.5
http://2010.igem.org/wiki/index.php?title=Team:St_Andrews/mootools-1.2.4-core-nc.js&diff=25211&oldid=prev
L7ukas: New page: /* --- script: Core.js description: The core of MooTools, contains all the base functions and the Native and Hash implementations. Required by all the other scripts. license: MIT-style ...
2010-07-16T23:08:17Z
<p>New page: /* --- script: Core.js description: The core of MooTools, contains all the base functions and the Native and Hash implementations. Required by all the other scripts. license: MIT-style ...</p>
<p><b>New page</b></p><div>/*<br />
---<br />
<br />
script: Core.js<br />
<br />
description: The core of MooTools, contains all the base functions and the Native and Hash implementations. Required by all the other scripts.<br />
<br />
license: MIT-style license.<br />
<br />
copyright: Copyright (c) 2006-2008 [Valerio Proietti](http://mad4milk.net/).<br />
<br />
authors: The MooTools production team (http://mootools.net/developers/)<br />
<br />
inspiration:<br />
- Class implementation inspired by [Base.js](http://dean.edwards.name/weblog/2006/03/base/) Copyright (c) 2006 Dean Edwards, [GNU Lesser General Public License](http://opensource.org/licenses/lgpl-license.php)<br />
- Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)<br />
<br />
provides: [Mootools, Native, Hash.base, Array.each, $util]<br />
<br />
...<br />
*/<br />
<br />
var MooTools = {<br />
'version': '1.2.4',<br />
'build': '0d9113241a90b9cd5643b926795852a2026710d4'<br />
};<br />
<br />
var Native = function(options){<br />
options = options || {};<br />
var name = options.name;<br />
var legacy = options.legacy;<br />
var protect = options.protect;<br />
var methods = options.implement;<br />
var generics = options.generics;<br />
var initialize = options.initialize;<br />
var afterImplement = options.afterImplement || function(){};<br />
var object = initialize || legacy;<br />
generics = generics !== false;<br />
<br />
object.constructor = Native;<br />
object.$family = {name: 'native'};<br />
if (legacy && initialize) object.prototype = legacy.prototype;<br />
object.prototype.constructor = object;<br />
<br />
if (name){<br />
var family = name.toLowerCase();<br />
object.prototype.$family = {name: family};<br />
Native.typize(object, family);<br />
}<br />
<br />
var add = function(obj, name, method, force){<br />
if (!protect || force || !obj.prototype[name]) obj.prototype[name] = method;<br />
if (generics) Native.genericize(obj, name, protect);<br />
afterImplement.call(obj, name, method);<br />
return obj;<br />
};<br />
<br />
object.alias = function(a1, a2, a3){<br />
if (typeof a1 == 'string'){<br />
var pa1 = this.prototype[a1];<br />
if ((a1 = pa1)) return add(this, a2, a1, a3);<br />
}<br />
for (var a in a1) this.alias(a, a1[a], a2);<br />
return this;<br />
};<br />
<br />
object.implement = function(a1, a2, a3){<br />
if (typeof a1 == 'string') return add(this, a1, a2, a3);<br />
for (var p in a1) add(this, p, a1[p], a2);<br />
return this;<br />
};<br />
<br />
if (methods) object.implement(methods);<br />
<br />
return object;<br />
};<br />
<br />
Native.genericize = function(object, property, check){<br />
if ((!check || !object[property]) && typeof object.prototype[property] == 'function') object[property] = function(){<br />
var args = Array.prototype.slice.call(arguments);<br />
return object.prototype[property].apply(args.shift(), args);<br />
};<br />
};<br />
<br />
Native.implement = function(objects, properties){<br />
for (var i = 0, l = objects.length; i < l; i++) objects[i].implement(properties);<br />
};<br />
<br />
Native.typize = function(object, family){<br />
if (!object.type) object.type = function(item){<br />
return ($type(item) === family);<br />
};<br />
};<br />
<br />
(function(){<br />
var natives = {'Array': Array, 'Date': Date, 'Function': Function, 'Number': Number, 'RegExp': RegExp, 'String': String};<br />
for (var n in natives) new Native({name: n, initialize: natives[n], protect: true});<br />
<br />
var types = {'boolean': Boolean, 'native': Native, 'object': Object};<br />
for (var t in types) Native.typize(types[t], t);<br />
<br />
var generics = {<br />
'Array': ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"],<br />
'String': ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"]<br />
};<br />
for (var g in generics){<br />
for (var i = generics[g].length; i--;) Native.genericize(natives[g], generics[g][i], true);<br />
}<br />
})();<br />
<br />
var Hash = new Native({<br />
<br />
name: 'Hash',<br />
<br />
initialize: function(object){<br />
if ($type(object) == 'hash') object = $unlink(object.getClean());<br />
for (var key in object) this[key] = object[key];<br />
return this;<br />
}<br />
<br />
});<br />
<br />
Hash.implement({<br />
<br />
forEach: function(fn, bind){<br />
for (var key in this){<br />
if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this);<br />
}<br />
},<br />
<br />
getClean: function(){<br />
var clean = {};<br />
for (var key in this){<br />
if (this.hasOwnProperty(key)) clean[key] = this[key];<br />
}<br />
return clean;<br />
},<br />
<br />
getLength: function(){<br />
var length = 0;<br />
for (var key in this){<br />
if (this.hasOwnProperty(key)) length++;<br />
}<br />
return length;<br />
}<br />
<br />
});<br />
<br />
Hash.alias('forEach', 'each');<br />
<br />
Array.implement({<br />
<br />
forEach: function(fn, bind){<br />
for (var i = 0, l = this.length; i < l; i++) fn.call(bind, this[i], i, this);<br />
}<br />
<br />
});<br />
<br />
Array.alias('forEach', 'each');<br />
<br />
function $A(iterable){<br />
if (iterable.item){<br />
var l = iterable.length, array = new Array(l);<br />
while (l--) array[l] = iterable[l];<br />
return array;<br />
}<br />
return Array.prototype.slice.call(iterable);<br />
};<br />
<br />
function $arguments(i){<br />
return function(){<br />
return arguments[i];<br />
};<br />
};<br />
<br />
function $chk(obj){<br />
return !!(obj || obj === 0);<br />
};<br />
<br />
function $clear(timer){<br />
clearTimeout(timer);<br />
clearInterval(timer);<br />
return null;<br />
};<br />
<br />
function $defined(obj){<br />
return (obj != undefined);<br />
};<br />
<br />
function $each(iterable, fn, bind){<br />
var type = $type(iterable);<br />
((type == 'arguments' || type == 'collection' || type == 'array') ? Array : Hash).each(iterable, fn, bind);<br />
};<br />
<br />
function $empty(){};<br />
<br />
function $extend(original, extended){<br />
for (var key in (extended || {})) original[key] = extended[key];<br />
return original;<br />
};<br />
<br />
function $H(object){<br />
return new Hash(object);<br />
};<br />
<br />
function $lambda(value){<br />
return ($type(value) == 'function') ? value : function(){<br />
return value;<br />
};<br />
};<br />
<br />
function $merge(){<br />
var args = Array.slice(arguments);<br />
args.unshift({});<br />
return $mixin.apply(null, args);<br />
};<br />
<br />
function $mixin(mix){<br />
for (var i = 1, l = arguments.length; i < l; i++){<br />
var object = arguments[i];<br />
if ($type(object) != 'object') continue;<br />
for (var key in object){<br />
var op = object[key], mp = mix[key];<br />
mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $mixin(mp, op) : $unlink(op);<br />
}<br />
}<br />
return mix;<br />
};<br />
<br />
function $pick(){<br />
for (var i = 0, l = arguments.length; i < l; i++){<br />
if (arguments[i] != undefined) return arguments[i];<br />
}<br />
return null;<br />
};<br />
<br />
function $random(min, max){<br />
return Math.floor(Math.random() * (max - min + 1) + min);<br />
};<br />
<br />
function $splat(obj){<br />
var type = $type(obj);<br />
return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : [];<br />
};<br />
<br />
var $time = Date.now || function(){<br />
return +new Date;<br />
};<br />
<br />
function $try(){<br />
for (var i = 0, l = arguments.length; i < l; i++){<br />
try {<br />
return arguments[i]();<br />
} catch(e){}<br />
}<br />
return null;<br />
};<br />
<br />
function $type(obj){<br />
if (obj == undefined) return false;<br />
if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name;<br />
if (obj.nodeName){<br />
switch (obj.nodeType){<br />
case 1: return 'element';<br />
case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';<br />
}<br />
} else if (typeof obj.length == 'number'){<br />
if (obj.callee) return 'arguments';<br />
else if (obj.item) return 'collection';<br />
}<br />
return typeof obj;<br />
};<br />
<br />
function $unlink(object){<br />
var unlinked;<br />
switch ($type(object)){<br />
case 'object':<br />
unlinked = {};<br />
for (var p in object) unlinked[p] = $unlink(object[p]);<br />
break;<br />
case 'hash':<br />
unlinked = new Hash(object);<br />
break;<br />
case 'array':<br />
unlinked = [];<br />
for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]);<br />
break;<br />
default: return object;<br />
}<br />
return unlinked;<br />
};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Browser.js<br />
<br />
description: The Browser Core. Contains Browser initialization, Window and Document, and the Browser Hash.<br />
<br />
license: MIT-style license.<br />
<br />
requires: <br />
- /Native<br />
- /$util<br />
<br />
provides: [Browser, Window, Document, $exec]<br />
<br />
...<br />
*/<br />
<br />
var Browser = $merge({<br />
<br />
Engine: {name: 'unknown', version: 0},<br />
<br />
Platform: {name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase()},<br />
<br />
Features: {xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector)},<br />
<br />
Plugins: {},<br />
<br />
Engines: {<br />
<br />
presto: function(){<br />
return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925));<br />
},<br />
<br />
trident: function(){<br />
return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4);<br />
},<br />
<br />
webkit: function(){<br />
return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419);<br />
},<br />
<br />
gecko: function(){<br />
return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18);<br />
}<br />
<br />
}<br />
<br />
}, Browser || {});<br />
<br />
Browser.Platform[Browser.Platform.name] = true;<br />
<br />
Browser.detect = function(){<br />
<br />
for (var engine in this.Engines){<br />
var version = this.Engines[engine]();<br />
if (version){<br />
this.Engine = {name: engine, version: version};<br />
this.Engine[engine] = this.Engine[engine + version] = true;<br />
break;<br />
}<br />
}<br />
<br />
return {name: engine, version: version};<br />
<br />
};<br />
<br />
Browser.detect();<br />
<br />
Browser.Request = function(){<br />
return $try(function(){<br />
return new XMLHttpRequest();<br />
}, function(){<br />
return new ActiveXObject('MSXML2.XMLHTTP');<br />
}, function(){<br />
return new ActiveXObject('Microsoft.XMLHTTP');<br />
});<br />
};<br />
<br />
Browser.Features.xhr = !!(Browser.Request());<br />
<br />
Browser.Plugins.Flash = (function(){<br />
var version = ($try(function(){<br />
return navigator.plugins['Shockwave Flash'].description;<br />
}, function(){<br />
return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');<br />
}) || '0 r0').match(/\d+/g);<br />
return {version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0};<br />
})();<br />
<br />
function $exec(text){<br />
if (!text) return text;<br />
if (window.execScript){<br />
window.execScript(text);<br />
} else {<br />
var script = document.createElement('script');<br />
script.setAttribute('type', 'text/javascript');<br />
script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;<br />
document.head.appendChild(script);<br />
document.head.removeChild(script);<br />
}<br />
return text;<br />
};<br />
<br />
Native.UID = 1;<br />
<br />
var $uid = (Browser.Engine.trident) ? function(item){<br />
return (item.uid || (item.uid = [Native.UID++]))[0];<br />
} : function(item){<br />
return item.uid || (item.uid = Native.UID++);<br />
};<br />
<br />
var Window = new Native({<br />
<br />
name: 'Window',<br />
<br />
legacy: (Browser.Engine.trident) ? null: window.Window,<br />
<br />
initialize: function(win){<br />
$uid(win);<br />
if (!win.Element){<br />
win.Element = $empty;<br />
if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2<br />
win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {};<br />
}<br />
win.document.window = win;<br />
return $extend(win, Window.Prototype);<br />
},<br />
<br />
afterImplement: function(property, value){<br />
window[property] = Window.Prototype[property] = value;<br />
}<br />
<br />
});<br />
<br />
Window.Prototype = {$family: {name: 'window'}};<br />
<br />
new Window(window);<br />
<br />
var Document = new Native({<br />
<br />
name: 'Document',<br />
<br />
legacy: (Browser.Engine.trident) ? null: window.Document,<br />
<br />
initialize: function(doc){<br />
$uid(doc);<br />
doc.head = doc.getElementsByTagName('head')[0];<br />
doc.html = doc.getElementsByTagName('html')[0];<br />
if (Browser.Engine.trident && Browser.Engine.version <= 4) $try(function(){<br />
doc.execCommand("BackgroundImageCache", false, true);<br />
});<br />
if (Browser.Engine.trident) doc.window.attachEvent('onunload', function(){<br />
doc.window.detachEvent('onunload', arguments.callee);<br />
doc.head = doc.html = doc.window = null;<br />
});<br />
return $extend(doc, Document.Prototype);<br />
},<br />
<br />
afterImplement: function(property, value){<br />
document[property] = Document.Prototype[property] = value;<br />
}<br />
<br />
});<br />
<br />
Document.Prototype = {$family: {name: 'document'}};<br />
<br />
new Document(document);<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Array.js<br />
<br />
description: Contains Array Prototypes like each, contains, and erase.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /$util<br />
- /Array.each<br />
<br />
provides: [Array]<br />
<br />
...<br />
*/<br />
<br />
Array.implement({<br />
<br />
every: function(fn, bind){<br />
for (var i = 0, l = this.length; i < l; i++){<br />
if (!fn.call(bind, this[i], i, this)) return false;<br />
}<br />
return true;<br />
},<br />
<br />
filter: function(fn, bind){<br />
var results = [];<br />
for (var i = 0, l = this.length; i < l; i++){<br />
if (fn.call(bind, this[i], i, this)) results.push(this[i]);<br />
}<br />
return results;<br />
},<br />
<br />
clean: function(){<br />
return this.filter($defined);<br />
},<br />
<br />
indexOf: function(item, from){<br />
var len = this.length;<br />
for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++){<br />
if (this[i] === item) return i;<br />
}<br />
return -1;<br />
},<br />
<br />
map: function(fn, bind){<br />
var results = [];<br />
for (var i = 0, l = this.length; i < l; i++) results[i] = fn.call(bind, this[i], i, this);<br />
return results;<br />
},<br />
<br />
some: function(fn, bind){<br />
for (var i = 0, l = this.length; i < l; i++){<br />
if (fn.call(bind, this[i], i, this)) return true;<br />
}<br />
return false;<br />
},<br />
<br />
associate: function(keys){<br />
var obj = {}, length = Math.min(this.length, keys.length);<br />
for (var i = 0; i < length; i++) obj[keys[i]] = this[i];<br />
return obj;<br />
},<br />
<br />
link: function(object){<br />
var result = {};<br />
for (var i = 0, l = this.length; i < l; i++){<br />
for (var key in object){<br />
if (object[key](this[i])){<br />
result[key] = this[i];<br />
delete object[key];<br />
break;<br />
}<br />
}<br />
}<br />
return result;<br />
},<br />
<br />
contains: function(item, from){<br />
return this.indexOf(item, from) != -1;<br />
},<br />
<br />
extend: function(array){<br />
for (var i = 0, j = array.length; i < j; i++) this.push(array[i]);<br />
return this;<br />
},<br />
<br />
getLast: function(){<br />
return (this.length) ? this[this.length - 1] : null;<br />
},<br />
<br />
getRandom: function(){<br />
return (this.length) ? this[$random(0, this.length - 1)] : null;<br />
},<br />
<br />
include: function(item){<br />
if (!this.contains(item)) this.push(item);<br />
return this;<br />
},<br />
<br />
combine: function(array){<br />
for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);<br />
return this;<br />
},<br />
<br />
erase: function(item){<br />
for (var i = this.length; i--; i){<br />
if (this[i] === item) this.splice(i, 1);<br />
}<br />
return this;<br />
},<br />
<br />
empty: function(){<br />
this.length = 0;<br />
return this;<br />
},<br />
<br />
flatten: function(){<br />
var array = [];<br />
for (var i = 0, l = this.length; i < l; i++){<br />
var type = $type(this[i]);<br />
if (!type) continue;<br />
array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]);<br />
}<br />
return array;<br />
},<br />
<br />
hexToRgb: function(array){<br />
if (this.length != 3) return null;<br />
var rgb = this.map(function(value){<br />
if (value.length == 1) value += value;<br />
return value.toInt(16);<br />
});<br />
return (array) ? rgb : 'rgb(' + rgb + ')';<br />
},<br />
<br />
rgbToHex: function(array){<br />
if (this.length < 3) return null;<br />
if (this.length == 4 && this[3] == 0 && !array) return 'transparent';<br />
var hex = [];<br />
for (var i = 0; i < 3; i++){<br />
var bit = (this[i] - 0).toString(16);<br />
hex.push((bit.length == 1) ? '0' + bit : bit);<br />
}<br />
return (array) ? hex : '#' + hex.join('');<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Function.js<br />
<br />
description: Contains Function Prototypes like create, bind, pass, and delay.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Native<br />
- /$util<br />
<br />
provides: [Function]<br />
<br />
...<br />
*/<br />
<br />
Function.implement({<br />
<br />
extend: function(properties){<br />
for (var property in properties) this[property] = properties[property];<br />
return this;<br />
},<br />
<br />
create: function(options){<br />
var self = this;<br />
options = options || {};<br />
return function(event){<br />
var args = options.arguments;<br />
args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0);<br />
if (options.event) args = [event || window.event].extend(args);<br />
var returns = function(){<br />
return self.apply(options.bind || null, args);<br />
};<br />
if (options.delay) return setTimeout(returns, options.delay);<br />
if (options.periodical) return setInterval(returns, options.periodical);<br />
if (options.attempt) return $try(returns);<br />
return returns();<br />
};<br />
},<br />
<br />
run: function(args, bind){<br />
return this.apply(bind, $splat(args));<br />
},<br />
<br />
pass: function(args, bind){<br />
return this.create({bind: bind, arguments: args});<br />
},<br />
<br />
bind: function(bind, args){<br />
return this.create({bind: bind, arguments: args});<br />
},<br />
<br />
bindWithEvent: function(bind, args){<br />
return this.create({bind: bind, arguments: args, event: true});<br />
},<br />
<br />
attempt: function(args, bind){<br />
return this.create({bind: bind, arguments: args, attempt: true})();<br />
},<br />
<br />
delay: function(delay, bind, args){<br />
return this.create({bind: bind, arguments: args, delay: delay})();<br />
},<br />
<br />
periodical: function(periodical, bind, args){<br />
return this.create({bind: bind, arguments: args, periodical: periodical})();<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Number.js<br />
<br />
description: Contains Number Prototypes like limit, round, times, and ceil.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Native<br />
- /$util<br />
<br />
provides: [Number]<br />
<br />
...<br />
*/<br />
<br />
Number.implement({<br />
<br />
limit: function(min, max){<br />
return Math.min(max, Math.max(min, this));<br />
},<br />
<br />
round: function(precision){<br />
precision = Math.pow(10, precision || 0);<br />
return Math.round(this * precision) / precision;<br />
},<br />
<br />
times: function(fn, bind){<br />
for (var i = 0; i < this; i++) fn.call(bind, i, this);<br />
},<br />
<br />
toFloat: function(){<br />
return parseFloat(this);<br />
},<br />
<br />
toInt: function(base){<br />
return parseInt(this, base || 10);<br />
}<br />
<br />
});<br />
<br />
Number.alias('times', 'each');<br />
<br />
(function(math){<br />
var methods = {};<br />
math.each(function(name){<br />
if (!Number[name]) methods[name] = function(){<br />
return Math[name].apply(null, [this].concat($A(arguments)));<br />
};<br />
});<br />
Number.implement(methods);<br />
})(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);<br />
<br />
<br />
/*<br />
---<br />
<br />
script: String.js<br />
<br />
description: Contains String Prototypes like camelCase, capitalize, test, and toInt.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Native<br />
<br />
provides: [String]<br />
<br />
...<br />
*/<br />
<br />
String.implement({<br />
<br />
test: function(regex, params){<br />
return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);<br />
},<br />
<br />
contains: function(string, separator){<br />
return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;<br />
},<br />
<br />
trim: function(){<br />
return this.replace(/^\s+|\s+$/g, '');<br />
},<br />
<br />
clean: function(){<br />
return this.replace(/\s+/g, ' ').trim();<br />
},<br />
<br />
camelCase: function(){<br />
return this.replace(/-\D/g, function(match){<br />
return match.charAt(1).toUpperCase();<br />
});<br />
},<br />
<br />
hyphenate: function(){<br />
return this.replace(/[A-Z]/g, function(match){<br />
return ('-' + match.charAt(0).toLowerCase());<br />
});<br />
},<br />
<br />
capitalize: function(){<br />
return this.replace(/\b[a-z]/g, function(match){<br />
return match.toUpperCase();<br />
});<br />
},<br />
<br />
escapeRegExp: function(){<br />
return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');<br />
},<br />
<br />
toInt: function(base){<br />
return parseInt(this, base || 10);<br />
},<br />
<br />
toFloat: function(){<br />
return parseFloat(this);<br />
},<br />
<br />
hexToRgb: function(array){<br />
var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);<br />
return (hex) ? hex.slice(1).hexToRgb(array) : null;<br />
},<br />
<br />
rgbToHex: function(array){<br />
var rgb = this.match(/\d{1,3}/g);<br />
return (rgb) ? rgb.rgbToHex(array) : null;<br />
},<br />
<br />
stripScripts: function(option){<br />
var scripts = '';<br />
var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(){<br />
scripts += arguments[1] + '\n';<br />
return '';<br />
});<br />
if (option === true) $exec(scripts);<br />
else if ($type(option) == 'function') option(scripts, text);<br />
return text;<br />
},<br />
<br />
substitute: function(object, regexp){<br />
return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){<br />
if (match.charAt(0) == '\\') return match.slice(1);<br />
return (object[name] != undefined) ? object[name] : '';<br />
});<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Hash.js<br />
<br />
description: Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Hash.base<br />
<br />
provides: [Hash]<br />
<br />
...<br />
*/<br />
<br />
Hash.implement({<br />
<br />
has: Object.prototype.hasOwnProperty,<br />
<br />
keyOf: function(value){<br />
for (var key in this){<br />
if (this.hasOwnProperty(key) && this[key] === value) return key;<br />
}<br />
return null;<br />
},<br />
<br />
hasValue: function(value){<br />
return (Hash.keyOf(this, value) !== null);<br />
},<br />
<br />
extend: function(properties){<br />
Hash.each(properties || {}, function(value, key){<br />
Hash.set(this, key, value);<br />
}, this);<br />
return this;<br />
},<br />
<br />
combine: function(properties){<br />
Hash.each(properties || {}, function(value, key){<br />
Hash.include(this, key, value);<br />
}, this);<br />
return this;<br />
},<br />
<br />
erase: function(key){<br />
if (this.hasOwnProperty(key)) delete this[key];<br />
return this;<br />
},<br />
<br />
get: function(key){<br />
return (this.hasOwnProperty(key)) ? this[key] : null;<br />
},<br />
<br />
set: function(key, value){<br />
if (!this[key] || this.hasOwnProperty(key)) this[key] = value;<br />
return this;<br />
},<br />
<br />
empty: function(){<br />
Hash.each(this, function(value, key){<br />
delete this[key];<br />
}, this);<br />
return this;<br />
},<br />
<br />
include: function(key, value){<br />
if (this[key] == undefined) this[key] = value;<br />
return this;<br />
},<br />
<br />
map: function(fn, bind){<br />
var results = new Hash;<br />
Hash.each(this, function(value, key){<br />
results.set(key, fn.call(bind, value, key, this));<br />
}, this);<br />
return results;<br />
},<br />
<br />
filter: function(fn, bind){<br />
var results = new Hash;<br />
Hash.each(this, function(value, key){<br />
if (fn.call(bind, value, key, this)) results.set(key, value);<br />
}, this);<br />
return results;<br />
},<br />
<br />
every: function(fn, bind){<br />
for (var key in this){<br />
if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false;<br />
}<br />
return true;<br />
},<br />
<br />
some: function(fn, bind){<br />
for (var key in this){<br />
if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true;<br />
}<br />
return false;<br />
},<br />
<br />
getKeys: function(){<br />
var keys = [];<br />
Hash.each(this, function(value, key){<br />
keys.push(key);<br />
});<br />
return keys;<br />
},<br />
<br />
getValues: function(){<br />
var values = [];<br />
Hash.each(this, function(value){<br />
values.push(value);<br />
});<br />
return values;<br />
},<br />
<br />
toQueryString: function(base){<br />
var queryString = [];<br />
Hash.each(this, function(value, key){<br />
if (base) key = base + '[' + key + ']';<br />
var result;<br />
switch ($type(value)){<br />
case 'object': result = Hash.toQueryString(value, key); break;<br />
case 'array':<br />
var qs = {};<br />
value.each(function(val, i){<br />
qs[i] = val;<br />
});<br />
result = Hash.toQueryString(qs, key);<br />
break;<br />
default: result = key + '=' + encodeURIComponent(value);<br />
}<br />
if (value != undefined) queryString.push(result);<br />
});<br />
<br />
return queryString.join('&');<br />
}<br />
<br />
});<br />
<br />
Hash.alias({keyOf: 'indexOf', hasValue: 'contains'});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Event.js<br />
<br />
description: Contains the Event Class, to make the event object cross-browser.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Window<br />
- /Document<br />
- /Hash<br />
- /Array<br />
- /Function<br />
- /String<br />
<br />
provides: [Event]<br />
<br />
...<br />
*/<br />
<br />
var Event = new Native({<br />
<br />
name: 'Event',<br />
<br />
initialize: function(event, win){<br />
win = win || window;<br />
var doc = win.document;<br />
event = event || win.event;<br />
if (event.$extended) return event;<br />
this.$extended = true;<br />
var type = event.type;<br />
var target = event.target || event.srcElement;<br />
while (target && target.nodeType == 3) target = target.parentNode;<br />
<br />
if (type.test(/key/)){<br />
var code = event.which || event.keyCode;<br />
var key = Event.Keys.keyOf(code);<br />
if (type == 'keydown'){<br />
var fKey = code - 111;<br />
if (fKey > 0 && fKey < 13) key = 'f' + fKey;<br />
}<br />
key = key || String.fromCharCode(code).toLowerCase();<br />
} else if (type.match(/(click|mouse|menu)/i)){<br />
doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;<br />
var page = {<br />
x: event.pageX || event.clientX + doc.scrollLeft,<br />
y: event.pageY || event.clientY + doc.scrollTop<br />
};<br />
var client = {<br />
x: (event.pageX) ? event.pageX - win.pageXOffset : event.clientX,<br />
y: (event.pageY) ? event.pageY - win.pageYOffset : event.clientY<br />
};<br />
if (type.match(/DOMMouseScroll|mousewheel/)){<br />
var wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;<br />
}<br />
var rightClick = (event.which == 3) || (event.button == 2);<br />
var related = null;<br />
if (type.match(/over|out/)){<br />
switch (type){<br />
case 'mouseover': related = event.relatedTarget || event.fromElement; break;<br />
case 'mouseout': related = event.relatedTarget || event.toElement;<br />
}<br />
if (!(function(){<br />
while (related && related.nodeType == 3) related = related.parentNode;<br />
return true;<br />
}).create({attempt: Browser.Engine.gecko})()) related = false;<br />
}<br />
}<br />
<br />
return $extend(this, {<br />
event: event,<br />
type: type,<br />
<br />
page: page,<br />
client: client,<br />
rightClick: rightClick,<br />
<br />
wheel: wheel,<br />
<br />
relatedTarget: related,<br />
target: target,<br />
<br />
code: code,<br />
key: key,<br />
<br />
shift: event.shiftKey,<br />
control: event.ctrlKey,<br />
alt: event.altKey,<br />
meta: event.metaKey<br />
});<br />
}<br />
<br />
});<br />
<br />
Event.Keys = new Hash({<br />
'enter': 13,<br />
'up': 38,<br />
'down': 40,<br />
'left': 37,<br />
'right': 39,<br />
'esc': 27,<br />
'space': 32,<br />
'backspace': 8,<br />
'tab': 9,<br />
'delete': 46<br />
});<br />
<br />
Event.implement({<br />
<br />
stop: function(){<br />
return this.stopPropagation().preventDefault();<br />
},<br />
<br />
stopPropagation: function(){<br />
if (this.event.stopPropagation) this.event.stopPropagation();<br />
else this.event.cancelBubble = true;<br />
return this;<br />
},<br />
<br />
preventDefault: function(){<br />
if (this.event.preventDefault) this.event.preventDefault();<br />
else this.event.returnValue = false;<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Class.js<br />
<br />
description: Contains the Class Function for easily creating, extending, and implementing reusable Classes.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /$util<br />
- /Native<br />
- /Array<br />
- /String<br />
- /Function<br />
- /Number<br />
- /Hash<br />
<br />
provides: [Class]<br />
<br />
...<br />
*/<br />
<br />
function Class(params){<br />
<br />
if (params instanceof Function) params = {initialize: params};<br />
<br />
var newClass = function(){<br />
Object.reset(this);<br />
if (newClass._prototyping) return this;<br />
this._current = $empty;<br />
var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;<br />
delete this._current; delete this.caller;<br />
return value;<br />
}.extend(this);<br />
<br />
newClass.implement(params);<br />
<br />
newClass.constructor = Class;<br />
newClass.prototype.constructor = newClass;<br />
<br />
return newClass;<br />
<br />
};<br />
<br />
Function.prototype.protect = function(){<br />
this._protected = true;<br />
return this;<br />
};<br />
<br />
Object.reset = function(object, key){<br />
<br />
if (key == null){<br />
for (var p in object) Object.reset(object, p);<br />
return object;<br />
}<br />
<br />
delete object[key];<br />
<br />
switch ($type(object[key])){<br />
case 'object':<br />
var F = function(){};<br />
F.prototype = object[key];<br />
var i = new F;<br />
object[key] = Object.reset(i);<br />
break;<br />
case 'array': object[key] = $unlink(object[key]); break;<br />
}<br />
<br />
return object;<br />
<br />
};<br />
<br />
new Native({name: 'Class', initialize: Class}).extend({<br />
<br />
instantiate: function(F){<br />
F._prototyping = true;<br />
var proto = new F;<br />
delete F._prototyping;<br />
return proto;<br />
},<br />
<br />
wrap: function(self, key, method){<br />
if (method._origin) method = method._origin;<br />
<br />
return function(){<br />
if (method._protected && this._current == null) throw new Error('The method "' + key + '" cannot be called.');<br />
var caller = this.caller, current = this._current;<br />
this.caller = current; this._current = arguments.callee;<br />
var result = method.apply(this, arguments);<br />
this._current = current; this.caller = caller;<br />
return result;<br />
}.extend({_owner: self, _origin: method, _name: key});<br />
<br />
}<br />
<br />
});<br />
<br />
Class.implement({<br />
<br />
implement: function(key, value){<br />
<br />
if ($type(key) == 'object'){<br />
for (var p in key) this.implement(p, key[p]);<br />
return this;<br />
}<br />
<br />
var mutator = Class.Mutators[key];<br />
<br />
if (mutator){<br />
value = mutator.call(this, value);<br />
if (value == null) return this;<br />
}<br />
<br />
var proto = this.prototype;<br />
<br />
switch ($type(value)){<br />
<br />
case 'function':<br />
if (value._hidden) return this;<br />
proto[key] = Class.wrap(this, key, value);<br />
break;<br />
<br />
case 'object':<br />
var previous = proto[key];<br />
if ($type(previous) == 'object') $mixin(previous, value);<br />
else proto[key] = $unlink(value);<br />
break;<br />
<br />
case 'array':<br />
proto[key] = $unlink(value);<br />
break;<br />
<br />
default: proto[key] = value;<br />
<br />
}<br />
<br />
return this;<br />
<br />
}<br />
<br />
});<br />
<br />
Class.Mutators = {<br />
<br />
Extends: function(parent){<br />
<br />
this.parent = parent;<br />
this.prototype = Class.instantiate(parent);<br />
<br />
this.implement('parent', function(){<br />
var name = this.caller._name, previous = this.caller._owner.parent.prototype[name];<br />
if (!previous) throw new Error('The method "' + name + '" has no parent.');<br />
return previous.apply(this, arguments);<br />
}.protect());<br />
<br />
},<br />
<br />
Implements: function(items){<br />
$splat(items).each(function(item){<br />
if (item instanceof Function) item = Class.instantiate(item);<br />
this.implement(item);<br />
}, this);<br />
<br />
}<br />
<br />
};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Class.Extras.js<br />
<br />
description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Class<br />
<br />
provides: [Chain, Events, Options]<br />
<br />
...<br />
*/<br />
<br />
var Chain = new Class({<br />
<br />
$chain: [],<br />
<br />
chain: function(){<br />
this.$chain.extend(Array.flatten(arguments));<br />
return this;<br />
},<br />
<br />
callChain: function(){<br />
return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;<br />
},<br />
<br />
clearChain: function(){<br />
this.$chain.empty();<br />
return this;<br />
}<br />
<br />
});<br />
<br />
var Events = new Class({<br />
<br />
$events: {},<br />
<br />
addEvent: function(type, fn, internal){<br />
type = Events.removeOn(type);<br />
if (fn != $empty){<br />
this.$events[type] = this.$events[type] || [];<br />
this.$events[type].include(fn);<br />
if (internal) fn.internal = true;<br />
}<br />
return this;<br />
},<br />
<br />
addEvents: function(events){<br />
for (var type in events) this.addEvent(type, events[type]);<br />
return this;<br />
},<br />
<br />
fireEvent: function(type, args, delay){<br />
type = Events.removeOn(type);<br />
if (!this.$events || !this.$events[type]) return this;<br />
this.$events[type].each(function(fn){<br />
fn.create({'bind': this, 'delay': delay, 'arguments': args})();<br />
}, this);<br />
return this;<br />
},<br />
<br />
removeEvent: function(type, fn){<br />
type = Events.removeOn(type);<br />
if (!this.$events[type]) return this;<br />
if (!fn.internal) this.$events[type].erase(fn);<br />
return this;<br />
},<br />
<br />
removeEvents: function(events){<br />
var type;<br />
if ($type(events) == 'object'){<br />
for (type in events) this.removeEvent(type, events[type]);<br />
return this;<br />
}<br />
if (events) events = Events.removeOn(events);<br />
for (type in this.$events){<br />
if (events && events != type) continue;<br />
var fns = this.$events[type];<br />
for (var i = fns.length; i--; i) this.removeEvent(type, fns[i]);<br />
}<br />
return this;<br />
}<br />
<br />
});<br />
<br />
Events.removeOn = function(string){<br />
return string.replace(/^on([A-Z])/, function(full, first){<br />
return first.toLowerCase();<br />
});<br />
};<br />
<br />
var Options = new Class({<br />
<br />
setOptions: function(){<br />
this.options = $merge.run([this.options].extend(arguments));<br />
if (!this.addEvent) return this;<br />
for (var option in this.options){<br />
if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;<br />
this.addEvent(option, this.options[option]);<br />
delete this.options[option];<br />
}<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Element.js<br />
<br />
description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Window<br />
- /Document<br />
- /Array<br />
- /String<br />
- /Function<br />
- /Number<br />
- /Hash<br />
<br />
provides: [Element, Elements, $, $$, Iframe]<br />
<br />
...<br />
*/<br />
<br />
var Element = new Native({<br />
<br />
name: 'Element',<br />
<br />
legacy: window.Element,<br />
<br />
initialize: function(tag, props){<br />
var konstructor = Element.Constructors.get(tag);<br />
if (konstructor) return konstructor(props);<br />
if (typeof tag == 'string') return document.newElement(tag, props);<br />
return document.id(tag).set(props);<br />
},<br />
<br />
afterImplement: function(key, value){<br />
Element.Prototype[key] = value;<br />
if (Array[key]) return;<br />
Elements.implement(key, function(){<br />
var items = [], elements = true;<br />
for (var i = 0, j = this.length; i < j; i++){<br />
var returns = this[i][key].apply(this[i], arguments);<br />
items.push(returns);<br />
if (elements) elements = ($type(returns) == 'element');<br />
}<br />
return (elements) ? new Elements(items) : items;<br />
});<br />
}<br />
<br />
});<br />
<br />
Element.Prototype = {$family: {name: 'element'}};<br />
<br />
Element.Constructors = new Hash;<br />
<br />
var IFrame = new Native({<br />
<br />
name: 'IFrame',<br />
<br />
generics: false,<br />
<br />
initialize: function(){<br />
var params = Array.link(arguments, {properties: Object.type, iframe: $defined});<br />
var props = params.properties || {};<br />
var iframe = document.id(params.iframe);<br />
var onload = props.onload || $empty;<br />
delete props.onload;<br />
props.id = props.name = $pick(props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + $time());<br />
iframe = new Element(iframe || 'iframe', props);<br />
var onFrameLoad = function(){<br />
var host = $try(function(){<br />
return iframe.contentWindow.location.host;<br />
});<br />
if (!host || host == window.location.host){<br />
var win = new Window(iframe.contentWindow);<br />
new Document(iframe.contentWindow.document);<br />
$extend(win.Element.prototype, Element.Prototype);<br />
}<br />
onload.call(iframe.contentWindow, iframe.contentWindow.document);<br />
};<br />
var contentWindow = $try(function(){<br />
return iframe.contentWindow;<br />
});<br />
((contentWindow && contentWindow.document.body) || window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);<br />
return iframe;<br />
}<br />
<br />
});<br />
<br />
var Elements = new Native({<br />
<br />
initialize: function(elements, options){<br />
options = $extend({ddup: true, cash: true}, options);<br />
elements = elements || [];<br />
if (options.ddup || options.cash){<br />
var uniques = {}, returned = [];<br />
for (var i = 0, l = elements.length; i < l; i++){<br />
var el = document.id(elements[i], !options.cash);<br />
if (options.ddup){<br />
if (uniques[el.uid]) continue;<br />
uniques[el.uid] = true;<br />
}<br />
if (el) returned.push(el);<br />
}<br />
elements = returned;<br />
}<br />
return (options.cash) ? $extend(elements, this) : elements;<br />
}<br />
<br />
});<br />
<br />
Elements.implement({<br />
<br />
filter: function(filter, bind){<br />
if (!filter) return this;<br />
return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item){<br />
return item.match(filter);<br />
} : filter, bind));<br />
}<br />
<br />
});<br />
<br />
Document.implement({<br />
<br />
newElement: function(tag, props){<br />
if (Browser.Engine.trident && props){<br />
['name', 'type', 'checked'].each(function(attribute){<br />
if (!props[attribute]) return;<br />
tag += ' ' + attribute + '="' + props[attribute] + '"';<br />
if (attribute != 'checked') delete props[attribute];<br />
});<br />
tag = '<' + tag + '>';<br />
}<br />
return document.id(this.createElement(tag)).set(props);<br />
},<br />
<br />
newTextNode: function(text){<br />
return this.createTextNode(text);<br />
},<br />
<br />
getDocument: function(){<br />
return this;<br />
},<br />
<br />
getWindow: function(){<br />
return this.window;<br />
},<br />
<br />
id: (function(){<br />
<br />
var types = {<br />
<br />
string: function(id, nocash, doc){<br />
id = doc.getElementById(id);<br />
return (id) ? types.element(id, nocash) : null;<br />
},<br />
<br />
element: function(el, nocash){<br />
$uid(el);<br />
if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)){<br />
var proto = Element.Prototype;<br />
for (var p in proto) el[p] = proto[p];<br />
};<br />
return el;<br />
},<br />
<br />
object: function(obj, nocash, doc){<br />
if (obj.toElement) return types.element(obj.toElement(doc), nocash);<br />
return null;<br />
}<br />
<br />
};<br />
<br />
types.textnode = types.whitespace = types.window = types.document = $arguments(0);<br />
<br />
return function(el, nocash, doc){<br />
if (el && el.$family && el.uid) return el;<br />
var type = $type(el);<br />
return (types[type]) ? types[type](el, nocash, doc || document) : null;<br />
};<br />
<br />
})()<br />
<br />
});<br />
<br />
if (window.$ == null) Window.implement({<br />
$: function(el, nc){<br />
return document.id(el, nc, this.document);<br />
}<br />
});<br />
<br />
Window.implement({<br />
<br />
$$: function(selector){<br />
if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector);<br />
var elements = [];<br />
var args = Array.flatten(arguments);<br />
for (var i = 0, l = args.length; i < l; i++){<br />
var item = args[i];<br />
switch ($type(item)){<br />
case 'element': elements.push(item); break;<br />
case 'string': elements.extend(this.document.getElements(item, true));<br />
}<br />
}<br />
return new Elements(elements);<br />
},<br />
<br />
getDocument: function(){<br />
return this.document;<br />
},<br />
<br />
getWindow: function(){<br />
return this;<br />
}<br />
<br />
});<br />
<br />
Native.implement([Element, Document], {<br />
<br />
getElement: function(selector, nocash){<br />
return document.id(this.getElements(selector, true)[0] || null, nocash);<br />
},<br />
<br />
getElements: function(tags, nocash){<br />
tags = tags.split(',');<br />
var elements = [];<br />
var ddup = (tags.length > 1);<br />
tags.each(function(tag){<br />
var partial = this.getElementsByTagName(tag.trim());<br />
(ddup) ? elements.extend(partial) : elements = partial;<br />
}, this);<br />
return new Elements(elements, {ddup: ddup, cash: !nocash});<br />
}<br />
<br />
});<br />
<br />
(function(){<br />
<br />
var collected = {}, storage = {};<br />
var props = {input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value'};<br />
<br />
var get = function(uid){<br />
return (storage[uid] || (storage[uid] = {}));<br />
};<br />
<br />
var clean = function(item, retain){<br />
if (!item) return;<br />
var uid = item.uid;<br />
if (Browser.Engine.trident){<br />
if (item.clearAttributes){<br />
var clone = retain && item.cloneNode(false);<br />
item.clearAttributes();<br />
if (clone) item.mergeAttributes(clone);<br />
} else if (item.removeEvents){<br />
item.removeEvents();<br />
}<br />
if ((/object/i).test(item.tagName)){<br />
for (var p in item){<br />
if (typeof item[p] == 'function') item[p] = $empty;<br />
}<br />
Element.dispose(item);<br />
}<br />
} <br />
if (!uid) return;<br />
collected[uid] = storage[uid] = null;<br />
};<br />
<br />
var purge = function(){<br />
Hash.each(collected, clean);<br />
if (Browser.Engine.trident) $A(document.getElementsByTagName('object')).each(clean);<br />
if (window.CollectGarbage) CollectGarbage();<br />
collected = storage = null;<br />
};<br />
<br />
var walk = function(element, walk, start, match, all, nocash){<br />
var el = element[start || walk];<br />
var elements = [];<br />
while (el){<br />
if (el.nodeType == 1 && (!match || Element.match(el, match))){<br />
if (!all) return document.id(el, nocash);<br />
elements.push(el);<br />
}<br />
el = el[walk];<br />
}<br />
return (all) ? new Elements(elements, {ddup: false, cash: !nocash}) : null;<br />
};<br />
<br />
var attributes = {<br />
'html': 'innerHTML',<br />
'class': 'className',<br />
'for': 'htmlFor',<br />
'defaultValue': 'defaultValue',<br />
'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'<br />
};<br />
var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];<br />
var camels = ['value', 'type', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];<br />
<br />
bools = bools.associate(bools);<br />
<br />
Hash.extend(attributes, bools);<br />
Hash.extend(attributes, camels.associate(camels.map(String.toLowerCase)));<br />
<br />
var inserters = {<br />
<br />
before: function(context, element){<br />
if (element.parentNode) element.parentNode.insertBefore(context, element);<br />
},<br />
<br />
after: function(context, element){<br />
if (!element.parentNode) return;<br />
var next = element.nextSibling;<br />
(next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context);<br />
},<br />
<br />
bottom: function(context, element){<br />
element.appendChild(context);<br />
},<br />
<br />
top: function(context, element){<br />
var first = element.firstChild;<br />
(first) ? element.insertBefore(context, first) : element.appendChild(context);<br />
}<br />
<br />
};<br />
<br />
inserters.inside = inserters.bottom;<br />
<br />
Hash.each(inserters, function(inserter, where){<br />
<br />
where = where.capitalize();<br />
<br />
Element.implement('inject' + where, function(el){<br />
inserter(this, document.id(el, true));<br />
return this;<br />
});<br />
<br />
Element.implement('grab' + where, function(el){<br />
inserter(document.id(el, true), this);<br />
return this;<br />
});<br />
<br />
});<br />
<br />
Element.implement({<br />
<br />
set: function(prop, value){<br />
switch ($type(prop)){<br />
case 'object':<br />
for (var p in prop) this.set(p, prop[p]);<br />
break;<br />
case 'string':<br />
var property = Element.Properties.get(prop);<br />
(property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);<br />
}<br />
return this;<br />
},<br />
<br />
get: function(prop){<br />
var property = Element.Properties.get(prop);<br />
return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);<br />
},<br />
<br />
erase: function(prop){<br />
var property = Element.Properties.get(prop);<br />
(property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);<br />
return this;<br />
},<br />
<br />
setProperty: function(attribute, value){<br />
var key = attributes[attribute];<br />
if (value == undefined) return this.removeProperty(attribute);<br />
if (key && bools[attribute]) value = !!value;<br />
(key) ? this[key] = value : this.setAttribute(attribute, '' + value);<br />
return this;<br />
},<br />
<br />
setProperties: function(attributes){<br />
for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);<br />
return this;<br />
},<br />
<br />
getProperty: function(attribute){<br />
var key = attributes[attribute];<br />
var value = (key) ? this[key] : this.getAttribute(attribute, 2);<br />
return (bools[attribute]) ? !!value : (key) ? value : value || null;<br />
},<br />
<br />
getProperties: function(){<br />
var args = $A(arguments);<br />
return args.map(this.getProperty, this).associate(args);<br />
},<br />
<br />
removeProperty: function(attribute){<br />
var key = attributes[attribute];<br />
(key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute);<br />
return this;<br />
},<br />
<br />
removeProperties: function(){<br />
Array.each(arguments, this.removeProperty, this);<br />
return this;<br />
},<br />
<br />
hasClass: function(className){<br />
return this.className.contains(className, ' ');<br />
},<br />
<br />
addClass: function(className){<br />
if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();<br />
return this;<br />
},<br />
<br />
removeClass: function(className){<br />
this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');<br />
return this;<br />
},<br />
<br />
toggleClass: function(className){<br />
return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);<br />
},<br />
<br />
adopt: function(){<br />
Array.flatten(arguments).each(function(element){<br />
element = document.id(element, true);<br />
if (element) this.appendChild(element);<br />
}, this);<br />
return this;<br />
},<br />
<br />
appendText: function(text, where){<br />
return this.grab(this.getDocument().newTextNode(text), where);<br />
},<br />
<br />
grab: function(el, where){<br />
inserters[where || 'bottom'](document.id(el, true), this);<br />
return this;<br />
},<br />
<br />
inject: function(el, where){<br />
inserters[where || 'bottom'](this, document.id(el, true));<br />
return this;<br />
},<br />
<br />
replaces: function(el){<br />
el = document.id(el, true);<br />
el.parentNode.replaceChild(this, el);<br />
return this;<br />
},<br />
<br />
wraps: function(el, where){<br />
el = document.id(el, true);<br />
return this.replaces(el).grab(el, where);<br />
},<br />
<br />
getPrevious: function(match, nocash){<br />
return walk(this, 'previousSibling', null, match, false, nocash);<br />
},<br />
<br />
getAllPrevious: function(match, nocash){<br />
return walk(this, 'previousSibling', null, match, true, nocash);<br />
},<br />
<br />
getNext: function(match, nocash){<br />
return walk(this, 'nextSibling', null, match, false, nocash);<br />
},<br />
<br />
getAllNext: function(match, nocash){<br />
return walk(this, 'nextSibling', null, match, true, nocash);<br />
},<br />
<br />
getFirst: function(match, nocash){<br />
return walk(this, 'nextSibling', 'firstChild', match, false, nocash);<br />
},<br />
<br />
getLast: function(match, nocash){<br />
return walk(this, 'previousSibling', 'lastChild', match, false, nocash);<br />
},<br />
<br />
getParent: function(match, nocash){<br />
return walk(this, 'parentNode', null, match, false, nocash);<br />
},<br />
<br />
getParents: function(match, nocash){<br />
return walk(this, 'parentNode', null, match, true, nocash);<br />
},<br />
<br />
getSiblings: function(match, nocash){<br />
return this.getParent().getChildren(match, nocash).erase(this);<br />
},<br />
<br />
getChildren: function(match, nocash){<br />
return walk(this, 'nextSibling', 'firstChild', match, true, nocash);<br />
},<br />
<br />
getWindow: function(){<br />
return this.ownerDocument.window;<br />
},<br />
<br />
getDocument: function(){<br />
return this.ownerDocument;<br />
},<br />
<br />
getElementById: function(id, nocash){<br />
var el = this.ownerDocument.getElementById(id);<br />
if (!el) return null;<br />
for (var parent = el.parentNode; parent != this; parent = parent.parentNode){<br />
if (!parent) return null;<br />
}<br />
return document.id(el, nocash);<br />
},<br />
<br />
getSelected: function(){<br />
return new Elements($A(this.options).filter(function(option){<br />
return option.selected;<br />
}));<br />
},<br />
<br />
getComputedStyle: function(property){<br />
if (this.currentStyle) return this.currentStyle[property.camelCase()];<br />
var computed = this.getDocument().defaultView.getComputedStyle(this, null);<br />
return (computed) ? computed.getPropertyValue([property.hyphenate()]) : null;<br />
},<br />
<br />
toQueryString: function(){<br />
var queryString = [];<br />
this.getElements('input, select, textarea', true).each(function(el){<br />
if (!el.name || el.disabled || el.type == 'submit' || el.type == 'reset' || el.type == 'file') return;<br />
var value = (el.tagName.toLowerCase() == 'select') ? Element.getSelected(el).map(function(opt){<br />
return opt.value;<br />
}) : ((el.type == 'radio' || el.type == 'checkbox') && !el.checked) ? null : el.value;<br />
$splat(value).each(function(val){<br />
if (typeof val != 'undefined') queryString.push(el.name + '=' + encodeURIComponent(val));<br />
});<br />
});<br />
return queryString.join('&');<br />
},<br />
<br />
clone: function(contents, keepid){<br />
contents = contents !== false;<br />
var clone = this.cloneNode(contents);<br />
var clean = function(node, element){<br />
if (!keepid) node.removeAttribute('id');<br />
if (Browser.Engine.trident){<br />
node.clearAttributes();<br />
node.mergeAttributes(element);<br />
node.removeAttribute('uid');<br />
if (node.options){<br />
var no = node.options, eo = element.options;<br />
for (var j = no.length; j--;) no[j].selected = eo[j].selected;<br />
}<br />
}<br />
var prop = props[element.tagName.toLowerCase()];<br />
if (prop && element[prop]) node[prop] = element[prop];<br />
};<br />
<br />
if (contents){<br />
var ce = clone.getElementsByTagName('*'), te = this.getElementsByTagName('*');<br />
for (var i = ce.length; i--;) clean(ce[i], te[i]);<br />
}<br />
<br />
clean(clone, this);<br />
return document.id(clone);<br />
},<br />
<br />
destroy: function(){<br />
Element.empty(this);<br />
Element.dispose(this);<br />
clean(this, true);<br />
return null;<br />
},<br />
<br />
empty: function(){<br />
$A(this.childNodes).each(function(node){<br />
Element.destroy(node);<br />
});<br />
return this;<br />
},<br />
<br />
dispose: function(){<br />
return (this.parentNode) ? this.parentNode.removeChild(this) : this;<br />
},<br />
<br />
hasChild: function(el){<br />
el = document.id(el, true);<br />
if (!el) return false;<br />
if (Browser.Engine.webkit && Browser.Engine.version < 420) return $A(this.getElementsByTagName(el.tagName)).contains(el);<br />
return (this.contains) ? (this != el && this.contains(el)) : !!(this.compareDocumentPosition(el) & 16);<br />
},<br />
<br />
match: function(tag){<br />
return (!tag || (tag == this) || (Element.get(this, 'tag') == tag));<br />
}<br />
<br />
});<br />
<br />
Native.implement([Element, Window, Document], {<br />
<br />
addListener: function(type, fn){<br />
if (type == 'unload'){<br />
var old = fn, self = this;<br />
fn = function(){<br />
self.removeListener('unload', fn);<br />
old();<br />
};<br />
} else {<br />
collected[this.uid] = this;<br />
}<br />
if (this.addEventListener) this.addEventListener(type, fn, false);<br />
else this.attachEvent('on' + type, fn);<br />
return this;<br />
},<br />
<br />
removeListener: function(type, fn){<br />
if (this.removeEventListener) this.removeEventListener(type, fn, false);<br />
else this.detachEvent('on' + type, fn);<br />
return this;<br />
},<br />
<br />
retrieve: function(property, dflt){<br />
var storage = get(this.uid), prop = storage[property];<br />
if (dflt != undefined && prop == undefined) prop = storage[property] = dflt;<br />
return $pick(prop);<br />
},<br />
<br />
store: function(property, value){<br />
var storage = get(this.uid);<br />
storage[property] = value;<br />
return this;<br />
},<br />
<br />
eliminate: function(property){<br />
var storage = get(this.uid);<br />
delete storage[property];<br />
return this;<br />
}<br />
<br />
});<br />
<br />
window.addListener('unload', purge);<br />
<br />
})();<br />
<br />
Element.Properties = new Hash;<br />
<br />
Element.Properties.style = {<br />
<br />
set: function(style){<br />
this.style.cssText = style;<br />
},<br />
<br />
get: function(){<br />
return this.style.cssText;<br />
},<br />
<br />
erase: function(){<br />
this.style.cssText = '';<br />
}<br />
<br />
};<br />
<br />
Element.Properties.tag = {<br />
<br />
get: function(){<br />
return this.tagName.toLowerCase();<br />
}<br />
<br />
};<br />
<br />
Element.Properties.html = (function(){<br />
var wrapper = document.createElement('div');<br />
<br />
var translations = {<br />
table: [1, '<table>', '</table>'],<br />
select: [1, '<select>', '</select>'],<br />
tbody: [2, '<table><tbody>', '</tbody></table>'],<br />
tr: [3, '<table><tbody><tr>', '</tr></tbody></table>']<br />
};<br />
translations.thead = translations.tfoot = translations.tbody;<br />
<br />
var html = {<br />
set: function(){<br />
var html = Array.flatten(arguments).join('');<br />
var wrap = Browser.Engine.trident && translations[this.get('tag')];<br />
if (wrap){<br />
var first = wrapper;<br />
first.innerHTML = wrap[1] + html + wrap[2];<br />
for (var i = wrap[0]; i--;) first = first.firstChild;<br />
this.empty().adopt(first.childNodes);<br />
} else {<br />
this.innerHTML = html;<br />
}<br />
}<br />
};<br />
<br />
html.erase = html.set;<br />
<br />
return html;<br />
})();<br />
<br />
if (Browser.Engine.webkit && Browser.Engine.version < 420) Element.Properties.text = {<br />
get: function(){<br />
if (this.innerText) return this.innerText;<br />
var temp = this.ownerDocument.newElement('div', {html: this.innerHTML}).inject(this.ownerDocument.body);<br />
var text = temp.innerText;<br />
temp.destroy();<br />
return text;<br />
}<br />
};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Element.Event.js<br />
<br />
description: Contains Element methods for dealing with events. This file also includes mouseenter and mouseleave custom Element Events.<br />
<br />
license: MIT-style license.<br />
<br />
requires: <br />
- /Element<br />
- /Event<br />
<br />
provides: [Element.Event]<br />
<br />
...<br />
*/<br />
<br />
Element.Properties.events = {set: function(events){<br />
this.addEvents(events);<br />
}};<br />
<br />
Native.implement([Element, Window, Document], {<br />
<br />
addEvent: function(type, fn){<br />
var events = this.retrieve('events', {});<br />
events[type] = events[type] || {'keys': [], 'values': []};<br />
if (events[type].keys.contains(fn)) return this;<br />
events[type].keys.push(fn);<br />
var realType = type, custom = Element.Events.get(type), condition = fn, self = this;<br />
if (custom){<br />
if (custom.onAdd) custom.onAdd.call(this, fn);<br />
if (custom.condition){<br />
condition = function(event){<br />
if (custom.condition.call(this, event)) return fn.call(this, event);<br />
return true;<br />
};<br />
}<br />
realType = custom.base || realType;<br />
}<br />
var defn = function(){<br />
return fn.call(self);<br />
};<br />
var nativeEvent = Element.NativeEvents[realType];<br />
if (nativeEvent){<br />
if (nativeEvent == 2){<br />
defn = function(event){<br />
event = new Event(event, self.getWindow());<br />
if (condition.call(self, event) === false) event.stop();<br />
};<br />
}<br />
this.addListener(realType, defn);<br />
}<br />
events[type].values.push(defn);<br />
return this;<br />
},<br />
<br />
removeEvent: function(type, fn){<br />
var events = this.retrieve('events');<br />
if (!events || !events[type]) return this;<br />
var pos = events[type].keys.indexOf(fn);<br />
if (pos == -1) return this;<br />
events[type].keys.splice(pos, 1);<br />
var value = events[type].values.splice(pos, 1)[0];<br />
var custom = Element.Events.get(type);<br />
if (custom){<br />
if (custom.onRemove) custom.onRemove.call(this, fn);<br />
type = custom.base || type;<br />
}<br />
return (Element.NativeEvents[type]) ? this.removeListener(type, value) : this;<br />
},<br />
<br />
addEvents: function(events){<br />
for (var event in events) this.addEvent(event, events[event]);<br />
return this;<br />
},<br />
<br />
removeEvents: function(events){<br />
var type;<br />
if ($type(events) == 'object'){<br />
for (type in events) this.removeEvent(type, events[type]);<br />
return this;<br />
}<br />
var attached = this.retrieve('events');<br />
if (!attached) return this;<br />
if (!events){<br />
for (type in attached) this.removeEvents(type);<br />
this.eliminate('events');<br />
} else if (attached[events]){<br />
while (attached[events].keys[0]) this.removeEvent(events, attached[events].keys[0]);<br />
attached[events] = null;<br />
}<br />
return this;<br />
},<br />
<br />
fireEvent: function(type, args, delay){<br />
var events = this.retrieve('events');<br />
if (!events || !events[type]) return this;<br />
events[type].keys.each(function(fn){<br />
fn.create({'bind': this, 'delay': delay, 'arguments': args})();<br />
}, this);<br />
return this;<br />
},<br />
<br />
cloneEvents: function(from, type){<br />
from = document.id(from);<br />
var fevents = from.retrieve('events');<br />
if (!fevents) return this;<br />
if (!type){<br />
for (var evType in fevents) this.cloneEvents(from, evType);<br />
} else if (fevents[type]){<br />
fevents[type].keys.each(function(fn){<br />
this.addEvent(type, fn);<br />
}, this);<br />
}<br />
return this;<br />
}<br />
<br />
});<br />
<br />
Element.NativeEvents = {<br />
click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons<br />
mousewheel: 2, DOMMouseScroll: 2, //mouse wheel<br />
mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement<br />
keydown: 2, keypress: 2, keyup: 2, //keyboard<br />
focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements<br />
load: 1, unload: 1, beforeunload: 2, resize: 1, move: 1, DOMContentLoaded: 1, readystatechange: 1, //window<br />
error: 1, abort: 1, scroll: 1 //misc<br />
};<br />
<br />
(function(){<br />
<br />
var $check = function(event){<br />
var related = event.relatedTarget;<br />
if (related == undefined) return true;<br />
if (related === false) return false;<br />
return ($type(this) != 'document' && related != this && related.prefix != 'xul' && !this.hasChild(related));<br />
};<br />
<br />
Element.Events = new Hash({<br />
<br />
mouseenter: {<br />
base: 'mouseover',<br />
condition: $check<br />
},<br />
<br />
mouseleave: {<br />
base: 'mouseout',<br />
condition: $check<br />
},<br />
<br />
mousewheel: {<br />
base: (Browser.Engine.gecko) ? 'DOMMouseScroll' : 'mousewheel'<br />
}<br />
<br />
});<br />
<br />
})();<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Element.Style.js<br />
<br />
description: Contains methods for interacting with the styles of Elements in a fashionable way.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Element<br />
<br />
provides: [Element.Style]<br />
<br />
...<br />
*/<br />
<br />
Element.Properties.styles = {set: function(styles){<br />
this.setStyles(styles);<br />
}};<br />
<br />
Element.Properties.opacity = {<br />
<br />
set: function(opacity, novisibility){<br />
if (!novisibility){<br />
if (opacity == 0){<br />
if (this.style.visibility != 'hidden') this.style.visibility = 'hidden';<br />
} else {<br />
if (this.style.visibility != 'visible') this.style.visibility = 'visible';<br />
}<br />
}<br />
if (!this.currentStyle || !this.currentStyle.hasLayout) this.style.zoom = 1;<br />
if (Browser.Engine.trident) this.style.filter = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')';<br />
this.style.opacity = opacity;<br />
this.store('opacity', opacity);<br />
},<br />
<br />
get: function(){<br />
return this.retrieve('opacity', 1);<br />
}<br />
<br />
};<br />
<br />
Element.implement({<br />
<br />
setOpacity: function(value){<br />
return this.set('opacity', value, true);<br />
},<br />
<br />
getOpacity: function(){<br />
return this.get('opacity');<br />
},<br />
<br />
setStyle: function(property, value){<br />
switch (property){<br />
case 'opacity': return this.set('opacity', parseFloat(value));<br />
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';<br />
}<br />
property = property.camelCase();<br />
if ($type(value) != 'string'){<br />
var map = (Element.Styles.get(property) || '@').split(' ');<br />
value = $splat(value).map(function(val, i){<br />
if (!map[i]) return '';<br />
return ($type(val) == 'number') ? map[i].replace('@', Math.round(val)) : val;<br />
}).join(' ');<br />
} else if (value == String(Number(value))){<br />
value = Math.round(value);<br />
}<br />
this.style[property] = value;<br />
return this;<br />
},<br />
<br />
getStyle: function(property){<br />
switch (property){<br />
case 'opacity': return this.get('opacity');<br />
case 'float': property = (Browser.Engine.trident) ? 'styleFloat' : 'cssFloat';<br />
}<br />
property = property.camelCase();<br />
var result = this.style[property];<br />
if (!$chk(result)){<br />
result = [];<br />
for (var style in Element.ShortStyles){<br />
if (property != style) continue;<br />
for (var s in Element.ShortStyles[style]) result.push(this.getStyle(s));<br />
return result.join(' ');<br />
}<br />
result = this.getComputedStyle(property);<br />
}<br />
if (result){<br />
result = String(result);<br />
var color = result.match(/rgba?\([\d\s,]+\)/);<br />
if (color) result = result.replace(color[0], color[0].rgbToHex());<br />
}<br />
if (Browser.Engine.presto || (Browser.Engine.trident && !$chk(parseInt(result, 10)))){<br />
if (property.test(/^(height|width)$/)){<br />
var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0;<br />
values.each(function(value){<br />
size += this.getStyle('border-' + value + '-width').toInt() + this.getStyle('padding-' + value).toInt();<br />
}, this);<br />
return this['offset' + property.capitalize()] - size + 'px';<br />
}<br />
if ((Browser.Engine.presto) && String(result).test('px')) return result;<br />
if (property.test(/(border(.+)Width|margin|padding)/)) return '0px';<br />
}<br />
return result;<br />
},<br />
<br />
setStyles: function(styles){<br />
for (var style in styles) this.setStyle(style, styles[style]);<br />
return this;<br />
},<br />
<br />
getStyles: function(){<br />
var result = {};<br />
Array.flatten(arguments).each(function(key){<br />
result[key] = this.getStyle(key);<br />
}, this);<br />
return result;<br />
}<br />
<br />
});<br />
<br />
Element.Styles = new Hash({<br />
left: '@px', top: '@px', bottom: '@px', right: '@px',<br />
width: '@px', height: '@px', maxWidth: '@px', maxHeight: '@px', minWidth: '@px', minHeight: '@px',<br />
backgroundColor: 'rgb(@, @, @)', backgroundPosition: '@px @px', color: 'rgb(@, @, @)',<br />
fontSize: '@px', letterSpacing: '@px', lineHeight: '@px', clip: 'rect(@px @px @px @px)',<br />
margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)',<br />
borderWidth: '@px @px @px @px', borderStyle: '@ @ @ @', borderColor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)',<br />
zIndex: '@', 'zoom': '@', fontWeight: '@', textIndent: '@px', opacity: '@'<br />
});<br />
<br />
Element.ShortStyles = {margin: {}, padding: {}, border: {}, borderWidth: {}, borderStyle: {}, borderColor: {}};<br />
<br />
['Top', 'Right', 'Bottom', 'Left'].each(function(direction){<br />
var Short = Element.ShortStyles;<br />
var All = Element.Styles;<br />
['margin', 'padding'].each(function(style){<br />
var sd = style + direction;<br />
Short[style][sd] = All[sd] = '@px';<br />
});<br />
var bd = 'border' + direction;<br />
Short.border[bd] = All[bd] = '@px @ rgb(@, @, @)';<br />
var bdw = bd + 'Width', bds = bd + 'Style', bdc = bd + 'Color';<br />
Short[bd] = {};<br />
Short.borderWidth[bdw] = Short[bd][bdw] = All[bdw] = '@px';<br />
Short.borderStyle[bds] = Short[bd][bds] = All[bds] = '@';<br />
Short.borderColor[bdc] = Short[bd][bdc] = All[bdc] = 'rgb(@, @, @)';<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Element.Dimensions.js<br />
<br />
description: Contains methods to work with size, scroll, or positioning of Elements and the window object.<br />
<br />
license: MIT-style license.<br />
<br />
credits:<br />
- Element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [LGPL License](http://www.gnu.org/licenses/lgpl.html).<br />
- Viewport dimensions based on [YUI](http://developer.yahoo.com/yui/) code, [BSD License](http://developer.yahoo.com/yui/license.html).<br />
<br />
requires:<br />
- /Element<br />
<br />
provides: [Element.Dimensions]<br />
<br />
...<br />
*/<br />
<br />
(function(){<br />
<br />
Element.implement({<br />
<br />
scrollTo: function(x, y){<br />
if (isBody(this)){<br />
this.getWindow().scrollTo(x, y);<br />
} else {<br />
this.scrollLeft = x;<br />
this.scrollTop = y;<br />
}<br />
return this;<br />
},<br />
<br />
getSize: function(){<br />
if (isBody(this)) return this.getWindow().getSize();<br />
return {x: this.offsetWidth, y: this.offsetHeight};<br />
},<br />
<br />
getScrollSize: function(){<br />
if (isBody(this)) return this.getWindow().getScrollSize();<br />
return {x: this.scrollWidth, y: this.scrollHeight};<br />
},<br />
<br />
getScroll: function(){<br />
if (isBody(this)) return this.getWindow().getScroll();<br />
return {x: this.scrollLeft, y: this.scrollTop};<br />
},<br />
<br />
getScrolls: function(){<br />
var element = this, position = {x: 0, y: 0};<br />
while (element && !isBody(element)){<br />
position.x += element.scrollLeft;<br />
position.y += element.scrollTop;<br />
element = element.parentNode;<br />
}<br />
return position;<br />
},<br />
<br />
getOffsetParent: function(){<br />
var element = this;<br />
if (isBody(element)) return null;<br />
if (!Browser.Engine.trident) return element.offsetParent;<br />
while ((element = element.parentNode) && !isBody(element)){<br />
if (styleString(element, 'position') != 'static') return element;<br />
}<br />
return null;<br />
},<br />
<br />
getOffsets: function(){<br />
if (this.getBoundingClientRect){<br />
var bound = this.getBoundingClientRect(),<br />
html = document.id(this.getDocument().documentElement),<br />
htmlScroll = html.getScroll(),<br />
elemScrolls = this.getScrolls(),<br />
elemScroll = this.getScroll(),<br />
isFixed = (styleString(this, 'position') == 'fixed');<br />
<br />
return {<br />
x: bound.left.toInt() + elemScrolls.x - elemScroll.x + ((isFixed) ? 0 : htmlScroll.x) - html.clientLeft,<br />
y: bound.top.toInt() + elemScrolls.y - elemScroll.y + ((isFixed) ? 0 : htmlScroll.y) - html.clientTop<br />
};<br />
}<br />
<br />
var element = this, position = {x: 0, y: 0};<br />
if (isBody(this)) return position;<br />
<br />
while (element && !isBody(element)){<br />
position.x += element.offsetLeft;<br />
position.y += element.offsetTop;<br />
<br />
if (Browser.Engine.gecko){<br />
if (!borderBox(element)){<br />
position.x += leftBorder(element);<br />
position.y += topBorder(element);<br />
}<br />
var parent = element.parentNode;<br />
if (parent && styleString(parent, 'overflow') != 'visible'){<br />
position.x += leftBorder(parent);<br />
position.y += topBorder(parent);<br />
}<br />
} else if (element != this && Browser.Engine.webkit){<br />
position.x += leftBorder(element);<br />
position.y += topBorder(element);<br />
}<br />
<br />
element = element.offsetParent;<br />
}<br />
if (Browser.Engine.gecko && !borderBox(this)){<br />
position.x -= leftBorder(this);<br />
position.y -= topBorder(this);<br />
}<br />
return position;<br />
},<br />
<br />
getPosition: function(relative){<br />
if (isBody(this)) return {x: 0, y: 0};<br />
var offset = this.getOffsets(),<br />
scroll = this.getScrolls();<br />
var position = {<br />
x: offset.x - scroll.x,<br />
y: offset.y - scroll.y<br />
};<br />
var relativePosition = (relative && (relative = document.id(relative))) ? relative.getPosition() : {x: 0, y: 0};<br />
return {x: position.x - relativePosition.x, y: position.y - relativePosition.y};<br />
},<br />
<br />
getCoordinates: function(element){<br />
if (isBody(this)) return this.getWindow().getCoordinates();<br />
var position = this.getPosition(element),<br />
size = this.getSize();<br />
var obj = {<br />
left: position.x,<br />
top: position.y,<br />
width: size.x,<br />
height: size.y<br />
};<br />
obj.right = obj.left + obj.width;<br />
obj.bottom = obj.top + obj.height;<br />
return obj;<br />
},<br />
<br />
computePosition: function(obj){<br />
return {<br />
left: obj.x - styleNumber(this, 'margin-left'),<br />
top: obj.y - styleNumber(this, 'margin-top')<br />
};<br />
},<br />
<br />
setPosition: function(obj){<br />
return this.setStyles(this.computePosition(obj));<br />
}<br />
<br />
});<br />
<br />
<br />
Native.implement([Document, Window], {<br />
<br />
getSize: function(){<br />
if (Browser.Engine.presto || Browser.Engine.webkit){<br />
var win = this.getWindow();<br />
return {x: win.innerWidth, y: win.innerHeight};<br />
}<br />
var doc = getCompatElement(this);<br />
return {x: doc.clientWidth, y: doc.clientHeight};<br />
},<br />
<br />
getScroll: function(){<br />
var win = this.getWindow(), doc = getCompatElement(this);<br />
return {x: win.pageXOffset || doc.scrollLeft, y: win.pageYOffset || doc.scrollTop};<br />
},<br />
<br />
getScrollSize: function(){<br />
var doc = getCompatElement(this), min = this.getSize();<br />
return {x: Math.max(doc.scrollWidth, min.x), y: Math.max(doc.scrollHeight, min.y)};<br />
},<br />
<br />
getPosition: function(){<br />
return {x: 0, y: 0};<br />
},<br />
<br />
getCoordinates: function(){<br />
var size = this.getSize();<br />
return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x};<br />
}<br />
<br />
});<br />
<br />
// private methods<br />
<br />
var styleString = Element.getComputedStyle;<br />
<br />
function styleNumber(element, style){<br />
return styleString(element, style).toInt() || 0;<br />
};<br />
<br />
function borderBox(element){<br />
return styleString(element, '-moz-box-sizing') == 'border-box';<br />
};<br />
<br />
function topBorder(element){<br />
return styleNumber(element, 'border-top-width');<br />
};<br />
<br />
function leftBorder(element){<br />
return styleNumber(element, 'border-left-width');<br />
};<br />
<br />
function isBody(element){<br />
return (/^(?:body|html)$/i).test(element.tagName);<br />
};<br />
<br />
function getCompatElement(element){<br />
var doc = element.getDocument();<br />
return (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;<br />
};<br />
<br />
})();<br />
<br />
//aliases<br />
Element.alias('setPosition', 'position'); //compatability<br />
<br />
Native.implement([Window, Document, Element], {<br />
<br />
getHeight: function(){<br />
return this.getSize().y;<br />
},<br />
<br />
getWidth: function(){<br />
return this.getSize().x;<br />
},<br />
<br />
getScrollTop: function(){<br />
return this.getScroll().y;<br />
},<br />
<br />
getScrollLeft: function(){<br />
return this.getScroll().x;<br />
},<br />
<br />
getScrollHeight: function(){<br />
return this.getScrollSize().y;<br />
},<br />
<br />
getScrollWidth: function(){<br />
return this.getScrollSize().x;<br />
},<br />
<br />
getTop: function(){<br />
return this.getPosition().y;<br />
},<br />
<br />
getLeft: function(){<br />
return this.getPosition().x;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Selectors.js<br />
<br />
description: Adds advanced CSS-style querying capabilities for targeting HTML Elements. Includes pseudo selectors.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Element<br />
<br />
provides: [Selectors]<br />
<br />
...<br />
*/<br />
<br />
Native.implement([Document, Element], {<br />
<br />
getElements: function(expression, nocash){<br />
expression = expression.split(',');<br />
var items, local = {};<br />
for (var i = 0, l = expression.length; i < l; i++){<br />
var selector = expression[i], elements = Selectors.Utils.search(this, selector, local);<br />
if (i != 0 && elements.item) elements = $A(elements);<br />
items = (i == 0) ? elements : (items.item) ? $A(items).concat(elements) : items.concat(elements);<br />
}<br />
return new Elements(items, {ddup: (expression.length > 1), cash: !nocash});<br />
}<br />
<br />
});<br />
<br />
Element.implement({<br />
<br />
match: function(selector){<br />
if (!selector || (selector == this)) return true;<br />
var tagid = Selectors.Utils.parseTagAndID(selector);<br />
var tag = tagid[0], id = tagid[1];<br />
if (!Selectors.Filters.byID(this, id) || !Selectors.Filters.byTag(this, tag)) return false;<br />
var parsed = Selectors.Utils.parseSelector(selector);<br />
return (parsed) ? Selectors.Utils.filter(this, parsed, {}) : true;<br />
}<br />
<br />
});<br />
<br />
var Selectors = {Cache: {nth: {}, parsed: {}}};<br />
<br />
Selectors.RegExps = {<br />
id: (/#([\w-]+)/),<br />
tag: (/^(\w+|\*)/),<br />
quick: (/^(\w+|\*)$/),<br />
splitter: (/\s*([+>~\s])\s*([a-zA-Z#.*:\[])/g),<br />
combined: (/\.([\w-]+)|\[(\w+)(?:([!*^$~|]?=)(["']?)([^\4]*?)\4)?\]|:([\w-]+)(?:\(["']?(.*?)?["']?\)|$)/g)<br />
};<br />
<br />
Selectors.Utils = {<br />
<br />
chk: function(item, uniques){<br />
if (!uniques) return true;<br />
var uid = $uid(item);<br />
if (!uniques[uid]) return uniques[uid] = true;<br />
return false;<br />
},<br />
<br />
parseNthArgument: function(argument){<br />
if (Selectors.Cache.nth[argument]) return Selectors.Cache.nth[argument];<br />
var parsed = argument.match(/^([+-]?\d*)?([a-z]+)?([+-]?\d*)?$/);<br />
if (!parsed) return false;<br />
var inta = parseInt(parsed[1], 10);<br />
var a = (inta || inta === 0) ? inta : 1;<br />
var special = parsed[2] || false;<br />
var b = parseInt(parsed[3], 10) || 0;<br />
if (a != 0){<br />
b--;<br />
while (b < 1) b += a;<br />
while (b >= a) b -= a;<br />
} else {<br />
a = b;<br />
special = 'index';<br />
}<br />
switch (special){<br />
case 'n': parsed = {a: a, b: b, special: 'n'}; break;<br />
case 'odd': parsed = {a: 2, b: 0, special: 'n'}; break;<br />
case 'even': parsed = {a: 2, b: 1, special: 'n'}; break;<br />
case 'first': parsed = {a: 0, special: 'index'}; break;<br />
case 'last': parsed = {special: 'last-child'}; break;<br />
case 'only': parsed = {special: 'only-child'}; break;<br />
default: parsed = {a: (a - 1), special: 'index'};<br />
}<br />
<br />
return Selectors.Cache.nth[argument] = parsed;<br />
},<br />
<br />
parseSelector: function(selector){<br />
if (Selectors.Cache.parsed[selector]) return Selectors.Cache.parsed[selector];<br />
var m, parsed = {classes: [], pseudos: [], attributes: []};<br />
while ((m = Selectors.RegExps.combined.exec(selector))){<br />
var cn = m[1], an = m[2], ao = m[3], av = m[5], pn = m[6], pa = m[7];<br />
if (cn){<br />
parsed.classes.push(cn);<br />
} else if (pn){<br />
var parser = Selectors.Pseudo.get(pn);<br />
if (parser) parsed.pseudos.push({parser: parser, argument: pa});<br />
else parsed.attributes.push({name: pn, operator: '=', value: pa});<br />
} else if (an){<br />
parsed.attributes.push({name: an, operator: ao, value: av});<br />
}<br />
}<br />
if (!parsed.classes.length) delete parsed.classes;<br />
if (!parsed.attributes.length) delete parsed.attributes;<br />
if (!parsed.pseudos.length) delete parsed.pseudos;<br />
if (!parsed.classes && !parsed.attributes && !parsed.pseudos) parsed = null;<br />
return Selectors.Cache.parsed[selector] = parsed;<br />
},<br />
<br />
parseTagAndID: function(selector){<br />
var tag = selector.match(Selectors.RegExps.tag);<br />
var id = selector.match(Selectors.RegExps.id);<br />
return [(tag) ? tag[1] : '*', (id) ? id[1] : false];<br />
},<br />
<br />
filter: function(item, parsed, local){<br />
var i;<br />
if (parsed.classes){<br />
for (i = parsed.classes.length; i--; i){<br />
var cn = parsed.classes[i];<br />
if (!Selectors.Filters.byClass(item, cn)) return false;<br />
}<br />
}<br />
if (parsed.attributes){<br />
for (i = parsed.attributes.length; i--; i){<br />
var att = parsed.attributes[i];<br />
if (!Selectors.Filters.byAttribute(item, att.name, att.operator, att.value)) return false;<br />
}<br />
}<br />
if (parsed.pseudos){<br />
for (i = parsed.pseudos.length; i--; i){<br />
var psd = parsed.pseudos[i];<br />
if (!Selectors.Filters.byPseudo(item, psd.parser, psd.argument, local)) return false;<br />
}<br />
}<br />
return true;<br />
},<br />
<br />
getByTagAndID: function(ctx, tag, id){<br />
if (id){<br />
var item = (ctx.getElementById) ? ctx.getElementById(id, true) : Element.getElementById(ctx, id, true);<br />
return (item && Selectors.Filters.byTag(item, tag)) ? [item] : [];<br />
} else {<br />
return ctx.getElementsByTagName(tag);<br />
}<br />
},<br />
<br />
search: function(self, expression, local){<br />
var splitters = [];<br />
<br />
var selectors = expression.trim().replace(Selectors.RegExps.splitter, function(m0, m1, m2){<br />
splitters.push(m1);<br />
return ':)' + m2;<br />
}).split(':)');<br />
<br />
var items, filtered, item;<br />
<br />
for (var i = 0, l = selectors.length; i < l; i++){<br />
<br />
var selector = selectors[i];<br />
<br />
if (i == 0 && Selectors.RegExps.quick.test(selector)){<br />
items = self.getElementsByTagName(selector);<br />
continue;<br />
}<br />
<br />
var splitter = splitters[i - 1];<br />
<br />
var tagid = Selectors.Utils.parseTagAndID(selector);<br />
var tag = tagid[0], id = tagid[1];<br />
<br />
if (i == 0){<br />
items = Selectors.Utils.getByTagAndID(self, tag, id);<br />
} else {<br />
var uniques = {}, found = [];<br />
for (var j = 0, k = items.length; j < k; j++) found = Selectors.Getters[splitter](found, items[j], tag, id, uniques);<br />
items = found;<br />
}<br />
<br />
var parsed = Selectors.Utils.parseSelector(selector);<br />
<br />
if (parsed){<br />
filtered = [];<br />
for (var m = 0, n = items.length; m < n; m++){<br />
item = items[m];<br />
if (Selectors.Utils.filter(item, parsed, local)) filtered.push(item);<br />
}<br />
items = filtered;<br />
}<br />
<br />
}<br />
<br />
return items;<br />
<br />
}<br />
<br />
};<br />
<br />
Selectors.Getters = {<br />
<br />
' ': function(found, self, tag, id, uniques){<br />
var items = Selectors.Utils.getByTagAndID(self, tag, id);<br />
for (var i = 0, l = items.length; i < l; i++){<br />
var item = items[i];<br />
if (Selectors.Utils.chk(item, uniques)) found.push(item);<br />
}<br />
return found;<br />
},<br />
<br />
'>': function(found, self, tag, id, uniques){<br />
var children = Selectors.Utils.getByTagAndID(self, tag, id);<br />
for (var i = 0, l = children.length; i < l; i++){<br />
var child = children[i];<br />
if (child.parentNode == self && Selectors.Utils.chk(child, uniques)) found.push(child);<br />
}<br />
return found;<br />
},<br />
<br />
'+': function(found, self, tag, id, uniques){<br />
while ((self = self.nextSibling)){<br />
if (self.nodeType == 1){<br />
if (Selectors.Utils.chk(self, uniques) && Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);<br />
break;<br />
}<br />
}<br />
return found;<br />
},<br />
<br />
'~': function(found, self, tag, id, uniques){<br />
while ((self = self.nextSibling)){<br />
if (self.nodeType == 1){<br />
if (!Selectors.Utils.chk(self, uniques)) break;<br />
if (Selectors.Filters.byTag(self, tag) && Selectors.Filters.byID(self, id)) found.push(self);<br />
}<br />
}<br />
return found;<br />
}<br />
<br />
};<br />
<br />
Selectors.Filters = {<br />
<br />
byTag: function(self, tag){<br />
return (tag == '*' || (self.tagName && self.tagName.toLowerCase() == tag));<br />
},<br />
<br />
byID: function(self, id){<br />
return (!id || (self.id && self.id == id));<br />
},<br />
<br />
byClass: function(self, klass){<br />
return (self.className && self.className.contains && self.className.contains(klass, ' '));<br />
},<br />
<br />
byPseudo: function(self, parser, argument, local){<br />
return parser.call(self, argument, local);<br />
},<br />
<br />
byAttribute: function(self, name, operator, value){<br />
var result = Element.prototype.getProperty.call(self, name);<br />
if (!result) return (operator == '!=');<br />
if (!operator || value == undefined) return true;<br />
switch (operator){<br />
case '=': return (result == value);<br />
case '*=': return (result.contains(value));<br />
case '^=': return (result.substr(0, value.length) == value);<br />
case '$=': return (result.substr(result.length - value.length) == value);<br />
case '!=': return (result != value);<br />
case '~=': return result.contains(value, ' ');<br />
case '|=': return result.contains(value, '-');<br />
}<br />
return false;<br />
}<br />
<br />
};<br />
<br />
Selectors.Pseudo = new Hash({<br />
<br />
// w3c pseudo selectors<br />
<br />
checked: function(){<br />
return this.checked;<br />
},<br />
<br />
empty: function(){<br />
return !(this.innerText || this.textContent || '').length;<br />
},<br />
<br />
not: function(selector){<br />
return !Element.match(this, selector);<br />
},<br />
<br />
contains: function(text){<br />
return (this.innerText || this.textContent || '').contains(text);<br />
},<br />
<br />
'first-child': function(){<br />
return Selectors.Pseudo.index.call(this, 0);<br />
},<br />
<br />
'last-child': function(){<br />
var element = this;<br />
while ((element = element.nextSibling)){<br />
if (element.nodeType == 1) return false;<br />
}<br />
return true;<br />
},<br />
<br />
'only-child': function(){<br />
var prev = this;<br />
while ((prev = prev.previousSibling)){<br />
if (prev.nodeType == 1) return false;<br />
}<br />
var next = this;<br />
while ((next = next.nextSibling)){<br />
if (next.nodeType == 1) return false;<br />
}<br />
return true;<br />
},<br />
<br />
'nth-child': function(argument, local){<br />
argument = (argument == undefined) ? 'n' : argument;<br />
var parsed = Selectors.Utils.parseNthArgument(argument);<br />
if (parsed.special != 'n') return Selectors.Pseudo[parsed.special].call(this, parsed.a, local);<br />
var count = 0;<br />
local.positions = local.positions || {};<br />
var uid = $uid(this);<br />
if (!local.positions[uid]){<br />
var self = this;<br />
while ((self = self.previousSibling)){<br />
if (self.nodeType != 1) continue;<br />
count ++;<br />
var position = local.positions[$uid(self)];<br />
if (position != undefined){<br />
count = position + count;<br />
break;<br />
}<br />
}<br />
local.positions[uid] = count;<br />
}<br />
return (local.positions[uid] % parsed.a == parsed.b);<br />
},<br />
<br />
// custom pseudo selectors<br />
<br />
index: function(index){<br />
var element = this, count = 0;<br />
while ((element = element.previousSibling)){<br />
if (element.nodeType == 1 && ++count > index) return false;<br />
}<br />
return (count == index);<br />
},<br />
<br />
even: function(argument, local){<br />
return Selectors.Pseudo['nth-child'].call(this, '2n+1', local);<br />
},<br />
<br />
odd: function(argument, local){<br />
return Selectors.Pseudo['nth-child'].call(this, '2n', local);<br />
},<br />
<br />
selected: function(){<br />
return this.selected;<br />
},<br />
<br />
enabled: function(){<br />
return (this.disabled === false);<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: DomReady.js<br />
<br />
description: Contains the custom event domready.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Element.Event<br />
<br />
provides: [DomReady]<br />
<br />
...<br />
*/<br />
<br />
Element.Events.domready = {<br />
<br />
onAdd: function(fn){<br />
if (Browser.loaded) fn.call(this);<br />
}<br />
<br />
};<br />
<br />
(function(){<br />
<br />
var domready = function(){<br />
if (Browser.loaded) return;<br />
Browser.loaded = true;<br />
window.fireEvent('domready');<br />
document.fireEvent('domready');<br />
};<br />
<br />
window.addEvent('load', domready);<br />
<br />
if (Browser.Engine.trident){<br />
var temp = document.createElement('div');<br />
(function(){<br />
($try(function(){<br />
temp.doScroll(); // Technique by Diego Perini<br />
return document.id(temp).inject(document.body).set('html', 'temp').dispose();<br />
})) ? domready() : arguments.callee.delay(50);<br />
})();<br />
} else if (Browser.Engine.webkit && Browser.Engine.version < 525){<br />
(function(){<br />
(['loaded', 'complete'].contains(document.readyState)) ? domready() : arguments.callee.delay(50);<br />
})();<br />
} else {<br />
document.addEvent('DOMContentLoaded', domready);<br />
}<br />
<br />
})();<br />
<br />
<br />
/*<br />
---<br />
<br />
script: JSON.js<br />
<br />
description: JSON encoder and decoder.<br />
<br />
license: MIT-style license.<br />
<br />
See Also: <http://www.json.org/><br />
<br />
requires:<br />
- /Array<br />
- /String<br />
- /Number<br />
- /Function<br />
- /Hash<br />
<br />
provides: [JSON]<br />
<br />
...<br />
*/<br />
<br />
var JSON = new Hash(this.JSON && {<br />
stringify: JSON.stringify,<br />
parse: JSON.parse<br />
}).extend({<br />
<br />
$specialChars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'},<br />
<br />
$replaceChars: function(chr){<br />
return JSON.$specialChars[chr] || '\\u00' + Math.floor(chr.charCodeAt() / 16).toString(16) + (chr.charCodeAt() % 16).toString(16);<br />
},<br />
<br />
encode: function(obj){<br />
switch ($type(obj)){<br />
case 'string':<br />
return '"' + obj.replace(/[\x00-\x1f\\"]/g, JSON.$replaceChars) + '"';<br />
case 'array':<br />
return '[' + String(obj.map(JSON.encode).clean()) + ']';<br />
case 'object': case 'hash':<br />
var string = [];<br />
Hash.each(obj, function(value, key){<br />
var json = JSON.encode(value);<br />
if (json) string.push(JSON.encode(key) + ':' + json);<br />
});<br />
return '{' + string + '}';<br />
case 'number': case 'boolean': return String(obj);<br />
case false: return 'null';<br />
}<br />
return null;<br />
},<br />
<br />
decode: function(string, secure){<br />
if ($type(string) != 'string' || !string.length) return null;<br />
if (secure && !(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null;<br />
return eval('(' + string + ')');<br />
}<br />
<br />
});<br />
<br />
Native.implement([Hash, Array, String, Number], {<br />
<br />
toJSON: function(){<br />
return JSON.encode(this);<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Cookie.js<br />
<br />
description: Class for creating, reading, and deleting browser Cookies.<br />
<br />
license: MIT-style license.<br />
<br />
credits:<br />
- Based on the functions by Peter-Paul Koch (http://quirksmode.org).<br />
<br />
requires:<br />
- /Options<br />
<br />
provides: [Cookie]<br />
<br />
...<br />
*/<br />
<br />
var Cookie = new Class({<br />
<br />
Implements: Options,<br />
<br />
options: {<br />
path: false,<br />
domain: false,<br />
duration: false,<br />
secure: false,<br />
document: document<br />
},<br />
<br />
initialize: function(key, options){<br />
this.key = key;<br />
this.setOptions(options);<br />
},<br />
<br />
write: function(value){<br />
value = encodeURIComponent(value);<br />
if (this.options.domain) value += '; domain=' + this.options.domain;<br />
if (this.options.path) value += '; path=' + this.options.path;<br />
if (this.options.duration){<br />
var date = new Date();<br />
date.setTime(date.getTime() + this.options.duration * 24 * 60 * 60 * 1000);<br />
value += '; expires=' + date.toGMTString();<br />
}<br />
if (this.options.secure) value += '; secure';<br />
this.options.document.cookie = this.key + '=' + value;<br />
return this;<br />
},<br />
<br />
read: function(){<br />
var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escapeRegExp() + '=([^;]*)');<br />
return (value) ? decodeURIComponent(value[1]) : null;<br />
},<br />
<br />
dispose: function(){<br />
new Cookie(this.key, $merge(this.options, {duration: -1})).write('');<br />
return this;<br />
}<br />
<br />
});<br />
<br />
Cookie.write = function(key, value, options){<br />
return new Cookie(key, options).write(value);<br />
};<br />
<br />
Cookie.read = function(key){<br />
return new Cookie(key).read();<br />
};<br />
<br />
Cookie.dispose = function(key, options){<br />
return new Cookie(key, options).dispose();<br />
};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Swiff.js<br />
<br />
description: Wrapper for embedding SWF movies. Supports External Interface Communication.<br />
<br />
license: MIT-style license.<br />
<br />
credits: <br />
- Flash detection & Internet Explorer + Flash Player 9 fix inspired by SWFObject.<br />
<br />
requires:<br />
- /Options<br />
- /$util<br />
<br />
provides: [Swiff]<br />
<br />
...<br />
*/<br />
<br />
var Swiff = new Class({<br />
<br />
Implements: [Options],<br />
<br />
options: {<br />
id: null,<br />
height: 1,<br />
width: 1,<br />
container: null,<br />
properties: {},<br />
params: {<br />
quality: 'high',<br />
allowScriptAccess: 'always',<br />
wMode: 'transparent',<br />
swLiveConnect: true<br />
},<br />
callBacks: {},<br />
vars: {}<br />
},<br />
<br />
toElement: function(){<br />
return this.object;<br />
},<br />
<br />
initialize: function(path, options){<br />
this.instance = 'Swiff_' + $time();<br />
<br />
this.setOptions(options);<br />
options = this.options;<br />
var id = this.id = options.id || this.instance;<br />
var container = document.id(options.container);<br />
<br />
Swiff.CallBacks[this.instance] = {};<br />
<br />
var params = options.params, vars = options.vars, callBacks = options.callBacks;<br />
var properties = $extend({height: options.height, width: options.width}, options.properties);<br />
<br />
var self = this;<br />
<br />
for (var callBack in callBacks){<br />
Swiff.CallBacks[this.instance][callBack] = (function(option){<br />
return function(){<br />
return option.apply(self.object, arguments);<br />
};<br />
})(callBacks[callBack]);<br />
vars[callBack] = 'Swiff.CallBacks.' + this.instance + '.' + callBack;<br />
}<br />
<br />
params.flashVars = Hash.toQueryString(vars);<br />
if (Browser.Engine.trident){<br />
properties.classid = 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000';<br />
params.movie = path;<br />
} else {<br />
properties.type = 'application/x-shockwave-flash';<br />
properties.data = path;<br />
}<br />
var build = '<object id="' + id + '"';<br />
for (var property in properties) build += ' ' + property + '="' + properties[property] + '"';<br />
build += '>';<br />
for (var param in params){<br />
if (params[param]) build += '<param name="' + param + '" value="' + params[param] + '" />';<br />
}<br />
build += '</object>';<br />
this.object = ((container) ? container.empty() : new Element('div')).set('html', build).firstChild;<br />
},<br />
<br />
replaces: function(element){<br />
element = document.id(element, true);<br />
element.parentNode.replaceChild(this.toElement(), element);<br />
return this;<br />
},<br />
<br />
inject: function(element){<br />
document.id(element, true).appendChild(this.toElement());<br />
return this;<br />
},<br />
<br />
remote: function(){<br />
return Swiff.remote.apply(Swiff, [this.toElement()].extend(arguments));<br />
}<br />
<br />
});<br />
<br />
Swiff.CallBacks = {};<br />
<br />
Swiff.remote = function(obj, fn){<br />
var rs = obj.CallFunction('<invoke name="' + fn + '" returntype="javascript">' + __flash__argumentsToXML(arguments, 2) + '</invoke>');<br />
return eval(rs);<br />
};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Fx.js<br />
<br />
description: Contains the basic animation logic to be extended by all other Fx Classes.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Chain<br />
- /Events<br />
- /Options<br />
<br />
provides: [Fx]<br />
<br />
...<br />
*/<br />
<br />
var Fx = new Class({<br />
<br />
Implements: [Chain, Events, Options],<br />
<br />
options: {<br />
/*<br />
onStart: $empty,<br />
onCancel: $empty,<br />
onComplete: $empty,<br />
*/<br />
fps: 50,<br />
unit: false,<br />
duration: 500,<br />
link: 'ignore'<br />
},<br />
<br />
initialize: function(options){<br />
this.subject = this.subject || this;<br />
this.setOptions(options);<br />
this.options.duration = Fx.Durations[this.options.duration] || this.options.duration.toInt();<br />
var wait = this.options.wait;<br />
if (wait === false) this.options.link = 'cancel';<br />
},<br />
<br />
getTransition: function(){<br />
return function(p){<br />
return -(Math.cos(Math.PI * p) - 1) / 2;<br />
};<br />
},<br />
<br />
step: function(){<br />
var time = $time();<br />
if (time < this.time + this.options.duration){<br />
var delta = this.transition((time - this.time) / this.options.duration);<br />
this.set(this.compute(this.from, this.to, delta));<br />
} else {<br />
this.set(this.compute(this.from, this.to, 1));<br />
this.complete();<br />
}<br />
},<br />
<br />
set: function(now){<br />
return now;<br />
},<br />
<br />
compute: function(from, to, delta){<br />
return Fx.compute(from, to, delta);<br />
},<br />
<br />
check: function(){<br />
if (!this.timer) return true;<br />
switch (this.options.link){<br />
case 'cancel': this.cancel(); return true;<br />
case 'chain': this.chain(this.caller.bind(this, arguments)); return false;<br />
}<br />
return false;<br />
},<br />
<br />
start: function(from, to){<br />
if (!this.check(from, to)) return this;<br />
this.from = from;<br />
this.to = to;<br />
this.time = 0;<br />
this.transition = this.getTransition();<br />
this.startTimer();<br />
this.onStart();<br />
return this;<br />
},<br />
<br />
complete: function(){<br />
if (this.stopTimer()) this.onComplete();<br />
return this;<br />
},<br />
<br />
cancel: function(){<br />
if (this.stopTimer()) this.onCancel();<br />
return this;<br />
},<br />
<br />
onStart: function(){<br />
this.fireEvent('start', this.subject);<br />
},<br />
<br />
onComplete: function(){<br />
this.fireEvent('complete', this.subject);<br />
if (!this.callChain()) this.fireEvent('chainComplete', this.subject);<br />
},<br />
<br />
onCancel: function(){<br />
this.fireEvent('cancel', this.subject).clearChain();<br />
},<br />
<br />
pause: function(){<br />
this.stopTimer();<br />
return this;<br />
},<br />
<br />
resume: function(){<br />
this.startTimer();<br />
return this;<br />
},<br />
<br />
stopTimer: function(){<br />
if (!this.timer) return false;<br />
this.time = $time() - this.time;<br />
this.timer = $clear(this.timer);<br />
return true;<br />
},<br />
<br />
startTimer: function(){<br />
if (this.timer) return false;<br />
this.time = $time() - this.time;<br />
this.timer = this.step.periodical(Math.round(1000 / this.options.fps), this);<br />
return true;<br />
}<br />
<br />
});<br />
<br />
Fx.compute = function(from, to, delta){<br />
return (to - from) * delta + from;<br />
};<br />
<br />
Fx.Durations = {'short': 250, 'normal': 500, 'long': 1000};<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Fx.CSS.js<br />
<br />
description: Contains the CSS animation logic. Used by Fx.Tween, Fx.Morph, Fx.Elements.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Fx<br />
- /Element.Style<br />
<br />
provides: [Fx.CSS]<br />
<br />
...<br />
*/<br />
<br />
Fx.CSS = new Class({<br />
<br />
Extends: Fx,<br />
<br />
//prepares the base from/to object<br />
<br />
prepare: function(element, property, values){<br />
values = $splat(values);<br />
var values1 = values[1];<br />
if (!$chk(values1)){<br />
values[1] = values[0];<br />
values[0] = element.getStyle(property);<br />
}<br />
var parsed = values.map(this.parse);<br />
return {from: parsed[0], to: parsed[1]};<br />
},<br />
<br />
//parses a value into an array<br />
<br />
parse: function(value){<br />
value = $lambda(value)();<br />
value = (typeof value == 'string') ? value.split(' ') : $splat(value);<br />
return value.map(function(val){<br />
val = String(val);<br />
var found = false;<br />
Fx.CSS.Parsers.each(function(parser, key){<br />
if (found) return;<br />
var parsed = parser.parse(val);<br />
if ($chk(parsed)) found = {value: parsed, parser: parser};<br />
});<br />
found = found || {value: val, parser: Fx.CSS.Parsers.String};<br />
return found;<br />
});<br />
},<br />
<br />
//computes by a from and to prepared objects, using their parsers.<br />
<br />
compute: function(from, to, delta){<br />
var computed = [];<br />
(Math.min(from.length, to.length)).times(function(i){<br />
computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser});<br />
});<br />
computed.$family = {name: 'fx:css:value'};<br />
return computed;<br />
},<br />
<br />
//serves the value as settable<br />
<br />
serve: function(value, unit){<br />
if ($type(value) != 'fx:css:value') value = this.parse(value);<br />
var returned = [];<br />
value.each(function(bit){<br />
returned = returned.concat(bit.parser.serve(bit.value, unit));<br />
});<br />
return returned;<br />
},<br />
<br />
//renders the change to an element<br />
<br />
render: function(element, property, value, unit){<br />
element.setStyle(property, this.serve(value, unit));<br />
},<br />
<br />
//searches inside the page css to find the values for a selector<br />
<br />
search: function(selector){<br />
if (Fx.CSS.Cache[selector]) return Fx.CSS.Cache[selector];<br />
var to = {};<br />
Array.each(document.styleSheets, function(sheet, j){<br />
var href = sheet.href;<br />
if (href && href.contains('://') && !href.contains(document.domain)) return;<br />
var rules = sheet.rules || sheet.cssRules;<br />
Array.each(rules, function(rule, i){<br />
if (!rule.style) return;<br />
var selectorText = (rule.selectorText) ? rule.selectorText.replace(/^\w+/, function(m){<br />
return m.toLowerCase();<br />
}) : null;<br />
if (!selectorText || !selectorText.test('^' + selector + '$')) return;<br />
Element.Styles.each(function(value, style){<br />
if (!rule.style[style] || Element.ShortStyles[style]) return;<br />
value = String(rule.style[style]);<br />
to[style] = (value.test(/^rgb/)) ? value.rgbToHex() : value;<br />
});<br />
});<br />
});<br />
return Fx.CSS.Cache[selector] = to;<br />
}<br />
<br />
});<br />
<br />
Fx.CSS.Cache = {};<br />
<br />
Fx.CSS.Parsers = new Hash({<br />
<br />
Color: {<br />
parse: function(value){<br />
if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hexToRgb(true);<br />
return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false;<br />
},<br />
compute: function(from, to, delta){<br />
return from.map(function(value, i){<br />
return Math.round(Fx.compute(from[i], to[i], delta));<br />
});<br />
},<br />
serve: function(value){<br />
return value.map(Number);<br />
}<br />
},<br />
<br />
Number: {<br />
parse: parseFloat,<br />
compute: Fx.compute,<br />
serve: function(value, unit){<br />
return (unit) ? value + unit : value;<br />
}<br />
},<br />
<br />
String: {<br />
parse: $lambda(false),<br />
compute: $arguments(1),<br />
serve: $arguments(0)<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Fx.Tween.js<br />
<br />
description: Formerly Fx.Style, effect to transition any CSS property for an element.<br />
<br />
license: MIT-style license.<br />
<br />
requires: <br />
- /Fx.CSS<br />
<br />
provides: [Fx.Tween, Element.fade, Element.highlight]<br />
<br />
...<br />
*/<br />
<br />
Fx.Tween = new Class({<br />
<br />
Extends: Fx.CSS,<br />
<br />
initialize: function(element, options){<br />
this.element = this.subject = document.id(element);<br />
this.parent(options);<br />
},<br />
<br />
set: function(property, now){<br />
if (arguments.length == 1){<br />
now = property;<br />
property = this.property || this.options.property;<br />
}<br />
this.render(this.element, property, now, this.options.unit);<br />
return this;<br />
},<br />
<br />
start: function(property, from, to){<br />
if (!this.check(property, from, to)) return this;<br />
var args = Array.flatten(arguments);<br />
this.property = this.options.property || args.shift();<br />
var parsed = this.prepare(this.element, this.property, args);<br />
return this.parent(parsed.from, parsed.to);<br />
}<br />
<br />
});<br />
<br />
Element.Properties.tween = {<br />
<br />
set: function(options){<br />
var tween = this.retrieve('tween');<br />
if (tween) tween.cancel();<br />
return this.eliminate('tween').store('tween:options', $extend({link: 'cancel'}, options));<br />
},<br />
<br />
get: function(options){<br />
if (options || !this.retrieve('tween')){<br />
if (options || !this.retrieve('tween:options')) this.set('tween', options);<br />
this.store('tween', new Fx.Tween(this, this.retrieve('tween:options')));<br />
}<br />
return this.retrieve('tween');<br />
}<br />
<br />
};<br />
<br />
Element.implement({<br />
<br />
tween: function(property, from, to){<br />
this.get('tween').start(arguments);<br />
return this;<br />
},<br />
<br />
fade: function(how){<br />
var fade = this.get('tween'), o = 'opacity', toggle;<br />
how = $pick(how, 'toggle');<br />
switch (how){<br />
case 'in': fade.start(o, 1); break;<br />
case 'out': fade.start(o, 0); break;<br />
case 'show': fade.set(o, 1); break;<br />
case 'hide': fade.set(o, 0); break;<br />
case 'toggle':<br />
var flag = this.retrieve('fade:flag', this.get('opacity') == 1);<br />
fade.start(o, (flag) ? 0 : 1);<br />
this.store('fade:flag', !flag);<br />
toggle = true;<br />
break;<br />
default: fade.start(o, arguments);<br />
}<br />
if (!toggle) this.eliminate('fade:flag');<br />
return this;<br />
},<br />
<br />
highlight: function(start, end){<br />
if (!end){<br />
end = this.retrieve('highlight:original', this.getStyle('background-color'));<br />
end = (end == 'transparent') ? '#fff' : end;<br />
}<br />
var tween = this.get('tween');<br />
tween.start('background-color', start || '#ffff88', end).chain(function(){<br />
this.setStyle('background-color', this.retrieve('highlight:original'));<br />
tween.callChain();<br />
}.bind(this));<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Fx.Morph.js<br />
<br />
description: Formerly Fx.Styles, effect to transition any number of CSS properties for an element using an object of rules, or CSS based selector rules.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Fx.CSS<br />
<br />
provides: [Fx.Morph]<br />
<br />
...<br />
*/<br />
<br />
Fx.Morph = new Class({<br />
<br />
Extends: Fx.CSS,<br />
<br />
initialize: function(element, options){<br />
this.element = this.subject = document.id(element);<br />
this.parent(options);<br />
},<br />
<br />
set: function(now){<br />
if (typeof now == 'string') now = this.search(now);<br />
for (var p in now) this.render(this.element, p, now[p], this.options.unit);<br />
return this;<br />
},<br />
<br />
compute: function(from, to, delta){<br />
var now = {};<br />
for (var p in from) now[p] = this.parent(from[p], to[p], delta);<br />
return now;<br />
},<br />
<br />
start: function(properties){<br />
if (!this.check(properties)) return this;<br />
if (typeof properties == 'string') properties = this.search(properties);<br />
var from = {}, to = {};<br />
for (var p in properties){<br />
var parsed = this.prepare(this.element, p, properties[p]);<br />
from[p] = parsed.from;<br />
to[p] = parsed.to;<br />
}<br />
return this.parent(from, to);<br />
}<br />
<br />
});<br />
<br />
Element.Properties.morph = {<br />
<br />
set: function(options){<br />
var morph = this.retrieve('morph');<br />
if (morph) morph.cancel();<br />
return this.eliminate('morph').store('morph:options', $extend({link: 'cancel'}, options));<br />
},<br />
<br />
get: function(options){<br />
if (options || !this.retrieve('morph')){<br />
if (options || !this.retrieve('morph:options')) this.set('morph', options);<br />
this.store('morph', new Fx.Morph(this, this.retrieve('morph:options')));<br />
}<br />
return this.retrieve('morph');<br />
}<br />
<br />
};<br />
<br />
Element.implement({<br />
<br />
morph: function(props){<br />
this.get('morph').start(props);<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Fx.Transitions.js<br />
<br />
description: Contains a set of advanced transitions to be used with any of the Fx Classes.<br />
<br />
license: MIT-style license.<br />
<br />
credits:<br />
- Easing Equations by Robert Penner, <http://www.robertpenner.com/easing/>, modified and optimized to be used with MooTools.<br />
<br />
requires:<br />
- /Fx<br />
<br />
provides: [Fx.Transitions]<br />
<br />
...<br />
*/<br />
<br />
Fx.implement({<br />
<br />
getTransition: function(){<br />
var trans = this.options.transition || Fx.Transitions.Sine.easeInOut;<br />
if (typeof trans == 'string'){<br />
var data = trans.split(':');<br />
trans = Fx.Transitions;<br />
trans = trans[data[0]] || trans[data[0].capitalize()];<br />
if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')];<br />
}<br />
return trans;<br />
}<br />
<br />
});<br />
<br />
Fx.Transition = function(transition, params){<br />
params = $splat(params);<br />
return $extend(transition, {<br />
easeIn: function(pos){<br />
return transition(pos, params);<br />
},<br />
easeOut: function(pos){<br />
return 1 - transition(1 - pos, params);<br />
},<br />
easeInOut: function(pos){<br />
return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2;<br />
}<br />
});<br />
};<br />
<br />
Fx.Transitions = new Hash({<br />
<br />
linear: $arguments(0)<br />
<br />
});<br />
<br />
Fx.Transitions.extend = function(transitions){<br />
for (var transition in transitions) Fx.Transitions[transition] = new Fx.Transition(transitions[transition]);<br />
};<br />
<br />
Fx.Transitions.extend({<br />
<br />
Pow: function(p, x){<br />
return Math.pow(p, x[0] || 6);<br />
},<br />
<br />
Expo: function(p){<br />
return Math.pow(2, 8 * (p - 1));<br />
},<br />
<br />
Circ: function(p){<br />
return 1 - Math.sin(Math.acos(p));<br />
},<br />
<br />
Sine: function(p){<br />
return 1 - Math.sin((1 - p) * Math.PI / 2);<br />
},<br />
<br />
Back: function(p, x){<br />
x = x[0] || 1.618;<br />
return Math.pow(p, 2) * ((x + 1) * p - x);<br />
},<br />
<br />
Bounce: function(p){<br />
var value;<br />
for (var a = 0, b = 1; 1; a += b, b /= 2){<br />
if (p >= (7 - 4 * a) / 11){<br />
value = b * b - Math.pow((11 - 6 * a - 11 * p) / 4, 2);<br />
break;<br />
}<br />
}<br />
return value;<br />
},<br />
<br />
Elastic: function(p, x){<br />
return Math.pow(2, 10 * --p) * Math.cos(20 * p * Math.PI * (x[0] || 1) / 3);<br />
}<br />
<br />
});<br />
<br />
['Quad', 'Cubic', 'Quart', 'Quint'].each(function(transition, i){<br />
Fx.Transitions[transition] = new Fx.Transition(function(p){<br />
return Math.pow(p, [i + 2]);<br />
});<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Request.js<br />
<br />
description: Powerful all purpose Request Class. Uses XMLHTTPRequest.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Element<br />
- /Chain<br />
- /Events<br />
- /Options<br />
- /Browser<br />
<br />
provides: [Request]<br />
<br />
...<br />
*/<br />
<br />
var Request = new Class({<br />
<br />
Implements: [Chain, Events, Options],<br />
<br />
options: {/*<br />
onRequest: $empty,<br />
onComplete: $empty,<br />
onCancel: $empty,<br />
onSuccess: $empty,<br />
onFailure: $empty,<br />
onException: $empty,*/<br />
url: '',<br />
data: '',<br />
headers: {<br />
'X-Requested-With': 'XMLHttpRequest',<br />
'Accept': 'text/javascript, text/html, application/xml, text/xml, */*'<br />
},<br />
async: true,<br />
format: false,<br />
method: 'post',<br />
link: 'ignore',<br />
isSuccess: null,<br />
emulation: true,<br />
urlEncoded: true,<br />
encoding: 'utf-8',<br />
evalScripts: false,<br />
evalResponse: false,<br />
noCache: false<br />
},<br />
<br />
initialize: function(options){<br />
this.xhr = new Browser.Request();<br />
this.setOptions(options);<br />
this.options.isSuccess = this.options.isSuccess || this.isSuccess;<br />
this.headers = new Hash(this.options.headers);<br />
},<br />
<br />
onStateChange: function(){<br />
if (this.xhr.readyState != 4 || !this.running) return;<br />
this.running = false;<br />
this.status = 0;<br />
$try(function(){<br />
this.status = this.xhr.status;<br />
}.bind(this));<br />
this.xhr.onreadystatechange = $empty;<br />
if (this.options.isSuccess.call(this, this.status)){<br />
this.response = {text: this.xhr.responseText, xml: this.xhr.responseXML};<br />
this.success(this.response.text, this.response.xml);<br />
} else {<br />
this.response = {text: null, xml: null};<br />
this.failure();<br />
}<br />
},<br />
<br />
isSuccess: function(){<br />
return ((this.status >= 200) && (this.status < 300));<br />
},<br />
<br />
processScripts: function(text){<br />
if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) return $exec(text);<br />
return text.stripScripts(this.options.evalScripts);<br />
},<br />
<br />
success: function(text, xml){<br />
this.onSuccess(this.processScripts(text), xml);<br />
},<br />
<br />
onSuccess: function(){<br />
this.fireEvent('complete', arguments).fireEvent('success', arguments).callChain();<br />
},<br />
<br />
failure: function(){<br />
this.onFailure();<br />
},<br />
<br />
onFailure: function(){<br />
this.fireEvent('complete').fireEvent('failure', this.xhr);<br />
},<br />
<br />
setHeader: function(name, value){<br />
this.headers.set(name, value);<br />
return this;<br />
},<br />
<br />
getHeader: function(name){<br />
return $try(function(){<br />
return this.xhr.getResponseHeader(name);<br />
}.bind(this));<br />
},<br />
<br />
check: function(){<br />
if (!this.running) return true;<br />
switch (this.options.link){<br />
case 'cancel': this.cancel(); return true;<br />
case 'chain': this.chain(this.caller.bind(this, arguments)); return false;<br />
}<br />
return false;<br />
},<br />
<br />
send: function(options){<br />
if (!this.check(options)) return this;<br />
this.running = true;<br />
<br />
var type = $type(options);<br />
if (type == 'string' || type == 'element') options = {data: options};<br />
<br />
var old = this.options;<br />
options = $extend({data: old.data, url: old.url, method: old.method}, options);<br />
var data = options.data, url = String(options.url), method = options.method.toLowerCase();<br />
<br />
switch ($type(data)){<br />
case 'element': data = document.id(data).toQueryString(); break;<br />
case 'object': case 'hash': data = Hash.toQueryString(data);<br />
}<br />
<br />
if (this.options.format){<br />
var format = 'format=' + this.options.format;<br />
data = (data) ? format + '&' + data : format;<br />
}<br />
<br />
if (this.options.emulation && !['get', 'post'].contains(method)){<br />
var _method = '_method=' + method;<br />
data = (data) ? _method + '&' + data : _method;<br />
method = 'post';<br />
}<br />
<br />
if (this.options.urlEncoded && method == 'post'){<br />
var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';<br />
this.headers.set('Content-type', 'application/x-www-form-urlencoded' + encoding);<br />
}<br />
<br />
if (this.options.noCache){<br />
var noCache = 'noCache=' + new Date().getTime();<br />
data = (data) ? noCache + '&' + data : noCache;<br />
}<br />
<br />
var trimPosition = url.lastIndexOf('/');<br />
if (trimPosition > -1 && (trimPosition = url.indexOf('#')) > -1) url = url.substr(0, trimPosition);<br />
<br />
if (data && method == 'get'){<br />
url = url + (url.contains('?') ? '&' : '?') + data;<br />
data = null;<br />
}<br />
<br />
this.xhr.open(method.toUpperCase(), url, this.options.async);<br />
<br />
this.xhr.onreadystatechange = this.onStateChange.bind(this);<br />
<br />
this.headers.each(function(value, key){<br />
try {<br />
this.xhr.setRequestHeader(key, value);<br />
} catch (e){<br />
this.fireEvent('exception', [key, value]);<br />
}<br />
}, this);<br />
<br />
this.fireEvent('request');<br />
this.xhr.send(data);<br />
if (!this.options.async) this.onStateChange();<br />
return this;<br />
},<br />
<br />
cancel: function(){<br />
if (!this.running) return this;<br />
this.running = false;<br />
this.xhr.abort();<br />
this.xhr.onreadystatechange = $empty;<br />
this.xhr = new Browser.Request();<br />
this.fireEvent('cancel');<br />
return this;<br />
}<br />
<br />
});<br />
<br />
(function(){<br />
<br />
var methods = {};<br />
['get', 'post', 'put', 'delete', 'GET', 'POST', 'PUT', 'DELETE'].each(function(method){<br />
methods[method] = function(){<br />
var params = Array.link(arguments, {url: String.type, data: $defined});<br />
return this.send($extend(params, {method: method}));<br />
};<br />
});<br />
<br />
Request.implement(methods);<br />
<br />
})();<br />
<br />
Element.Properties.send = {<br />
<br />
set: function(options){<br />
var send = this.retrieve('send');<br />
if (send) send.cancel();<br />
return this.eliminate('send').store('send:options', $extend({<br />
data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action')<br />
}, options));<br />
},<br />
<br />
get: function(options){<br />
if (options || !this.retrieve('send')){<br />
if (options || !this.retrieve('send:options')) this.set('send', options);<br />
this.store('send', new Request(this.retrieve('send:options')));<br />
}<br />
return this.retrieve('send');<br />
}<br />
<br />
};<br />
<br />
Element.implement({<br />
<br />
send: function(url){<br />
var sender = this.get('send');<br />
sender.send({data: this, url: url || sender.options.url});<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Request.HTML.js<br />
<br />
description: Extends the basic Request Class with additional methods for interacting with HTML responses.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Request<br />
- /Element<br />
<br />
provides: [Request.HTML]<br />
<br />
...<br />
*/<br />
<br />
Request.HTML = new Class({<br />
<br />
Extends: Request,<br />
<br />
options: {<br />
update: false,<br />
append: false,<br />
evalScripts: true,<br />
filter: false<br />
},<br />
<br />
processHTML: function(text){<br />
var match = text.match(/<body[^>]*>([\s\S]*?)<\/body>/i);<br />
text = (match) ? match[1] : text;<br />
<br />
var container = new Element('div');<br />
<br />
return $try(function(){<br />
var root = '<root>' + text + '</root>', doc;<br />
if (Browser.Engine.trident){<br />
doc = new ActiveXObject('Microsoft.XMLDOM');<br />
doc.async = false;<br />
doc.loadXML(root);<br />
} else {<br />
doc = new DOMParser().parseFromString(root, 'text/xml');<br />
}<br />
root = doc.getElementsByTagName('root')[0];<br />
if (!root) return null;<br />
for (var i = 0, k = root.childNodes.length; i < k; i++){<br />
var child = Element.clone(root.childNodes[i], true, true);<br />
if (child) container.grab(child);<br />
}<br />
return container;<br />
}) || container.set('html', text);<br />
},<br />
<br />
success: function(text){<br />
var options = this.options, response = this.response;<br />
<br />
response.html = text.stripScripts(function(script){<br />
response.javascript = script;<br />
});<br />
<br />
var temp = this.processHTML(response.html);<br />
<br />
response.tree = temp.childNodes;<br />
response.elements = temp.getElements('*');<br />
<br />
if (options.filter) response.tree = response.elements.filter(options.filter);<br />
if (options.update) document.id(options.update).empty().set('html', response.html);<br />
else if (options.append) document.id(options.append).adopt(temp.getChildren());<br />
if (options.evalScripts) $exec(response.javascript);<br />
<br />
this.onSuccess(response.tree, response.elements, response.html, response.javascript);<br />
}<br />
<br />
});<br />
<br />
Element.Properties.load = {<br />
<br />
set: function(options){<br />
var load = this.retrieve('load');<br />
if (load) load.cancel();<br />
return this.eliminate('load').store('load:options', $extend({data: this, link: 'cancel', update: this, method: 'get'}, options));<br />
},<br />
<br />
get: function(options){<br />
if (options || ! this.retrieve('load')){<br />
if (options || !this.retrieve('load:options')) this.set('load', options);<br />
this.store('load', new Request.HTML(this.retrieve('load:options')));<br />
}<br />
return this.retrieve('load');<br />
}<br />
<br />
};<br />
<br />
Element.implement({<br />
<br />
load: function(){<br />
this.get('load').send(Array.link(arguments, {data: Object.type, url: String.type}));<br />
return this;<br />
}<br />
<br />
});<br />
<br />
<br />
/*<br />
---<br />
<br />
script: Request.JSON.js<br />
<br />
description: Extends the basic Request Class with additional methods for sending and receiving JSON data.<br />
<br />
license: MIT-style license.<br />
<br />
requires:<br />
- /Request JSON<br />
<br />
provides: [Request.HTML]<br />
<br />
...<br />
*/<br />
<br />
Request.JSON = new Class({<br />
<br />
Extends: Request,<br />
<br />
options: {<br />
secure: true<br />
},<br />
<br />
initialize: function(options){<br />
this.parent(options);<br />
this.headers.extend({'Accept': 'application/json', 'X-Request': 'JSON'});<br />
},<br />
<br />
success: function(text){<br />
this.response.json = JSON.decode(text, this.options.secure);<br />
this.onSuccess(this.response.json, text);<br />
}<br />
<br />
});</div>
L7ukas