/* --- mootools: the javascript framework web build: - http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0 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.delegation 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-2012 [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.4.5', build: 'ab8ea8824dc3b24b6666867a2c4ed58ebb762cf0' }; // typeof, instanceof var typeof = this.typeof = function(item){ if (item == null) return 'null'; if (item.$family != null) 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; } /**/ if (!item.hasownproperty) return false; /**/ 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 (typeof a != 'string') args = a; else if (arguments.length > 1) args = arguments; else if (useplural) args = [a]; 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; 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)); }); }; var extend = function(name, method){ if (method && method.$hidden) return; var previous = this[name]; if (previous == null || !previous.$protected) this[name] = method; }; 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) object.implement(key, proto.protect()); } if (istype){ var methodsenumerable = prototype.propertyisenumerable(methods[0]); object.foreachmethod = function(fn){ if (!methodsenumerable) for (var i = 0, l = methods.length; i < l; i++){ fn.call(prototype, prototype[methods[i]], methods[i]); } for (var key in prototype) fn.call(prototype, prototype[key], key) }; } return force; }; force('string', string, [ 'charat', 'charcodeat', 'concat', 'indexof', 'lastindexof', 'match', 'quote', 'replace', 'search', 'slice', 'split', 'substr', 'substring', 'trim', '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 var hasownproperty = object.prototype.hasownproperty; object.extend('foreach', function(object, fn, bind){ for (var key in object){ if (hasownproperty.call(object, 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({ /**/ every: function(fn, bind){ for (var i = 0, l = this.length >>> 0; 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 value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this){ value = this[i]; if (fn.call(bind, value, i, this)) results.push(value); } return results; }, indexof: function(item, from){ var length = this.length >>> 0; for (var i = (from < 0) ? math.max(0, length + from) : from || 0; i < length; i++){ if (this[i] === item) return i; } return -1; }, map: function(fn, bind){ var length = this.length >>> 0, results = array(length); for (var i = 0; i < length; 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 >>> 0; i < l; i++){ if ((i in this) && fn.call(bind, this[i], i, this)) return true; } return false; }, /**/ clean: function(){ return this.filter(function(item){ return item != null; }); }, invoke: function(methodname){ var args = array.slice(arguments, 1); return this.map(function(item){ return item[methodname].apply(item, args); }); }, 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 : string(this).indexof(string) > -1; }, trim: function(){ return string(this).replace(/^\s+|\s+$/g, ''); }, clean: function(){ return string(this).replace(/\s+/g, ' ').trim(); }, camelcase: function(){ return string(this).replace(/-\d/g, function(match){ return match.charat(1).touppercase(); }); }, hyphenate: function(){ return string(this).replace(/[a-z]/g, function(match){ return ('-' + match.charat(0).tolowercase()); }); }, capitalize: function(){ return string(this).replace(/\b[a-z]/g, function(match){ return match.touppercase(); }); }, escaperegexp: function(){ return string(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1'); }, toint: function(base){ return parseint(this, base || 10); }, tofloat: function(){ return parsefloat(this); }, hextorgb: function(array){ var hex = string(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/); return (hex) ? hex.slice(1).hextorgb(array) : null; }, rgbtohex: function(array){ var rgb = string(this).match(/\d{1,3}/g); return (rgb) ? rgb.rgbtohex(array) : null; }, substitute: function(object, regexp){ return string(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(that){ var self = this, args = arguments.length > 1 ? array.slice(arguments, 1) : null, f = function(){}; var bound = function(){ var context = that, length = arguments.length; if (this instanceof bound){ f.prototype = self.prototype; context = new f; } var result = (!args && !length) ? self.call(context) : self.apply(context, args && length ? args.concat(array.slice(arguments)) : args || arguments); return context == that ? result : context; }; return bound; }, /**/ 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 == null ? [] : args), bind), delay); }, periodical: function(periodical, bind, args){ return setinterval(this.pass((args == null ? [] : 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)); } }); if (object.create == function.prototype.create) object.create = null; var $try = function.attempt; // /* --- name: object description: object generic methods license: mit-style license. requires: type provides: [object, hash] ... */ (function(){ var hasownproperty = object.prototype.hasownproperty; object.extend({ subset: function(object, keys){ var results = {}; for (var i = 0, l = keys.length; i < l; i++){ var k = keys[i]; if (k in object) results[k] = object[k]; } return results; }, map: function(object, fn, bind){ var results = {}; for (var key in object){ if (hasownproperty.call(object, key)) results[key] = fn.call(bind, object[key], key, object); } return results; }, filter: function(object, fn, bind){ var results = {}; for (var key in object){ var value = object[key]; if (hasownproperty.call(object, key) && fn.call(bind, value, key, object)) results[key] = value; } return results; }, every: function(object, fn, bind){ for (var key in object){ if (hasownproperty.call(object, key) && !fn.call(bind, object[key], key)) return false; } return true; }, some: function(object, fn, bind){ for (var key in object){ if (hasownproperty.call(object, key) && fn.call(bind, object[key], key)) return true; } return false; }, keys: function(object){ var keys = []; for (var key in object){ if (hasownproperty.call(object, key)) keys.push(key); } return keys; }, values: function(object){ var values = []; for (var key in object){ if (hasownproperty.call(object, 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 (hasownproperty.call(object, 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 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; if (!document.head) 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 type, to make the event object cross-browser. license: mit-style license. requires: [window, document, array, function, string, object] provides: event ... */ (function() { var _keys = {}; var domevent = this.domevent = new type('domevent', function(event, win){ if (!win) win = window; event = event || win.event; if (event.$extended) return event; this.event = event; this.$extended = true; this.shift = event.shiftkey; this.control = event.ctrlkey; this.alt = event.altkey; this.meta = event.metakey; var type = this.type = event.type; var target = event.target || event.srcelement; while (target && target.nodetype == 3) target = target.parentnode; this.target = document.id(target); if (type.indexof('key') == 0){ var code = this.code = (event.which || event.keycode); this.key = _keys[code]/*<1.3compat>*/ || object.keyof(event.keys, code)/**/; if (type == 'keydown'){ if (code > 111 && code < 124) this.key = 'f' + (code - 111); else if (code > 95 && code < 106) this.key = code - 96; } if (this.key == null) this.key = string.fromcharcode(code).tolowercase(); } else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'dommousescroll' || type.indexof('mouse') == 0){ var doc = win.document; doc = (!doc.compatmode || doc.compatmode == 'css1compat') ? doc.html : doc.body; this.page = { x: (event.pagex != null) ? event.pagex : event.clientx + doc.scrollleft, y: (event.pagey != null) ? event.pagey : event.clienty + doc.scrolltop }; this.client = { x: (event.pagex != null) ? event.pagex - win.pagexoffset : event.clientx, y: (event.pagey != null) ? event.pagey - win.pageyoffset : event.clienty }; if (type == 'dommousescroll' || type == 'mousewheel') this.wheel = (event.wheeldelta) ? event.wheeldelta / 120 : -(event.detail || 0) / 3; this.rightclick = (event.which == 3 || event.button == 2); if (type == 'mouseover' || type == 'mouseout'){ var related = event.relatedtarget || event[(type == 'mouseover' ? 'from' : 'to') + 'element']; while (related && related.nodetype == 3) related = related.parentnode; this.relatedtarget = document.id(related); } } else if (type.indexof('touch') == 0 || type.indexof('gesture') == 0){ 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]; this.page = {x: touch.pagex, y: touch.pagey}; this.client = {x: touch.clientx, y: touch.clienty}; } } if (!this.client) this.client = {}; if (!this.page) this.page = {}; }); domevent.implement({ stop: function(){ return this.preventdefault().stoppropagation(); }, 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; } }); domevent.definekey = function(code, key){ _keys[code] = key; return this; }; domevent.definekeys = domevent.definekey.overloadsetter(true); domevent.definekeys({ '38': 'up', '40': 'down', '37': 'left', '39': 'right', '27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab', '46': 'delete', '13': 'enter' }); })(); /*<1.3compat>*/ var event = domevent; event.keys = {}; /**/ /*<1.2compat>*/ event.keys = new hash(event.keys); /**/ /* --- 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--;) if (i in fns){ 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) 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[parsed.raw] = (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, function(match){ return '\\' + match; }); }; 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*\\](?!\\])|(:+)(+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)" .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, pseudomarker, 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, type: pseudomarker.length == 1 ? 'class' : 'element' }); } 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 = {}, featurescache = {}, tostring = object.prototype.tostring; // feature / bug detection local.isnativecode = function(fn){ return (/\{\s*\[native code\]\s*\}/).test('' + fn); }; local.isxml = function(document){ return (!!document.xmlversion) || (!!document.xml) || (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. var nodetype = document.nodetype; if (nodetype == 9); // document else if (nodetype) 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; // check if we have done feature detection on this document before var root = document.documentelement, rootuid = this.getuidxml(root), features = featurescache[rootuid], feature; if (features){ for (feature in features){ this[feature] = features[feature]; } return; } features = featurescache[rootuid] = {}; features.root = root; features.isxmldocument = this.isxml(document); features.brokenstargebtn = features.starselectsclosedqsa = features.idgetsname = features.brokenmixedcaseqsa = features.brokengebcn = features.brokencheckedqsa = features.brokenemptyattributeqsa = features.ishtmldocument = features.nativematchesselector = false; var starselectsclosed, starselectscomments, brokensecondclassnamegebcn, cachedgetelementsbyclassname, brokenformattributegetter; var selected, id = 'slick_uniqueid'; var testnode = document.createelement('div'); var testroot = document.body || document.getelementsbytagname('body')[0] || root; testroot.appendchild(testnode); // on non-html documents innerhtml and getelementsbyid doesnt work properly try { testnode.innerhtml = ''; features.ishtmldocument = !!document.getelementbyid(id); } catch(e){}; if (features.ishtmldocument){ testnode.style.display = 'none'; // ie returns comment nodes for getelementsbytagname('*') for some documents testnode.appendchild(document.createcomment('')); starselectscomments = (testnode.getelementsbytagname('*').length > 1); // 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){}; features.brokenstargebtn = starselectscomments || starselectsclosed; // ie returns elements with the name instead of just id for getelementsbyid for some documents try { testnode.innerhtml = ''; features.idgetsname = document.getelementbyid(id) === testnode.firstchild; } catch(e){}; if (testnode.getelementsbyclassname){ // safari 3.2 getelementsbyclassname caches results 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){}; features.brokengebcn = cachedgetelementsbyclassname || brokensecondclassnamegebcn; } if (testnode.queryselectorall){ // ie 8 returns closed nodes (eg:"") for queryselectorall('*') for some documents try { testnode.innerhtml = 'foo'; selected = testnode.queryselectorall('*'); features.starselectsclosedqsa = (selected && !!selected.length && selected[0].nodename.charat(0) == '/'); } catch(e){}; // safari 3.2 queryselectorall doesnt work with mixedcase on quirksmode try { testnode.innerhtml = ''; features.brokenmixedcaseqsa = !testnode.queryselectorall('.mix').length; } catch(e){}; // webkit and opera dont return selected options on queryselectorall try { testnode.innerhtml = ''; features.brokencheckedqsa = (testnode.queryselectorall(':checked').length == 0); } catch(e){}; // ie returns incorrect results for attr[*^$]="" selectors on queryselectorall try { testnode.innerhtml = ''; features.brokenemptyattributeqsa = (testnode.queryselectorall('[class*=""]').length != 0); } catch(e){}; } // ie6-7, if a form has an input of id x, form.getattribute(x) returns a reference to the input try { testnode.innerhtml = '
'; brokenformattributegetter = (testnode.firstchild.getattribute('action') != 's'); } catch(e){}; // native matchesselector function features.nativematchesselector = root.matchesselector || /*root.msmatchesselector ||*/ root.mozmatchesselector || root.webkitmatchesselector; if (features.nativematchesselector) try { // if matchesselector trows errors on incorrect sintaxes we can use it features.nativematchesselector.call(root, ':slick'); features.nativematchesselector = null; } catch(e){}; } try { root.slick_expando = 1; delete root.slick_expando; features.getuid = this.getuidhtml; } catch(e) { features.getuid = this.getuidxml; } testroot.removechild(testnode); testnode = selected = testroot = null; // getattribute features.getattribute = (features.ishtmldocument && brokenformattributegetter) ? function(node, name){ var method = this.attributegetters[name]; if (method) return method.call(node); var attributenode = node.getattributenode(name); return (attributenode) ? attributenode.nodevalue : null; } : function(node, name){ var method = this.attributegetters[name]; return (method) ? method.call(node) : node.getattribute(name); }; // hasattribute features.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? var nativerootcontains = root && this.isnativecode(root.contains), nativedocumentcontains = document && this.isnativecode(document.contains); features.contains = (nativerootcontains && nativedocumentcontains) ? function(context, node){ return context.contains(node); } : (nativerootcontains && !nativedocumentcontains) ? function(context, node){ // ie8 does not have .contains on document. return context === node || ((context === document) ? document.documentelement : 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/) features.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 ; root = null; for (feature in features){ this[feature] = features[feature]; } }; // main method var resimpleselector = /^([#.]?)((?:[\w-]+|\*))$/, reemptyattribute = /\[.+[*$^]=(?:""|'')?\]/, qsafailexpcache = {}; local.search = function(context, expression, append, first){ var found = this.found = (first) ? null : (append || []); if (!context) return found; else if (context.navigator) context = context.document; // convert the node from a window to a document else if (!context.nodetype) return found; // setup var parsed, i, uniques = this.uniques = {}, hasothers = !!(append && append.length), contextisdocument = (context.nodetype == 9); if (this.document !== (contextisdocument ? context : context.ownerdocument)) this.setdocument(context); // avoid duplicating items already in the append array if (hasothers) for (i = found.length; i--;) uniques[this.getuid(found[i])] = true; // expression checks if (typeof expression == 'string'){ // expression is a string /**/ var simpleselector = expression.match(resimpleselector); simpleselectors: if (simpleselector) { var symbol = simpleselector[1], name = simpleselector[2], node, nodes; if (!symbol){ if (name == '*' && this.brokenstargebtn) break simpleselectors; nodes = context.getelementsbytagname(name); if (first) return nodes[0] || null; for (i = 0; node = nodes[i++];){ if (!(hasothers && uniques[this.getuid(node)])) found.push(node); } } else if (symbol == '#'){ if (!this.ishtmldocument || !contextisdocument) break simpleselectors; node = context.getelementbyid(name); if (!node) return found; if (this.idgetsname && node.getattributenode('id').nodevalue != name) break simpleselectors; if (first) return node || null; if (!(hasothers && uniques[this.getuid(node)])) found.push(node); } else if (symbol == '.'){ if (!this.ishtmldocument || ((!context.getelementsbyclassname || this.brokengebcn) && context.queryselectorall)) break simpleselectors; if (context.getelementsbyclassname && !this.brokengebcn){ nodes = context.getelementsbyclassname(name); if (first) return nodes[0] || null; for (i = 0; node = nodes[i++];){ if (!(hasothers && uniques[this.getuid(node)])) found.push(node); } } else { var matchclass = new regexp('(^|\\s)'+ slick.escaperegexp(name) +'(\\s|$)'); nodes = context.getelementsbytagname('*'); for (i = 0; node = nodes[i++];){ classname = node.classname; if (!(classname && matchclass.test(classname))) continue; if (first) return node; if (!(hasothers && uniques[this.getuid(node)])) found.push(node); } } } if (hasothers) this.sort(found); return (first) ? null : found; } /**/ /**/ queryselector: if (context.queryselectorall) { if (!this.ishtmldocument || qsafailexpcache[expression] //todo: only skip when expression is actually mixed case || this.brokenmixedcaseqsa || (this.brokencheckedqsa && expression.indexof(':checked') > -1) || (this.brokenemptyattributeqsa && reemptyattribute.test(expression)) || (!contextisdocument //abort when !contextisdocument and... // there are multiple expressions in the selector // since we currently only fix non-document rooted qsa for single expression selectors && expression.indexof(',') > -1 ) || slick.disableqsa ) break queryselector; var _expression = expression, _context = context; if (!contextisdocument){ // non-document rooted qsa // credits to andrew dupont var currentid = _context.getattribute('id'), slickid = 'slickid__'; _context.setattribute('id', slickid); _expression = '#' + slickid + ' ' + _expression; context = _context.parentnode; } try { if (first) return context.queryselector(_expression) || null; else nodes = context.queryselectorall(_expression); } catch(e) { qsafailexpcache[expression] = 1; break queryselector; } finally { if (!contextisdocument){ if (currentid) _context.setattribute('id', currentid); else _context.removeattribute('id'); context = _context; } } if (this.starselectsclosedqsa) for (i = 0; node = nodes[i++];){ if (node.nodename > '@' && !(hasothers && uniques[this.getuid(node)])) found.push(node); } else for (i = 0; node = nodes[i++];){ if (!(hasothers && uniques[this.getuid(node)])) found.push(node); } if (hasothers) this.sort(found); return found; } /**/ 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 = (!hasothers && (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; } // should sort if there are nodes in append and if you pass multiple expressions. if (hasothers || (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){ if (this.ishtmldocument && this.nativematchesselector){ try { return this.nativematchesselector.call(node, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]')); } catch(matcherror) {} } var parsed = this.slick.parse(selector); if (!parsed) return true; // simple (single) selectors var expressions = parsed.expressions, simpleexpcounter = 0, i; for (i = 0; (currentexpression = expressions[i]); i++){ if (currentexpression.length == 1){ var exp = currentexpression[0]; if (this.matchselector(node, (this.isxmldocument) ? exp.tag : exp.tag.touppercase(), exp.id, exp.classes, exp.attributes, exp.pseudos)) return true; simpleexpcounter++; } } if (simpleexpcounter == parsed.length) return false; var nodes = this.search(this.document, parsed), item; for (i = 0; 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){ var nodename = (this.isxmldocument) ? node.nodename : node.nodename.touppercase(); if (tag == '*'){ if (nodename < '@') return false; // fix for comment nodes and closed nodes } else { if (nodename != tag) return false; } } if (id && node.getattribute('id') != id) return false; var i, part, cls; if (classes) for (i = classes.length; i--;){ cls = this.getattribute(node, '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++];){ var idnode = item.getattributenode('id'); if (idnode && idnode.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.root, 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){ return this['pseudo:nth-child'](node, '2n'); }, 'odd': function(node){ 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; }, 'disabled': function(node){ return node.disabled; }, '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 var attributegetters = local.attributegetters = { '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'); }, 'tabindex': function(){ var attributenode = this.getattributenode('tabindex'); return (attributenode && attributenode.specified) ? attributenode.nodevalue : null; }, 'type': function(){ return this.getattribute('type'); }, 'maxlength': function(){ var attributenode = this.getattributenode('maxlength'); return (attributenode && attributenode.specified) ? attributenode.nodevalue : null; } }; attributegetters.maxlength = attributegetters.maxlength = attributegetters.maxlength; // slick var slick = local.slick = (this.slick || {}); slick.version = '1.1.7'; // 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){ local.setdocument(node); return local.getattribute(node, name); }; slick.hasattribute = function(node, name){ local.setdocument(node); return local.hasattribute(node, name); }; // slick matcher slick.match = function(node, selector){ if (!(node && selector)) return false; if (!selector || selector === node) return true; 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, object, 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 (!(/^[\w-]+$/).test(tag)){ 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 attr, i = 0, l = attributes.length; i < l; i++){ attr = attributes[i]; if (props[attr.key] != null) continue; if (attr.value != null && attr.operator == '=') props[attr.key] = attr.value; else if (!attr.value && !attr.operator) props[attr.key] = true; } if (parsed.classlist && props['class'] == null) props['class'] = parsed.classlist.join(' '); } return document.newelement(tag, props); }; if (browser.element){ element.prototype = browser.element.prototype; // ie8 and ie9 require the wrapping. element.prototype._fireevent = (function(fireevent){ return function(type, event){ return fireevent.call(this, type, event); }; })(element.prototype.fireevent); } 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 = { '$constructor': element, '$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(), unshift: function(){ var items = []; for (var i = 0, l = arguments.length; i < l; i++){ var item = document.id(arguments[i]); if (item) items.push(item); } return array.prototype.unshift.apply(this, items); }.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() }); //<1.2compat> elements.alias('extend', 'append'); // (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; var result = splice.apply(this, arguments); while (length >= this.length) delete this[length--]; return result; }.protect()); array.foreachmethod(function(method, name){ elements.implement(name, method); }); array.mirror(elements); /**/ var createelementacceptshtml; try { createelementacceptshtml = (document.createelement('').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); } }); })(); (function(){ slick.uidof(window); slick.uidof(document); 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){ slick.uidof(el); if (!nocash && !el.$family && !(/^(?:object|embed)$/i).test(el.tagname)){ var fireevent = el.fireevent; // wrapping needed in ie7, or else crash el._fireevent = function(type, event){ return fireevent(type, event); }; 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.uniquenumber) 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)); } }); 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); }); (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); // // tree walking var injectcombinator = function(expression, combinator){ if (!expression) return combinator; expression = object.clone(slick.parse(expression)); var expressions = expression.expressions; for (var i = expressions.length; i--;) expressions[i][0].combinator = combinator; return expression; }; object.foreach({ getnext: '~', getprevious: '!~', getparent: '!' }, function(combinator, method){ element.implement(method, function(expression){ return this.getelement(injectcombinator(expression, combinator)); }); }); object.foreach({ getallnext: '~', getallprevious: '!~', getsiblings: '~~', getchildren: '>', getparents: '!' }, function(combinator, method){ element.implement(method, function(expression){ return this.getelements(injectcombinator(expression, combinator)); }); }); element.implement({ getfirst: function(expression){ return document.id(slick.search(this, injectcombinator(expression, '>'))[0]); }, getlast: function(expression){ return document.id(slick.search(this, injectcombinator(expression, '>')).getlast()); }, 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'))); }, match: function(expression){ return !expression || slick.match(this, expression); } }); //<1.2compat> 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); }); // inserters 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); }); // // getproperty / setproperty var propertygetters = {}, propertysetters = {}; // properties var properties = {}; array.foreach([ 'type', 'value', 'defaultvalue', 'accesskey', 'cellpadding', 'cellspacing', 'colspan', 'frameborder', 'rowspan', 'tabindex', 'usemap' ], function(property){ properties[property.tolowercase()] = property; }); properties.html = 'innerhtml'; properties.text = (document.createelement('div').textcontent == null) ? 'innertext': 'textcontent'; object.foreach(properties, function(real, key){ propertysetters[key] = function(node, value){ node[real] = value; }; propertygetters[key] = function(node){ return node[real]; }; }); // booleans var bools = [ 'compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer', 'defaultchecked', 'autofocus', 'controls', 'autoplay', 'loop' ]; var booleans = {}; array.foreach(bools, function(bool){ var lower = bool.tolowercase(); booleans[lower] = bool; propertysetters[lower] = function(node, value){ node[bool] = !!value; }; propertygetters[lower] = function(node){ return !!node[bool]; }; }); // special cases object.append(propertysetters, { 'class': function(node, value){ ('classname' in node) ? node.classname = (value || '') : node.setattribute('class', value); }, 'for': function(node, value){ ('htmlfor' in node) ? node.htmlfor = value : node.setattribute('for', value); }, 'style': function(node, value){ (node.style) ? node.style.csstext = value : node.setattribute('style', value); }, 'value': function(node, value){ node.value = (value != null) ? value : ''; } }); propertygetters['class'] = function(node){ return ('classname' in node) ? node.classname || null : node.getattribute('class'); }; /* */ var el = document.createelement('button'); // ie sets type as readonly and throws try { el.type = 'button'; } catch(e){} if (el.type != 'button') propertysetters.type = function(node, value){ node.setattribute('type', value); }; el = null; /* */ /**/ var input = document.createelement('input'); input.value = 't'; input.type = 'submit'; if (input.value != 't') propertysetters.type = function(node, type){ var value = node.value; node.type = type; node.value = value; }; input = null; /**/ /* getproperty, setproperty */ /* */ var pollutesgetattribute = (function(div){ div.random = 'attribute'; return (div.getattribute('random') == 'attribute'); })(document.createelement('div')); /* */ element.implement({ setproperty: function(name, value){ var setter = propertysetters[name.tolowercase()]; if (setter){ setter(this, value); } else { /* */ if (pollutesgetattribute) var attributewhitelist = this.retrieve('$attributewhitelist', {}); /* */ if (value == null){ this.removeattribute(name); /* */ if (pollutesgetattribute) delete attributewhitelist[name]; /* */ } else { this.setattribute(name, '' + value); /* */ if (pollutesgetattribute) attributewhitelist[name] = true; /* */ } } return this; }, setproperties: function(attributes){ for (var attribute in attributes) this.setproperty(attribute, attributes[attribute]); return this; }, getproperty: function(name){ var getter = propertygetters[name.tolowercase()]; if (getter) return getter(this); /* */ if (pollutesgetattribute){ var attr = this.getattributenode(name), attributewhitelist = this.retrieve('$attributewhitelist', {}); if (!attr) return null; if (attr.expando && !attributewhitelist[name]){ var outer = this.outerhtml; // segment by the opening tag and find mention of attribute name if (outer.substr(0, outer.search(/\/?['"]?>(?![^<]*<['"])/)).indexof(name) < 0) return null; attributewhitelist[name] = true; } } /* */ var result = slick.getattribute(this, name); return (!result && !slick.hasattribute(this, name)) ? null : result; }, getproperties: function(){ var args = array.from(arguments); return args.map(this.getproperty, this).associate(args); }, removeproperty: function(name){ return this.setproperty(name, null); }, removeproperties: function(){ array.each(arguments, this.removeproperty, this); return this; }, 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; }, 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); }, 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('&'); } }); var collected = {}, storage = {}; var get = function(uid){ return (storage[uid] || (storage[uid] = {})); }; var clean = function(item){ var uid = item.uniquenumber; if (item.removeevents) item.removeevents(); if (item.clearattributes) item.clearattributes(); if (uid != null){ delete collected[uid]; delete storage[uid]; } return item; }; var formprops = {input: 'checked', option: 'selected', textarea: 'value'}; element.implement({ 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; }, clone: function(contents, keepid){ contents = contents !== false; var clone = this.clonenode(contents), ce = [clone], te = [this], i; if (contents){ ce.append(array.from(clone.getelementsbytagname('*'))); te.append(array.from(this.getelementsbytagname('*'))); } for (i = ce.length; i--;){ var node = ce[i], element = te[i]; if (!keepid) node.removeattribute('id'); /**/ if (node.clearattributes){ node.clearattributes(); node.mergeattributes(element); node.removeattribute('uniquenumber'); if (node.options){ var no = node.options, eo = element.options; for (var j = no.length; j--;) no[j].selected = eo[j].selected; } } /**/ var prop = formprops[element.tagname.tolowercase()]; if (prop && element[prop]) node[prop] = element[prop]; } /**/ if (browser.ie){ var co = clone.getelementsbytagname('object'), to = this.getelementsbytagname('object'); for (i = co.length; i--;) co[i].outerhtml = to[i].outerhtml; } /**/ return document.id(clone); } }); [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[slick.uidof(this)] = this; } if (this.addeventlistener) this.addeventlistener(type, fn, !!arguments[2]); else this.attachevent('on' + type, fn); return this; }, removelistener: function(type, fn){ if (this.removeeventlistener) this.removeeventlistener(type, fn, !!arguments[2]); else this.detachevent('on' + type, fn); return this; }, retrieve: function(property, dflt){ var storage = get(slick.uidof(this)), prop = storage[property]; if (dflt != null && prop == null) prop = storage[property] = dflt; return prop != null ? prop : null; }, store: function(property, value){ var storage = get(slick.uidof(this)); storage[property] = value; return this; }, eliminate: function(property){ var storage = get(slick.uidof(this)); delete storage[property]; return this; } }); /**/ 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(); } }; element.properties.html = { set: function(html){ if (html == null) html = ''; else if (typeof(html) == 'array') html = html.join(''); this.innerhtml = html; }, erase: function(){ this.innerhtml = ''; } }; /**/ // technique by jdbarlett - http://jdbartlett.com/innershiv/ var div = document.createelement('div'); div.innerhtml = ''; var supportshtml5elements = (div.childnodes.length == 1); if (!supportshtml5elements){ var tags = 'abbr article aside audio canvas datalist details figcaption figure footer header hgroup mark meter nav output progress section summary time video'.split(' '), fragment = document.createdocumentfragment(), l = tags.length; while (l--) fragment.createelement(tags[l]); } div = null; /**/ /**/ var supportstableinnerhtml = function.attempt(function(){ var table = document.createelement('table'); table.innerhtml = ''; return true; }); /**/ var tr = document.createelement('tr'), html = ''; tr.innerhtml = html; var supportstrinnerhtml = (tr.innerhtml == html); tr = null; /**/ if (!supportstableinnerhtml || !supportstrinnerhtml || !supportshtml5elements){ element.properties.html.set = (function(set){ var translations = { table: [1, '', '
'], select: [1, ''], tbody: [2, '', '
'], tr: [3, '', '
'] }; translations.thead = translations.tfoot = translations.tbody; return function(html){ var wrap = translations[this.get('tag')]; if (!wrap && !supportshtml5elements) wrap = [0, '', '']; if (!wrap) return set.call(this, html); var level = wrap[0], wrapper = document.createelement('div'), target = wrapper; if (!supportshtml5elements) fragment.appendchild(wrapper); wrapper.innerhtml = [wrap[1], html, wrap[2]].flatten().join(''); while (level--) target = target.firstchild; this.empty().adopt(target.childnodes); if (!supportshtml5elements) fragment.removechild(wrapper); wrapper = null; }; })(element.properties.html.set); } /*
*/ /**/ var testform = document.createelement('form'); testform.innerhtml = ''; if (testform.firstchild.value != 's') element.properties.value = { set: function(value){ var tag = this.get('tag'); if (tag != 'select') return this.setproperty('value', value); var options = this.getelements('option'); for (var i = 0; i < options.length; i++){ var option = options[i], attr = option.getattributenode('value'), optionvalue = (attr && attr.specified) ? option.value : option.get('text'); if (optionvalue == value) return option.selected = true; } }, get: function(){ var option = this, tag = option.get('tag'); if (tag != 'select' && tag != 'option') return this.getproperty('value'); if (tag == 'select' && !(option = option.getselected()[0])) return ''; var attr = option.getattributenode('value'); return (attr && attr.specified) ? option.value : option.get('text'); } }; testform = null; /**/ /**/ if (document.createelement('div').getattributenode('id')) element.properties.id = { set: function(id){ this.id = this.getattributenode('id').value = id; }, get: function(){ return this.id || null; }, erase: function(){ this.id = this.getattributenode('id').value = ''; } }; /**/ })(); /* --- 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; // // check for oldie, which does not remove styles when they're set to null var el = document.createelement('div'); el.style.color = 'red'; el.style.color = null; var doesnotremovestyles = el.style.color == 'red'; el = null; // element.properties.styles = {set: function(styles){ this.setstyles(styles); }}; var hasopacity = (html.style.opacity != null), hasfilter = (html.style.filter != null), realpha = /alpha\(opacity=([\d.]+)\)/i; var setvisibility = function(element, opacity){ element.store('$opacity', opacity); element.style.visibility = opacity > 0 || opacity == null ? 'visible' : 'hidden'; }; var setopacity = (hasopacity ? function(element, opacity){ element.style.opacity = opacity; } : (hasfilter ? function(element, opacity){ var style = element.style; if (!element.currentstyle || !element.currentstyle.haslayout) style.zoom = 1; if (opacity == null || opacity == 1) opacity = ''; else opacity = 'alpha(opacity=' + (opacity * 100).limit(0, 100).round() + ')'; var filter = style.filter || element.getcomputedstyle('filter') || ''; style.filter = realpha.test(filter) ? filter.replace(realpha, opacity) : filter + opacity; if (!style.filter) style.removeattribute('filter'); } : setvisibility)); var getopacity = (hasopacity ? function(element){ var opacity = element.style.opacity || element.getcomputedstyle('opacity'); return (opacity == '') ? 1 : opacity.tofloat(); } : (hasfilter ? function(element){ var filter = (element.style.filter || element.getcomputedstyle('filter')), opacity; if (filter) opacity = filter.match(realpha); return (opacity == null || filter == null) ? 1 : (opacity[1] / 100); } : function(element){ var opacity = element.retrieve('$opacity'); if (opacity == null) opacity = (element.style.visibility == 'hidden' ? 0 : 1); return opacity; })); 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; }, setstyle: function(property, value){ if (property == 'opacity'){ if (value != null) value = parsefloat(value); setopacity(this, value); return this; } property = (property == 'float' ? floatname : 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; // if ((value == '' || value == null) && doesnotremovestyles && this.style.removeattribute){ this.style.removeattribute(property); } // return this; }, getstyle: function(property){ if (property == 'opacity') return getopacity(this); property = (property == 'float' ? floatname : 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){ if ((/^(height|width)$/).test(property) && !(/px$/.test(result))){ 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.ie && (/^border(.+)width|margin|padding/).test(property) && isnan(parsefloat(result))){ 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.3compat> element.implement({ setopacity: function(value){ setopacity(this, value); return this; }, getopacity: function(){ return getopacity(this); } }); element.properties.opacity = { set: function(opacity){ setopacity(this, opacity); setvisibility(this, opacity); }, get: function(){ return getopacity(this); } }; // //<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, if necessary. 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, type); if (custom.condition){ condition = function(event){ if (custom.condition.call(this, event, type)) return fn.call(this, event); return true; }; } if (custom.base) realtype = function.from(custom.base).call(this, type); } var defn = function(){ return fn.call(self); }; var nativeevent = element.nativeevents[realtype]; if (nativeevent){ if (nativeevent == 2){ defn = function(event){ event = new domevent(event, self.getwindow()); if (condition.call(self, event) === false) event.stop(); }; } this.addlistener(realtype, defn, arguments[2]); } 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); if (custom.base) type = function.from(custom.base).call(this, type); } return (element.nativeevents[type]) ? this.removelistener(type, value, arguments[2]) : 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; } }); 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, paste: 2, input: 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 }; element.events = {mousewheel: { base: (browser.firefox) ? 'dommousescroll' : 'mousewheel' }}; if ('onmouseenter' in document.documentelement){ element.nativeevents.mouseenter = element.nativeevents.mouseleave = 2; } else { 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 }; element.events.mouseleave = { base: 'mouseout', condition: check }; } /**/ if (!window.addeventlistener){ element.nativeevents.propertychange = 2; element.events.change = { base: function(){ var type = this.type; return (this.get('tag') == 'input' && (type == 'radio' || type == 'checkbox')) ? 'propertychange' : 'change' }, condition: function(event){ return this.type != 'radio' || (event.event.propertyname == 'checked' && this.checked); } } } /**/ //<1.2compat> element.events = new hash(element.events); // })(); /* --- name: element.delegation description: extends the element native object to include the delegate method for more efficient event management. license: mit-style license. requires: [element.event] provides: [element.delegation] ... */ (function(){ var eventlistenersupport = !!window.addeventlistener; element.nativeevents.focusin = element.nativeevents.focusout = 2; var bubbleup = function(self, match, fn, event, target){ while (target && target != self){ if (match(target, event)) return fn.call(target, event, target); target = document.id(target.parentnode); } }; var map = { mouseenter: { base: 'mouseover' }, mouseleave: { base: 'mouseout' }, focus: { base: 'focus' + (eventlistenersupport ? '' : 'in'), capture: true }, blur: { base: eventlistenersupport ? 'blur' : 'focusout', capture: true } }; /**/ var _key = '$delegation:'; var formobserver = function(type){ return { base: 'focusin', remove: function(self, uid){ var list = self.retrieve(_key + type + 'listeners', {})[uid]; if (list && list.forms) for (var i = list.forms.length; i--;){ list.forms[i].removeevent(type, list.fns[i]); } }, listen: function(self, match, fn, event, target, uid){ var form = (target.get('tag') == 'form') ? target : event.target.getparent('form'); if (!form) return; var listeners = self.retrieve(_key + type + 'listeners', {}), listener = listeners[uid] || {forms: [], fns: []}, forms = listener.forms, fns = listener.fns; if (forms.indexof(form) != -1) return; forms.push(form); var _fn = function(event){ bubbleup(self, match, fn, event, target); }; form.addevent(type, _fn); fns.push(_fn); listeners[uid] = listener; self.store(_key + type + 'listeners', listeners); } }; }; var inputobserver = function(type){ return { base: 'focusin', listen: function(self, match, fn, event, target){ var events = {blur: function(){ this.removeevents(events); }}; events[type] = function(event){ bubbleup(self, match, fn, event, target); }; event.target.addevents(events); } }; }; if (!eventlistenersupport) object.append(map, { submit: formobserver('submit'), reset: formobserver('reset'), change: inputobserver('change'), select: inputobserver('select') }); /**/ var proto = element.prototype, addevent = proto.addevent, removeevent = proto.removeevent; var relay = function(old, method){ return function(type, fn, usecapture){ if (type.indexof(':relay') == -1) return old.call(this, type, fn, usecapture); var parsed = slick.parse(type).expressions[0][0]; if (parsed.pseudos[0].key != 'relay') return old.call(this, type, fn, usecapture); var newtype = parsed.tag; parsed.pseudos.slice(1).each(function(pseudo){ newtype += ':' + pseudo.key + (pseudo.value ? '(' + pseudo.value + ')' : ''); }); old.call(this, type, fn); return method.call(this, newtype, parsed.pseudos[0].value, fn); }; }; var delegation = { addevent: function(type, match, fn){ var storage = this.retrieve('$delegates', {}), stored = storage[type]; if (stored) for (var _uid in stored){ if (stored[_uid].fn == fn && stored[_uid].match == match) return this; } var _type = type, _match = match, _fn = fn, _map = map[type] || {}; type = _map.base || _type; match = function(target){ return slick.match(target, _match); }; var elementevent = element.events[_type]; if (elementevent && elementevent.condition){ var __match = match, condition = elementevent.condition; match = function(target, event){ return __match(target, event) && condition.call(target, event, type); }; } var self = this, uid = string.uniqueid(); var delegator = _map.listen ? function(event, target){ if (!target && event && event.target) target = event.target; if (target) _map.listen(self, match, fn, event, target, uid); } : function(event, target){ if (!target && event && event.target) target = event.target; if (target) bubbleup(self, match, fn, event, target); }; if (!stored) stored = {}; stored[uid] = { match: _match, fn: _fn, delegator: delegator }; storage[_type] = stored; return addevent.call(this, type, delegator, _map.capture); }, removeevent: function(type, match, fn, _uid){ var storage = this.retrieve('$delegates', {}), stored = storage[type]; if (!stored) return this; if (_uid){ var _type = type, delegator = stored[_uid].delegator, _map = map[type] || {}; type = _map.base || _type; if (_map.remove) _map.remove(this, _uid); delete stored[_uid]; storage[_type] = stored; return removeevent.call(this, type, delegator); } var __uid, s; if (fn) for (__uid in stored){ s = stored[__uid]; if (s.match == match && s.fn == fn) return delegation.removeevent.call(this, type, match, fn, __uid); } else for (__uid in stored){ s = stored[__uid]; if (s.match == match) delegation.removeevent.call(this, type, match, s.fn, __uid); } return this; } }; [element, window, document].invoke('implement', { addevent: relay(addevent, delegation.addevent), removeevent: relay(removeevent, delegation.removeevent) }); })(); /* --- 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(){ var element = document.createelement('div'), child = document.createelement('div'); element.style.height = '0'; element.appendchild(child); var brokenoffsetparent = (child.offsetparent === element); element = child = null; var isoffset = function(el){ return stylestring(el, 'position') != 'static' || isbody(el); }; var isoffsetstatic = function(el){ return isoffset(el) || (/^(?:table|td|th)$/i).test(el.tagname); }; 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: brokenoffsetparent ? function(){ var element = this; if (isbody(element) || stylestring(element, 'position') == 'fixed') return null; var isoffsetcheck = (stylestring(element, 'position') == 'static') ? isoffsetstatic : isoffset; while ((element = element.parentnode)){ if (isoffsetcheck(element)) return element; } return null; } : function(){ var element = this; if (isbody(element) || stylestring(element, 'position') == 'fixed') return null; try { return element.offsetparent; } catch(e) {} 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){ 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: 60, unit: false, duration: 500, frames: null, frameskip: true, 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(now){ if (this.options.frameskip){ var diff = (this.time != null) ? (now - this.time) : 0, frames = diff / this.frameinterval; this.time = now; this.frame += frames; } else { this.frame++; } if (this.frame < this.frames){ var delta = this.transition(this.frame / this.frames); this.set(this.compute(this.from, this.to, delta)); } else { this.frame = this.frames; this.set(this.compute(this.from, this.to, 1)); this.stop(); } }, set: function(now){ return now; }, compute: function(from, to, delta){ return fx.compute(from, to, delta); }, check: function(){ if (!this.isrunning()) 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; this.from = from; this.to = to; this.frame = (this.options.frameskip) ? 0 : -1; this.time = null; this.transition = this.gettransition(); var frames = this.options.frames, fps = this.options.fps, duration = this.options.duration; this.duration = fx.durations[duration] || duration.toint(); this.frameinterval = 1000 / fps; this.frames = frames || math.round(this.duration / this.frameinterval); this.fireevent('start', this.subject); pushinstance.call(this, fps); return this; }, stop: function(){ if (this.isrunning()){ this.time = null; pullinstance.call(this, this.options.fps); if (this.frames == this.frame){ this.fireevent('complete', this.subject); if (!this.callchain()) this.fireevent('chaincomplete', this.subject); } else { this.fireevent('stop', this.subject); } } return this; }, cancel: function(){ if (this.isrunning()){ this.time = null; pullinstance.call(this, this.options.fps); this.frame = this.frames; this.fireevent('cancel', this.subject).clearchain(); } return this; }, pause: function(){ if (this.isrunning()){ this.time = null; pullinstance.call(this, this.options.fps); } return this; }, resume: function(){ if ((this.frame < this.frames) && !this.isrunning()) pushinstance.call(this, this.options.fps); return this; }, isrunning: function(){ var list = instances[this.options.fps]; return list && list.contains(this); } }); 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(){ var now = date.now(); for (var i = this.length; i--;){ var instance = this[i]; if (instance) instance.step(now); } }; var pushinstance = function(fps){ var list = instances[fps] || (instances[fps] = []); list.push(this); if (!timers[fps]) timers[fps] = loop.periodical(math.round(1000 / fps), list); }; var pullinstance = function(fps){ var list = instances[fps]; if (list){ list.erase(this); if (!list.length && timers[fps]){ delete instances[fps]; timers[fps] = clearinterval(timers[fps]); } } }; })(); /* --- 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); var from = values[0], to = values[1]; if (to == null){ to = from; from = element.getstyle(property); var unit = this.options.unit; // adapted from: https://github.com/ryanmorr/fx/blob/master/fx.js#l299 if (unit && from.slice(-unit.length) != unit && parsefloat(from) != 0){ element.setstyle(property, to + unit); var value = element.getcomputedstyle(property); // ie and opera support pixelleft or pixelwidth if (!(/px$/.test(value))){ value = element.style[('pixel-' + property).camelcase()]; if (value == null){ // adapted from dean edwards' http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291 var left = element.style.left; element.style.left = to + unit; value = element.style.pixelleft; element.style.left = left; } } from = (to || 1) / (parsefloat(value) || 1) * (parsefloat(from) || 0); element.setstyle(property, from + unit); } } return {from: this.parse(from), to: this.parse(to)}; }, //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 = {}, selectortest = new regexp('^' + selector.escaperegexp() + '$'); 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 || !selectortest.test(selectortext)) return; object.each(element.styles, function(value, style){ if (!rule.style[style] || element.shortstyles[style]) return; value = string(rule.style[style]); to[style] = ((/^rgb/).test(value)) ? 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(property, from, to); return this; }, fade: function(how){ var fade = this.get('tween'), method, args = ['opacity'].append(arguments), toggle; if (args[1] == null) args[1] = 'toggle'; switch (args[1]){ case 'in': method = 'start'; args[1] = 1; break; case 'out': method = 'start'; args[1] = 0; break; case 'show': method = 'set'; args[1] = 1; break; case 'hide': method = 'set'; args[1] = 0; break; case 'toggle': var flag = this.retrieve('fade:flag', this.getstyle('opacity') == 1); method = 'start'; args[1] = flag ? 0 : 1; this.store('fade:flag', !flag); toggle = true; break; default: method = 'start'; } if (!toggle) this.eliminate('fade:flag'); fade[method].apply(fade, args); var to = args[args.length - 1]; if (method == 'set' || to != 0) this.setstyle('visibility', to == 0 ? 'hidden' : 'visible'); else fade.chain(function(){ this.element.setstyle('visibility', 'hidden'); this.callchain(); }); 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); var easein = function(pos){ return transition(pos, params); }; return object.append(easein, { easein: easein, easeout: function(pos){ return 1 - transition(1 - pos, params); }, easeinout: function(pos){ return (pos <= 0.5 ? transition(2 * pos, params) : (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.cos(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 empty = function(){}, 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 = empty; if (progresssupport) xhr.onprogress = xhr.onloadstart = empty; 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(); else 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 = empty; if (progresssupport) xhr.onprogress = xhr.onloadstart = empty; 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){ var object = { method: method }; if (data != null) object.data = data; return this.send(object); }; }); 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(options.filter || '*'); if (options.filter) response.tree = response.elements; if (options.update){ var update = document.id(options.update).empty(); if (options.filter) update.adopt(response.elements); else update.set('html', response.html); } else if (options.append){ var append = document.id(options.append); if (options.filter) response.elements.reverse().inject(append); else 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. seealso: requires: [array, string, number, function] provides: json ... */ if (typeof json == 'undefined') this.json = {}; //<1.2compat> json = new hash({ stringify: json.stringify, parse: json.parse }); // (function(){ var special = {'\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\'}; var escape = function(chr){ return special[chr] || '\\u' + ('0000' + chr.charcodeat(0).tostring(16)).slice(-4); }; json.validate = function(string){ string = string.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fa-f]{4})/g, '@'). replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[ee][+\-]?\d+)?/g, ']'). replace(/(?:^|:|,)(?:\s*\[)+/g, ''); return (/^[\],:{}\s]*$/).test(string); }; json.encode = json.stringify ? function(obj){ return json.stringify(obj); } : function(obj){ if (obj && obj.tojson) obj = obj.tojson(); switch (typeof(obj)){ case 'string': return '"' + obj.replace(/[\x00-\x1f\\"]/g, escape) + '"'; case 'array': return '[' + 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 '' + obj; case 'null': return 'null'; } return null; }; json.decode = function(string, secure){ if (!string || typeof(string) != 'string') return null; if (secure || json.secure){ if (json.parse) return json.parse(string); if (!json.validate(string)) throw new error('json could not decode the input; security is enabled and the value is not secure.'); } 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: { /*onerror: function(text, error){},*/ secure: true }, initialize: function(options){ this.parent(options); object.append(this.headers, { 'accept': 'application/json', 'x-request': 'json' }); }, success: function(text){ var json; try { json = this.response.json = json.decode(text, this.options.secure); } catch (error){ this.fireevent('error', [text, error]); return; } 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, browser] 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, testelement = document.createelement('div'); 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/ // testelement.doscroll() throws when the dom is not ready, only in the top window var doscrollworks = function(){ try { testelement.doscroll(); return true; } catch (e){} return false; }; // if doscroll works already, it can't be used to determine domready // e.g. in an iframe if (testelement.doscroll && !doscrollworks()){ checks.push(doscrollworks); 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, element] provides: swiff ... */ (function(){ 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_' + string.uniqueid(); 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()].append(arguments)); } }); swiff.callbacks = {}; swiff.remote = function(obj, fn){ var rs = obj.callfunction('' + __flash__argumentstoxml(arguments, 2) + ''); return eval(rs); }; })();