PageRenderTime 61ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 1ms

/media/system/js/mootools-core-uncompressed.js

https://bitbucket.org/pastor399/newcastleunifc
JavaScript | 2006 lines | 1344 code | 396 blank | 266 comment | 467 complexity | cadb9ed581ae24473a627594e9a01b00 MD5 | raw file
  1. /*
  2. ---
  3. MooTools: the javascript framework
  4. web build:
  5. - http://mootools.net/core/76bf47062d6c1983d66ce47ad66aa0e0
  6. packager build:
  7. - 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
  8. ...
  9. */
  10. /*
  11. ---
  12. name: Core
  13. description: The heart of MooTools.
  14. license: MIT-style license.
  15. copyright: Copyright (c) 2006-2012 [Valerio Proietti](http://mad4milk.net/).
  16. authors: The MooTools production team (http://mootools.net/developers/)
  17. inspiration:
  18. - 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)
  19. - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
  20. provides: [Core, MooTools, Type, typeOf, instanceOf, Native]
  21. ...
  22. */
  23. (function(){
  24. this.MooTools = {
  25. version: '1.4.5',
  26. build: '74e34796f5f76640cdb98853004650aea1499d69'
  27. };
  28. // typeOf, instanceOf
  29. var typeOf = this.typeOf = function(item){
  30. if (item == null) return 'null';
  31. if (item.$family != null) return item.$family();
  32. if (item.nodeName){
  33. if (item.nodeType == 1) return 'element';
  34. if (item.nodeType == 3) return (/\S/).test(item.nodeValue) ? 'textnode' : 'whitespace';
  35. } else if (typeof item.length == 'number'){
  36. if (item.callee) return 'arguments';
  37. if ('item' in item) return 'collection';
  38. }
  39. return typeof item;
  40. };
  41. var instanceOf = this.instanceOf = function(item, object){
  42. if (item == null) return false;
  43. var constructor = item.$constructor || item.constructor;
  44. while (constructor){
  45. if (constructor === object) return true;
  46. constructor = constructor.parent;
  47. }
  48. /*<ltIE8>*/
  49. if (!item.hasOwnProperty) return false;
  50. /*</ltIE8>*/
  51. return item instanceof object;
  52. };
  53. // Function overloading
  54. var Function = this.Function;
  55. var enumerables = true;
  56. for (var i in {toString: 1}) enumerables = null;
  57. if (enumerables) enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable', 'toLocaleString', 'toString', 'constructor'];
  58. Function.prototype.overloadSetter = function(usePlural){
  59. var self = this;
  60. return function(a, b){
  61. if (a == null) return this;
  62. if (usePlural || typeof a != 'string'){
  63. for (var k in a) self.call(this, k, a[k]);
  64. if (enumerables) for (var i = enumerables.length; i--;){
  65. k = enumerables[i];
  66. if (a.hasOwnProperty(k)) self.call(this, k, a[k]);
  67. }
  68. } else {
  69. self.call(this, a, b);
  70. }
  71. return this;
  72. };
  73. };
  74. Function.prototype.overloadGetter = function(usePlural){
  75. var self = this;
  76. return function(a){
  77. var args, result;
  78. if (typeof a != 'string') args = a;
  79. else if (arguments.length > 1) args = arguments;
  80. else if (usePlural) args = [a];
  81. if (args){
  82. result = {};
  83. for (var i = 0; i < args.length; i++) result[args[i]] = self.call(this, args[i]);
  84. } else {
  85. result = self.call(this, a);
  86. }
  87. return result;
  88. };
  89. };
  90. Function.prototype.extend = function(key, value){
  91. this[key] = value;
  92. }.overloadSetter();
  93. Function.prototype.implement = function(key, value){
  94. this.prototype[key] = value;
  95. }.overloadSetter();
  96. // From
  97. var slice = Array.prototype.slice;
  98. Function.from = function(item){
  99. return (typeOf(item) == 'function') ? item : function(){
  100. return item;
  101. };
  102. };
  103. Array.from = function(item){
  104. if (item == null) return [];
  105. return (Type.isEnumerable(item) && typeof item != 'string') ? (typeOf(item) == 'array') ? item : slice.call(item) : [item];
  106. };
  107. Number.from = function(item){
  108. var number = parseFloat(item);
  109. return isFinite(number) ? number : null;
  110. };
  111. String.from = function(item){
  112. return item + '';
  113. };
  114. // hide, protect
  115. Function.implement({
  116. hide: function(){
  117. this.$hidden = true;
  118. return this;
  119. },
  120. protect: function(){
  121. this.$protected = true;
  122. return this;
  123. }
  124. });
  125. // Type
  126. var Type = this.Type = function(name, object){
  127. if (name){
  128. var lower = name.toLowerCase();
  129. var typeCheck = function(item){
  130. return (typeOf(item) == lower);
  131. };
  132. Type['is' + name] = typeCheck;
  133. if (object != null){
  134. object.prototype.$family = (function(){
  135. return lower;
  136. }).hide();
  137. }
  138. }
  139. if (object == null) return null;
  140. object.extend(this);
  141. object.$constructor = Type;
  142. object.prototype.$constructor = object;
  143. return object;
  144. };
  145. var toString = Object.prototype.toString;
  146. Type.isEnumerable = function(item){
  147. return (item != null && typeof item.length == 'number' && toString.call(item) != '[object Function]' );
  148. };
  149. var hooks = {};
  150. var hooksOf = function(object){
  151. var type = typeOf(object.prototype);
  152. return hooks[type] || (hooks[type] = []);
  153. };
  154. var implement = function(name, method){
  155. if (method && method.$hidden) return;
  156. var hooks = hooksOf(this);
  157. for (var i = 0; i < hooks.length; i++){
  158. var hook = hooks[i];
  159. if (typeOf(hook) == 'type') implement.call(hook, name, method);
  160. else hook.call(this, name, method);
  161. }
  162. var previous = this.prototype[name];
  163. if (previous == null || !previous.$protected) this.prototype[name] = method;
  164. if (this[name] == null && typeOf(method) == 'function') extend.call(this, name, function(item){
  165. return method.apply(item, slice.call(arguments, 1));
  166. });
  167. };
  168. var extend = function(name, method){
  169. if (method && method.$hidden) return;
  170. var previous = this[name];
  171. if (previous == null || !previous.$protected) this[name] = method;
  172. };
  173. Type.implement({
  174. implement: implement.overloadSetter(),
  175. extend: extend.overloadSetter(),
  176. alias: function(name, existing){
  177. implement.call(this, name, this.prototype[existing]);
  178. }.overloadSetter(),
  179. mirror: function(hook){
  180. hooksOf(this).push(hook);
  181. return this;
  182. }
  183. });
  184. new Type('Type', Type);
  185. // Default Types
  186. var force = function(name, object, methods){
  187. var isType = (object != Object),
  188. prototype = object.prototype;
  189. if (isType) object = new Type(name, object);
  190. for (var i = 0, l = methods.length; i < l; i++){
  191. var key = methods[i],
  192. generic = object[key],
  193. proto = prototype[key];
  194. if (generic) generic.protect();
  195. if (isType && proto) object.implement(key, proto.protect());
  196. }
  197. if (isType){
  198. var methodsEnumerable = prototype.propertyIsEnumerable(methods[0]);
  199. object.forEachMethod = function(fn){
  200. if (!methodsEnumerable) for (var i = 0, l = methods.length; i < l; i++){
  201. fn.call(prototype, prototype[methods[i]], methods[i]);
  202. }
  203. for (var key in prototype) fn.call(prototype, prototype[key], key)
  204. };
  205. }
  206. return force;
  207. };
  208. force('String', String, [
  209. 'charAt', 'charCodeAt', 'concat', 'indexOf', 'lastIndexOf', 'match', 'quote', 'replace', 'search',
  210. 'slice', 'split', 'substr', 'substring', 'trim', 'toLowerCase', 'toUpperCase'
  211. ])('Array', Array, [
  212. 'pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice',
  213. 'indexOf', 'lastIndexOf', 'filter', 'forEach', 'every', 'map', 'some', 'reduce', 'reduceRight'
  214. ])('Number', Number, [
  215. 'toExponential', 'toFixed', 'toLocaleString', 'toPrecision'
  216. ])('Function', Function, [
  217. 'apply', 'call', 'bind'
  218. ])('RegExp', RegExp, [
  219. 'exec', 'test'
  220. ])('Object', Object, [
  221. 'create', 'defineProperty', 'defineProperties', 'keys',
  222. 'getPrototypeOf', 'getOwnPropertyDescriptor', 'getOwnPropertyNames',
  223. 'preventExtensions', 'isExtensible', 'seal', 'isSealed', 'freeze', 'isFrozen'
  224. ])('Date', Date, ['now']);
  225. Object.extend = extend.overloadSetter();
  226. Date.extend('now', function(){
  227. return +(new Date);
  228. });
  229. new Type('Boolean', Boolean);
  230. // fixes NaN returning as Number
  231. Number.prototype.$family = function(){
  232. return isFinite(this) ? 'number' : 'null';
  233. }.hide();
  234. // Number.random
  235. Number.extend('random', function(min, max){
  236. return Math.floor(Math.random() * (max - min + 1) + min);
  237. });
  238. // forEach, each
  239. var hasOwnProperty = Object.prototype.hasOwnProperty;
  240. Object.extend('forEach', function(object, fn, bind){
  241. for (var key in object){
  242. if (hasOwnProperty.call(object, key)) fn.call(bind, object[key], key, object);
  243. }
  244. });
  245. Object.each = Object.forEach;
  246. Array.implement({
  247. forEach: function(fn, bind){
  248. for (var i = 0, l = this.length; i < l; i++){
  249. if (i in this) fn.call(bind, this[i], i, this);
  250. }
  251. },
  252. each: function(fn, bind){
  253. Array.forEach(this, fn, bind);
  254. return this;
  255. }
  256. });
  257. // Array & Object cloning, Object merging and appending
  258. var cloneOf = function(item){
  259. switch (typeOf(item)){
  260. case 'array': return item.clone();
  261. case 'object': return Object.clone(item);
  262. default: return item;
  263. }
  264. };
  265. Array.implement('clone', function(){
  266. var i = this.length, clone = new Array(i);
  267. while (i--) clone[i] = cloneOf(this[i]);
  268. return clone;
  269. });
  270. var mergeOne = function(source, key, current){
  271. switch (typeOf(current)){
  272. case 'object':
  273. if (typeOf(source[key]) == 'object') Object.merge(source[key], current);
  274. else source[key] = Object.clone(current);
  275. break;
  276. case 'array': source[key] = current.clone(); break;
  277. default: source[key] = current;
  278. }
  279. return source;
  280. };
  281. Object.extend({
  282. merge: function(source, k, v){
  283. if (typeOf(k) == 'string') return mergeOne(source, k, v);
  284. for (var i = 1, l = arguments.length; i < l; i++){
  285. var object = arguments[i];
  286. for (var key in object) mergeOne(source, key, object[key]);
  287. }
  288. return source;
  289. },
  290. clone: function(object){
  291. var clone = {};
  292. for (var key in object) clone[key] = cloneOf(object[key]);
  293. return clone;
  294. },
  295. append: function(original){
  296. for (var i = 1, l = arguments.length; i < l; i++){
  297. var extended = arguments[i] || {};
  298. for (var key in extended) original[key] = extended[key];
  299. }
  300. return original;
  301. }
  302. });
  303. // Object-less types
  304. ['Object', 'WhiteSpace', 'TextNode', 'Collection', 'Arguments'].each(function(name){
  305. new Type(name);
  306. });
  307. // Unique ID
  308. var UID = Date.now();
  309. String.extend('uniqueID', function(){
  310. return (UID++).toString(36);
  311. });
  312. })();
  313. /*
  314. ---
  315. name: Array
  316. description: Contains Array Prototypes like each, contains, and erase.
  317. license: MIT-style license.
  318. requires: Type
  319. provides: Array
  320. ...
  321. */
  322. Array.implement({
  323. /*<!ES5>*/
  324. every: function(fn, bind){
  325. for (var i = 0, l = this.length >>> 0; i < l; i++){
  326. if ((i in this) && !fn.call(bind, this[i], i, this)) return false;
  327. }
  328. return true;
  329. },
  330. filter: function(fn, bind){
  331. var results = [];
  332. for (var value, i = 0, l = this.length >>> 0; i < l; i++) if (i in this){
  333. value = this[i];
  334. if (fn.call(bind, value, i, this)) results.push(value);
  335. }
  336. return results;
  337. },
  338. indexOf: function(item, from){
  339. var length = this.length >>> 0;
  340. for (var i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++){
  341. if (this[i] === item) return i;
  342. }
  343. return -1;
  344. },
  345. map: function(fn, bind){
  346. var length = this.length >>> 0, results = Array(length);
  347. for (var i = 0; i < length; i++){
  348. if (i in this) results[i] = fn.call(bind, this[i], i, this);
  349. }
  350. return results;
  351. },
  352. some: function(fn, bind){
  353. for (var i = 0, l = this.length >>> 0; i < l; i++){
  354. if ((i in this) && fn.call(bind, this[i], i, this)) return true;
  355. }
  356. return false;
  357. },
  358. /*</!ES5>*/
  359. clean: function(){
  360. return this.filter(function(item){
  361. return item != null;
  362. });
  363. },
  364. invoke: function(methodName){
  365. var args = Array.slice(arguments, 1);
  366. return this.map(function(item){
  367. return item[methodName].apply(item, args);
  368. });
  369. },
  370. associate: function(keys){
  371. var obj = {}, length = Math.min(this.length, keys.length);
  372. for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
  373. return obj;
  374. },
  375. link: function(object){
  376. var result = {};
  377. for (var i = 0, l = this.length; i < l; i++){
  378. for (var key in object){
  379. if (object[key](this[i])){
  380. result[key] = this[i];
  381. delete object[key];
  382. break;
  383. }
  384. }
  385. }
  386. return result;
  387. },
  388. contains: function(item, from){
  389. return this.indexOf(item, from) != -1;
  390. },
  391. append: function(array){
  392. this.push.apply(this, array);
  393. return this;
  394. },
  395. getLast: function(){
  396. return (this.length) ? this[this.length - 1] : null;
  397. },
  398. getRandom: function(){
  399. return (this.length) ? this[Number.random(0, this.length - 1)] : null;
  400. },
  401. include: function(item){
  402. if (!this.contains(item)) this.push(item);
  403. return this;
  404. },
  405. combine: function(array){
  406. for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
  407. return this;
  408. },
  409. erase: function(item){
  410. for (var i = this.length; i--;){
  411. if (this[i] === item) this.splice(i, 1);
  412. }
  413. return this;
  414. },
  415. empty: function(){
  416. this.length = 0;
  417. return this;
  418. },
  419. flatten: function(){
  420. var array = [];
  421. for (var i = 0, l = this.length; i < l; i++){
  422. var type = typeOf(this[i]);
  423. if (type == 'null') continue;
  424. array = array.concat((type == 'array' || type == 'collection' || type == 'arguments' || instanceOf(this[i], Array)) ? Array.flatten(this[i]) : this[i]);
  425. }
  426. return array;
  427. },
  428. pick: function(){
  429. for (var i = 0, l = this.length; i < l; i++){
  430. if (this[i] != null) return this[i];
  431. }
  432. return null;
  433. },
  434. hexToRgb: function(array){
  435. if (this.length != 3) return null;
  436. var rgb = this.map(function(value){
  437. if (value.length == 1) value += value;
  438. return value.toInt(16);
  439. });
  440. return (array) ? rgb : 'rgb(' + rgb + ')';
  441. },
  442. rgbToHex: function(array){
  443. if (this.length < 3) return null;
  444. if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
  445. var hex = [];
  446. for (var i = 0; i < 3; i++){
  447. var bit = (this[i] - 0).toString(16);
  448. hex.push((bit.length == 1) ? '0' + bit : bit);
  449. }
  450. return (array) ? hex : '#' + hex.join('');
  451. }
  452. });
  453. /*
  454. ---
  455. name: String
  456. description: Contains String Prototypes like camelCase, capitalize, test, and toInt.
  457. license: MIT-style license.
  458. requires: Type
  459. provides: String
  460. ...
  461. */
  462. String.implement({
  463. test: function(regex, params){
  464. return ((typeOf(regex) == 'regexp') ? regex : new RegExp('' + regex, params)).test(this);
  465. },
  466. contains: function(string, separator){
  467. return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : String(this).indexOf(string) > -1;
  468. },
  469. trim: function(){
  470. return String(this).replace(/^\s+|\s+$/g, '');
  471. },
  472. clean: function(){
  473. return String(this).replace(/\s+/g, ' ').trim();
  474. },
  475. camelCase: function(){
  476. return String(this).replace(/-\D/g, function(match){
  477. return match.charAt(1).toUpperCase();
  478. });
  479. },
  480. hyphenate: function(){
  481. return String(this).replace(/[A-Z]/g, function(match){
  482. return ('-' + match.charAt(0).toLowerCase());
  483. });
  484. },
  485. capitalize: function(){
  486. return String(this).replace(/\b[a-z]/g, function(match){
  487. return match.toUpperCase();
  488. });
  489. },
  490. escapeRegExp: function(){
  491. return String(this).replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
  492. },
  493. toInt: function(base){
  494. return parseInt(this, base || 10);
  495. },
  496. toFloat: function(){
  497. return parseFloat(this);
  498. },
  499. hexToRgb: function(array){
  500. var hex = String(this).match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
  501. return (hex) ? hex.slice(1).hexToRgb(array) : null;
  502. },
  503. rgbToHex: function(array){
  504. var rgb = String(this).match(/\d{1,3}/g);
  505. return (rgb) ? rgb.rgbToHex(array) : null;
  506. },
  507. substitute: function(object, regexp){
  508. return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
  509. if (match.charAt(0) == '\\') return match.slice(1);
  510. return (object[name] != null) ? object[name] : '';
  511. });
  512. }
  513. });
  514. /*
  515. ---
  516. name: Number
  517. description: Contains Number Prototypes like limit, round, times, and ceil.
  518. license: MIT-style license.
  519. requires: Type
  520. provides: Number
  521. ...
  522. */
  523. Number.implement({
  524. limit: function(min, max){
  525. return Math.min(max, Math.max(min, this));
  526. },
  527. round: function(precision){
  528. precision = Math.pow(10, precision || 0).toFixed(precision < 0 ? -precision : 0);
  529. return Math.round(this * precision) / precision;
  530. },
  531. times: function(fn, bind){
  532. for (var i = 0; i < this; i++) fn.call(bind, i, this);
  533. },
  534. toFloat: function(){
  535. return parseFloat(this);
  536. },
  537. toInt: function(base){
  538. return parseInt(this, base || 10);
  539. }
  540. });
  541. Number.alias('each', 'times');
  542. (function(math){
  543. var methods = {};
  544. math.each(function(name){
  545. if (!Number[name]) methods[name] = function(){
  546. return Math[name].apply(null, [this].concat(Array.from(arguments)));
  547. };
  548. });
  549. Number.implement(methods);
  550. })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
  551. /*
  552. ---
  553. name: Function
  554. description: Contains Function Prototypes like create, bind, pass, and delay.
  555. license: MIT-style license.
  556. requires: Type
  557. provides: Function
  558. ...
  559. */
  560. Function.extend({
  561. attempt: function(){
  562. for (var i = 0, l = arguments.length; i < l; i++){
  563. try {
  564. return arguments[i]();
  565. } catch (e){}
  566. }
  567. return null;
  568. }
  569. });
  570. Function.implement({
  571. attempt: function(args, bind){
  572. try {
  573. return this.apply(bind, Array.from(args));
  574. } catch (e){}
  575. return null;
  576. },
  577. /*<!ES5-bind>*/
  578. bind: function(that){
  579. var self = this,
  580. args = arguments.length > 1 ? Array.slice(arguments, 1) : null,
  581. F = function(){};
  582. var bound = function(){
  583. var context = that, length = arguments.length;
  584. if (this instanceof bound){
  585. F.prototype = self.prototype;
  586. context = new F;
  587. }
  588. var result = (!args && !length)
  589. ? self.call(context)
  590. : self.apply(context, args && length ? args.concat(Array.slice(arguments)) : args || arguments);
  591. return context == that ? result : context;
  592. };
  593. return bound;
  594. },
  595. /*</!ES5-bind>*/
  596. pass: function(args, bind){
  597. var self = this;
  598. if (args != null) args = Array.from(args);
  599. return function(){
  600. return self.apply(bind, args || arguments);
  601. };
  602. },
  603. delay: function(delay, bind, args){
  604. return setTimeout(this.pass((args == null ? [] : args), bind), delay);
  605. },
  606. periodical: function(periodical, bind, args){
  607. return setInterval(this.pass((args == null ? [] : args), bind), periodical);
  608. }
  609. });
  610. /*
  611. ---
  612. name: Object
  613. description: Object generic methods
  614. license: MIT-style license.
  615. requires: Type
  616. provides: [Object, Hash]
  617. ...
  618. */
  619. (function(){
  620. var hasOwnProperty = Object.prototype.hasOwnProperty;
  621. Object.extend({
  622. subset: function(object, keys){
  623. var results = {};
  624. for (var i = 0, l = keys.length; i < l; i++){
  625. var k = keys[i];
  626. if (k in object) results[k] = object[k];
  627. }
  628. return results;
  629. },
  630. map: function(object, fn, bind){
  631. var results = {};
  632. for (var key in object){
  633. if (hasOwnProperty.call(object, key)) results[key] = fn.call(bind, object[key], key, object);
  634. }
  635. return results;
  636. },
  637. filter: function(object, fn, bind){
  638. var results = {};
  639. for (var key in object){
  640. var value = object[key];
  641. if (hasOwnProperty.call(object, key) && fn.call(bind, value, key, object)) results[key] = value;
  642. }
  643. return results;
  644. },
  645. every: function(object, fn, bind){
  646. for (var key in object){
  647. if (hasOwnProperty.call(object, key) && !fn.call(bind, object[key], key)) return false;
  648. }
  649. return true;
  650. },
  651. some: function(object, fn, bind){
  652. for (var key in object){
  653. if (hasOwnProperty.call(object, key) && fn.call(bind, object[key], key)) return true;
  654. }
  655. return false;
  656. },
  657. keys: function(object){
  658. var keys = [];
  659. for (var key in object){
  660. if (hasOwnProperty.call(object, key)) keys.push(key);
  661. }
  662. return keys;
  663. },
  664. values: function(object){
  665. var values = [];
  666. for (var key in object){
  667. if (hasOwnProperty.call(object, key)) values.push(object[key]);
  668. }
  669. return values;
  670. },
  671. getLength: function(object){
  672. return Object.keys(object).length;
  673. },
  674. keyOf: function(object, value){
  675. for (var key in object){
  676. if (hasOwnProperty.call(object, key) && object[key] === value) return key;
  677. }
  678. return null;
  679. },
  680. contains: function(object, value){
  681. return Object.keyOf(object, value) != null;
  682. },
  683. toQueryString: function(object, base){
  684. var queryString = [];
  685. Object.each(object, function(value, key){
  686. if (base) key = base + '[' + key + ']';
  687. var result;
  688. switch (typeOf(value)){
  689. case 'object': result = Object.toQueryString(value, key); break;
  690. case 'array':
  691. var qs = {};
  692. value.each(function(val, i){
  693. qs[i] = val;
  694. });
  695. result = Object.toQueryString(qs, key);
  696. break;
  697. default: result = key + '=' + encodeURIComponent(value);
  698. }
  699. if (value != null) queryString.push(result);
  700. });
  701. return queryString.join('&');
  702. }
  703. });
  704. })();
  705. /*
  706. ---
  707. name: Browser
  708. description: The Browser Object. Contains Browser initialization, Window and Document, and the Browser Hash.
  709. license: MIT-style license.
  710. requires: [Array, Function, Number, String]
  711. provides: [Browser, Window, Document]
  712. ...
  713. */
  714. (function(){
  715. var document = this.document;
  716. var window = document.window = this;
  717. var ua = navigator.userAgent.toLowerCase(),
  718. platform = navigator.platform.toLowerCase(),
  719. UA = ua.match(/(opera|ie|firefox|chrome|version)[\s\/:]([\w\d\.]+)?.*?(safari|version[\s\/:]([\w\d\.]+)|$)/) || [null, 'unknown', 0],
  720. mode = UA[1] == 'ie' && document.documentMode;
  721. var Browser = this.Browser = {
  722. extend: Function.prototype.extend,
  723. name: (UA[1] == 'version') ? UA[3] : UA[1],
  724. version: mode || parseFloat((UA[1] == 'opera' && UA[4]) ? UA[4] : UA[2]),
  725. Platform: {
  726. name: ua.match(/ip(?:ad|od|hone)/) ? 'ios' : (ua.match(/(?:webos|android)/) || platform.match(/mac|win|linux/) || ['other'])[0]
  727. },
  728. Features: {
  729. xpath: !!(document.evaluate),
  730. air: !!(window.runtime),
  731. query: !!(document.querySelector),
  732. json: !!(window.JSON)
  733. },
  734. Plugins: {}
  735. };
  736. Browser[Browser.name] = true;
  737. Browser[Browser.name + parseInt(Browser.version, 10)] = true;
  738. Browser.Platform[Browser.Platform.name] = true;
  739. // Request
  740. Browser.Request = (function(){
  741. var XMLHTTP = function(){
  742. return new XMLHttpRequest();
  743. };
  744. var MSXML2 = function(){
  745. return new ActiveXObject('MSXML2.XMLHTTP');
  746. };
  747. var MSXML = function(){
  748. return new ActiveXObject('Microsoft.XMLHTTP');
  749. };
  750. return Function.attempt(function(){
  751. XMLHTTP();
  752. return XMLHTTP;
  753. }, function(){
  754. MSXML2();
  755. return MSXML2;
  756. }, function(){
  757. MSXML();
  758. return MSXML;
  759. });
  760. })();
  761. Browser.Features.xhr = !!(Browser.Request);
  762. // Flash detection
  763. var version = (Function.attempt(function(){
  764. return navigator.plugins['Shockwave Flash'].description;
  765. }, function(){
  766. return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
  767. }) || '0 r0').match(/\d+/g);
  768. Browser.Plugins.Flash = {
  769. version: Number(version[0] || '0.' + version[1]) || 0,
  770. build: Number(version[2]) || 0
  771. };
  772. // String scripts
  773. Browser.exec = function(text){
  774. if (!text) return text;
  775. if (window.execScript){
  776. window.execScript(text);
  777. } else {
  778. var script = document.createElement('script');
  779. script.setAttribute('type', 'text/javascript');
  780. script.text = text;
  781. document.head.appendChild(script);
  782. document.head.removeChild(script);
  783. }
  784. return text;
  785. };
  786. String.implement('stripScripts', function(exec){
  787. var scripts = '';
  788. var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function(all, code){
  789. scripts += code + '\n';
  790. return '';
  791. });
  792. if (exec === true) Browser.exec(scripts);
  793. else if (typeOf(exec) == 'function') exec(scripts, text);
  794. return text;
  795. });
  796. // Window, Document
  797. Browser.extend({
  798. Document: this.Document,
  799. Window: this.Window,
  800. Element: this.Element,
  801. Event: this.Event
  802. });
  803. this.Window = this.$constructor = new Type('Window', function(){});
  804. this.$family = Function.from('window').hide();
  805. Window.mirror(function(name, method){
  806. window[name] = method;
  807. });
  808. this.Document = document.$constructor = new Type('Document', function(){});
  809. document.$family = Function.from('document').hide();
  810. Document.mirror(function(name, method){
  811. document[name] = method;
  812. });
  813. document.html = document.documentElement;
  814. if (!document.head) document.head = document.getElementsByTagName('head')[0];
  815. if (document.execCommand) try {
  816. document.execCommand("BackgroundImageCache", false, true);
  817. } catch (e){}
  818. /*<ltIE9>*/
  819. if (this.attachEvent && !this.addEventListener){
  820. var unloadEvent = function(){
  821. this.detachEvent('onunload', unloadEvent);
  822. document.head = document.html = document.window = null;
  823. };
  824. this.attachEvent('onunload', unloadEvent);
  825. }
  826. // IE fails on collections and <select>.options (refers to <select>)
  827. var arrayFrom = Array.from;
  828. try {
  829. arrayFrom(document.html.childNodes);
  830. } catch(e){
  831. Array.from = function(item){
  832. if (typeof item != 'string' && Type.isEnumerable(item) && typeOf(item) != 'array'){
  833. var i = item.length, array = new Array(i);
  834. while (i--) array[i] = item[i];
  835. return array;
  836. }
  837. return arrayFrom(item);
  838. };
  839. var prototype = Array.prototype,
  840. slice = prototype.slice;
  841. ['pop', 'push', 'reverse', 'shift', 'sort', 'splice', 'unshift', 'concat', 'join', 'slice'].each(function(name){
  842. var method = prototype[name];
  843. Array[name] = function(item){
  844. return method.apply(Array.from(item), slice.call(arguments, 1));
  845. };
  846. });
  847. }
  848. /*</ltIE9>*/
  849. })();
  850. /*
  851. ---
  852. name: Event
  853. description: Contains the Event Type, to make the event object cross-browser.
  854. license: MIT-style license.
  855. requires: [Window, Document, Array, Function, String, Object]
  856. provides: Event
  857. ...
  858. */
  859. (function() {
  860. var _keys = {};
  861. var DOMEvent = this.DOMEvent = new Type('DOMEvent', function(event, win){
  862. if (!win) win = window;
  863. event = event || win.event;
  864. if (event.$extended) return event;
  865. this.event = event;
  866. this.$extended = true;
  867. this.shift = event.shiftKey;
  868. this.control = event.ctrlKey;
  869. this.alt = event.altKey;
  870. this.meta = event.metaKey;
  871. var type = this.type = event.type;
  872. var target = event.target || event.srcElement;
  873. while (target && target.nodeType == 3) target = target.parentNode;
  874. this.target = document.id(target);
  875. if (type.indexOf('key') == 0){
  876. var code = this.code = (event.which || event.keyCode);
  877. this.key = _keys[code];
  878. if (type == 'keydown'){
  879. if (code > 111 && code < 124) this.key = 'f' + (code - 111);
  880. else if (code > 95 && code < 106) this.key = code - 96;
  881. }
  882. if (this.key == null) this.key = String.fromCharCode(code).toLowerCase();
  883. } else if (type == 'click' || type == 'dblclick' || type == 'contextmenu' || type == 'DOMMouseScroll' || type.indexOf('mouse') == 0){
  884. var doc = win.document;
  885. doc = (!doc.compatMode || doc.compatMode == 'CSS1Compat') ? doc.html : doc.body;
  886. this.page = {
  887. x: (event.pageX != null) ? event.pageX : event.clientX + doc.scrollLeft,
  888. y: (event.pageY != null) ? event.pageY : event.clientY + doc.scrollTop
  889. };
  890. this.client = {
  891. x: (event.pageX != null) ? event.pageX - win.pageXOffset : event.clientX,
  892. y: (event.pageY != null) ? event.pageY - win.pageYOffset : event.clientY
  893. };
  894. if (type == 'DOMMouseScroll' || type == 'mousewheel')
  895. this.wheel = (event.wheelDelta) ? event.wheelDelta / 120 : -(event.detail || 0) / 3;
  896. this.rightClick = (event.which == 3 || event.button == 2);
  897. if (type == 'mouseover' || type == 'mouseout'){
  898. var related = event.relatedTarget || event[(type == 'mouseover' ? 'from' : 'to') + 'Element'];
  899. while (related && related.nodeType == 3) related = related.parentNode;
  900. this.relatedTarget = document.id(related);
  901. }
  902. } else if (type.indexOf('touch') == 0 || type.indexOf('gesture') == 0){
  903. this.rotation = event.rotation;
  904. this.scale = event.scale;
  905. this.targetTouches = event.targetTouches;
  906. this.changedTouches = event.changedTouches;
  907. var touches = this.touches = event.touches;
  908. if (touches && touches[0]){
  909. var touch = touches[0];
  910. this.page = {x: touch.pageX, y: touch.pageY};
  911. this.client = {x: touch.clientX, y: touch.clientY};
  912. }
  913. }
  914. if (!this.client) this.client = {};
  915. if (!this.page) this.page = {};
  916. });
  917. DOMEvent.implement({
  918. stop: function(){
  919. return this.preventDefault().stopPropagation();
  920. },
  921. stopPropagation: function(){
  922. if (this.event.stopPropagation) this.event.stopPropagation();
  923. else this.event.cancelBubble = true;
  924. return this;
  925. },
  926. preventDefault: function(){
  927. if (this.event.preventDefault) this.event.preventDefault();
  928. else this.event.returnValue = false;
  929. return this;
  930. }
  931. });
  932. DOMEvent.defineKey = function(code, key){
  933. _keys[code] = key;
  934. return this;
  935. };
  936. DOMEvent.defineKeys = DOMEvent.defineKey.overloadSetter(true);
  937. DOMEvent.defineKeys({
  938. '38': 'up', '40': 'down', '37': 'left', '39': 'right',
  939. '27': 'esc', '32': 'space', '8': 'backspace', '9': 'tab',
  940. '46': 'delete', '13': 'enter'
  941. });
  942. })();
  943. /*
  944. ---
  945. name: Class
  946. description: Contains the Class Function for easily creating, extending, and implementing reusable Classes.
  947. license: MIT-style license.
  948. requires: [Array, String, Function, Number]
  949. provides: Class
  950. ...
  951. */
  952. (function(){
  953. var Class = this.Class = new Type('Class', function(params){
  954. if (instanceOf(params, Function)) params = {initialize: params};
  955. var newClass = function(){
  956. reset(this);
  957. if (newClass.$prototyping) return this;
  958. this.$caller = null;
  959. var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;
  960. this.$caller = this.caller = null;
  961. return value;
  962. }.extend(this).implement(params);
  963. newClass.$constructor = Class;
  964. newClass.prototype.$constructor = newClass;
  965. newClass.prototype.parent = parent;
  966. return newClass;
  967. });
  968. var parent = function(){
  969. if (!this.$caller) throw new Error('The method "parent" cannot be called.');
  970. var name = this.$caller.$name,
  971. parent = this.$caller.$owner.parent,
  972. previous = (parent) ? parent.prototype[name] : null;
  973. if (!previous) throw new Error('The method "' + name + '" has no parent.');
  974. return previous.apply(this, arguments);
  975. };
  976. var reset = function(object){
  977. for (var key in object){
  978. var value = object[key];
  979. switch (typeOf(value)){
  980. case 'object':
  981. var F = function(){};
  982. F.prototype = value;
  983. object[key] = reset(new F);
  984. break;
  985. case 'array': object[key] = value.clone(); break;
  986. }
  987. }
  988. return object;
  989. };
  990. var wrap = function(self, key, method){
  991. if (method.$origin) method = method.$origin;
  992. var wrapper = function(){
  993. if (method.$protected && this.$caller == null) throw new Error('The method "' + key + '" cannot be called.');
  994. var caller = this.caller, current = this.$caller;
  995. this.caller = current; this.$caller = wrapper;
  996. var result = method.apply(this, arguments);
  997. this.$caller = current; this.caller = caller;
  998. return result;
  999. }.extend({$owner: self, $origin: method, $name: key});
  1000. return wrapper;
  1001. };
  1002. var implement = function(key, value, retain){
  1003. if (Class.Mutators.hasOwnProperty(key)){
  1004. value = Class.Mutators[key].call(this, value);
  1005. if (value == null) return this;
  1006. }
  1007. if (typeOf(value) == 'function'){
  1008. if (value.$hidden) return this;
  1009. this.prototype[key] = (retain) ? value : wrap(this, key, value);
  1010. } else {
  1011. Object.merge(this.prototype, key, value);
  1012. }
  1013. return this;
  1014. };
  1015. var getInstance = function(klass){
  1016. klass.$prototyping = true;
  1017. var proto = new klass;
  1018. delete klass.$prototyping;
  1019. return proto;
  1020. };
  1021. Class.implement('implement', implement.overloadSetter());
  1022. Class.Mutators = {
  1023. Extends: function(parent){
  1024. this.parent = parent;
  1025. this.prototype = getInstance(parent);
  1026. },
  1027. Implements: function(items){
  1028. Array.from(items).each(function(item){
  1029. var instance = new item;
  1030. for (var key in instance) implement.call(this, key, instance[key], true);
  1031. }, this);
  1032. }
  1033. };
  1034. })();
  1035. /*
  1036. ---
  1037. name: Class.Extras
  1038. description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.
  1039. license: MIT-style license.
  1040. requires: Class
  1041. provides: [Class.Extras, Chain, Events, Options]
  1042. ...
  1043. */
  1044. (function(){
  1045. this.Chain = new Class({
  1046. $chain: [],
  1047. chain: function(){
  1048. this.$chain.append(Array.flatten(arguments));
  1049. return this;
  1050. },
  1051. callChain: function(){
  1052. return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
  1053. },
  1054. clearChain: function(){
  1055. this.$chain.empty();
  1056. return this;
  1057. }
  1058. });
  1059. var removeOn = function(string){
  1060. return string.replace(/^on([A-Z])/, function(full, first){
  1061. return first.toLowerCase();
  1062. });
  1063. };
  1064. this.Events = new Class({
  1065. $events: {},
  1066. addEvent: function(type, fn, internal){
  1067. type = removeOn(type);
  1068. this.$events[type] = (this.$events[type] || []).include(fn);
  1069. if (internal) fn.internal = true;
  1070. return this;
  1071. },
  1072. addEvents: function(events){
  1073. for (var type in events) this.addEvent(type, events[type]);
  1074. return this;
  1075. },
  1076. fireEvent: function(type, args, delay){
  1077. type = removeOn(type);
  1078. var events = this.$events[type];
  1079. if (!events) return this;
  1080. args = Array.from(args);
  1081. events.each(function(fn){
  1082. if (delay) fn.delay(delay, this, args);
  1083. else fn.apply(this, args);
  1084. }, this);
  1085. return this;
  1086. },
  1087. removeEvent: function(type, fn){
  1088. type = removeOn(type);
  1089. var events = this.$events[type];
  1090. if (events && !fn.internal){
  1091. var index = events.indexOf(fn);
  1092. if (index != -1) delete events[index];
  1093. }
  1094. return this;
  1095. },
  1096. removeEvents: function(events){
  1097. var type;
  1098. if (typeOf(events) == 'object'){
  1099. for (type in events) this.removeEvent(type, events[type]);
  1100. return this;
  1101. }
  1102. if (events) events = removeOn(events);
  1103. for (type in this.$events){
  1104. if (events && events != type) continue;
  1105. var fns = this.$events[type];
  1106. for (var i = fns.length; i--;) if (i in fns){
  1107. this.removeEvent(type, fns[i]);
  1108. }
  1109. }
  1110. return this;
  1111. }
  1112. });
  1113. this.Options = new Class({
  1114. setOptions: function(){
  1115. var options = this.options = Object.merge.apply(null, [{}, this.options].append(arguments));
  1116. if (this.addEvent) for (var option in options){
  1117. if (typeOf(options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
  1118. this.addEvent(option, options[option]);
  1119. delete options[option];
  1120. }
  1121. return this;
  1122. }
  1123. });
  1124. })();
  1125. /*
  1126. ---
  1127. name: Slick.Parser
  1128. description: Standalone CSS3 Selector parser
  1129. provides: Slick.Parser
  1130. ...
  1131. */
  1132. ;(function(){
  1133. var parsed,
  1134. separatorIndex,
  1135. combinatorIndex,
  1136. reversed,
  1137. cache = {},
  1138. reverseCache = {},
  1139. reUnescape = /\\/g;
  1140. var parse = function(expression, isReversed){
  1141. if (expression == null) return null;
  1142. if (expression.Slick === true) return expression;
  1143. expression = ('' + expression).replace(/^\s+|\s+$/g, '');
  1144. reversed = !!isReversed;
  1145. var currentCache = (reversed) ? reverseCache : cache;
  1146. if (currentCache[expression]) return currentCache[expression];
  1147. parsed = {
  1148. Slick: true,
  1149. expressions: [],
  1150. raw: expression,
  1151. reverse: function(){
  1152. return parse(this.raw, true);
  1153. }
  1154. };
  1155. separatorIndex = -1;
  1156. while (expression != (expression = expression.replace(regexp, parser)));
  1157. parsed.length = parsed.expressions.length;
  1158. return currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed;
  1159. };
  1160. var reverseCombinator = function(combinator){
  1161. if (combinator === '!') return ' ';
  1162. else if (combinator === ' ') return '!';
  1163. else if ((/^!/).test(combinator)) return combinator.replace(/^!/, '');
  1164. else return '!' + combinator;
  1165. };
  1166. var reverse = function(expression){
  1167. var expressions = expression.expressions;
  1168. for (var i = 0; i < expressions.length; i++){
  1169. var exp = expressions[i];
  1170. var last = {parts: [], tag: '*', combinator: reverseCombinator(exp[0].combinator)};
  1171. for (var j = 0; j < exp.length; j++){
  1172. var cexp = exp[j];
  1173. if (!cexp.reverseCombinator) cexp.reverseCombinator = ' ';
  1174. cexp.combinator = cexp.reverseCombinator;
  1175. delete cexp.reverseCombinator;
  1176. }
  1177. exp.reverse().push(last);
  1178. }
  1179. return expression;
  1180. };
  1181. var escapeRegExp = function(string){// Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan <http://stevenlevithan.com/regex/xregexp/> MIT License
  1182. return string.replace(/[-[\]{}()*+?.\\^$|,#\s]/g, function(match){
  1183. return '\\' + match;
  1184. });
  1185. };
  1186. var regexp = new RegExp(
  1187. /*
  1188. #!/usr/bin/env ruby
  1189. puts "\t\t" + DATA.read.gsub(/\(\?x\)|\s+#.*$|\s+|\\$|\\n/,'')
  1190. __END__
  1191. "(?x)^(?:\
  1192. \\s* ( , ) \\s* # Separator \n\
  1193. | \\s* ( <combinator>+ ) \\s* # Combinator \n\
  1194. | ( \\s+ ) # CombinatorChildren \n\
  1195. | ( <unicode>+ | \\* ) # Tag \n\
  1196. | \\# ( <unicode>+ ) # ID \n\
  1197. | \\. ( <unicode>+ ) # ClassName \n\
  1198. | # Attribute \n\
  1199. \\[ \
  1200. \\s* (<unicode1>+) (?: \
  1201. \\s* ([*^$!~|]?=) (?: \
  1202. \\s* (?:\
  1203. ([\"']?)(.*?)\\9 \
  1204. )\
  1205. ) \
  1206. )? \\s* \
  1207. \\](?!\\]) \n\
  1208. | :+ ( <unicode>+ )(?:\
  1209. \\( (?:\
  1210. (?:([\"'])([^\\12]*)\\12)|((?:\\([^)]+\\)|[^()]*)+)\
  1211. ) \\)\
  1212. )?\
  1213. )"
  1214. */
  1215. "^(?:\\s*(,)\\s*|\\s*(<combinator>+)\\s*|(\\s+)|(<unicode>+|\\*)|\\#(<unicode>+)|\\.(<unicode>+)|\\[\\s*(<unicode1>+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(<unicode>+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)"
  1216. .replace(/<combinator>/, '[' + escapeRegExp(">+~`!@$%^&={}\\;</") + ']')
  1217. .replace(/<unicode>/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  1218. .replace(/<unicode1>/g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])')
  1219. );
  1220. function parser(
  1221. rawMatch,
  1222. separator,
  1223. combinator,
  1224. combinatorChildren,
  1225. tagName,
  1226. id,
  1227. className,
  1228. attributeKey,
  1229. attributeOperator,
  1230. attributeQuote,
  1231. attributeValue,
  1232. pseudoMarker,
  1233. pseudoClass,
  1234. pseudoQuote,
  1235. pseudoClassQuotedValue,
  1236. pseudoClassValue
  1237. ){
  1238. if (separator || separatorIndex === -1){
  1239. parsed.expressions[++separatorIndex] = [];
  1240. combinatorIndex = -1;
  1241. if (separator) return '';
  1242. }
  1243. if (combinator || combinatorChildren || combinatorIndex === -1){
  1244. combinator = combinator || ' ';
  1245. var currentSeparator = parsed.expressions[separatorIndex];
  1246. if (reversed && currentSeparator[combinatorIndex])
  1247. currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator);
  1248. currentSeparator[++combinatorIndex] = {combinator: combinator, tag: '*'};
  1249. }
  1250. var currentParsed = parsed.expressions[separatorIndex][combinatorIndex];
  1251. if (tagName){
  1252. currentParsed.tag = tagName.replace(reUnescape, '');
  1253. } else if (id){
  1254. currentParsed.id = id.replace(reUnescape, '');
  1255. } else if (className){
  1256. className = className.replace(reUnescape, '');
  1257. if (!currentParsed.classList) currentParsed.classList = [];
  1258. if (!currentParsed.classes) currentParsed.classes = [];
  1259. currentParsed.classList.push(className);
  1260. currentParsed.classes.push({
  1261. value: className,
  1262. regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)')
  1263. });
  1264. } else if (pseudoClass){
  1265. pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue;
  1266. pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null;
  1267. if (!currentParsed.pseudos) currentParsed.pseudos = [];
  1268. currentParsed.pseudos.push({
  1269. key: pseudoClass.replace(reUnescape, ''),
  1270. value: pseudoClassValue,
  1271. type: pseudoMarker.length == 1 ? 'class' : 'element'
  1272. });
  1273. } else if (attributeKey){
  1274. attributeKey = attributeKey.replace(reUnescape, '');
  1275. attributeValue = (attributeValue || '').replace(reUnescape, '');
  1276. var test, regexp;
  1277. switch (attributeOperator){
  1278. case '^=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) ); break;
  1279. case '$=' : regexp = new RegExp( escapeRegExp(attributeValue) +'$' ); break;
  1280. case '~=' : regexp = new RegExp( '(^|\\s)'+ escapeRegExp(attributeValue) +'(\\s|$)' ); break;
  1281. case '|=' : regexp = new RegExp( '^'+ escapeRegExp(attributeValue) +'(-|$)' ); break;
  1282. case '=' : test = function(value){
  1283. return attributeValue == value;
  1284. }; break;
  1285. case '*=' : test = function(value){
  1286. return value && value.indexOf(attributeValue) > -1;
  1287. }; break;
  1288. case '!=' : test = function(value){
  1289. return attributeValue != value;
  1290. }; break;
  1291. default : test = function(value){
  1292. return !!value;
  1293. };
  1294. }
  1295. if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function(){
  1296. return false;
  1297. };
  1298. if (!test) test = function(value){
  1299. return value && regexp.test(value);
  1300. };
  1301. if (!currentParsed.attributes) currentParsed.attributes = [];
  1302. currentParsed.attributes.push({
  1303. key: attributeKey,
  1304. operator: attributeOperator,
  1305. value: attributeValue,
  1306. test: test
  1307. });
  1308. }
  1309. return '';
  1310. };
  1311. // Slick NS
  1312. var Slick = (this.Slick || {});
  1313. Slick.parse = function(expression){
  1314. return parse(expression);
  1315. };
  1316. Slick.escapeRegExp = escapeRegExp;
  1317. if (!this.Slick) this.Slick = Slick;
  1318. }).apply(/*<CommonJS>*/(typeof exports != 'undefined') ? exports : /*</CommonJS>*/this);
  1319. /*
  1320. ---
  1321. name: Slick.Finder
  1322. description: The new, superfast css selector engine.
  1323. provides: Slick.Finder
  1324. requires: Slick.Parser
  1325. ...
  1326. */
  1327. ;(function(){
  1328. var local = {},
  1329. featuresCache = {},
  1330. toString = Object.prototype.toString;
  1331. // Feature / Bug detection
  1332. local.isNativeCode = function(fn){
  1333. return (/\{\s*\[native code\]\s*\}/).test('' + fn);
  1334. };
  1335. local.isXML = function(document){
  1336. return (!!document.xmlVersion) || (!!document.xml) || (toString.call(document) == '[object XMLDocument]') ||
  1337. (document.nodeType == 9 && document.documentElement.nodeName != 'HTML');
  1338. };
  1339. local.setDocument = function(document){
  1340. // convert elements / window arguments to document. if document cannot be extrapolated, the function returns.
  1341. var nodeType = document.nodeType;
  1342. if (nodeType == 9); // document
  1343. else if (nodeType) document = document.ownerDocument; // node
  1344. else if (document.navigator) document = document.document; // window
  1345. else return;
  1346. // check if it's the old document
  1347. if (this.document === document) return;
  1348. this.document = document;
  1349. // check if we have done feature detection on this document before
  1350. var root = document.documentElement,
  1351. rootUid = this.getUIDXML(root),
  1352. features = featuresCache[rootUid],
  1353. feature;
  1354. if (features){
  1355. for (feature in features){
  1356. this[feature] = features[feature];
  1357. }
  1358. return;
  1359. }
  1360. features = featuresCache[rootUid] = {};
  1361. features.root = root;
  1362. features.isXMLDocument = this.isXML(document);
  1363. features.brokenStarGEBTN
  1364. = features.starSelectsClosedQSA
  1365. = features.idGetsName
  1366. = features.brokenMixedCaseQSA
  1367. = features.brokenGEBCN
  1368. = features.brokenCheckedQSA
  1369. = features.brokenEmptyAttributeQSA
  1370. = features.isHTMLDocument
  1371. = features.nativeMatchesSelector
  1372. = false;
  1373. var starSelectsClosed, starSelectsComments,
  1374. brokenSecondClassNameGEBCN, cachedGetElementsByClassName,
  1375. brokenFormAttributeGetter;
  1376. var selected, id = 'slick_uniqueid';
  1377. var testNode = document.createElement('div');
  1378. var testRoot = document.body || document.getElementsByTagName('body')[0] || root;
  1379. testRoot.appendChild(testNode);
  1380. // on non-HTML documents innerHTML and getElementsById doesnt work properly
  1381. try {
  1382. testNode.innerHTML = '<a id="'+id+'"></a>';
  1383. features.isHTMLDocument = !!document.getElementById(id);
  1384. } catch(e){};
  1385. if (features.isHTMLDocument){
  1386. testNode.style.display = 'none';
  1387. // IE returns comment nodes for getElementsByTagName('*') for some documents
  1388. testNode.appendChild(document.createComment(''));
  1389. starSelectsComments = (testNode.getElementsByTagName('*').length > 1);
  1390. // IE returns closed nodes (EG:"</foo>") for getElementsByTagName('*') for some documents
  1391. try {
  1392. testNode.innerHTML = 'foo</foo>';
  1393. selected = testNode.getElementsByTagName('*');
  1394. starSelectsClosed = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
  1395. } catch(e){};
  1396. features.brokenStarGEBTN = starSelectsComments || starSelectsClosed;
  1397. // IE returns elements with the name instead of just id for getElementsById for some documents
  1398. try {
  1399. testNode.innerHTML = '<a name="'+ id +'"></a><b id="'+ id +'"></b>';
  1400. features.idGetsName = document.getElementById(id) === testNode.firstChild;
  1401. } catch(e){};
  1402. if (testNode.getElementsByClassName){
  1403. // Safari 3.2 getElementsByClassName caches results
  1404. try {
  1405. testNode.innerHTML = '<a class="f"></a><a class="b"></a>';
  1406. testNode.getElementsByClassName('b').length;
  1407. testNode.firstChild.className = 'b';
  1408. cachedGetElementsByClassName = (testNode.getElementsByClassName('b').length != 2);
  1409. } catch(e){};
  1410. // Opera 9.6 getElementsByClassName doesnt detects the class if its not the first one
  1411. try {
  1412. testNode.innerHTML = '<a class="a"></a><a class="f b a"></a>';
  1413. brokenSecondClassNameGEBCN = (testNode.getElementsByClassName('a').length != 2);
  1414. } catch(e){};
  1415. features.brokenGEBCN = cachedGetElementsByClassName || brokenSecondClassNameGEBCN;
  1416. }
  1417. if (testNode.querySelectorAll){
  1418. // IE 8 returns closed nodes (EG:"</foo>") for querySelectorAll('*') for some documents
  1419. try {
  1420. testNode.innerHTML = 'foo</foo>';
  1421. selected = testNode.querySelectorAll('*');
  1422. features.starSelectsClosedQSA = (selected && !!selected.length && selected[0].nodeName.charAt(0) == '/');
  1423. } catch(e){};
  1424. // Safari 3.2 querySelectorAll doesnt work with mixedcase on quirksmode
  1425. try {
  1426. testNode.innerHTML = '<a class="MiX"></a>';
  1427. features.brokenMixedCaseQSA = !testNode.querySelectorAll('.MiX').length;
  1428. } catch(e){};
  1429. // Webkit and Opera dont return selected options on querySelectorAll
  1430. try {
  1431. testNode.innerHTML = '<select><option selected="selected">a</option></select>';
  1432. features.brokenCheckedQSA = (testNode.querySelectorAll(':checked').length == 0);
  1433. } catch(e){};
  1434. // IE returns incorrect results for attr[*^$]="" selectors on querySelectorAll
  1435. try {
  1436. testNode.innerHTML = '<a class=""></a>';
  1437. features.brokenEmptyAttributeQSA = (testNode.querySelectorAll('[class*=""]').length != 0);
  1438. } catch(e){};
  1439. }
  1440. // IE6-7, if a form has an input of id x, form.getAttribute(x) returns a reference to the input
  1441. try {
  1442. testNode.innerHTML = '<form action="s"><input id="action"/></form>';
  1443. brokenFormAttributeGetter = (testNode.firstChild.getAttribute('action') != 's');
  1444. } catch(e){};
  1445. // native matchesSelector function
  1446. features.nativeMatchesSelector = root.matchesSelector || /*root.msMatchesSelector ||*/ root.mozMatchesSelector || root.webkitMatchesSelector;
  1447. if (features.nativeMatchesSelector) try {
  1448. // if matchesSelector trows errors on incorrect sintaxes we can use it
  1449. features.nativeMatchesSelector.call(root, ':slick');
  1450. features.nativeMatchesSelector = null;
  1451. } catch(e){};
  1452. }
  1453. try {
  1454. root.slick_expando = 1;
  1455. delete root.slick_expando;
  1456. features.getUID = this.getUIDHTML;
  1457. } catch(e) {
  1458. features.getUID = this.getUIDXML;
  1459. }
  1460. testRoot.removeChild(testNode);
  1461. testNode = selected = testRoot = null;
  1462. // getAttribute
  1463. features.getAttribute = (features.isHTMLDocument && brokenFormAttributeGetter) ? function(node, name){
  1464. var method = this.attributeGetters[name];
  1465. if (method) return method.call(node);
  1466. var attributeNode = node.getAttributeNode(name);
  1467. return (attributeNode) ? attributeNode.nodeValue : null;
  1468. } : function(node, name){
  1469. var method = this.attributeGetters[name];
  1470. return (method) ? method.call(node) : node.getAttribute(name);
  1471. };
  1472. // hasAttribute
  1473. features.hasAttribute = (root && this.isNativeCode(root.hasAttribute)) ? function(node, attribute) {
  1474. return node.hasAttribute(attribute);
  1475. } : function(node, attribute) {
  1476. node = node.getAttributeNode(attribute);
  1477. return !!(node && (node.specified || node.nodeValue));
  1478. };
  1479. // contains
  1480. // FIXME: Add specs: local.contains should be different for xml and html documents?
  1481. var nativeRootContains = root && this.isNativeCode(root.contains),
  1482. nativeDocumentContains = document && this.isNativeCode(document.contains);
  1483. features.contains = (nativeRootContains && nativeDocumentContains) ? function(context, node){
  1484. return context.contains(node);
  1485. } : (nativeRootContains && !nativeDocumentContains) ? function(context, node){
  1486. // IE8 does not have .contains on document.
  1487. return context === node || ((context === document) ? document.documentElement : context).contains(node);
  1488. } : (root && root.compareDocumentPosition) ? function(context, node){
  1489. return context === node || !!(context.compareDocumentPosition(node) & 16);
  1490. } : function(context, node){
  1491. if (node) do {
  1492. if (node === context) return true;
  1493. } while ((node = node.parentNode));
  1494. return false;
  1495. };
  1496. // document order sorting
  1497. // credits to Sizzle (http://sizzlejs.com/)
  1498. features.documentSorter = (root.compareDocumentPosition) ? function(a, b){
  1499. if (!a.compareDocumentPosition || !b.compareDocumentPosition) return 0;
  1500. return a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
  1501. } : ('sourceIndex' in root) ? function(a, b){
  1502. if (!a.sourceIndex || !b.sourceIndex) return 0;
  1503. return a.sourceIndex - b.sourceIndex;
  1504. } : (document.createRange) ? function(a, b){
  1505. if (!a.ownerDocument || !b.ownerDocument) return 0;
  1506. var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
  1507. aRange.setStart(a, 0);
  1508. aRange.setEnd(a, 0);
  1509. bRange.setStart(b, 0);
  1510. bRange.setEnd(b, 0);
  1511. return aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
  1512. } : null ;
  1513. root = null;
  1514. for (feature in features){
  1515. this[feature] = features[feature];
  1516. }
  1517. };
  1518. // Main Method
  1519. var reSimpleSelector = /^([#.]?)((?:[\w-]+|\*))$/,
  1520. reEmptyAttribute = /\[.+[*$^]=(?:""|'')?\]/,
  1521. qsaFailExpCache = {};
  1522. local.search = function(context, expression, append, first){
  1523. var found = this.found = (first) ? null : (append || []);
  1524. if (!context) return found;
  1525. else if (context.navigator) context = context.document; // Convert the node from a window to a document
  1526. else if (!context.nodeType) return found;
  1527. // setup
  1528. var parsed, i,
  1529. uniques = this.uniques = {},
  1530. hasOthers = !!(append && append.length),
  1531. contextIsDocument = (context.nodeType == 9);
  1532. if (this.document !== (contextIsDocument ? context : context.ownerDocument)) this.setDocument(context);
  1533. // avoid duplicating items already in the append array
  1534. if (hasOthers) for (i = found.length; i--;) uniques[this.getUID(found[i])] = true;
  1535. // expression checks
  1536. if (typeof expression == 'string'){ // expression is a string
  1537. /*<simple-selectors-override>*/
  1538. var simpleSelector = expression.match(reSimpleSelector);
  1539. simpleSelectors: if (simpleSelector) {
  1540. var symbol = simpleSelector[1],
  1541. name = simpleSelector[2],
  1542. node, nodes;
  1543. if (!symbol){
  1544. if (name == '*' && this.brokenStarGEBTN) break simpleSelectors;
  1545. nodes = context.getElemen