/* --- mootools: the javascript framework web build: - http://mootools.net/core/7c56cfef9dddcf170a5d68e3fb61cfd7 packager build: - packager build core/core core/array core/string core/number core/function core/object core/event core/browser core/class core/class.extras core/slick.parser core/slick.finder core/element core/element.style core/element.event core/element.dimensions core/fx core/fx.css core/fx.tween core/fx.morph core/fx.transitions core/request core/request.html core/request.json core/cookie core/json core/domready core/swiff /* --- name: core description: the heart of mootools. license: mit-style license. copyright: copyright (c) 2006-2010 [valerio proietti](http://mad4milk.net/). authors: the mootools production team (http://mootools.net/developers/) inspiration: - 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) - some functionality inspired by [prototype.js](http://prototypejs.org) copyright (c) 2005-2007 sam stephenson, [mit license](http://opensource.org/licenses/mit-license.php) provides: [core, mootools, type, typeof, instanceof, native] ... */ (function(){ this.mootools = { version: '1.3', build: 'a3eed692dd85050d80168ec2c708efe901bb7db3' }; // typeof, instanceof var typeof = this.typeof = function(item){ if (item == null) return 'null'; if (item.$family) return item.$family(); if (item.nodename){ if (item.nodetype == 1) return 'element'; if (item.nodetype == 3) return (/\s/).test(item.nodevalue) ? 'textnode' : 'whitespace'; } else if (typeof item.length == 'number'){ if (item.callee) return 'arguments'; if ('item' in item) return 'collection'; } return typeof item; }; var instanceof = this.instanceof = function(item, object){ if (item == null) return false; var constructor = item.$constructor || item.constructor; while (constructor){ if (constructor === object) return true; constructor = constructor.parent; } return item instanceof object; }; // function overloading var function = this.function; var enumerables = true; for (var i in {tostring: 1}) enumerables = null; if (enumerables) enumerables = ['hasownproperty', 'valueof', 'isprototypeof', 'propertyisenumerable', 'tolocalestring', 'tostring', 'constructor']; function.prototype.overloadsetter = function(useplural){ var self = this; return function(a, b){ if (a == null) return this; if (useplural || typeof a != 'string'){ for (var k in a) self.call(this, k, a[k]); if (enumerables) for (var i = enumerables.length; i--;){ k = enumerables[i]; if (a.hasownproperty(k)) self.call(this, k, a[k]); } } else { self.call(this, a, b); } return this; }; }; function.prototype.overloadgetter = function(useplural){ var self = this; return function(a){ var args, result; if (useplural || typeof a != 'string') args = a; else if (arguments.length > 1) args = arguments; if (args){ result = {}; for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]); } else { result = self.call(this, a); } return result; }; }; function.prototype.extend = function(key, value){ this[key] = value; }.overloadsetter(); function.prototype.implement = function(key, value){ this.prototype[key] = value; }.overloadsetter(); // from var slice = array.prototype.slice; function.from = function(item){ return (typeof(item) == 'function') ? item : function(){ return item; }; }; array.from = function(item){ if (item == null) return []; return (type.isenumerable(item) && typeof item != 'string') ? (typeof(item) == 'array') ? item : slice.call(item) : [item]; }; number.from = function(item){ var number = parsefloat(item); return isfinite(number) ? number : null; }; string.from = function(item){ return item + ''; }; // hide, protect function.implement({ hide: function(){ this.$hidden = true; return this; }, protect: function(){ this.$protected = true; return this; } }); // type var type = this.type = function(name, object){ if (name){ var lower = name.tolowercase(); var typecheck = function(item){ return (typeof(item) == lower); }; type['is' + name] = typecheck; if (object != null){ object.prototype.$family = (function(){ return lower; }).hide(); //<1.2compat> object.type = typecheck; // } } if (object == null) return null; object.extend(this); object.$constructor = type; object.prototype.$constructor = object; return object; }; var tostring = object.prototype.tostring; type.isenumerable = function(item){ return (item != null && typeof item.length == 'number' && tostring.call(item) != '[object function]' ); }; var hooks = {}; var hooksof = function(object){ var type = typeof(object.prototype); return hooks[type] || (hooks[type] = []); }; var implement = function(name, method){ if (method && method.$hidden) return this; var hooks = hooksof(this); for (var i = 0; i < hooks.length; i++){ var hook = hooks[i]; if (typeof(hook) == 'type') implement.call(hook, name, method); else hook.call(this, name, method); } var previous = this.prototype[name]; if (previous == null || !previous.$protected) this.prototype[name] = method; if (this[name] == null && typeof(method) == 'function') extend.call(this, name, function(item){ return method.apply(item, slice.call(arguments, 1)); }); return this; }; var extend = function(name, method){ if (method && method.$hidden) return this; var previous = this[name]; if (previous == null || !previous.$protected) this[name] = method; return this; }; type.implement({ implement: implement.overloadsetter(), extend: extend.overloadsetter(), alias: function(name, existing){ implement.call(this, name, this.prototype[existing]); }.overloadsetter(), mirror: function(hook){ hooksof(this).push(hook); return this; } }); new type('type', type); // default types var force = function(name, object, methods){ var istype = (object != object), prototype = object.prototype; if (istype) object = new type(name, object); for (var i = 0, l = methods.length; i < l; i++){ var key = methods[i], generic = object[key], proto = prototype[key]; if (generic) generic.protect(); if (istype && proto){ delete prototype[key]; prototype[key] = proto.protect(); } } if (istype) object.implement(prototype); return force; }; force('string', string, [ 'charat', 'charcodeat', 'concat', 'indexof', 'lastindexof', 'match', 'quote', 'replace', 'search', 'slice', 'split', 'substr', 'substring', 'tolowercase', 'touppercase' ])('array', array, [ 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice', 'indexof', 'lastindexof', 'filter', 'foreach', 'every', 'map', 'some', 'reduce', 'reduceright' ])('number', number, [ 'toexponential', 'tofixed', 'tolocalestring', 'toprecision' ])('function', function, [ 'apply', 'call', 'bind' ])('regexp', regexp, [ 'exec', 'test' ])('object', object, [ 'create', 'defineproperty', 'defineproperties', 'keys', 'getprototypeof', 'getownpropertydescriptor', 'getownpropertynames', 'preventextensions', 'isextensible', 'seal', 'issealed', 'freeze', 'isfrozen' ])('date', date, ['now']); object.extend = extend.overloadsetter(); date.extend('now', function(){ return +(new date); }); new type('boolean', boolean); // fixes nan returning as number number.prototype.$family = function(){ return isfinite(this) ? 'number' : 'null'; }.hide(); // number.random number.extend('random', function(min, max){ return math.floor(math.random() * (max - min + 1) + min); }); // foreach, each object.extend('foreach', function(object, fn, bind){ for (var key in object){ if (object.hasownproperty(key)) fn.call(bind, object[key], key, object); } }); object.each = object.foreach; array.implement({ foreach: function(fn, bind){ for (var i = 0, l = this.length; i < l; i++){ if (i in this) fn.call(bind, this[i], i, this); } }, each: function(fn, bind){ array.foreach(this, fn, bind); return this; } }); // array & object cloning, object merging and appending var cloneof = function(item){ switch (typeof(item)){ case 'array': return item.clone(); case 'object': return object.clone(item); default: return item; } }; array.implement('clone', function(){ var i = this.length, clone = new array(i); while (i--) clone[i] = cloneof(this[i]); return clone; }); var mergeone = function(source, key, current){ switch (typeof(current)){ case 'object': if (typeof(source[key]) == 'object') object.merge(source[key], current); else source[key] = object.clone(current); break; case 'array': source[key] = current.clone(); break; default: source[key] = current; } return source; }; object.extend({ merge: function(source, k, v){ if (typeof(k) == 'string') return mergeone(source, k, v); for (var i = 1, l = arguments.length; i < l; i++){ var object = arguments[i]; for (var key in object) mergeone(source, key, object[key]); } return source; }, clone: function(object){ var clone = {}; for (var key in object) clone[key] = cloneof(object[key]); return clone; }, append: function(original){ for (var i = 1, l = arguments.length; i < l; i++){ var extended = arguments[i] || {}; for (var key in extended) original[key] = extended[key]; } return original; } }); // object-less types ['object', 'whitespace', 'textnode', 'collection', 'arguments'].each(function(name){ new type(name); }); // unique id var uid = date.now(); string.extend('uniqueid', function(){ return (uid++).tostring(36); }); //<1.2compat> var hash = this.hash = new type('hash', function(object){ if (typeof(object) == 'hash') object = object.clone(object.getclean()); for (var key in object) this[key] = object[key]; return this; }); hash.implement({ foreach: function(fn, bind){ object.foreach(this, fn, bind); }, getclean: function(){ var clean = {}; for (var key in this){ if (this.hasownproperty(key)) clean[key] = this[key]; } return clean; }, getlength: function(){ var length = 0; for (var key in this){ if (this.hasownproperty(key)) length++; } return length; } }); hash.alias('each', 'foreach'); object.type = type.isobject; var native = this.native = function(properties){ return new type(properties.name, properties.initialize); }; native.type = type.type; native.implement = function(objects, methods){ for (var i = 0; i < objects.length; i++) objects[i].implement(methods); return native; }; var arraytype = array.type; array.type = function(item){ return instanceof(item, array) || arraytype(item); }; this.$a = function(item){ return array.from(item).slice(); }; this.$arguments = function(i){ return function(){ return arguments[i]; }; }; this.$chk = function(obj){ return !!(obj || obj === 0); }; this.$clear = function(timer){ cleartimeout(timer); clearinterval(timer); return null; }; this.$defined = function(obj){ return (obj != null); }; this.$each = function(iterable, fn, bind){ var type = typeof(iterable); ((type == 'arguments' || type == 'collection' || type == 'array' || type == 'elements') ? array : object).each(iterable, fn, bind); }; this.$empty = function(){}; this.$extend = function(original, extended){ return object.append(original, extended); }; this.$h = function(object){ return new hash(object); }; this.$merge = function(){ var args = array.slice(arguments); args.unshift({}); return object.merge.apply(null, args); }; this.$lambda = function.from; this.$mixin = object.merge; this.$random = number.random; this.$splat = array.from; this.$time = date.now; this.$type = function(object){ var type = typeof(object); if (type == 'elements') return 'array'; return (type == 'null') ? false : type; }; this.$unlink = function(object){ switch (typeof(object)){ case 'object': return object.clone(object); case 'array': return array.clone(object); case 'hash': return new hash(object); default: return object; } }; // })(); /* --- name: array description: contains array prototypes like each, contains, and erase. license: mit-style license. requires: type provides: array ... */ array.implement({ invoke: function(methodname){ var args = array.slice(arguments, 1); return this.map(function(item){ return item[methodname].apply(item, args); }); }, every: function(fn, bind){ for (var i = 0, l = this.length; i < l; i++){ if ((i in this) && !fn.call(bind, this[i], i, this)) return false; } return true; }, filter: function(fn, bind){ var results = []; for (var i = 0, l = this.length; i < l; i++){ if ((i in this) && fn.call(bind, this[i], i, this)) results.push(this[i]); } return results; }, clean: function(){ return this.filter(function(item){ return item != null; }); }, indexof: function(item, from){ var len = this.length; for (var i = (from < 0) ? math.max(0, len + from) : from || 0; i < len; i++){ if (this[i] === item) return i; } return -1; }, map: function(fn, bind){ var results = []; for (var i = 0, l = this.length; i < l; i++){ if (i in this) results[i] = fn.call(bind, this[i], i, this); } return results; }, some: function(fn, bind){ for (var i = 0, l = this.length; i < l; i++){ if ((i in this) && fn.call(bind, this[i], i, this)) return true; } return false; }, associate: function(keys){ var obj = {}, length = math.min(this.length, keys.length); for (var i = 0; i < length; i++) obj[keys[i]] = this[i]; return obj; }, link: function(object){ var result = {}; for (var i = 0, l = this.length; i < l; i++){ for (var key in object){ if (object[key](this[i])){ result[key] = this[i]; delete object[key]; break; } } } return result; }, contains: function(item, from){ return this.indexof(item, from) != -1; }, append: function(array){ this.push.apply(this, array); return this; }, getlast: function(){ return (this.length) ? this[this.length - 1] : null; }, getrandom: function(){ return (this.length) ? this[number.random(0, this.length - 1)] : null; }, include: function(item){ if (!this.contains(item)) this.push(item); return this; }, combine: function(array){ for (var i = 0, l = array.length; i < l; i++) this.include(array[i]); return this; }, erase: function(item){ for (var i = this.length; i--;){ if (this[i] === item) this.splice(i, 1); } return this; }, empty: function(){ this.length = 0; return this; }, flatten: function(){ var array = []; for (var i = 0, l = this.length; i < l; i++){ var type = typeof(this[i]); if (type == 'null') continue; array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceof(this[i], array)) ? array.flatten(this[i]) : this[i]); } return array; }, pick: function(){ for (var i = 0, l = this.length; i < l; i++){ if (this[i] != null) return this[i]; } return null; }, hextorgb: function(array){ if (this.length != 3) return null; var rgb = this.map(function(value){ if (value.length == 1) value += value; return value.toint(16); }); return (array) ? rgb : 'rgb(' + rgb + ')'; }, rgbtohex: function(array){ if (this.length < 3) return null; if (this.length == 4 && this[3] == 0 && !array) return 'transparent'; var hex = []; for (var i = 0; i < 3; i++){ var bit = (this[i] - 0).tostring(16); hex.push((bit.length == 1) ? '0' + bit : bit); } return (array) ? hex : '#' + hex.join(''); } }); //<1.2compat> array.alias('extend', 'append'); var $pick = function(){ return array.from(arguments).pick(); }; // /* --- name: string description: contains string prototypes like camelcase, capitalize, test, and toint. license: mit-style license. requires: type provides: string ... */ string.implement({ test: function(regex, params){ return ((typeof(regex) == 'regexp') ? regex : new regexp('' + regex, params)).test(this); }, contains: function(string, separator){ return (separator) ? (separator + this + separator).indexof(separator + string + separator) > -1 : this.indexof(string) > -1; }, trim: function(){ return this.replace(/^\s+|\s+$/g, ''); }, clean: function(){ return this.replace(/\s+/g, ' ').trim(); }, camelcase: function(){ return this.replace(/-\d/g, function(match){ return match.charat(1).touppercase(); }); }, hyphenate: function(){ return this.replace(/[a-z]/g, function(match){ return ('-' + match.charat(0).tolowercase()); }); }, capitalize: function(){ return this.replace(/\b[a-z]/g, function(match){ return match.touppercase(); }); }, escaperegexp: function(){ return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); }, toint: function(base){ return parseint(this, base || 10); }, tofloat: function(){ return parsefloat(this); }, hextorgb: function(array){ var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); return (hex) ? hex.slice(1).hextorgb(array) : null; }, rgbtohex: function(array){ var rgb = this.match(/\d{1,3}/g); return (rgb) ? rgb.rgbtohex(array) : null; }, substitute: function(object, regexp){ return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){ if (match.charat(0) == '\\') return match.slice(1); return (object[name] != null) ? object[name] : ''; }); } }); /* --- name: number description: contains number prototypes like limit, round, times, and ceil. license: mit-style license. requires: type provides: number ... */ number.implement({ limit: function(min, max){ return math.min(max, math.max(min, this)); }, round: function(precision){ precision = math.pow(10, precision || 0).tofixed(precision < 0 ? -precision : 0); return math.round(this * precision) / precision; }, times: function(fn, bind){ for (var i = 0; i < this; i++) fn.call(bind, i, this); }, tofloat: function(){ return parsefloat(this); }, toint: function(base){ return parseint(this, base || 10); } }); number.alias('each', 'times'); (function(math){ var methods = {}; math.each(function(name){ if (!number[name]) methods[name] = function(){ return math[name].apply(null, [this].concat(array.from(arguments))); }; }); number.implement(methods); })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']); /* --- name: function description: contains function prototypes like create, bind, pass, and delay. license: mit-style license. requires: type provides: function ... */ function.extend({ attempt: function(){ for (var i = 0, l = arguments.length; i < l; i++){ try { return arguments[i](); } catch (e){} } return null; } }); function.implement({ attempt: function(args, bind){ try { return this.apply(bind, array.from(args)); } catch (e){} return null; }, bind: function(bind){ var self = this, args = (arguments.length > 1) ? array.slice(arguments, 1) : null; return function(){ if (!args && !arguments.length) return self.call(bind); if (args && arguments.length) return self.apply(bind, args.concat(array.from(arguments))); return self.apply(bind, args || arguments); }; }, pass: function(args, bind){ var self = this; if (args != null) args = array.from(args); return function(){ return self.apply(bind, args || arguments); }; }, delay: function(delay, bind, args){ return settimeout(this.pass(args, bind), delay); }, periodical: function(periodical, bind, args){ return setinterval(this.pass(args, bind), periodical); } }); //<1.2compat> delete function.prototype.bind; function.implement({ create: function(options){ var self = this; options = options || {}; return function(event){ var args = options.arguments; args = (args != null) ? array.from(args) : array.slice(arguments, (options.event) ? 1 : 0); if (options.event) args = [event || window.event].extend(args); var returns = function(){ return self.apply(options.bind || null, args); }; if (options.delay) return settimeout(returns, options.delay); if (options.periodical) return setinterval(returns, options.periodical); if (options.attempt) return function.attempt(returns); return returns(); }; }, bind: function(bind, args){ var self = this; if (args != null) args = array.from(args); return function(){ return self.apply(bind, args || arguments); }; }, bindwithevent: function(bind, args){ var self = this; if (args != null) args = array.from(args); return function(event){ return self.apply(bind, (args == null) ? arguments : [event].concat(args)); }; }, run: function(args, bind){ return this.apply(bind, array.from(args)); } }); var $try = function.attempt; // /* --- name: object description: object generic methods license: mit-style license. requires: type provides: [object, hash] ... */ object.extend({ subset: function(object, keys){ var results = {}; for (var i = 0, l = keys.length; i < l; i++){ var k = keys[i]; results[k] = object[k]; } return results; }, map: function(object, fn, bind){ var results = {}; for (var key in object){ if (object.hasownproperty(key)) results[key] = fn.call(bind, object[key], key, object); } return results; }, filter: function(object, fn, bind){ var results = {}; object.each(object, function(value, key){ if (fn.call(bind, value, key, object)) results[key] = value; }); return results; }, every: function(object, fn, bind){ for (var key in object){ if (object.hasownproperty(key) && !fn.call(bind, object[key], key)) return false; } return true; }, some: function(object, fn, bind){ for (var key in object){ if (object.hasownproperty(key) && fn.call(bind, object[key], key)) return true; } return false; }, keys: function(object){ var keys = []; for (var key in object){ if (object.hasownproperty(key)) keys.push(key); } return keys; }, values: function(object){ var values = []; for (var key in object){ if (object.hasownproperty(key)) values.push(object[key]); } return values; }, getlength: function(object){ return object.keys(object).length; }, keyof: function(object, value){ for (var key in object){ if (object.hasownproperty(key) && object[key] === value) return key; } return null; }, contains: function(object, value){ return object.keyof(object, value) != null; }, toquerystring: function(object, base){ var querystring = []; object.each(object, function(value, key){ if (base) key = base + '[' + key + ']'; var result; switch (typeof(value)){ case 'object': result = object.toquerystring(value, key); break; case 'array': var qs = {}; value.each(function(val, i){ qs[i] = val; }); result = object.toquerystring(qs, key); break; default: result = key + '=' + encodeuricomponent(value); } if (value != null) querystring.push(result); }); return querystring.join('&'); } }); //<1.2compat> hash.implement({ has: object.prototype.hasownproperty, keyof: function(value){ return object.keyof(this, value); }, hasvalue: function(value){ return object.contains(this, value); }, extend: function(properties){ hash.each(properties || {}, function(value, key){ hash.set(this, key, value); }, this); return this; }, combine: function(properties){ hash.each(properties || {}, function(value, key){ hash.include(this, key, value); }, this); return this; }, erase: function(key){ if (this.hasownproperty(key)) delete this[key]; return this; }, get: function(key){ return (this.hasownproperty(key)) ? this[key] : null; }, set: function(key, value){ if (!this[key] || this.hasownproperty(key)) this[key] = value; return this; }, empty: function(){ hash.each(this, function(value, key){ delete this[key]; }, this); return this; }, include: function(key, value){ if (this[key] == null) this[key] = value; return this; }, map: function(fn, bind){ return new hash(object.map(this, fn, bind)); }, filter: function(fn, bind){ return new hash(object.filter(this, fn, bind)); }, every: function(fn, bind){ return object.every(this, fn, bind); }, some: function(fn, bind){ return object.some(this, fn, bind); }, getkeys: function(){ return object.keys(this); }, getvalues: function(){ return object.values(this); }, toquerystring: function(base){ return object.toquerystring(this, base); } }); hash.extend = object.append; hash.alias({indexof: 'keyof', contains: 'hasvalue'}); // /* --- name: browser description: the browser object. contains browser initialization, window and document, and the browser hash. license: mit-style license. requires: [array, function, number, string] provides: [browser, window, document] ... */ (function(){ var document = this.document; var window = document.window = this; var uid = 1; this.$uid = (window.activexobject) ? function(item){ return (item.uid || (item.uid = [uid++]))[0]; } : function(item){ return item.uid || (item.uid = uid++); }; $uid(window); $uid(document); var ua = navigator.useragent.tolowercase(), platform = navigator.platform.tolowercase(), ua = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0], mode = ua[1] == 'ie' && document.documentmode; var browser = this.browser = { extend: function.prototype.extend, name: (ua[1] == 'version') ? ua[3] : ua[1], version: mode || parsefloat((ua[1] == 'opera' && ua[4]) ? ua[4] : ua[2]), platform: { name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0] }, features: { xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.queryselector), json: !!(window.json) }, plugins: {} }; browser[browser.name] = true; browser[browser.name + parseint(browser.version, 10)] = true; browser.platform[browser.platform.name] = true; // request browser.request = (function(){ var xmlhttp = function(){ return new xmlhttprequest(); }; var msxml2 = function(){ return new activexobject('msxml2.xmlhttp'); }; var msxml = function(){ return new activexobject('microsoft.xmlhttp'); }; return function.attempt(function(){ xmlhttp(); return xmlhttp; }, function(){ msxml2(); return msxml2; }, function(){ msxml(); return msxml; }); })(); browser.features.xhr = !!(browser.request); // flash detection var version = (function.attempt(function(){ return navigator.plugins['shockwave flash'].description; }, function(){ return new activexobject('shockwaveflash.shockwaveflash').getvariable('$version'); }) || '0 r0').match(/\d+/g); browser.plugins.flash = { version: number(version[0] || '0.' + version[1]) || 0, build: number(version[2]) || 0 }; // string scripts browser.exec = function(text){ if (!text) return text; if (window.execscript){ window.execscript(text); } else { var script = document.createelement('script'); script.setattribute('type', 'text/javascript'); script.text = text; document.head.appendchild(script); document.head.removechild(script); } return text; }; string.implement('stripscripts', function(exec){ var scripts = ''; var text = this.replace(/]*>([\s\s]*?)<\/script>/gi, function(all, code){ scripts += code + '\n'; return ''; }); if (exec === true) browser.exec(scripts); else if (typeof(exec) == 'function') exec(scripts, text); return text; }); // window, document browser.extend({ document: this.document, window: this.window, element: this.element, event: this.event }); this.window = this.$constructor = new type('window', function(){}); this.$family = function.from('window').hide(); window.mirror(function(name, method){ window[name] = method; }); this.document = document.$constructor = new type('document', function(){}); document.$family = function.from('document').hide(); document.mirror(function(name, method){ document[name] = method; }); document.html = document.documentelement; document.head = document.getelementsbytagname('head')[0]; if (document.execcommand) try { document.execcommand("backgroundimagecache", false, true); } catch (e){} if (this.attachevent && !this.addeventlistener){ var unloadevent = function(){ this.detachevent('onunload', unloadevent); document.head = document.html = document.window = null; }; this.attachevent('onunload', unloadevent); } // ie fails on collections and ) var arrayfrom = array.from; try { arrayfrom(document.html.childnodes); } catch(e){ array.from = function(item){ if (typeof item != 'string' && type.isenumerable(item) && typeof(item) != 'array'){ var i = item.length, array = new array(i); while (i--) array[i] = item[i]; return array; } return arrayfrom(item); }; var prototype = array.prototype, slice = prototype.slice; ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function(name){ var method = prototype[name]; array[name] = function(item){ return method.apply(array.from(item), slice.call(arguments, 1)); }; }); } //<1.2compat> if (browser.platform.ios) browser.platform.ipod = true; browser.engine = {}; var setengine = function(name, version){ browser.engine.name = name; browser.engine[name + version] = true; browser.engine.version = version; }; if (browser.ie){ browser.engine.trident = true; switch (browser.version){ case 6: setengine('trident', 4); break; case 7: setengine('trident', 5); break; case 8: setengine('trident', 6); } } if (browser.firefox){ browser.engine.gecko = true; if (browser.version >= 3) setengine('gecko', 19); else setengine('gecko', 18); } if (browser.safari || browser.chrome){ browser.engine.webkit = true; switch (browser.version){ case 2: setengine('webkit', 419); break; case 3: setengine('webkit', 420); break; case 4: setengine('webkit', 525); } } if (browser.opera){ browser.engine.presto = true; if (browser.version >= 9.6) setengine('presto', 960); else if (browser.version >= 9.5) setengine('presto', 950); else setengine('presto', 925); } if (browser.name == 'unknown'){ switch ((ua.match(/(?:webkit|khtml|gecko)/) || [])[0]){ case 'webkit': case 'khtml': browser.engine.webkit = true; break; case 'gecko': browser.engine.gecko = true; } } this.$exec = browser.exec; // })(); /* --- name: event description: contains the event class, to make the event object cross-browser. license: mit-style license. requires: [window, document, array, function, string, object] provides: event ... */ var event = new type('event', function(event, win){ if (!win) win = window; var doc = win.document; event = event || win.event; if (event.$extended) return event; this.$extended = true; var type = event.type, target = event.target || event.srcelement, page = {}, client = {}; while (target && target.nodetype == 3) target = target.parentnode; if (type.indexof('key') != -1){ var code = event.which || event.keycode; var key = object.keyof(event.keys, code); if (type == 'keydown'){ var fkey = code - 111; if (fkey > 0 && fkey < 13) key = 'f' + fkey; } if (!key) key = string.fromcharcode(code).tolowercase(); } else if (type.test(/click|mouse|menu/i)){ doc = (!doc.compatmode || doc.compatmode == 'css1compat') ? doc.html : doc.body; page = { x: (event.pagex != null) ? event.pagex : event.clientx + doc.scrollleft, y: (event.pagey != null) ? event.pagey : event.clienty + doc.scrolltop }; client = { x: (event.pagex != null) ? event.pagex - win.pagexoffset : event.clientx, y: (event.pagey != null) ? event.pagey - win.pageyoffset : event.clienty }; if (type.test(/dommousescroll|mousewheel/)){ var wheel = (event.wheeldelta) ? event.wheeldelta / 120 : -(event.detail || 0) / 3; } var rightclick = (event.which == 3) || (event.button == 2), related = null; if (type.test(/over|out/)){ related = event.relatedtarget || event[(type == 'mouseover' ? 'from' : 'to') + 'element']; var testrelated = function(){ while (related && related.nodetype == 3) related = related.parentnode; return true; }; var hasrelated = (browser.firefox2) ? testrelated.attempt() : testrelated(); related = (hasrelated) ? related : null; } } else if (type.test(/gesture|touch/i)){ this.rotation = event.rotation; this.scale = event.scale; this.targettouches = event.targettouches; this.changedtouches = event.changedtouches; var touches = this.touches = event.touches; if (touches && touches[0]){ var touch = touches[0]; page = {x: touch.pagex, y: touch.pagey}; client = {x: touch.clientx, y: touch.clienty}; } } return object.append(this, { event: event, type: type, page: page, client: client, rightclick: rightclick, wheel: wheel, relatedtarget: document.id(related), target: document.id(target), code: code, key: key, shift: event.shiftkey, control: event.ctrlkey, alt: event.altkey, meta: event.metakey }); }); event.keys = { 'enter': 13, 'up': 38, 'down': 40, 'left': 37, 'right': 39, 'esc': 27, 'space': 32, 'backspace': 8, 'tab': 9, 'delete': 46 }; //<1.2compat> event.keys = new hash(event.keys); // event.implement({ stop: function(){ return this.stoppropagation().preventdefault(); }, stoppropagation: function(){ if (this.event.stoppropagation) this.event.stoppropagation(); else this.event.cancelbubble = true; return this; }, preventdefault: function(){ if (this.event.preventdefault) this.event.preventdefault(); else this.event.returnvalue = false; return this; } }); /* --- name: class description: contains the class function for easily creating, extending, and implementing reusable classes. license: mit-style license. requires: [array, string, function, number] provides: class ... */ (function(){ var class = this.class = new type('class', function(params){ if (instanceof(params, function)) params = {initialize: params}; var newclass = function(){ reset(this); if (newclass.$prototyping) return this; this.$caller = null; var value = (this.initialize) ? this.initialize.apply(this, arguments) : this; this.$caller = this.caller = null; return value; }.extend(this).implement(params); newclass.$constructor = class; newclass.prototype.$constructor = newclass; newclass.prototype.parent = parent; return newclass; }); var parent = function(){ if (!this.$caller) throw new error('the method "parent" cannot be called.'); var name = this.$caller.$name, parent = this.$caller.$owner.parent, previous = (parent) ? parent.prototype[name] : null; if (!previous) throw new error('the method "' + name + '" has no parent.'); return previous.apply(this, arguments); }; var reset = function(object){ for (var key in object){ var value = object[key]; switch (typeof(value)){ case 'object': var f = function(){}; f.prototype = value; object[key] = reset(new f); break; case 'array': object[key] = value.clone(); break; } } return object; }; var wrap = function(self, key, method){ if (method.$origin) method = method.$origin; var wrapper = function(){ if (method.$protected && this.$caller == null) throw new error('the method "' + key + '" cannot be called.'); var caller = this.caller, current = this.$caller; this.caller = current; this.$caller = wrapper; var result = method.apply(this, arguments); this.$caller = current; this.caller = caller; return result; }.extend({$owner: self, $origin: method, $name: key}); return wrapper; }; var implement = function(key, value, retain){ if (class.mutators.hasownproperty(key)){ value = class.mutators[key].call(this, value); if (value == null) return this; } if (typeof(value) == 'function'){ if (value.$hidden) return this; this.prototype[key] = (retain) ? value : wrap(this, key, value); } else { object.merge(this.prototype, key, value); } return this; }; var getinstance = function(klass){ klass.$prototyping = true; var proto = new klass; delete klass.$prototyping; return proto; }; class.implement('implement', implement.overloadsetter()); class.mutators = { extends: function(parent){ this.parent = parent; this.prototype = getinstance(parent); }, implements: function(items){ array.from(items).each(function(item){ var instance = new item; for (var key in instance) implement.call(this, key, instance[key], true); }, this); } }; })(); /* --- name: class.extras description: contains utility classes that can be implemented into your own classes to ease the execution of many common tasks. license: mit-style license. requires: class provides: [class.extras, chain, events, options] ... */ (function(){ this.chain = new class({ $chain: [], chain: function(){ this.$chain.append(array.flatten(arguments)); return this; }, callchain: function(){ return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false; }, clearchain: function(){ this.$chain.empty(); return this; } }); var removeon = function(string){ return string.replace(/^on([a-z])/, function(full, first){ return first.tolowercase(); }); }; this.events = new class({ $events: {}, addevent: function(type, fn, internal){ type = removeon(type); /*<1.2compat>*/ if (fn == $empty) return this; /**/ this.$events[type] = (this.$events[type] || []).include(fn); if (internal) fn.internal = true; return this; }, addevents: function(events){ for (var type in events) this.addevent(type, events[type]); return this; }, fireevent: function(type, args, delay){ type = removeon(type); var events = this.$events[type]; if (!events) return this; args = array.from(args); events.each(function(fn){ if (delay) fn.delay(delay, this, args); else fn.apply(this, args); }, this); return this; }, removeevent: function(type, fn){ type = removeon(type); var events = this.$events[type]; if (events && !fn.internal){ var index = events.indexof(fn); if (index != -1) delete events[index]; } return this; }, removeevents: function(events){ var type; if (typeof(events) == 'object'){ for (type in events) this.removeevent(type, events[type]); return this; } if (events) events = removeon(events); for (type in this.$events){ if (events && events != type) continue; var fns = this.$events[type]; for (var i = fns.length; i--;) this.removeevent(type, fns[i]); } return this; } }); this.options = new class({ setoptions: function(){ var options = this.options = object.merge.apply(null, [{}, this.options].append(arguments)); if (!this.addevent) return this; for (var option in options){ if (typeof(options[option]) != 'function' || !(/^on[a-z]/).test(option)) continue; this.addevent(option, options[option]); delete options[option]; } return this; } }); })(); /* --- name: slick.parser description: standalone css3 selector parser provides: slick.parser ... */ (function(){ var parsed, separatorindex, combinatorindex, reversed, cache = {}, reversecache = {}, reunescape = /\\/g; var parse = function(expression, isreversed){ if (expression == null) return null; if (expression.slick === true) return expression; expression = ('' + expression).replace(/^\s+|\s+$/g, ''); reversed = !!isreversed; var currentcache = (reversed) ? reversecache : cache; if (currentcache[expression]) return currentcache[expression]; parsed = {slick: true, expressions: [], raw: expression, reverse: function(){ return parse(this.raw, true); }}; separatorindex = -1; while (expression != (expression = expression.replace(regexp, parser))); parsed.length = parsed.expressions.length; return currentcache[expression] = (reversed) ? reverse(parsed) : parsed; }; var reversecombinator = function(combinator){ if (combinator === '!') return ' '; else if (combinator === ' ') return '!'; else if ((/^!/).test(combinator)) return combinator.replace(/^!/, ''); else return '!' + combinator; }; var reverse = function(expression){ var expressions = expression.expressions; for (var i = 0; i < expressions.length; i++){ var exp = expressions[i]; var last = {parts: [], tag: '*', combinator: reversecombinator(exp[0].combinator)}; for (var j = 0; j < exp.length; j++){ var cexp = exp[j]; if (!cexp.reversecombinator) cexp.reversecombinator = ' '; cexp.combinator = cexp.reversecombinator; delete cexp.reversecombinator; } exp.reverse().push(last); } return expression; }; var escaperegexp = function(string){// credit: xregexp 0.6.1 (c) 2007-2008 steven levithan mit license return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, "\\$&"); }; var regexp = new regexp( /* #!/usr/bin/env ruby puts "\t\t" + data.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'') __end__ "(?x)^(?:\ \\s* ( , ) \\s* # separator \n\ | \\s* ( + ) \\s* # combinator \n\ | ( \\s+ ) # combinatorchildren \n\ | ( + | \\* ) # tag \n\ | \\# ( + ) # id \n\ | \\. ( + ) # classname \n\ | # attribute \n\ \\[ \ \\s* (+) (?: \ \\s* ([*^$!~|]?=) (?: \ \\s* (?:\ ([\"']?)(.*?)\\9 \ )\ ) \ )? \\s* \ \\](?!\\]) \n\ | :+ ( + )(?:\ \\( (?:\ (?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\ ) \\)\ )?\ )" */ "^(?:\\s*(,)\\s*|\\s*(+)\\s*|(\\s+)|(+|\\*)|\\#(+)|\\.(+)|\\[\\s*(+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|:+(+)(?:\\((?:(?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+))\\))?)" .replace(//, '[' + escaperegexp(">+~`!@$%^&={}\\;/g, '(?:[\\w\\u00a1-\\uffff-]|\\\\[^\\s0-9a-f])') .replace(//g, '(?:[:\\w\\u00a1-\\uffff-]|\\\\[^\\s0-9a-f])') ); function parser( rawmatch, separator, combinator, combinatorchildren, tagname, id, classname, attributekey, attributeoperator, attributequote, attributevalue, pseudoclass, pseudoquote, pseudoclassquotedvalue, pseudoclassvalue ){ if (separator || separatorindex === -1){ parsed.expressions[++separatorindex] = []; combinatorindex = -1; if (separator) return ''; } if (combinator || combinatorchildren || combinatorindex === -1){ combinator = combinator || ' '; var currentseparator = parsed.expressions[separatorindex]; if (reversed && currentseparator[combinatorindex]) currentseparator[combinatorindex].reversecombinator = reversecombinator(combinator); currentseparator[++combinatorindex] = {combinator: combinator, tag: '*'}; } var currentparsed = parsed.expressions[separatorindex][combinatorindex]; if (tagname){ currentparsed.tag = tagname.replace(reunescape, ''); } else if (id){ currentparsed.id = id.replace(reunescape, ''); } else if (classname){ classname = classname.replace(reunescape, ''); if (!currentparsed.classlist) currentparsed.classlist = []; if (!currentparsed.classes) currentparsed.classes = []; currentparsed.classlist.push(classname); currentparsed.classes.push({ value: classname, regexp: new regexp('(^|\\s)' + escaperegexp(classname) + '(\\s|$)') }); } else if (pseudoclass){ pseudoclassvalue = pseudoclassvalue || pseudoclassquotedvalue; pseudoclassvalue = pseudoclassvalue ? pseudoclassvalue.replace(reunescape, '') : null; if (!currentparsed.pseudos) currentparsed.pseudos = []; currentparsed.pseudos.push({ key: pseudoclass.replace(reunescape, ''), value: pseudoclassvalue }); } else if (attributekey){ attributekey = attributekey.replace(reunescape, ''); attributevalue = (attributevalue || '').replace(reunescape, ''); var test, regexp; switch (attributeoperator){ case '^=' : regexp = new regexp( '^'+ escaperegexp(attributevalue) ); break; case '$=' : regexp = new regexp( escaperegexp(attributevalue) +'$' ); break; case '~=' : regexp = new regexp( '(^|\\s)'+ escaperegexp(attributevalue) +'(\\s|$)' ); break; case '|=' : regexp = new regexp( '^'+ escaperegexp(attributevalue) +'(-|$)' ); break; case '=' : test = function(value){ return attributevalue == value; }; break; case '*=' : test = function(value){ return value && value.indexof(attributevalue) > -1; }; break; case '!=' : test = function(value){ return attributevalue != value; }; break; default : test = function(value){ return !!value; }; } if (attributevalue == '' && (/^[*$^]=$/).test(attributeoperator)) test = function(){ return false; }; if (!test) test = function(value){ return value && regexp.test(value); }; if (!currentparsed.attributes) currentparsed.attributes = []; currentparsed.attributes.push({ key: attributekey, operator: attributeoperator, value: attributevalue, test: test }); } return ''; }; // slick ns var slick = (this.slick || {}); slick.parse = function(expression){ return parse(expression); }; slick.escaperegexp = escaperegexp; if (!this.slick) this.slick = slick; }).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); /* --- name: slick.finder description: the new, superfast css selector engine. provides: slick.finder requires: slick.parser ... */ (function(){ var local = {}; // feature / bug detection local.isnativecode = function(fn){ return (/\{\s*\[native code\]\s*\}/).test('' + fn); }; local.isxml = function(document){ return (!!document.xmlversion) || (!!document.xml) || (object.prototype.tostring.call(document) === '[object xmldocument]') || (document.nodetype === 9 && document.documentelement.nodename !== 'html'); }; local.setdocument = function(document){ // convert elements / window arguments to document. if document cannot be extrapolated, the function returns. if (document.nodetype === 9); // document else if (document.ownerdocument) document = document.ownerdocument; // node else if (document.navigator) document = document.document; // window else return; // check if it's the old document if (this.document === document) return; this.document = document; var root = this.root = document.documentelement; this.isxmldocument = this.isxml(document); this.brokenstargebtn = this.starselectsclosedqsa = this.idgetsname = this.brokenmixedcaseqsa = this.brokengebcn = this.brokencheckedqsa = this.brokenemptyattributeqsa = this.ishtmldocument = false; var starselectsclosed, starselectscomments, brokensecondclassnamegebcn, cachedgetelementsbyclassname; var selected, id; var testnode = document.createelement('div'); root.appendchild(testnode); // on non-html documents innerhtml and getelementsbyid doesnt work properly try { id = 'slick_getbyid_test'; testnode.innerhtml = ''; this.ishtmldocument = !!document.getelementbyid(id); } catch(e){}; if (this.ishtmldocument){ testnode.style.display = 'none'; // ie returns comment nodes for getelementsbytagname('*') for some documents testnode.appendchild(document.createcomment('')); starselectscomments = (testnode.getelementsbytagname('*').length > 0); // ie returns closed nodes (eg:"") for getelementsbytagname('*') for some documents try { testnode.innerhtml = 'foo'; selected = testnode.getelementsbytagname('*'); starselectsclosed = (selected && selected.length && selected[0].nodename.charat(0) == '/'); } catch(e){}; this.brokenstargebtn = starselectscomments || starselectsclosed; // ie 8 returns closed nodes (eg:"") for queryselectorall('*') for some documents if (testnode.queryselectorall) try { testnode.innerhtml = 'foo'; selected = testnode.queryselectorall('*'); this.starselectsclosedqsa = (selected && selected.length && selected[0].nodename.charat(0) == '/'); } catch(e){}; // ie returns elements with the name instead of just id for getelementsbyid for some documents try { id = 'slick_id_gets_name'; testnode.innerhtml = ''; this.idgetsname = document.getelementbyid(id) === testnode.firstchild; } catch(e){}; // safari 3.2 queryselectorall doesnt work with mixedcase on quirksmode try { testnode.innerhtml = ''; this.brokenmixedcaseqsa = !testnode.queryselectorall('.mixedcase').length; } catch(e){}; try { testnode.innerhtml = ''; testnode.getelementsbyclassname('b').length; testnode.firstchild.classname = 'b'; cachedgetelementsbyclassname = (testnode.getelementsbyclassname('b').length != 2); } catch(e){}; // opera 9.6 getelementsbyclassname doesnt detects the class if its not the first one try { testnode.innerhtml = ''; brokensecondclassnamegebcn = (testnode.getelementsbyclassname('a').length != 2); } catch(e){}; this.brokengebcn = cachedgetelementsbyclassname || brokensecondclassnamegebcn; // webkit dont return selected options on queryselectorall try { testnode.innerhtml = ''; this.brokencheckedqsa = (testnode.queryselectorall(':checked').length == 0); } catch(e){}; // ie returns incorrect results for attr[*^$]="" selectors on queryselectorall try { testnode.innerhtml = ''; this.brokenemptyattributeqsa = (testnode.queryselectorall('[class*=""]').length != 0); } catch(e){}; } root.removechild(testnode); testnode = null; // hasattribute this.hasattribute = (root && this.isnativecode(root.hasattribute)) ? function(node, attribute) { return node.hasattribute(attribute); } : function(node, attribute) { node = node.getattributenode(attribute); return !!(node && (node.specified || node.nodevalue)); }; // contains // fixme: add specs: local.contains should be different for xml and html documents? this.contains = (root && this.isnativecode(root.contains)) ? function(context, node){ return context.contains(node); } : (root && root.comparedocumentposition) ? function(context, node){ return context === node || !!(context.comparedocumentposition(node) & 16); } : function(context, node){ if (node) do { if (node === context) return true; } while ((node = node.parentnode)); return false; }; // document order sorting // credits to sizzle (http://sizzlejs.com/) this.documentsorter = (root.comparedocumentposition) ? function(a, b){ if (!a.comparedocumentposition || !b.comparedocumentposition) return 0; return a.comparedocumentposition(b) & 4 ? -1 : a === b ? 0 : 1; } : ('sourceindex' in root) ? function(a, b){ if (!a.sourceindex || !b.sourceindex) return 0; return a.sourceindex - b.sourceindex; } : (document.createrange) ? function(a, b){ if (!a.ownerdocument || !b.ownerdocument) return 0; var arange = a.ownerdocument.createrange(), brange = b.ownerdocument.createrange(); arange.setstart(a, 0); arange.setend(a, 0); brange.setstart(b, 0); brange.setend(b, 0); return arange.compareboundarypoints(range.start_to_end, brange); } : null ; this.getuid = (this.ishtmldocument) ? this.getuidhtml : this.getuidxml; }; // main method local.search = function(context, expression, append, first){ var found = this.found = (first) ? null : (append || []); // context checks if (!context) return found; // no context if (context.navigator) context = context.document; // convert the node from a window to a document else if (!context.nodetype) return found; // reject misc junk input // setup var parsed, i; var uniques = this.uniques = {}; if (this.document !== (context.ownerdocument || context)) this.setdocument(context); // should sort if there are nodes in append and if you pass multiple expressions. // should remove duplicates if append already has items var shoulduniques = !!(append && append.length); // avoid duplicating items already in the append array if (shoulduniques) for (i = found.length; i--;) this.uniques[this.getuid(found[i])] = true; // expression checks if (typeof expression == 'string'){ // expression is a string // overrides for (i = this.overrides.length; i--;){ var override = this.overrides[i]; if (override.regexp.test(expression)){ var result = override.method.call(context, expression, found, first); if (result === false) continue; if (result === true) return found; return result; } } parsed = this.slick.parse(expression); if (!parsed.length) return found; } else if (expression == null){ // there is no expression return found; } else if (expression.slick){ // expression is a parsed slick object parsed = expression; } else if (this.contains(context.documentelement || context, expression)){ // expression is a node (found) ? found.push(expression) : found = expression; return found; } else { // other junk return found; } // cache elements for the nth selectors /**//**/ this.posnth = {}; this.posnthlast = {}; this.posnthtype = {}; this.posnthtypelast = {}; /**//**/ // if append is null and there is only a single selector with one expression use pusharray, else use pushuid this.push = (!shoulduniques && (first || (parsed.length == 1 && parsed.expressions[0].length == 1))) ? this.pusharray : this.pushuid; if (found == null) found = []; // default engine var j, m, n; var combinator, tag, id, classlist, classes, attributes, pseudos; var currentitems, currentexpression, currentbit, lastbit, expressions = parsed.expressions; search: for (i = 0; (currentexpression = expressions[i]); i++) for (j = 0; (currentbit = currentexpression[j]); j++){ combinator = 'combinator:' + currentbit.combinator; if (!this[combinator]) continue search; tag = (this.isxmldocument) ? currentbit.tag : currentbit.tag.touppercase(); id = currentbit.id; classlist = currentbit.classlist; classes = currentbit.classes; attributes = currentbit.attributes; pseudos = currentbit.pseudos; lastbit = (j === (currentexpression.length - 1)); this.bituniques = {}; if (lastbit){ this.uniques = uniques; this.found = found; } else { this.uniques = {}; this.found = []; } if (j === 0){ this[combinator](context, tag, id, classes, attributes, pseudos, classlist); if (first && lastbit && found.length) break search; } else { if (first && lastbit) for (m = 0, n = currentitems.length; m < n; m++){ this[combinator](currentitems[m], tag, id, classes, attributes, pseudos, classlist); if (found.length) break search; } else for (m = 0, n = currentitems.length; m < n; m++) this[combinator](currentitems[m], tag, id, classes, attributes, pseudos, classlist); } currentitems = this.found; } if (shoulduniques || (parsed.expressions.length > 1)) this.sort(found); return (first) ? (found[0] || null) : found; }; // utils local.uidx = 1; local.uidk = 'slick:uniqueid'; local.getuidxml = function(node){ var uid = node.getattribute(this.uidk); if (!uid){ uid = this.uidx++; node.setattribute(this.uidk, uid); } return uid; }; local.getuidhtml = function(node){ return node.uniquenumber || (node.uniquenumber = this.uidx++); }; // sort based on the setdocument documentsorter method. local.sort = function(results){ if (!this.documentsorter) return results; results.sort(this.documentsorter); return results; }; /**//**/ local.cachenth = {}; local.matchnth = /^([+-]?\d*)?([a-z]+)?([+-]\d+)?$/; local.parsenthargument = function(argument){ var parsed = argument.match(this.matchnth); if (!parsed) return false; var special = parsed[2] || false; var a = parsed[1] || 1; if (a == '-') a = -1; var b = +parsed[3] || 0; parsed = (special == 'n') ? {a: a, b: b} : (special == 'odd') ? {a: 2, b: 1} : (special == 'even') ? {a: 2, b: 0} : {a: 0, b: a}; return (this.cachenth[argument] = parsed); }; local.createnthpseudo = function(child, sibling, positions, oftype){ return function(node, argument){ var uid = this.getuid(node); if (!this[positions][uid]){ var parent = node.parentnode; if (!parent) return false; var el = parent[child], count = 1; if (oftype){ var nodename = node.nodename; do { if (el.nodename !== nodename) continue; this[positions][this.getuid(el)] = count++; } while ((el = el[sibling])); } else { do { if (el.nodetype !== 1) continue; this[positions][this.getuid(el)] = count++; } while ((el = el[sibling])); } } argument = argument || 'n'; var parsed = this.cachenth[argument] || this.parsenthargument(argument); if (!parsed) return false; var a = parsed.a, b = parsed.b, pos = this[positions][uid]; if (a == 0) return b == pos; if (a > 0){ if (pos < b) return false; } else { if (b < pos) return false; } return ((pos - b) % a) == 0; }; }; /**//**/ local.pusharray = function(node, tag, id, classes, attributes, pseudos){ if (this.matchselector(node, tag, id, classes, attributes, pseudos)) this.found.push(node); }; local.pushuid = function(node, tag, id, classes, attributes, pseudos){ var uid = this.getuid(node); if (!this.uniques[uid] && this.matchselector(node, tag, id, classes, attributes, pseudos)){ this.uniques[uid] = true; this.found.push(node); } }; local.matchnode = function(node, selector){ var parsed = this.slick.parse(selector); if (!parsed) return true; // simple (single) selectors if(parsed.length == 1 && parsed.expressions[0].length == 1){ var exp = parsed.expressions[0][0]; return this.matchselector(node, (this.isxmldocument) ? exp.tag : exp.tag.touppercase(), exp.id, exp.classes, exp.attributes, exp.pseudos); } var nodes = this.search(this.document, parsed); for (var i = 0, item; item = nodes[i++];){ if (item === node) return true; } return false; }; local.matchpseudo = function(node, name, argument){ var pseudoname = 'pseudo:' + name; if (this[pseudoname]) return this[pseudoname](node, argument); var attribute = this.getattribute(node, name); return (argument) ? argument == attribute : !!attribute; }; local.matchselector = function(node, tag, id, classes, attributes, pseudos){ if (tag){ if (tag == '*'){ if (node.nodename < '@') return false; // fix for comment nodes and closed nodes } else { if (node.nodename != tag) return false; } } if (id && node.getattribute('id') != id) return false; var i, part, cls; if (classes) for (i = classes.length; i--;){ cls = ('classname' in node) ? node.classname : node.getattribute('class'); if (!(cls && classes[i].regexp.test(cls))) return false; } if (attributes) for (i = attributes.length; i--;){ part = attributes[i]; if (part.operator ? !part.test(this.getattribute(node, part.key)) : !this.hasattribute(node, part.key)) return false; } if (pseudos) for (i = pseudos.length; i--;){ part = pseudos[i]; if (!this.matchpseudo(node, part.key, part.value)) return false; } return true; }; var combinators = { ' ': function(node, tag, id, classes, attributes, pseudos, classlist){ // all child nodes, any level var i, item, children; if (this.ishtmldocument){ getbyid: if (id){ item = this.document.getelementbyid(id); if ((!item && node.all) || (this.idgetsname && item && item.getattributenode('id').nodevalue != id)){ // all[id] returns all the elements with that name or id inside node // if theres just one it will return the element, else it will be a collection children = node.all[id]; if (!children) return; if (!children[0]) children = [children]; for (i = 0; item = children[i++];) if (item.getattributenode('id').nodevalue == id){ this.push(item, tag, null, classes, attributes, pseudos); break; } return; } if (!item){ // if the context is in the dom we return, else we will try gebtn, breaking the getbyid label if (this.contains(this.document.documentelement, node)) return; else break getbyid; } else if (this.document !== node && !this.contains(node, item)) return; this.push(item, tag, null, classes, attributes, pseudos); return; } getbyclass: if (classes && node.getelementsbyclassname && !this.brokengebcn){ children = node.getelementsbyclassname(classlist.join(' ')); if (!(children && children.length)) break getbyclass; for (i = 0; item = children[i++];) this.push(item, tag, id, null, attributes, pseudos); return; } } getbytag: { children = node.getelementsbytagname(tag); if (!(children && children.length)) break getbytag; if (!this.brokenstargebtn) tag = null; for (i = 0; item = children[i++];) this.push(item, tag, id, classes, attributes, pseudos); } }, '>': function(node, tag, id, classes, attributes, pseudos){ // direct children if ((node = node.firstchild)) do { if (node.nodetype === 1) this.push(node, tag, id, classes, attributes, pseudos); } while ((node = node.nextsibling)); }, '+': function(node, tag, id, classes, attributes, pseudos){ // next sibling while ((node = node.nextsibling)) if (node.nodetype === 1){ this.push(node, tag, id, classes, attributes, pseudos); break; } }, '^': function(node, tag, id, classes, attributes, pseudos){ // first child node = node.firstchild; if (node){ if (node.nodetype === 1) this.push(node, tag, id, classes, attributes, pseudos); else this['combinator:+'](node, tag, id, classes, attributes, pseudos); } }, '~': function(node, tag, id, classes, attributes, pseudos){ // next siblings while ((node = node.nextsibling)){ if (node.nodetype !== 1) continue; var uid = this.getuid(node); if (this.bituniques[uid]) break; this.bituniques[uid] = true; this.push(node, tag, id, classes, attributes, pseudos); } }, '++': function(node, tag, id, classes, attributes, pseudos){ // next sibling and previous sibling this['combinator:+'](node, tag, id, classes, attributes, pseudos); this['combinator:!+'](node, tag, id, classes, attributes, pseudos); }, '~~': function(node, tag, id, classes, attributes, pseudos){ // next siblings and previous siblings this['combinator:~'](node, tag, id, classes, attributes, pseudos); this['combinator:!~'](node, tag, id, classes, attributes, pseudos); }, '!': function(node, tag, id, classes, attributes, pseudos){ // all parent nodes up to document while ((node = node.parentnode)) if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos); }, '!>': function(node, tag, id, classes, attributes, pseudos){ // direct parent (one level) node = node.parentnode; if (node !== this.document) this.push(node, tag, id, classes, attributes, pseudos); }, '!+': function(node, tag, id, classes, attributes, pseudos){ // previous sibling while ((node = node.previoussibling)) if (node.nodetype === 1){ this.push(node, tag, id, classes, attributes, pseudos); break; } }, '!^': function(node, tag, id, classes, attributes, pseudos){ // last child node = node.lastchild; if (node){ if (node.nodetype === 1) this.push(node, tag, id, classes, attributes, pseudos); else this['combinator:!+'](node, tag, id, classes, attributes, pseudos); } }, '!~': function(node, tag, id, classes, attributes, pseudos){ // previous siblings while ((node = node.previoussibling)){ if (node.nodetype !== 1) continue; var uid = this.getuid(node); if (this.bituniques[uid]) break; this.bituniques[uid] = true; this.push(node, tag, id, classes, attributes, pseudos); } } }; for (var c in combinators) local['combinator:' + c] = combinators[c]; var pseudos = { /**/ 'empty': function(node){ var child = node.firstchild; return !(child && child.nodetype == 1) && !(node.innertext || node.textcontent || '').length; }, 'not': function(node, expression){ return !this.matchnode(node, expression); }, 'contains': function(node, text){ return (node.innertext || node.textcontent || '').indexof(text) > -1; }, 'first-child': function(node){ while ((node = node.previoussibling)) if (node.nodetype === 1) return false; return true; }, 'last-child': function(node){ while ((node = node.nextsibling)) if (node.nodetype === 1) return false; return true; }, 'only-child': function(node){ var prev = node; while ((prev = prev.previoussibling)) if (prev.nodetype === 1) return false; var next = node; while ((next = next.nextsibling)) if (next.nodetype === 1) return false; return true; }, /**/ 'nth-child': local.createnthpseudo('firstchild', 'nextsibling', 'posnth'), 'nth-last-child': local.createnthpseudo('lastchild', 'previoussibling', 'posnthlast'), 'nth-of-type': local.createnthpseudo('firstchild', 'nextsibling', 'posnthtype', true), 'nth-last-of-type': local.createnthpseudo('lastchild', 'previoussibling', 'posnthtypelast', true), 'index': function(node, index){ return this['pseudo:nth-child'](node, '' + index + 1); }, 'even': function(node, argument){ return this['pseudo:nth-child'](node, '2n'); }, 'odd': function(node, argument){ return this['pseudo:nth-child'](node, '2n+1'); }, /**/ /**/ 'first-of-type': function(node){ var nodename = node.nodename; while ((node = node.previoussibling)) if (node.nodename === nodename) return false; return true; }, 'last-of-type': function(node){ var nodename = node.nodename; while ((node = node.nextsibling)) if (node.nodename === nodename) return false; return true; }, 'only-of-type': function(node){ var prev = node, nodename = node.nodename; while ((prev = prev.previoussibling)) if (prev.nodename === nodename) return false; var next = node; while ((next = next.nextsibling)) if (next.nodename === nodename) return false; return true; }, /**/ // custom pseudos 'enabled': function(node){ return (node.disabled === false); }, 'disabled': function(node){ return (node.disabled === true); }, 'checked': function(node){ return node.checked || node.selected; }, 'focus': function(node){ return this.ishtmldocument && this.document.activeelement === node && (node.href || node.type || this.hasattribute(node, 'tabindex')); }, 'root': function(node){ return (node === this.root); }, 'selected': function(node){ return node.selected; } /**/ }; for (var p in pseudos) local['pseudo:' + p] = pseudos[p]; // attributes methods local.attributegetters = { 'class': function(){ return ('classname' in this) ? this.classname : this.getattribute('class'); }, 'for': function(){ return ('htmlfor' in this) ? this.htmlfor : this.getattribute('for'); }, 'href': function(){ return ('href' in this) ? this.getattribute('href', 2) : this.getattribute('href'); }, 'style': function(){ return (this.style) ? this.style.csstext : this.getattribute('style'); } }; local.getattribute = function(node, name){ // fixme: check if getattribute() will get input elements on a form on this browser // getattribute is faster than getattributenode().nodevalue var method = this.attributegetters[name]; if (method) return method.call(node); var attributenode = node.getattributenode(name); return attributenode ? attributenode.nodevalue : null; }; // overrides local.overrides = []; local.override = function(regexp, method){ this.overrides.push({regexp: regexp, method: method}); }; /**/ /**/ var reemptyattribute = /\[.*[*$^]=(?:["']{2})?\]/; local.override(/./, function(expression, found, first){ //queryselectorall override if (!this.queryselectorall || this.nodetype != 9 || !local.ishtmldocument || local.brokenmixedcaseqsa || (local.brokencheckedqsa && expression.indexof(':checked') > -1) || (local.brokenemptyattributeqsa && reemptyattribute.test(expression)) || slick.disableqsa) return false; var nodes, node; try { if (first) return this.queryselector(expression) || null; else nodes = this.queryselectorall(expression); } catch(error){ return false; } var i, hasothers = !!(found.length); if (local.starselectsclosedqsa) for (i = 0; node = nodes[i++];){ if (node.nodename > '@' && (!hasothers || !local.uniques[local.getuidhtml(node)])) found.push(node); } else for (i = 0; node = nodes[i++];){ if (!hasothers || !local.uniques[local.getuidhtml(node)]) found.push(node); } if (hasothers) local.sort(found); return true; }); /**/ /**/ local.override(/^[\w-]+$|^\*$/, function(expression, found, first){ // tag override var tag = expression; if (tag == '*' && local.brokenstargebtn) return false; var nodes = this.getelementsbytagname(tag); if (first) return nodes[0] || null; var i, node, hasothers = !!(found.length); for (i = 0; node = nodes[i++];){ if (!hasothers || !local.uniques[local.getuid(node)]) found.push(node); } if (hasothers) local.sort(found); return true; }); /**/ /**/ local.override(/^\.[\w-]+$/, function(expression, found, first){ // class override if (!local.ishtmldocument || (!this.getelementsbyclassname && this.queryselectorall)) return false; var nodes, node, i, hasothers = !!(found && found.length), classname = expression.substring(1); if (this.getelementsbyclassname && !local.brokengebcn){ nodes = this.getelementsbyclassname(classname); if (first) return nodes[0] || null; for (i = 0; node = nodes[i++];){ if (!hasothers || !local.uniques[local.getuidhtml(node)]) found.push(node); } } else { var matchclass = new regexp('(^|\\s)'+ slick.escaperegexp(classname) +'(\\s|$)'); nodes = this.getelementsbytagname('*'); for (i = 0; node = nodes[i++];){ classname = node.classname; if (!classname || !matchclass.test(classname)) continue; if (first) return node; if (!hasothers || !local.uniques[local.getuidhtml(node)]) found.push(node); } } if (hasothers) local.sort(found); return (first) ? null : true; }); /**/ /**/ local.override(/^#[\w-]+$/, function(expression, found, first){ // id override if (!local.ishtmldocument || this.nodetype != 9) return false; var id = expression.substring(1), el = this.getelementbyid(id); if (!el) return found; if (local.idgetsname && el.getattributenode('id').nodevalue != id) return false; if (first) return el || null; var hasothers = !!(found.length); if (!hasothers || !local.uniques[local.getuidhtml(el)]) found.push(el); if (hasothers) local.sort(found); return true; }); /**/ /**/ if (typeof document != 'undefined') local.setdocument(document); // slick var slick = local.slick = (this.slick || {}); slick.version = '0.9dev'; // slick finder slick.search = function(context, expression, append){ return local.search(context, expression, append); }; slick.find = function(context, expression){ return local.search(context, expression, null, true); }; // slick containment checker slick.contains = function(container, node){ local.setdocument(container); return local.contains(container, node); }; // slick attribute getter slick.getattribute = function(node, name){ return local.getattribute(node, name); }; // slick matcher slick.match = function(node, selector){ if (!(node && selector)) return false; if (!selector || selector === node) return true; if (typeof selector != 'string') return false; local.setdocument(node); return local.matchnode(node, selector); }; // slick attribute accessor slick.defineattributegetter = function(name, fn){ local.attributegetters[name] = fn; return this; }; slick.lookupattributegetter = function(name){ return local.attributegetters[name]; }; // slick pseudo accessor slick.definepseudo = function(name, fn){ local['pseudo:' + name] = function(node, argument){ return fn.call(node, argument); }; return this; }; slick.lookuppseudo = function(name){ var pseudo = local['pseudo:' + name]; if (pseudo) return function(argument){ return pseudo.call(this, argument); }; return null; }; // slick overrides accessor slick.override = function(regexp, fn){ local.override(regexp, fn); return this; }; slick.isxml = local.isxml; slick.uidof = function(node){ return local.getuidhtml(node); }; if (!this.slick) this.slick = slick; }).apply(/**/(typeof exports != 'undefined') ? exports : /**/this); /* --- name: element 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. license: mit-style license. requires: [window, document, array, string, function, number, slick.parser, slick.finder] provides: [element, elements, $, $$, iframe, selectors] ... */ var element = function(tag, props){ var konstructor = element.constructors[tag]; if (konstructor) return konstructor(props); if (typeof tag != 'string') return document.id(tag).set(props); if (!props) props = {}; if (!tag.test(/^[\w-]+$/)){ var parsed = slick.parse(tag).expressions[0][0]; tag = (parsed.tag == '*') ? 'div' : parsed.tag; if (parsed.id && props.id == null) props.id = parsed.id; var attributes = parsed.attributes; if (attributes) for (var i = 0, l = attributes.length; i < l; i++){ var attr = attributes[i]; if (attr.value != null && attr.operator == '=' && props[attr.key] == null) props[attr.key] = attr.value; } if (parsed.classlist && props['class'] == null) props['class'] = parsed.classlist.join(' '); } return document.newelement(tag, props); }; if (browser.element) element.prototype = browser.element.prototype; new type('element', element).mirror(function(name){ if (array.prototype[name]) return; var obj = {}; obj[name] = function(){ var results = [], args = arguments, elements = true; for (var i = 0, l = this.length; i < l; i++){ var element = this[i], result = results[i] = element[name].apply(element, args); elements = (elements && typeof(result) == 'element'); } return (elements) ? new elements(results) : results; }; elements.implement(obj); }); if (!browser.element){ element.parent = object; element.prototype = {'$family': function.from('element').hide()}; element.mirror(function(name, method){ element.prototype[name] = method; }); } element.constructors = {}; //<1.2compat> element.constructors = new hash; // var iframe = new type('iframe', function(){ var params = array.link(arguments, { properties: type.isobject, iframe: function(obj){ return (obj != null); } }); var props = params.properties || {}, iframe; if (params.iframe) iframe = document.id(params.iframe); var onload = props.onload || function(){}; delete props.onload; props.id = props.name = [props.id, props.name, iframe ? (iframe.id || iframe.name) : 'iframe_' + string.uniqueid()].pick(); iframe = new element(iframe || 'iframe', props); var onload = function(){ onload.call(iframe.contentwindow); }; if (window.frames[props.id]) onload(); else iframe.addlistener('load', onload); return iframe; }); var elements = this.elements = function(nodes){ if (nodes && nodes.length){ var uniques = {}, node; for (var i = 0; node = nodes[i++];){ var uid = slick.uidof(node); if (!uniques[uid]){ uniques[uid] = true; this.push(node); } } } }; elements.prototype = {length: 0}; elements.parent = array; new type('elements', elements).implement({ filter: function(filter, bind){ if (!filter) return this; return new elements(array.filter(this, (typeof(filter) == 'string') ? function(item){ return item.match(filter); } : filter, bind)); }.protect(), push: function(){ var length = this.length; for (var i = 0, l = arguments.length; i < l; i++){ var item = document.id(arguments[i]); if (item) this[length++] = item; } return (this.length = length); }.protect(), concat: function(){ var newelements = new elements(this); for (var i = 0, l = arguments.length; i < l; i++){ var item = arguments[i]; if (type.isenumerable(item)) newelements.append(item); else newelements.push(item); } return newelements; }.protect(), append: function(collection){ for (var i = 0, l = collection.length; i < l; i++) this.push(collection[i]); return this; }.protect(), empty: function(){ while (this.length) delete this[--this.length]; return this; }.protect() }); (function(){ // ff, ie var splice = array.prototype.splice, object = {'0': 0, '1': 1, length: 2}; splice.call(object, 1, 1); if (object[1] == 1) elements.implement('splice', function(){ var length = this.length; splice.apply(this, arguments); while (length >= this.length) delete this[length--]; return this; }.protect()); elements.implement(array.prototype); array.mirror(elements); /**/ var createelementacceptshtml; try { var x = document.createelement(''); createelementacceptshtml = (x.name == 'x'); } catch(e){} var escapequotes = function(html){ return ('' + html).replace(/&/g, '&').replace(/"/g, '"'); }; /**/ document.implement({ newelement: function(tag, props){ if (props && props.checked != null) props.defaultchecked = props.checked; /**/// fix for readonly name and type properties in ie < 8 if (createelementacceptshtml && props){ tag = '<' + tag; if (props.name) tag += ' name="' + escapequotes(props.name) + '"'; if (props.type) tag += ' type="' + escapequotes(props.type) + '"'; tag += '>'; delete props.name; delete props.type; } /**/ return this.id(this.createelement(tag)).set(props); } }); })(); document.implement({ newtextnode: function(text){ return this.createtextnode(text); }, getdocument: function(){ return this; }, getwindow: function(){ return this.window; }, id: (function(){ var types = { string: function(id, nocash, doc){ id = slick.find(doc, '#' + id.replace(/(\w)/g, '\\$1')); return (id) ? types.element(id, nocash) : null; }, element: function(el, nocash){ $uid(el); if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagname)){ object.append(el, element.prototype); } return el; }, object: function(obj, nocash, doc){ if (obj.toelement) return types.element(obj.toelement(doc), nocash); return null; } }; types.textnode = types.whitespace = types.window = types.document = function(zero){ return zero; }; return function(el, nocash, doc){ if (el && el.$family && el.uid) return el; var type = typeof(el); return (types[type]) ? types[type](el, nocash, doc || document) : null; }; })() }); if (window.$ == null) window.implement('$', function(el, nc){ return document.id(el, nc, this.document); }); window.implement({ getdocument: function(){ return this.document; }, getwindow: function(){ return this; } }); [document, element].invoke('implement', { getelements: function(expression){ return slick.search(this, expression, new elements); }, getelement: function(expression){ return document.id(slick.find(this, expression)); } }); //<1.2compat> (function(search, find, match){ this.selectors = {}; var pseudos = this.selectors.pseudo = new hash(); var addslickpseudos = function(){ for (var name in pseudos) if (pseudos.hasownproperty(name)){ slick.definepseudo(name, pseudos[name]); delete pseudos[name]; } }; slick.search = function(context, expression, append){ addslickpseudos(); return search.call(this, context, expression, append); }; slick.find = function(context, expression){ addslickpseudos(); return find.call(this, context, expression); }; slick.match = function(node, selector){ addslickpseudos(); return match.call(this, node, selector); }; })(slick.search, slick.find, slick.match); if (window.$$ == null) window.implement('$$', function(selector){ var elements = new elements; if (arguments.length == 1 && typeof selector == 'string') return slick.search(this.document, selector, elements); var args = array.flatten(arguments); for (var i = 0, l = args.length; i < l; i++){ var item = args[i]; switch (typeof(item)){ case 'element': elements.push(item); break; case 'string': slick.search(this.document, item, elements); } } return elements; }); // if (window.$$ == null) window.implement('$$', function(selector){ if (arguments.length == 1){ if (typeof selector == 'string') return slick.search(this.document, selector, new elements); else if (type.isenumerable(selector)) return new elements(selector); } return new elements(arguments); }); (function(){ var collected = {}, storage = {}; var props = {input: 'checked', option: 'selected', textarea: 'value'}; var get = function(uid){ return (storage[uid] || (storage[uid] = {})); }; var clean = function(item){ if (item.removeevents) item.removeevents(); if (item.clearattributes) item.clearattributes(); var uid = item.uid; if (uid != null){ delete collected[uid]; delete storage[uid]; } return item; }; var camels = ['defaultvalue', 'accesskey', 'cellpadding', 'cellspacing', 'colspan', 'frameborder', 'maxlength', 'readonly', 'rowspan', 'tabindex', 'usemap' ]; var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer' ]; var attributes = { 'html': 'innerhtml', 'class': 'classname', 'for': 'htmlfor', 'text': (function(){ var temp = document.createelement('div'); return (temp.innertext == null) ? 'textcontent' : 'innertext'; })() }; var readonly = ['type']; var expandos = ['value', 'defaultvalue']; var uriattrs = /^(?:href|src|usemap)$/i; bools = bools.associate(bools); camels = camels.associate(camels.map(string.tolowercase)); readonly = readonly.associate(readonly); object.append(attributes, expandos.associate(expandos)); var inserters = { before: function(context, element){ var parent = element.parentnode; if (parent) parent.insertbefore(context, element); }, after: function(context, element){ var parent = element.parentnode; if (parent) parent.insertbefore(context, element.nextsibling); }, bottom: function(context, element){ element.appendchild(context); }, top: function(context, element){ element.insertbefore(context, element.firstchild); } }; inserters.inside = inserters.bottom; //<1.2compat> object.each(inserters, function(inserter, where){ where = where.capitalize(); var methods = {}; methods['inject' + where] = function(el){ inserter(this, document.id(el, true)); return this; }; methods['grab' + where] = function(el){ inserter(document.id(el, true), this); return this; }; element.implement(methods); }); // var injectcombinator = function(expression, combinator){ if (!expression) return combinator; expression = slick.parse(expression); var expressions = expression.expressions; for (var i = expressions.length; i--;) expressions[i][0].combinator = combinator; return expression; }; element.implement({ set: function(prop, value){ var property = element.properties[prop]; (property && property.set) ? property.set.call(this, value) : this.setproperty(prop, value); }.overloadsetter(), get: function(prop){ var property = element.properties[prop]; return (property && property.get) ? property.get.apply(this) : this.getproperty(prop); }.overloadgetter(), erase: function(prop){ var property = element.properties[prop]; (property && property.erase) ? property.erase.apply(this) : this.removeproperty(prop); return this; }, setproperty: function(attribute, value){ attribute = camels[attribute] || attribute; if (value == null) return this.removeproperty(attribute); var key = attributes[attribute]; (key) ? this[key] = value : (bools[attribute]) ? this[attribute] = !!value : this.setattribute(attribute, '' + value); return this; }, setproperties: function(attributes){ for (var attribute in attributes) this.setproperty(attribute, attributes[attribute]); return this; }, getproperty: function(attribute){ attribute = camels[attribute] || attribute; var key = attributes[attribute] || readonly[attribute]; return (key) ? this[key] : (bools[attribute]) ? !!this[attribute] : (uriattrs.test(attribute) ? this.getattribute(attribute, 2) : (key = this.getattributenode(attribute)) ? key.nodevalue : null) || null; }, getproperties: function(){ var args = array.from(arguments); return args.map(this.getproperty, this).associate(args); }, removeproperty: function(attribute){ attribute = camels[attribute] || attribute; var key = attributes[attribute]; (key) ? this[key] = '' : (bools[attribute]) ? this[attribute] = false : this.removeattribute(attribute); return this; }, removeproperties: function(){ array.each(arguments, this.removeproperty, this); return this; }, hasclass: function(classname){ return this.classname.clean().contains(classname, ' '); }, addclass: function(classname){ if (!this.hasclass(classname)) this.classname = (this.classname + ' ' + classname).clean(); return this; }, removeclass: function(classname){ this.classname = this.classname.replace(new regexp('(^|\\s)' + classname + '(?:\\s|$)'), '$1'); return this; }, toggleclass: function(classname, force){ if (force == null) force = !this.hasclass(classname); return (force) ? this.addclass(classname) : this.removeclass(classname); }, adopt: function(){ var parent = this, fragment, elements = array.flatten(arguments), length = elements.length; if (length > 1) parent = fragment = document.createdocumentfragment(); for (var i = 0; i < length; i++){ var element = document.id(elements[i], true); if (element) parent.appendchild(element); } if (fragment) this.appendchild(fragment); return this; }, appendtext: function(text, where){ return this.grab(this.getdocument().newtextnode(text), where); }, grab: function(el, where){ inserters[where || 'bottom'](document.id(el, true), this); return this; }, inject: function(el, where){ inserters[where || 'bottom'](this, document.id(el, true)); return this; }, replaces: function(el){ el = document.id(el, true); el.parentnode.replacechild(this, el); return this; }, wraps: function(el, where){ el = document.id(el, true); return this.replaces(el).grab(el, where); }, getprevious: function(expression){ return document.id(slick.find(this, injectcombinator(expression, '!~'))); }, getallprevious: function(expression){ return slick.search(this, injectcombinator(expression, '!~'), new elements); }, getnext: function(expression){ return document.id(slick.find(this, injectcombinator(expression, '~'))); }, getallnext: function(expression){ return slick.search(this, injectcombinator(expression, '~'), new elements); }, getfirst: function(expression){ return document.id(slick.search(this, injectcombinator(expression, '>'))[0]); }, getlast: function(expression){ return document.id(slick.search(this, injectcombinator(expression, '>')).getlast()); }, getparent: function(expression){ return document.id(slick.find(this, injectcombinator(expression, '!'))); }, getparents: function(expression){ return slick.search(this, injectcombinator(expression, '!'), new elements); }, getsiblings: function(expression){ return slick.search(this, injectcombinator(expression, '~~'), new elements); }, getchildren: function(expression){ return slick.search(this, injectcombinator(expression, '>'), new elements); }, getwindow: function(){ return this.ownerdocument.window; }, getdocument: function(){ return this.ownerdocument; }, getelementbyid: function(id){ return document.id(slick.find(this, '#' + ('' + id).replace(/(\w)/g, '\\$1'))); }, getselected: function(){ this.selectedindex; // safari 3.2.1 return new elements(array.from(this.options).filter(function(option){ return option.selected; })); }, toquerystring: function(){ var querystring = []; this.getelements('input, select, textarea').each(function(el){ var type = el.type; if (!el.name || el.disabled || type == 'submit' || type == 'reset' || type == 'file' || type == 'image') return; var value = (el.get('tag') == 'select') ? el.getselected().map(function(opt){ // ie return document.id(opt).get('value'); }) : ((type == 'radio' || type == 'checkbox') && !el.checked) ? null : el.get('value'); array.from(value).each(function(val){ if (typeof val != 'undefined') querystring.push(encodeuricomponent(el.name) + '=' + encodeuricomponent(val)); }); }); return querystring.join('&'); }, clone: function(contents, keepid){ contents = contents !== false; var clone = this.clonenode(contents); var clean = function(node, element){ if (!keepid) node.removeattribute('id'); if (browser.ie){ node.clearattributes(); node.mergeattributes(element); node.removeattribute('uid'); if (node.options){ var no = node.options, eo = element.options; for (var j = no.length; j--;) no[j].selected = eo[j].selected; } } var prop = props[element.tagname.tolowercase()]; if (prop && element[prop]) node[prop] = element[prop]; }; var i; if (contents){ var ce = clone.getelementsbytagname('*'), te = this.getelementsbytagname('*'); for (i = ce.length; i--;) clean(ce[i], te[i]); } clean(clone, this); if (browser.ie){ var ts = this.getelementsbytagname('object'), cs = clone.getelementsbytagname('object'), tl = ts.length, cl = cs.length; for (i = 0; i < tl && i < cl; i++) cs[i].outerhtml = ts[i].outerhtml; } return document.id(clone); }, destroy: function(){ var children = clean(this).getelementsbytagname('*'); array.each(children, clean); element.dispose(this); return null; }, empty: function(){ array.from(this.childnodes).each(element.dispose); return this; }, dispose: function(){ return (this.parentnode) ? this.parentnode.removechild(this) : this; }, match: function(expression){ return !expression || slick.match(this, expression); } }); var contains = {contains: function(element){ return slick.contains(this, element); }}; if (!document.contains) document.implement(contains); if (!document.createelement('div').contains) element.implement(contains); //<1.2compat> element.implement('haschild', function(element){ return this !== element && this.contains(element); }); // [element, window, document].invoke('implement', { addlistener: function(type, fn){ if (type == 'unload'){ var old = fn, self = this; fn = function(){ self.removelistener('unload', fn); old(); }; } else { collected[this.uid] = this; } if (this.addeventlistener) this.addeventlistener(type, fn, false); else this.attachevent('on' + type, fn); return this; }, removelistener: function(type, fn){ if (this.removeeventlistener) this.removeeventlistener(type, fn, false); else this.detachevent('on' + type, fn); return this; }, retrieve: function(property, dflt){ var storage = get(this.uid), prop = storage[property]; if (dflt != null && prop == null) prop = storage[property] = dflt; return prop != null ? prop : null; }, store: function(property, value){ var storage = get(this.uid); storage[property] = value; return this; }, eliminate: function(property){ var storage = get(this.uid); delete storage[property]; return this; } }); // ie purge if (window.attachevent && !window.addeventlistener) window.addlistener('unload', function(){ object.each(collected, clean); if (window.collectgarbage) collectgarbage(); }); })(); element.properties = {}; //<1.2compat> element.properties = new hash; // element.properties.style = { set: function(style){ this.style.csstext = style; }, get: function(){ return this.style.csstext; }, erase: function(){ this.style.csstext = ''; } }; element.properties.tag = { get: function(){ return this.tagname.tolowercase(); } }; (function(maxlength){ if (maxlength != null) element.properties.maxlength = element.properties.maxlength = { get: function(){ var maxlength = this.getattribute('maxlength'); return maxlength == maxlength ? null : maxlength; } }; })(document.createelement('input').getattribute('maxlength')); element.properties.html = (function(){ var tabletest = function.attempt(function(){ var table = document.createelement('table'); table.innerhtml = ''; }); var wrapper = document.createelement('div'); var translations = { table: [1, '', '
'], select: [1, ''], tbody: [2, '', '
'], tr: [3, '', '
'] }; translations.thead = translations.tfoot = translations.tbody; var html = { set: function(){ var html = array.flatten(arguments).join(''); var wrap = (!tabletest && translations[this.get('tag')]); if (wrap){ var first = wrapper; first.innerhtml = wrap[1] + html + wrap[2]; for (var i = wrap[0]; i--;) first = first.firstchild; this.empty().adopt(first.childnodes); } else { this.innerhtml = html; } } }; html.erase = html.set; return html; })(); /* --- name: element.style description: contains methods for interacting with the styles of elements in a fashionable way. license: mit-style license. requires: element provides: element.style ... */ (function(){ var html = document.html; element.properties.styles = {set: function(styles){ this.setstyles(styles); }}; var hasopacity = (html.style.opacity != null); var realpha = /alpha\(opacity=([\d.]+)\)/i; var setopacity = function(element, opacity){ if (!element.currentstyle || !element.currentstyle.haslayout) element.style.zoom = 1; if (hasopacity){ element.style.opacity = opacity; } else { opacity = (opacity == 1) ? '' : 'alpha(opacity=' + opacity * 100 + ')'; var filter = element.style.filter || element.getcomputedstyle('filter') || ''; element.style.filter = filter.test(realpha) ? filter.replace(realpha, opacity) : filter + opacity; } }; element.properties.opacity = { set: function(opacity){ var visibility = this.style.visibility; if (opacity == 0 && visibility != 'hidden') this.style.visibility = 'hidden'; else if (opacity != 0 && visibility != 'visible') this.style.visibility = 'visible'; setopacity(this, opacity); }, get: (hasopacity) ? function(){ var opacity = this.style.opacity || this.getcomputedstyle('opacity'); return (opacity == '') ? 1 : opacity; } : function(){ var opacity, filter = (this.style.filter || this.getcomputedstyle('filter')); if (filter) opacity = filter.match(realpha); return (opacity == null || filter == null) ? 1 : (opacity[1] / 100); } }; var floatname = (html.style.cssfloat == null) ? 'stylefloat' : 'cssfloat'; element.implement({ getcomputedstyle: function(property){ if (this.currentstyle) return this.currentstyle[property.camelcase()]; var defaultview = element.getdocument(this).defaultview, computed = defaultview ? defaultview.getcomputedstyle(this, null) : null; return (computed) ? computed.getpropertyvalue((property == floatname) ? 'float' : property.hyphenate()) : null; }, setopacity: function(value){ setopacity(this, value); return this; }, getopacity: function(){ return this.get('opacity'); }, setstyle: function(property, value){ switch (property){ case 'opacity': return this.set('opacity', parsefloat(value)); case 'float': property = floatname; } property = property.camelcase(); if (typeof(value) != 'string'){ var map = (element.styles[property] || '@').split(' '); value = array.from(value).map(function(val, i){ if (!map[i]) return ''; return (typeof(val) == 'number') ? map[i].replace('@', math.round(val)) : val; }).join(' '); } else if (value == string(number(value))){ value = math.round(value); } this.style[property] = value; return this; }, getstyle: function(property){ switch (property){ case 'opacity': return this.get('opacity'); case 'float': property = floatname; } property = property.camelcase(); var result = this.style[property]; if (!result || property == 'zindex'){ result = []; for (var style in element.shortstyles){ if (property != style) continue; for (var s in element.shortstyles[style]) result.push(this.getstyle(s)); return result.join(' '); } result = this.getcomputedstyle(property); } if (result){ result = string(result); var color = result.match(/rgba?\([\d\s,]+\)/); if (color) result = result.replace(color[0], color[0].rgbtohex()); } if (browser.opera || (browser.ie && isnan(parsefloat(result)))){ if (property.test(/^(height|width)$/)){ var values = (property == 'width') ? ['left', 'right'] : ['top', 'bottom'], size = 0; values.each(function(value){ size += this.getstyle('border-' + value + '-width').toint() + this.getstyle('padding-' + value).toint(); }, this); return this['offset' + property.capitalize()] - size + 'px'; } if (browser.opera && string(result).indexof('px') != -1) return result; if (property.test(/(border(.+)width|margin|padding)/)) return '0px'; } return result; }, setstyles: function(styles){ for (var style in styles) this.setstyle(style, styles[style]); return this; }, getstyles: function(){ var result = {}; array.flatten(arguments).each(function(key){ result[key] = this.getstyle(key); }, this); return result; } }); element.styles = { left: '@px', top: '@px', bottom: '@px', right: '@px', width: '@px', height: '@px', maxwidth: '@px', maxheight: '@px', minwidth: '@px', minheight: '@px', backgroundcolor: 'rgb(@, @, @)', backgroundposition: '@px @px', color: 'rgb(@, @, @)', fontsize: '@px', letterspacing: '@px', lineheight: '@px', clip: 'rect(@px @px @px @px)', margin: '@px @px @px @px', padding: '@px @px @px @px', border: '@px @ rgb(@, @, @) @px @ rgb(@, @, @) @px @ rgb(@, @, @)', borderwidth: '@px @px @px @px', borderstyle: '@ @ @ @', bordercolor: 'rgb(@, @, @) rgb(@, @, @) rgb(@, @, @) rgb(@, @, @)', zindex: '@', 'zoom': '@', fontweight: '@', textindent: '@px', opacity: '@' }; //<1.2compat> element.styles = new hash(element.styles); // element.shortstyles = {margin: {}, padding: {}, border: {}, borderwidth: {}, borderstyle: {}, bordercolor: {}}; ['top', 'right', 'bottom', 'left'].each(function(direction){ var short = element.shortstyles; var all = element.styles; ['margin', 'padding'].each(function(style){ var sd = style + direction; short[style][sd] = all[sd] = '@px'; }); var bd = 'border' + direction; short.border[bd] = all[bd] = '@px @ rgb(@, @, @)'; var bdw = bd + 'width', bds = bd + 'style', bdc = bd + 'color'; short[bd] = {}; short.borderwidth[bdw] = short[bd][bdw] = all[bdw] = '@px'; short.borderstyle[bds] = short[bd][bds] = all[bds] = '@'; short.bordercolor[bdc] = short[bd][bdc] = all[bdc] = 'rgb(@, @, @)'; }); })(); /* --- name: element.event description: contains element methods for dealing with events. this file also includes mouseenter and mouseleave custom element events. license: mit-style license. requires: [element, event] provides: element.event ... */ (function(){ element.properties.events = {set: function(events){ this.addevents(events); }}; [element, window, document].invoke('implement', { addevent: function(type, fn){ var events = this.retrieve('events', {}); if (!events[type]) events[type] = {keys: [], values: []}; if (events[type].keys.contains(fn)) return this; events[type].keys.push(fn); var realtype = type, custom = element.events[type], condition = fn, self = this; if (custom){ if (custom.onadd) custom.onadd.call(this, fn); if (custom.condition){ condition = function(event){ if (custom.condition.call(this, event)) return fn.call(this, event); return true; }; } realtype = custom.base || realtype; } var defn = function(){ return fn.call(self); }; var nativeevent = element.nativeevents[realtype]; if (nativeevent){ if (nativeevent == 2){ defn = function(event){ event = new event(event, self.getwindow()); if (condition.call(self, event) === false) event.stop(); }; } this.addlistener(realtype, defn); } events[type].values.push(defn); return this; }, removeevent: function(type, fn){ var events = this.retrieve('events'); if (!events || !events[type]) return this; var list = events[type]; var index = list.keys.indexof(fn); if (index == -1) return this; var value = list.values[index]; delete list.keys[index]; delete list.values[index]; var custom = element.events[type]; if (custom){ if (custom.onremove) custom.onremove.call(this, fn); type = custom.base || type; } return (element.nativeevents[type]) ? this.removelistener(type, value) : this; }, addevents: function(events){ for (var event in events) this.addevent(event, events[event]); return this; }, removeevents: function(events){ var type; if (typeof(events) == 'object'){ for (type in events) this.removeevent(type, events[type]); return this; } var attached = this.retrieve('events'); if (!attached) return this; if (!events){ for (type in attached) this.removeevents(type); this.eliminate('events'); } else if (attached[events]){ attached[events].keys.each(function(fn){ this.removeevent(events, fn); }, this); delete attached[events]; } return this; }, fireevent: function(type, args, delay){ var events = this.retrieve('events'); if (!events || !events[type]) return this; args = array.from(args); events[type].keys.each(function(fn){ if (delay) fn.delay(delay, this, args); else fn.apply(this, args); }, this); return this; }, cloneevents: function(from, type){ from = document.id(from); var events = from.retrieve('events'); if (!events) return this; if (!type){ for (var eventtype in events) this.cloneevents(from, eventtype); } else if (events[type]){ events[type].keys.each(function(fn){ this.addevent(type, fn); }, this); } return this; } }); // ie9 try { if (typeof htmlelement != 'undefined') htmlelement.prototype.fireevent = element.prototype.fireevent; } catch(e){} element.nativeevents = { click: 2, dblclick: 2, mouseup: 2, mousedown: 2, contextmenu: 2, //mouse buttons mousewheel: 2, dommousescroll: 2, //mouse wheel mouseover: 2, mouseout: 2, mousemove: 2, selectstart: 2, selectend: 2, //mouse movement keydown: 2, keypress: 2, keyup: 2, //keyboard orientationchange: 2, // mobile touchstart: 2, touchmove: 2, touchend: 2, touchcancel: 2, // touch gesturestart: 2, gesturechange: 2, gestureend: 2, // gesture focus: 2, blur: 2, change: 2, reset: 2, select: 2, submit: 2, //form elements load: 2, unload: 1, beforeunload: 2, resize: 1, move: 1, domcontentloaded: 1, readystatechange: 1, //window error: 1, abort: 1, scroll: 1 //misc }; var check = function(event){ var related = event.relatedtarget; if (related == null) return true; if (!related) return false; return (related != this && related.prefix != 'xul' && typeof(this) != 'document' && !this.contains(related)); }; element.events = { mouseenter: { base: 'mouseover', condition: check }, mouseleave: { base: 'mouseout', condition: check }, mousewheel: { base: (browser.firefox) ? 'dommousescroll' : 'mousewheel' } }; //<1.2compat> element.events = new hash(element.events); // })(); /* --- name: element.dimensions description: contains methods to work with size, scroll, or positioning of elements and the window object. license: mit-style license. credits: - element positioning based on the [qooxdoo](http://qooxdoo.org/) code and smart browser fixes, [lgpl license](http://www.gnu.org/licenses/lgpl.html). - viewport dimensions based on [yui](http://developer.yahoo.com/yui/) code, [bsd license](http://developer.yahoo.com/yui/license.html). requires: [element, element.style] provides: [element.dimensions] ... */ (function(){ element.implement({ scrollto: function(x, y){ if (isbody(this)){ this.getwindow().scrollto(x, y); } else { this.scrollleft = x; this.scrolltop = y; } return this; }, getsize: function(){ if (isbody(this)) return this.getwindow().getsize(); return {x: this.offsetwidth, y: this.offsetheight}; }, getscrollsize: function(){ if (isbody(this)) return this.getwindow().getscrollsize(); return {x: this.scrollwidth, y: this.scrollheight}; }, getscroll: function(){ if (isbody(this)) return this.getwindow().getscroll(); return {x: this.scrollleft, y: this.scrolltop}; }, getscrolls: function(){ var element = this.parentnode, position = {x: 0, y: 0}; while (element && !isbody(element)){ position.x += element.scrollleft; position.y += element.scrolltop; element = element.parentnode; } return position; }, getoffsetparent: function(){ var element = this; if (isbody(element)) return null; if (!browser.ie) return element.offsetparent; while ((element = element.parentnode)){ if (stylestring(element, 'position') != 'static' || isbody(element)) return element; } return null; }, getoffsets: function(){ if (this.getboundingclientrect && !browser.platform.ios){ var bound = this.getboundingclientrect(), html = document.id(this.getdocument().documentelement), htmlscroll = html.getscroll(), elemscrolls = this.getscrolls(), isfixed = (stylestring(this, 'position') == 'fixed'); return { x: bound.left.toint() + elemscrolls.x + ((isfixed) ? 0 : htmlscroll.x) - html.clientleft, y: bound.top.toint() + elemscrolls.y + ((isfixed) ? 0 : htmlscroll.y) - html.clienttop }; } var element = this, position = {x: 0, y: 0}; if (isbody(this)) return position; while (element && !isbody(element)){ position.x += element.offsetleft; position.y += element.offsettop; if (browser.firefox){ if (!borderbox(element)){ position.x += leftborder(element); position.y += topborder(element); } var parent = element.parentnode; if (parent && stylestring(parent, 'overflow') != 'visible'){ position.x += leftborder(parent); position.y += topborder(parent); } } else if (element != this && browser.safari){ position.x += leftborder(element); position.y += topborder(element); } element = element.offsetparent; } if (browser.firefox && !borderbox(this)){ position.x -= leftborder(this); position.y -= topborder(this); } return position; }, getposition: function(relative){ if (isbody(this)) return {x: 0, y: 0}; var offset = this.getoffsets(), scroll = this.getscrolls(); var position = { x: offset.x - scroll.x, y: offset.y - scroll.y }; if (relative && (relative = document.id(relative))){ var relativeposition = relative.getposition(); return {x: position.x - relativeposition.x - leftborder(relative), y: position.y - relativeposition.y - topborder(relative)}; } return position; }, getcoordinates: function(element){ if (isbody(this)) return this.getwindow().getcoordinates(); var position = this.getposition(element), size = this.getsize(); var obj = { left: position.x, top: position.y, width: size.x, height: size.y }; obj.right = obj.left + obj.width; obj.bottom = obj.top + obj.height; return obj; }, computeposition: function(obj){ return { left: obj.x - stylenumber(this, 'margin-left'), top: obj.y - stylenumber(this, 'margin-top') }; }, setposition: function(obj){ return this.setstyles(this.computeposition(obj)); } }); [document, window].invoke('implement', { getsize: function(){ var doc = getcompatelement(this); return {x: doc.clientwidth, y: doc.clientheight}; }, getscroll: function(){ var win = this.getwindow(), doc = getcompatelement(this); return {x: win.pagexoffset || doc.scrollleft, y: win.pageyoffset || doc.scrolltop}; }, getscrollsize: function(){ var doc = getcompatelement(this), min = this.getsize(), body = this.getdocument().body; return {x: math.max(doc.scrollwidth, body.scrollwidth, min.x), y: math.max(doc.scrollheight, body.scrollheight, min.y)}; }, getposition: function(){ return {x: 0, y: 0}; }, getcoordinates: function(){ var size = this.getsize(); return {top: 0, left: 0, bottom: size.y, right: size.x, height: size.y, width: size.x}; } }); // private methods var stylestring = element.getcomputedstyle; function stylenumber(element, style){ return stylestring(element, style).toint() || 0; }; function borderbox(element){ return stylestring(element, '-moz-box-sizing') == 'border-box'; }; function topborder(element){ return stylenumber(element, 'border-top-width'); }; function leftborder(element){ return stylenumber(element, 'border-left-width'); }; function isbody(element){ return (/^(?:body|html)$/i).test(element.tagname); }; function getcompatelement(element){ var doc = element.getdocument(); return (!doc.compatmode || doc.compatmode == 'css1compat') ? doc.html : doc.body; }; })(); //aliases element.alias({position: 'setposition'}); //compatability [window, document, element].invoke('implement', { getheight: function(){ return this.getsize().y; }, getwidth: function(){ return this.getsize().x; }, getscrolltop: function(){ return this.getscroll().y; }, getscrollleft: function(){ return this.getscroll().x; }, getscrollheight: function(){ return this.getscrollsize().y; }, getscrollwidth: function(){ return this.getscrollsize().x; }, gettop: function(){ return this.getposition().y; }, getleft: function(){ return this.getposition().x; } }); /* --- name: fx description: contains the basic animation logic to be extended by all other fx classes. license: mit-style license. requires: [chain, events, options] provides: fx ... */ (function(){ var fx = this.fx = new class({ implements: [chain, events, options], options: { /* onstart: nil, oncancel: nil, oncomplete: nil, */ fps: 50, unit: false, duration: 500, link: 'ignore' }, initialize: function(options){ this.subject = this.subject || this; this.setoptions(options); }, gettransition: function(){ return function(p){ return -(math.cos(math.pi * p) - 1) / 2; }; }, step: function(){ var time = date.now(); if (time < this.time + this.options.duration){ var delta = this.transition((time - this.time) / this.options.duration); this.set(this.compute(this.from, this.to, delta)); } else { this.set(this.compute(this.from, this.to, 1)); this.complete(); } }, set: function(now){ return now; }, compute: function(from, to, delta){ return fx.compute(from, to, delta); }, check: function(){ if (!this.timer) return true; switch (this.options.link){ case 'cancel': this.cancel(); return true; case 'chain': this.chain(this.caller.pass(arguments, this)); return false; } return false; }, start: function(from, to){ if (!this.check(from, to)) return this; var duration = this.options.duration; this.options.duration = fx.durations[duration] || duration.toint(); this.from = from; this.to = to; this.time = 0; this.transition = this.gettransition(); this.starttimer(); this.onstart(); return this; }, complete: function(){ if (this.stoptimer()) this.oncomplete(); return this; }, cancel: function(){ if (this.stoptimer()) this.oncancel(); return this; }, onstart: function(){ this.fireevent('start', this.subject); }, oncomplete: function(){ this.fireevent('complete', this.subject); if (!this.callchain()) this.fireevent('chaincomplete', this.subject); }, oncancel: function(){ this.fireevent('cancel', this.subject).clearchain(); }, pause: function(){ this.stoptimer(); return this; }, resume: function(){ this.starttimer(); return this; }, stoptimer: function(){ if (!this.timer) return false; this.time = date.now() - this.time; this.timer = removeinstance(this); return true; }, starttimer: function(){ if (this.timer) return false; this.time = date.now() - this.time; this.timer = addinstance(this); return true; } }); fx.compute = function(from, to, delta){ return (to - from) * delta + from; }; fx.durations = {'short': 250, 'normal': 500, 'long': 1000}; // global timers var instances = {}, timers = {}; var loop = function(){ for (var i = this.length; i--;){ if (this[i]) this[i].step(); } }; var addinstance = function(instance){ var fps = instance.options.fps, list = instances[fps] || (instances[fps] = []); list.push(instance); if (!timers[fps]) timers[fps] = loop.periodical(math.round(1000 / fps), list); return true; }; var removeinstance = function(instance){ var fps = instance.options.fps, list = instances[fps] || []; list.erase(instance); if (!list.length && timers[fps]) timers[fps] = clearinterval(timers[fps]); return false; }; })(); /* --- name: fx.css description: contains the css animation logic. used by fx.tween, fx.morph, fx.elements. license: mit-style license. requires: [fx, element.style] provides: fx.css ... */ fx.css = new class({ extends: fx, //prepares the base from/to object prepare: function(element, property, values){ values = array.from(values); if (values[1] == null){ values[1] = values[0]; values[0] = element.getstyle(property); } var parsed = values.map(this.parse); return {from: parsed[0], to: parsed[1]}; }, //parses a value into an array parse: function(value){ value = function.from(value)(); value = (typeof value == 'string') ? value.split(' ') : array.from(value); return value.map(function(val){ val = string(val); var found = false; object.each(fx.css.parsers, function(parser, key){ if (found) return; var parsed = parser.parse(val); if (parsed || parsed === 0) found = {value: parsed, parser: parser}; }); found = found || {value: val, parser: fx.css.parsers.string}; return found; }); }, //computes by a from and to prepared objects, using their parsers. compute: function(from, to, delta){ var computed = []; (math.min(from.length, to.length)).times(function(i){ computed.push({value: from[i].parser.compute(from[i].value, to[i].value, delta), parser: from[i].parser}); }); computed.$family = function.from('fx:css:value'); return computed; }, //serves the value as settable serve: function(value, unit){ if (typeof(value) != 'fx:css:value') value = this.parse(value); var returned = []; value.each(function(bit){ returned = returned.concat(bit.parser.serve(bit.value, unit)); }); return returned; }, //renders the change to an element render: function(element, property, value, unit){ element.setstyle(property, this.serve(value, unit)); }, //searches inside the page css to find the values for a selector search: function(selector){ if (fx.css.cache[selector]) return fx.css.cache[selector]; var to = {}; array.each(document.stylesheets, function(sheet, j){ var href = sheet.href; if (href && href.contains('://') && !href.contains(document.domain)) return; var rules = sheet.rules || sheet.cssrules; array.each(rules, function(rule, i){ if (!rule.style) return; var selectortext = (rule.selectortext) ? rule.selectortext.replace(/^\w+/, function(m){ return m.tolowercase(); }) : null; if (!selectortext || !selectortext.test('^' + selector + '$')) return; element.styles.each(function(value, style){ if (!rule.style[style] || element.shortstyles[style]) return; value = string(rule.style[style]); to[style] = (value.test(/^rgb/)) ? value.rgbtohex() : value; }); }); }); return fx.css.cache[selector] = to; } }); fx.css.cache = {}; fx.css.parsers = { color: { parse: function(value){ if (value.match(/^#[0-9a-f]{3,6}$/i)) return value.hextorgb(true); return ((value = value.match(/(\d+),\s*(\d+),\s*(\d+)/))) ? [value[1], value[2], value[3]] : false; }, compute: function(from, to, delta){ return from.map(function(value, i){ return math.round(fx.compute(from[i], to[i], delta)); }); }, serve: function(value){ return value.map(number); } }, number: { parse: parsefloat, compute: fx.compute, serve: function(value, unit){ return (unit) ? value + unit : value; } }, string: { parse: function.from(false), compute: function(zero, one){ return one; }, serve: function(zero){ return zero; } } }; //<1.2compat> fx.css.parsers = new hash(fx.css.parsers); // /* --- name: fx.tween description: formerly fx.style, effect to transition any css property for an element. license: mit-style license. requires: fx.css provides: [fx.tween, element.fade, element.highlight] ... */ fx.tween = new class({ extends: fx.css, initialize: function(element, options){ this.element = this.subject = document.id(element); this.parent(options); }, set: function(property, now){ if (arguments.length == 1){ now = property; property = this.property || this.options.property; } this.render(this.element, property, now, this.options.unit); return this; }, start: function(property, from, to){ if (!this.check(property, from, to)) return this; var args = array.flatten(arguments); this.property = this.options.property || args.shift(); var parsed = this.prepare(this.element, this.property, args); return this.parent(parsed.from, parsed.to); } }); element.properties.tween = { set: function(options){ this.get('tween').cancel().setoptions(options); return this; }, get: function(){ var tween = this.retrieve('tween'); if (!tween){ tween = new fx.tween(this, {link: 'cancel'}); this.store('tween', tween); } return tween; } }; element.implement({ tween: function(property, from, to){ this.get('tween').start(arguments); return this; }, fade: function(how){ var fade = this.get('tween'), o = 'opacity', toggle; how = [how, 'toggle'].pick(); switch (how){ case 'in': fade.start(o, 1); break; case 'out': fade.start(o, 0); break; case 'show': fade.set(o, 1); break; case 'hide': fade.set(o, 0); break; case 'toggle': var flag = this.retrieve('fade:flag', this.get('opacity') == 1); fade.start(o, (flag) ? 0 : 1); this.store('fade:flag', !flag); toggle = true; break; default: fade.start(o, arguments); } if (!toggle) this.eliminate('fade:flag'); return this; }, highlight: function(start, end){ if (!end){ end = this.retrieve('highlight:original', this.getstyle('background-color')); end = (end == 'transparent') ? '#fff' : end; } var tween = this.get('tween'); tween.start('background-color', start || '#ffff88', end).chain(function(){ this.setstyle('background-color', this.retrieve('highlight:original')); tween.callchain(); }.bind(this)); return this; } }); /* --- name: fx.morph 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. license: mit-style license. requires: fx.css provides: fx.morph ... */ fx.morph = new class({ extends: fx.css, initialize: function(element, options){ this.element = this.subject = document.id(element); this.parent(options); }, set: function(now){ if (typeof now == 'string') now = this.search(now); for (var p in now) this.render(this.element, p, now[p], this.options.unit); return this; }, compute: function(from, to, delta){ var now = {}; for (var p in from) now[p] = this.parent(from[p], to[p], delta); return now; }, start: function(properties){ if (!this.check(properties)) return this; if (typeof properties == 'string') properties = this.search(properties); var from = {}, to = {}; for (var p in properties){ var parsed = this.prepare(this.element, p, properties[p]); from[p] = parsed.from; to[p] = parsed.to; } return this.parent(from, to); } }); element.properties.morph = { set: function(options){ this.get('morph').cancel().setoptions(options); return this; }, get: function(){ var morph = this.retrieve('morph'); if (!morph){ morph = new fx.morph(this, {link: 'cancel'}); this.store('morph', morph); } return morph; } }; element.implement({ morph: function(props){ this.get('morph').start(props); return this; } }); /* --- name: fx.transitions description: contains a set of advanced transitions to be used with any of the fx classes. license: mit-style license. credits: - easing equations by robert penner, , modified and optimized to be used with mootools. requires: fx provides: fx.transitions ... */ fx.implement({ gettransition: function(){ var trans = this.options.transition || fx.transitions.sine.easeinout; if (typeof trans == 'string'){ var data = trans.split(':'); trans = fx.transitions; trans = trans[data[0]] || trans[data[0].capitalize()]; if (data[1]) trans = trans['ease' + data[1].capitalize() + (data[2] ? data[2].capitalize() : '')]; } return trans; } }); fx.transition = function(transition, params){ params = array.from(params); return object.append(transition, { easein: function(pos){ return transition(pos, params); }, easeout: function(pos){ return 1 - transition(1 - pos, params); }, easeinout: function(pos){ return (pos <= 0.5) ? transition(2 * pos, params) / 2 : (2 - transition(2 * (1 - pos), params)) / 2; } }); }; fx.transitions = { linear: function(zero){ return zero; } }; //<1.2compat> fx.transitions = new hash(fx.transitions); // fx.transitions.extend = function(transitions){ for (var transition in transitions) fx.transitions[transition] = new fx.transition(transitions[transition]); }; fx.transitions.extend({ pow: function(p, x){ return math.pow(p, x && x[0] || 6); }, expo: function(p){ return math.pow(2, 8 * (p - 1)); }, circ: function(p){ return 1 - math.sin(math.acos(p)); }, sine: function(p){ return 1 - math.sin((1 - p) * math.pi / 2); }, back: function(p, x){ x = x && x[0] || 1.618; return math.pow(p, 2) * ((x + 1) * p - x); }, bounce: function(p){ var value; for (var a = 0, b = 1; 1; a += b, b /= 2){ if (p >= (7 - 4 * a) / 11){ value = b * b - math.pow((11 - 6 * a - 11 * p) / 4, 2); break; } } return value; }, elastic: function(p, x){ return math.pow(2, 10 * --p) * math.cos(20 * p * math.pi * (x && x[0] || 1) / 3); } }); ['quad', 'cubic', 'quart', 'quint'].each(function(transition, i){ fx.transitions[transition] = new fx.transition(function(p){ return math.pow(p, [i + 2]); }); }); /* --- name: request description: powerful all purpose request class. uses xmlhttprequest. license: mit-style license. requires: [object, element, chain, events, options, browser] provides: request ... */ (function(){ var progresssupport = ('onprogress' in new browser.request); var request = this.request = new class({ implements: [chain, events, options], options: {/* onrequest: function(){}, onloadstart: function(event, xhr){}, onprogress: function(event, xhr){}, oncomplete: function(){}, oncancel: function(){}, onsuccess: function(responsetext, responsexml){}, onfailure: function(xhr){}, onexception: function(headername, value){}, ontimeout: function(){}, user: '', password: '',*/ url: '', data: '', headers: { 'x-requested-with': 'xmlhttprequest', 'accept': 'text/javascript, text/html, application/xml, text/xml, */*' }, async: true, format: false, method: 'post', link: 'ignore', issuccess: null, emulation: true, urlencoded: true, encoding: 'utf-8', evalscripts: false, evalresponse: false, timeout: 0, nocache: false }, initialize: function(options){ this.xhr = new browser.request(); this.setoptions(options); this.headers = this.options.headers; }, onstatechange: function(){ var xhr = this.xhr; if (xhr.readystate != 4 || !this.running) return; this.running = false; this.status = 0; function.attempt(function(){ var status = xhr.status; this.status = (status == 1223) ? 204 : status; }.bind(this)); xhr.onreadystatechange = function(){}; cleartimeout(this.timer); this.response = {text: this.xhr.responsetext || '', xml: this.xhr.responsexml}; if (this.options.issuccess.call(this, this.status)) this.success(this.response.text, this.response.xml); else this.failure(); }, issuccess: function(){ var status = this.status; return (status >= 200 && status < 300); }, isrunning: function(){ return !!this.running; }, processscripts: function(text){ if (this.options.evalresponse || (/(ecma|java)script/).test(this.getheader('content-type'))) return browser.exec(text); return text.stripscripts(this.options.evalscripts); }, success: function(text, xml){ this.onsuccess(this.processscripts(text), xml); }, onsuccess: function(){ this.fireevent('complete', arguments).fireevent('success', arguments).callchain(); }, failure: function(){ this.onfailure(); }, onfailure: function(){ this.fireevent('complete').fireevent('failure', this.xhr); }, loadstart: function(event){ this.fireevent('loadstart', [event, this.xhr]); }, progress: function(event){ this.fireevent('progress', [event, this.xhr]); }, timeout: function(){ this.fireevent('timeout', this.xhr); }, setheader: function(name, value){ this.headers[name] = value; return this; }, getheader: function(name){ return function.attempt(function(){ return this.xhr.getresponseheader(name); }.bind(this)); }, check: function(){ if (!this.running) return true; switch (this.options.link){ case 'cancel': this.cancel(); return true; case 'chain': this.chain(this.caller.pass(arguments, this)); return false; } return false; }, send: function(options){ if (!this.check(options)) return this; this.options.issuccess = this.options.issuccess || this.issuccess; this.running = true; var type = typeof(options); if (type == 'string' || type == 'element') options = {data: options}; var old = this.options; options = object.append({data: old.data, url: old.url, method: old.method}, options); var data = options.data, url = string(options.url), method = options.method.tolowercase(); switch (typeof(data)){ case 'element': data = document.id(data).toquerystring(); break; case 'object': case 'hash': data = object.toquerystring(data); } if (this.options.format){ var format = 'format=' + this.options.format; data = (data) ? format + '&' + data : format; } if (this.options.emulation && !['get', 'post'].contains(method)){ var _method = '_method=' + method; data = (data) ? _method + '&' + data : _method; method = 'post'; } if (this.options.urlencoded && ['post', 'put'].contains(method)){ var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : ''; this.headers['content-type'] = 'application/x-www-form-urlencoded' + encoding; } if (!url) url = document.location.pathname; var trimposition = url.lastindexof('/'); if (trimposition > -1 && (trimposition = url.indexof('#')) > -1) url = url.substr(0, trimposition); if (this.options.nocache) url += (url.contains('?') ? '&' : '?') + string.uniqueid(); if (data && method == 'get'){ url += (url.contains('?') ? '&' : '?') + data; data = null; } var xhr = this.xhr; if (progresssupport){ xhr.onloadstart = this.loadstart.bind(this); xhr.onprogress = this.progress.bind(this); } xhr.open(method.touppercase(), url, this.options.async, this.options.user, this.options.password); if (this.options.user && 'withcredentials' in xhr) xhr.withcredentials = true; xhr.onreadystatechange = this.onstatechange.bind(this); object.each(this.headers, function(value, key){ try { xhr.setrequestheader(key, value); } catch (e){ this.fireevent('exception', [key, value]); } }, this); this.fireevent('request'); xhr.send(data); if (!this.options.async) this.onstatechange(); if (this.options.timeout) this.timer = this.timeout.delay(this.options.timeout, this); return this; }, cancel: function(){ if (!this.running) return this; this.running = false; var xhr = this.xhr; xhr.abort(); cleartimeout(this.timer); xhr.onreadystatechange = xhr.onprogress = xhr.onloadstart = function(){}; this.xhr = new browser.request(); this.fireevent('cancel'); return this; } }); var methods = {}; ['get', 'post', 'put', 'delete', 'get', 'post', 'put', 'delete'].each(function(method){ methods[method] = function(data){ return this.send({ data: data, method: method }); }; }); request.implement(methods); element.properties.send = { set: function(options){ var send = this.get('send').cancel(); send.setoptions(options); return this; }, get: function(){ var send = this.retrieve('send'); if (!send){ send = new request({ data: this, link: 'cancel', method: this.get('method') || 'post', url: this.get('action') }); this.store('send', send); } return send; } }; element.implement({ send: function(url){ var sender = this.get('send'); sender.send({data: this, url: url || sender.options.url}); return this; } }); })(); /* --- name: request.html description: extends the basic request class with additional methods for interacting with html responses. license: mit-style license. requires: [element, request] provides: request.html ... */ request.html = new class({ extends: request, options: { update: false, append: false, evalscripts: true, filter: false, headers: { accept: 'text/html, application/xml, text/xml, */*' } }, success: function(text){ var options = this.options, response = this.response; response.html = text.stripscripts(function(script){ response.javascript = script; }); var match = response.html.match(/]*>([\s\s]*?)<\/body>/i); if (match) response.html = match[1]; var temp = new element('div').set('html', response.html); response.tree = temp.childnodes; response.elements = temp.getelements('*'); if (options.filter) response.tree = response.elements.filter(options.filter); if (options.update) document.id(options.update).empty().set('html', response.html); else if (options.append) document.id(options.append).adopt(temp.getchildren()); if (options.evalscripts) browser.exec(response.javascript); this.onsuccess(response.tree, response.elements, response.html, response.javascript); } }); element.properties.load = { set: function(options){ var load = this.get('load').cancel(); load.setoptions(options); return this; }, get: function(){ var load = this.retrieve('load'); if (!load){ load = new request.html({data: this, link: 'cancel', update: this, method: 'get'}); this.store('load', load); } return load; } }; element.implement({ load: function(){ this.get('load').send(array.link(arguments, {data: type.isobject, url: type.isstring})); return this; } }); /* --- name: json description: json encoder and decoder. license: mit-style license. see also: requires: [array, string, number, function] provides: json ... */ if (!this.json) this.json = {}; //<1.2compat> json = new hash({ stringify: json.stringify, parse: json.parse }); // object.append(json, { $specialchars: {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'}, $replacechars: function(chr){ return json.$specialchars[chr] || '\\u00' + math.floor(chr.charcodeat() / 16).tostring(16) + (chr.charcodeat() % 16).tostring(16); }, encode: function(obj){ switch (typeof(obj)){ case 'string': return '"' + obj.replace(/[\x00-\x1f\\"]/g, json.$replacechars) + '"'; case 'array': return '[' + string(obj.map(json.encode).clean()) + ']'; case 'object': case 'hash': var string = []; object.each(obj, function(value, key){ var json = json.encode(value); if (json) string.push(json.encode(key) + ':' + json); }); return '{' + string + '}'; case 'number': case 'boolean': return string(obj); case 'null': return 'null'; } return null; }, decode: function(string, secure){ if (typeof(string) != 'string' || !string.length) return null; if (secure && !(/^[,:{}\[\]0-9.\-+eaeflnr-u \n\r\t]*$/).test(string.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''))) return null; return eval('(' + string + ')'); } }); /* --- name: request.json description: extends the basic request class with additional methods for sending and receiving json data. license: mit-style license. requires: [request, json] provides: request.json ... */ request.json = new class({ extends: request, options: { secure: true }, initialize: function(options){ this.parent(options); object.append(this.headers, { 'accept': 'application/json', 'x-request': 'json' }); }, success: function(text){ var secure = this.options.secure; var json = this.response.json = function.attempt(function(){ return json.decode(text, secure); }); if (json == null) this.onfailure(); else this.onsuccess(json, text); } }); /* --- name: cookie description: class for creating, reading, and deleting browser cookies. license: mit-style license. credits: - based on the functions by peter-paul koch (http://quirksmode.org). requires: options provides: cookie ... */ var cookie = new class({ implements: options, options: { path: '/', domain: false, duration: false, secure: false, document: document, encode: true }, initialize: function(key, options){ this.key = key; this.setoptions(options); }, write: function(value){ if (this.options.encode) value = encodeuricomponent(value); if (this.options.domain) value += '; domain=' + this.options.domain; if (this.options.path) value += '; path=' + this.options.path; if (this.options.duration){ var date = new date(); date.settime(date.gettime() + this.options.duration * 24 * 60 * 60 * 1000); value += '; expires=' + date.togmtstring(); } if (this.options.secure) value += '; secure'; this.options.document.cookie = this.key + '=' + value; return this; }, read: function(){ var value = this.options.document.cookie.match('(?:^|;)\\s*' + this.key.escaperegexp() + '=([^;]*)'); return (value) ? decodeuricomponent(value[1]) : null; }, dispose: function(){ new cookie(this.key, object.merge({}, this.options, {duration: -1})).write(''); return this; } }); cookie.write = function(key, value, options){ return new cookie(key, options).write(value); }; cookie.read = function(key){ return new cookie(key).read(); }; cookie.dispose = function(key, options){ return new cookie(key, options).dispose(); }; /* --- name: domready description: contains the custom event domready. license: mit-style license. requires: [browser, element, element.event] provides: [domready, domready] ... */ (function(window, document){ var ready, loaded, checks = [], shouldpoll, timer, isframed = true; // thanks to rich dougherty try { isframed = window.frameelement != null; } catch(e){} var domready = function(){ cleartimeout(timer); if (ready) return; browser.loaded = ready = true; document.removelistener('domcontentloaded', domready).removelistener('readystatechange', check); document.fireevent('domready'); window.fireevent('domready'); }; var check = function(){ for (var i = checks.length; i--;) if (checks[i]()){ domready(); return true; } return false; }; var poll = function(){ cleartimeout(timer); if (!check()) timer = settimeout(poll, 10); }; document.addlistener('domcontentloaded', domready); // doscroll technique by diego perini http://javascript.nwbox.com/iecontentloaded/ var testelement = document.createelement('div'); if (testelement.doscroll && !isframed){ checks.push(function(){ try { testelement.doscroll(); return true; } catch (e){} return false; }); shouldpoll = true; } if (document.readystate) checks.push(function(){ var state = document.readystate; return (state == 'loaded' || state == 'complete'); }); if ('onreadystatechange' in document) document.addlistener('readystatechange', check); else shouldpoll = true; if (shouldpoll) poll(); element.events.domready = { onadd: function(fn){ if (ready) fn.call(this); } }; // make sure that domready fires before load element.events.load = { base: 'load', onadd: function(fn){ if (loaded && this == window) fn.call(this); }, condition: function(){ if (this == window){ domready(); delete element.events.load; } return true; } }; // this is based on the custom load event window.addevent('load', function(){ loaded = true; }); })(window, document); /* --- name: swiff description: wrapper for embedding swf movies. supports external interface communication. license: mit-style license. credits: - flash detection & internet explorer + flash player 9 fix inspired by swfobject. requires: [options, object] provides: swiff ... */ (function(){ var id = 0; var swiff = this.swiff = new class({ implements: options, options: { id: null, height: 1, width: 1, container: null, properties: {}, params: { quality: 'high', allowscriptaccess: 'always', wmode: 'window', swliveconnect: true }, callbacks: {}, vars: {} }, toelement: function(){ return this.object; }, initialize: function(path, options){ this.instance = 'swiff_' + id++; this.setoptions(options); options = this.options; var id = this.id = options.id || this.instance; var container = document.id(options.container); swiff.callbacks[this.instance] = {}; var params = options.params, vars = options.vars, callbacks = options.callbacks; var properties = object.append({height: options.height, width: options.width}, options.properties); var self = this; for (var callback in callbacks){ swiff.callbacks[this.instance][callback] = (function(option){ return function(){ return option.apply(self.object, arguments); }; })(callbacks[callback]); vars[callback] = 'swiff.callbacks.' + this.instance + '.' + callback; } params.flashvars = object.toquerystring(vars); if (browser.ie){ properties.classid = 'clsid:d27cdb6e-ae6d-11cf-96b8-444553540000'; params.movie = path; } else { properties.type = 'application/x-shockwave-flash'; } properties.data = path; var build = ''; } build += ''; this.object = ((container) ? container.empty() : new element('div')).set('html', build).firstchild; }, replaces: function(element){ element = document.id(element, true); element.parentnode.replacechild(this.toelement(), element); return this; }, inject: function(element){ document.id(element, true).appendchild(this.toelement()); return this; }, remote: function(){ return swiff.remote.apply(swiff, [this.toelement()].extend(arguments)); } }); swiff.callbacks = {}; swiff.remote = function(obj, fn){ var rs = obj.callfunction('' + __flash__argumentstoxml(arguments, 2) + ''); return eval(rs); }; })();