PageRenderTime 56ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/admin/thirdparty/history-js/vendor/mootools.js

http://github.com/silverstripe/sapphire
JavaScript | 2494 lines | 1769 code | 446 blank | 279 comment | 599 complexity | 328c2d38f957374cd771d19143c1a06f MD5 | raw file
Possible License(s): BSD-3-Clause, MIT, CC-BY-3.0, GPL-2.0, AGPL-1.0, LGPL-2.1

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

Large files files are truncated, but you can click here to view the full file