PageRenderTime 32ms CodeModel.GetById 18ms RepoModel.GetById 1ms app.codeStats 0ms

/CMSScripts/mootools.js

https://bitbucket.org/kudutest2/kenticogit
JavaScript | 1790 lines | 1363 code | 267 blank | 160 comment | 259 complexity | 680d8c8df0d2926d4c066791345265e4 MD5 | raw file
  1. /*
  2. ---
  3. name: Core
  4. description: The core of MooTools, contains all the base functions and the Native and Hash implementations. Required by all the other scripts.
  5. license: MIT-style license.
  6. copyright: Copyright (c) 2006-2008 [Valerio Proietti](http://mad4milk.net/).
  7. authors: The MooTools production team (http://mootools.net/developers/)
  8. inspiration:
  9. - 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)
  10. - Some functionality inspired by [Prototype.js](http://prototypejs.org) Copyright (c) 2005-2007 Sam Stephenson, [MIT License](http://opensource.org/licenses/mit-license.php)
  11. provides: [MooTools, Native, Hash.base, Array.each, $util]
  12. ...
  13. */
  14. /* CMS
  15. All occurences of 'document.id' were replaced with 'document.byid'.
  16. END CMS */
  17. var MooTools = {
  18. 'version': '1.2.5',
  19. 'build': '008d8f0f2fcc2044e54fdd3635341aaab274e757'
  20. };
  21. var Native = function(options) {
  22. options = options || {};
  23. var name = options.name;
  24. var legacy = options.legacy;
  25. var protect = options.protect;
  26. var methods = options.implement;
  27. var generics = options.generics;
  28. var initialize = options.initialize;
  29. var afterImplement = options.afterImplement || function() { };
  30. var object = initialize || legacy;
  31. generics = generics !== false;
  32. object.constructor = Native;
  33. object.$family = { name: 'native' };
  34. if (legacy && initialize) object.prototype = legacy.prototype;
  35. object.prototype.constructor = object;
  36. if (name) {
  37. var family = name.toLowerCase();
  38. object.prototype.$family = { name: family };
  39. Native.typize(object, family);
  40. }
  41. var add = function(obj, name, method, force) {
  42. if (!protect || force || !obj.prototype[name]) obj.prototype[name] = method;
  43. if (generics) Native.genericize(obj, name, protect);
  44. afterImplement.call(obj, name, method);
  45. return obj;
  46. };
  47. object.alias = function(a1, a2, a3) {
  48. if (typeof a1 == 'string') {
  49. var pa1 = this.prototype[a1];
  50. if ((a1 = pa1)) return add(this, a2, a1, a3);
  51. }
  52. for (var a in a1) this.alias(a, a1[a], a2);
  53. return this;
  54. };
  55. object.implement = function(a1, a2, a3) {
  56. if (typeof a1 == 'string') return add(this, a1, a2, a3);
  57. for (var p in a1) add(this, p, a1[p], a2);
  58. return this;
  59. };
  60. if (methods) object.implement(methods);
  61. return object;
  62. };
  63. Native.genericize = function(object, property, check) {
  64. if ((!check || !object[property]) && typeof object.prototype[property] == 'function') object[property] = function() {
  65. var args = Array.prototype.slice.call(arguments);
  66. return object.prototype[property].apply(args.shift(), args);
  67. };
  68. };
  69. Native.implement = function(objects, properties) {
  70. for (var i = 0, l = objects.length; i < l; i++) objects[i].implement(properties);
  71. };
  72. Native.typize = function(object, family) {
  73. if (!object.type) object.type = function(item) {
  74. return ($type(item) === family);
  75. };
  76. };
  77. (function() {
  78. var natives = { 'Array': Array, 'Date': Date, 'Function': Function, 'Number': Number, 'RegExp': RegExp, 'String': String };
  79. for (var n in natives) new Native({ name: n, initialize: natives[n], protect: true });
  80. var types = { 'boolean': Boolean, 'native': Native, 'object': Object };
  81. for (var t in types) Native.typize(types[t], t);
  82. var generics = {
  83. 'Array': ["concat", "indexOf", "join", "lastIndexOf", "pop", "push", "reverse", "shift", "slice", "sort", "splice", "toString", "unshift", "valueOf"],
  84. 'String': ["charAt", "charCodeAt", "concat", "indexOf", "lastIndexOf", "match", "replace", "search", "slice", "split", "substr", "substring", "toLowerCase", "toUpperCase", "valueOf"]
  85. };
  86. for (var g in generics) {
  87. for (var i = generics[g].length; i--; ) Native.genericize(natives[g], generics[g][i], true);
  88. }
  89. })();
  90. var Hash = new Native({
  91. name: 'Hash',
  92. initialize: function(object) {
  93. if ($type(object) == 'hash') object = $unlink(object.getClean());
  94. for (var key in object) this[key] = object[key];
  95. return this;
  96. }
  97. });
  98. Hash.implement({
  99. forEach: function(fn, bind) {
  100. for (var key in this) {
  101. if (this.hasOwnProperty(key)) fn.call(bind, this[key], key, this);
  102. }
  103. },
  104. getClean: function() {
  105. var clean = {};
  106. for (var key in this) {
  107. if (this.hasOwnProperty(key)) clean[key] = this[key];
  108. }
  109. return clean;
  110. },
  111. getLength: function() {
  112. var length = 0;
  113. for (var key in this) {
  114. if (this.hasOwnProperty(key)) length++;
  115. }
  116. return length;
  117. }
  118. });
  119. Hash.alias('forEach', 'each');
  120. Array.implement({
  121. forEach: function(fn, bind) {
  122. for (var i = 0, l = this.length; i < l; i++) fn.call(bind, this[i], i, this);
  123. }
  124. });
  125. Array.alias('forEach', 'each');
  126. function $A(iterable) {
  127. if (iterable.item) {
  128. var l = iterable.length, array = new Array(l);
  129. while (l--) array[l] = iterable[l];
  130. return array;
  131. }
  132. return Array.prototype.slice.call(iterable);
  133. };
  134. function $arguments(i) {
  135. return function() {
  136. return arguments[i];
  137. };
  138. };
  139. function $chk(obj) {
  140. return !!(obj || obj === 0);
  141. };
  142. function $clear(timer) {
  143. clearTimeout(timer);
  144. clearInterval(timer);
  145. return null;
  146. };
  147. function $defined(obj) {
  148. return (obj != undefined);
  149. };
  150. function $each(iterable, fn, bind) {
  151. var type = $type(iterable);
  152. ((type == 'arguments' || type == 'collection' || type == 'array') ? Array : Hash).each(iterable, fn, bind);
  153. };
  154. function $empty() { };
  155. function $extend(original, extended) {
  156. for (var key in (extended || {})) original[key] = extended[key];
  157. return original;
  158. };
  159. function $H(object) {
  160. return new Hash(object);
  161. };
  162. function $lambda(value) {
  163. return ($type(value) == 'function') ? value : function() {
  164. return value;
  165. };
  166. };
  167. function $merge() {
  168. var args = Array.slice(arguments);
  169. args.unshift({});
  170. return $mixin.apply(null, args);
  171. };
  172. function $mixin(mix) {
  173. for (var i = 1, l = arguments.length; i < l; i++) {
  174. var object = arguments[i];
  175. if ($type(object) != 'object') continue;
  176. for (var key in object) {
  177. var op = object[key], mp = mix[key];
  178. mix[key] = (mp && $type(op) == 'object' && $type(mp) == 'object') ? $mixin(mp, op) : $unlink(op);
  179. }
  180. }
  181. return mix;
  182. };
  183. function $pick() {
  184. for (var i = 0, l = arguments.length; i < l; i++) {
  185. if (arguments[i] != undefined) return arguments[i];
  186. }
  187. return null;
  188. };
  189. function $random(min, max) {
  190. return Math.floor(Math.random() * (max - min + 1) + min);
  191. };
  192. function $splat(obj) {
  193. var type = $type(obj);
  194. return (type) ? ((type != 'array' && type != 'arguments') ? [obj] : obj) : [];
  195. };
  196. var $time = Date.now || function() {
  197. return +new Date;
  198. };
  199. function $try() {
  200. for (var i = 0, l = arguments.length; i < l; i++) {
  201. try {
  202. return arguments[i]();
  203. } catch (e) { }
  204. }
  205. return null;
  206. };
  207. function $type(obj) {
  208. if (obj == undefined) return false;
  209. if (obj.$family) return (obj.$family.name == 'number' && !isFinite(obj)) ? false : obj.$family.name;
  210. if (obj.nodeName) {
  211. switch (obj.nodeType) {
  212. case 1: return 'element';
  213. case 3: return (/\S/).test(obj.nodeValue) ? 'textnode' : 'whitespace';
  214. }
  215. } else if (typeof obj.length == 'number') {
  216. if (obj.callee) return 'arguments';
  217. else if (obj.item) return 'collection';
  218. }
  219. return typeof obj;
  220. };
  221. function $unlink(object) {
  222. var unlinked;
  223. switch ($type(object)) {
  224. case 'object':
  225. unlinked = {};
  226. for (var p in object) unlinked[p] = $unlink(object[p]);
  227. break;
  228. case 'hash':
  229. unlinked = new Hash(object);
  230. break;
  231. case 'array':
  232. unlinked = [];
  233. for (var i = 0, l = object.length; i < l; i++) unlinked[i] = $unlink(object[i]);
  234. break;
  235. default: return object;
  236. }
  237. return unlinked;
  238. };
  239. /*
  240. ---
  241. name: Array
  242. description: Contains Array Prototypes like each, contains, and erase.
  243. license: MIT-style license.
  244. requires: [$util, Array.each]
  245. provides: Array
  246. ...
  247. */
  248. Array.implement({
  249. every: function(fn, bind) {
  250. for (var i = 0, l = this.length; i < l; i++) {
  251. if (!fn.call(bind, this[i], i, this)) return false;
  252. }
  253. return true;
  254. },
  255. filter: function(fn, bind) {
  256. var results = [];
  257. for (var i = 0, l = this.length; i < l; i++) {
  258. if (fn.call(bind, this[i], i, this)) results.push(this[i]);
  259. }
  260. return results;
  261. },
  262. clean: function() {
  263. return this.filter($defined);
  264. },
  265. indexOf: function(item, from) {
  266. var len = this.length;
  267. for (var i = (from < 0) ? Math.max(0, len + from) : from || 0; i < len; i++) {
  268. if (this[i] === item) return i;
  269. }
  270. return -1;
  271. },
  272. map: function(fn, bind) {
  273. var results = [];
  274. for (var i = 0, l = this.length; i < l; i++) results[i] = fn.call(bind, this[i], i, this);
  275. return results;
  276. },
  277. some: function(fn, bind) {
  278. for (var i = 0, l = this.length; i < l; i++) {
  279. if (fn.call(bind, this[i], i, this)) return true;
  280. }
  281. return false;
  282. },
  283. associate: function(keys) {
  284. var obj = {}, length = Math.min(this.length, keys.length);
  285. for (var i = 0; i < length; i++) obj[keys[i]] = this[i];
  286. return obj;
  287. },
  288. link: function(object) {
  289. var result = {};
  290. for (var i = 0, l = this.length; i < l; i++) {
  291. for (var key in object) {
  292. if (object[key](this[i])) {
  293. result[key] = this[i];
  294. delete object[key];
  295. break;
  296. }
  297. }
  298. }
  299. return result;
  300. },
  301. contains: function(item, from) {
  302. return this.indexOf(item, from) != -1;
  303. },
  304. extend: function(array) {
  305. for (var i = 0, j = array.length; i < j; i++) this.push(array[i]);
  306. return this;
  307. },
  308. getLast: function() {
  309. return (this.length) ? this[this.length - 1] : null;
  310. },
  311. getRandom: function() {
  312. return (this.length) ? this[$random(0, this.length - 1)] : null;
  313. },
  314. include: function(item) {
  315. if (!this.contains(item)) this.push(item);
  316. return this;
  317. },
  318. combine: function(array) {
  319. for (var i = 0, l = array.length; i < l; i++) this.include(array[i]);
  320. return this;
  321. },
  322. erase: function(item) {
  323. for (var i = this.length; i--; i) {
  324. if (this[i] === item) this.splice(i, 1);
  325. }
  326. return this;
  327. },
  328. empty: function() {
  329. this.length = 0;
  330. return this;
  331. },
  332. flatten: function() {
  333. var array = [];
  334. for (var i = 0, l = this.length; i < l; i++) {
  335. var type = $type(this[i]);
  336. if (!type) continue;
  337. array = array.concat((type == 'array' || type == 'collection' || type == 'arguments') ? Array.flatten(this[i]) : this[i]);
  338. }
  339. return array;
  340. },
  341. hexToRgb: function(array) {
  342. if (this.length != 3) return null;
  343. var rgb = this.map(function(value) {
  344. if (value.length == 1) value += value;
  345. return value.toInt(16);
  346. });
  347. return (array) ? rgb : 'rgb(' + rgb + ')';
  348. },
  349. rgbToHex: function(array) {
  350. if (this.length < 3) return null;
  351. if (this.length == 4 && this[3] == 0 && !array) return 'transparent';
  352. var hex = [];
  353. for (var i = 0; i < 3; i++) {
  354. var bit = (this[i] - 0).toString(16);
  355. hex.push((bit.length == 1) ? '0' + bit : bit);
  356. }
  357. return (array) ? hex : '#' + hex.join('');
  358. }
  359. });
  360. /*
  361. ---
  362. name: String
  363. description: Contains String Prototypes like camelCase, capitalize, test, and toInt.
  364. license: MIT-style license.
  365. requires: Native
  366. provides: String
  367. ...
  368. */
  369. String.implement({
  370. test: function(regex, params) {
  371. return ((typeof regex == 'string') ? new RegExp(regex, params) : regex).test(this);
  372. },
  373. contains: function(string, separator) {
  374. return (separator) ? (separator + this + separator).indexOf(separator + string + separator) > -1 : this.indexOf(string) > -1;
  375. },
  376. trim: function() {
  377. return this.replace(/^\s+|\s+$/g, '');
  378. },
  379. clean: function() {
  380. return this.replace(/\s+/g, ' ').trim();
  381. },
  382. camelCase: function() {
  383. return this.replace(/-\D/g, function(match) {
  384. return match.charAt(1).toUpperCase();
  385. });
  386. },
  387. hyphenate: function() {
  388. return this.replace(/[A-Z]/g, function(match) {
  389. return ('-' + match.charAt(0).toLowerCase());
  390. });
  391. },
  392. capitalize: function() {
  393. return this.replace(/\b[a-z]/g, function(match) {
  394. return match.toUpperCase();
  395. });
  396. },
  397. escapeRegExp: function() {
  398. return this.replace(/([-.*+?^${}()|[\]\/\\])/g, '\\$1');
  399. },
  400. toInt: function(base) {
  401. return parseInt(this, base || 10);
  402. },
  403. toFloat: function() {
  404. return parseFloat(this);
  405. },
  406. hexToRgb: function(array) {
  407. var hex = this.match(/^#?(\w{1,2})(\w{1,2})(\w{1,2})$/);
  408. return (hex) ? hex.slice(1).hexToRgb(array) : null;
  409. },
  410. rgbToHex: function(array) {
  411. var rgb = this.match(/\d{1,3}/g);
  412. return (rgb) ? rgb.rgbToHex(array) : null;
  413. },
  414. stripScripts: function(option) {
  415. var scripts = '';
  416. var text = this.replace(/<script[^>]*>([\s\S]*?)<\/script>/gi, function() {
  417. scripts += arguments[1] + '\n';
  418. return '';
  419. });
  420. if (option === true) $exec(scripts);
  421. else if ($type(option) == 'function') option(scripts, text);
  422. return text;
  423. },
  424. substitute: function(object, regexp) {
  425. return this.replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name) {
  426. if (match.charAt(0) == '\\') return match.slice(1);
  427. return (object[name] != undefined) ? object[name] : '';
  428. });
  429. }
  430. });
  431. /*
  432. ---
  433. name: Function
  434. description: Contains Function Prototypes like create, bind, pass, and delay.
  435. license: MIT-style license.
  436. requires: [Native, $util]
  437. provides: Function
  438. ...
  439. */
  440. try {
  441. delete Function.prototype.bind;
  442. } catch (e) { }
  443. Function.implement({
  444. extend: function(properties) {
  445. for (var property in properties) this[property] = properties[property];
  446. return this;
  447. },
  448. create: function(options) {
  449. var self = this;
  450. options = options || {};
  451. return function(event) {
  452. var args = options.arguments;
  453. args = (args != undefined) ? $splat(args) : Array.slice(arguments, (options.event) ? 1 : 0);
  454. if (options.event) args = [event || window.event].extend(args);
  455. var returns = function() {
  456. return self.apply(options.bind || null, args);
  457. };
  458. if (options.delay) return setTimeout(returns, options.delay);
  459. if (options.periodical) return setInterval(returns, options.periodical);
  460. if (options.attempt) return $try(returns);
  461. return returns();
  462. };
  463. },
  464. run: function(args, bind) {
  465. return this.apply(bind, $splat(args));
  466. },
  467. pass: function(args, bind) {
  468. return this.create({ bind: bind, arguments: args });
  469. },
  470. bind: function(bind, args) {
  471. return this.create({ bind: bind, arguments: args });
  472. },
  473. bindWithEvent: function(bind, args) {
  474. return this.create({ bind: bind, arguments: args, event: true });
  475. },
  476. attempt: function(args, bind) {
  477. return this.create({ bind: bind, arguments: args, attempt: true })();
  478. },
  479. delay: function(delay, bind, args) {
  480. return this.create({ bind: bind, arguments: args, delay: delay })();
  481. },
  482. periodical: function(periodical, bind, args) {
  483. return this.create({ bind: bind, arguments: args, periodical: periodical })();
  484. }
  485. });
  486. /*
  487. ---
  488. name: Number
  489. description: Contains Number Prototypes like limit, round, times, and ceil.
  490. license: MIT-style license.
  491. requires: [Native, $util]
  492. provides: Number
  493. ...
  494. */
  495. Number.implement({
  496. limit: function(min, max) {
  497. return Math.min(max, Math.max(min, this));
  498. },
  499. round: function(precision) {
  500. precision = Math.pow(10, precision || 0);
  501. return Math.round(this * precision) / precision;
  502. },
  503. times: function(fn, bind) {
  504. for (var i = 0; i < this; i++) fn.call(bind, i, this);
  505. },
  506. toFloat: function() {
  507. return parseFloat(this);
  508. },
  509. toInt: function(base) {
  510. return parseInt(this, base || 10);
  511. }
  512. });
  513. Number.alias('times', 'each');
  514. (function(math) {
  515. var methods = {};
  516. math.each(function(name) {
  517. if (!Number[name]) methods[name] = function() {
  518. return Math[name].apply(null, [this].concat($A(arguments)));
  519. };
  520. });
  521. Number.implement(methods);
  522. })(['abs', 'acos', 'asin', 'atan', 'atan2', 'ceil', 'cos', 'exp', 'floor', 'log', 'max', 'min', 'pow', 'sin', 'sqrt', 'tan']);
  523. /*
  524. ---
  525. name: Hash
  526. description: Contains Hash Prototypes. Provides a means for overcoming the JavaScript practical impossibility of extending native Objects.
  527. license: MIT-style license.
  528. requires: Hash.base
  529. provides: Hash
  530. ...
  531. */
  532. Hash.implement({
  533. has: Object.prototype.hasOwnProperty,
  534. keyOf: function(value) {
  535. for (var key in this) {
  536. if (this.hasOwnProperty(key) && this[key] === value) return key;
  537. }
  538. return null;
  539. },
  540. hasValue: function(value) {
  541. return (Hash.keyOf(this, value) !== null);
  542. },
  543. extend: function(properties) {
  544. Hash.each(properties || {}, function(value, key) {
  545. Hash.set(this, key, value);
  546. }, this);
  547. return this;
  548. },
  549. combine: function(properties) {
  550. Hash.each(properties || {}, function(value, key) {
  551. Hash.include(this, key, value);
  552. }, this);
  553. return this;
  554. },
  555. erase: function(key) {
  556. if (this.hasOwnProperty(key)) delete this[key];
  557. return this;
  558. },
  559. get: function(key) {
  560. return (this.hasOwnProperty(key)) ? this[key] : null;
  561. },
  562. set: function(key, value) {
  563. if (!this[key] || this.hasOwnProperty(key)) this[key] = value;
  564. return this;
  565. },
  566. empty: function() {
  567. Hash.each(this, function(value, key) {
  568. delete this[key];
  569. }, this);
  570. return this;
  571. },
  572. include: function(key, value) {
  573. if (this[key] == undefined) this[key] = value;
  574. return this;
  575. },
  576. map: function(fn, bind) {
  577. var results = new Hash;
  578. Hash.each(this, function(value, key) {
  579. results.set(key, fn.call(bind, value, key, this));
  580. }, this);
  581. return results;
  582. },
  583. filter: function(fn, bind) {
  584. var results = new Hash;
  585. Hash.each(this, function(value, key) {
  586. if (fn.call(bind, value, key, this)) results.set(key, value);
  587. }, this);
  588. return results;
  589. },
  590. every: function(fn, bind) {
  591. for (var key in this) {
  592. if (this.hasOwnProperty(key) && !fn.call(bind, this[key], key)) return false;
  593. }
  594. return true;
  595. },
  596. some: function(fn, bind) {
  597. for (var key in this) {
  598. if (this.hasOwnProperty(key) && fn.call(bind, this[key], key)) return true;
  599. }
  600. return false;
  601. },
  602. getKeys: function() {
  603. var keys = [];
  604. Hash.each(this, function(value, key) {
  605. keys.push(key);
  606. });
  607. return keys;
  608. },
  609. getValues: function() {
  610. var values = [];
  611. Hash.each(this, function(value) {
  612. values.push(value);
  613. });
  614. return values;
  615. },
  616. toQueryString: function(base) {
  617. var queryString = [];
  618. Hash.each(this, function(value, key) {
  619. if (base) key = base + '[' + key + ']';
  620. var result;
  621. switch ($type(value)) {
  622. case 'object': result = Hash.toQueryString(value, key); break;
  623. case 'array':
  624. var qs = {};
  625. value.each(function(val, i) {
  626. qs[i] = val;
  627. });
  628. result = Hash.toQueryString(qs, key);
  629. break;
  630. default: result = key + '=' + encodeURIComponent(value);
  631. }
  632. if (value != undefined) queryString.push(result);
  633. });
  634. return queryString.join('&');
  635. }
  636. });
  637. Hash.alias({ keyOf: 'indexOf', hasValue: 'contains' });
  638. /*
  639. ---
  640. name: Class
  641. description: Contains the Class Function for easily creating, extending, and implementing reusable Classes.
  642. license: MIT-style license.
  643. requires: [$util, Native, Array, String, Function, Number, Hash]
  644. provides: Class
  645. ...
  646. */
  647. function Class(params) {
  648. if (params instanceof Function) params = { initialize: params };
  649. var newClass = function() {
  650. Object.reset(this);
  651. if (newClass._prototyping) return this;
  652. this._current = $empty;
  653. var value = (this.initialize) ? this.initialize.apply(this, arguments) : this;
  654. delete this._current; delete this.caller;
  655. return value;
  656. } .extend(this);
  657. newClass.implement(params);
  658. newClass.constructor = Class;
  659. newClass.prototype.constructor = newClass;
  660. return newClass;
  661. };
  662. Function.prototype.protect = function() {
  663. this._protected = true;
  664. return this;
  665. };
  666. Object.reset = function(object, key) {
  667. if (key == null) {
  668. for (var p in object) Object.reset(object, p);
  669. return object;
  670. }
  671. delete object[key];
  672. switch ($type(object[key])) {
  673. case 'object':
  674. var F = function() { };
  675. F.prototype = object[key];
  676. var i = new F;
  677. object[key] = Object.reset(i);
  678. break;
  679. case 'array': object[key] = $unlink(object[key]); break;
  680. }
  681. return object;
  682. };
  683. new Native({ name: 'Class', initialize: Class }).extend({
  684. instantiate: function(F) {
  685. F._prototyping = true;
  686. var proto = new F;
  687. delete F._prototyping;
  688. return proto;
  689. },
  690. wrap: function(self, key, method) {
  691. if (method._origin) method = method._origin;
  692. return function() {
  693. if (method._protected && this._current == null) throw new Error('The method "' + key + '" cannot be called.');
  694. var caller = this.caller, current = this._current;
  695. this.caller = current; this._current = arguments.callee;
  696. var result = method.apply(this, arguments);
  697. this._current = current; this.caller = caller;
  698. return result;
  699. } .extend({ _owner: self, _origin: method, _name: key });
  700. }
  701. });
  702. Class.implement({
  703. implement: function(key, value) {
  704. if ($type(key) == 'object') {
  705. for (var p in key) this.implement(p, key[p]);
  706. return this;
  707. }
  708. var mutator = Class.Mutators[key];
  709. if (mutator) {
  710. value = mutator.call(this, value);
  711. if (value == null) return this;
  712. }
  713. var proto = this.prototype;
  714. switch ($type(value)) {
  715. case 'function':
  716. if (value._hidden) return this;
  717. proto[key] = Class.wrap(this, key, value);
  718. break;
  719. case 'object':
  720. var previous = proto[key];
  721. if ($type(previous) == 'object') $mixin(previous, value);
  722. else proto[key] = $unlink(value);
  723. break;
  724. case 'array':
  725. proto[key] = $unlink(value);
  726. break;
  727. default: proto[key] = value;
  728. }
  729. return this;
  730. }
  731. });
  732. Class.Mutators = {
  733. Extends: function(parent) {
  734. this.parent = parent;
  735. this.prototype = Class.instantiate(parent);
  736. this.implement('parent', function() {
  737. var name = this.caller._name, previous = this.caller._owner.parent.prototype[name];
  738. if (!previous) throw new Error('The method "' + name + '" has no parent.');
  739. return previous.apply(this, arguments);
  740. } .protect());
  741. },
  742. Implements: function(items) {
  743. $splat(items).each(function(item) {
  744. if (item instanceof Function) item = Class.instantiate(item);
  745. this.implement(item);
  746. }, this);
  747. }
  748. };
  749. /*
  750. ---
  751. name: Class.Extras
  752. description: Contains Utility Classes that can be implemented into your own Classes to ease the execution of many common tasks.
  753. license: MIT-style license.
  754. requires: Class
  755. provides: [Chain, Events, Options, Class.Extras]
  756. ...
  757. */
  758. var Chain = new Class({
  759. $chain: [],
  760. chain: function() {
  761. this.$chain.extend(Array.flatten(arguments));
  762. return this;
  763. },
  764. callChain: function() {
  765. return (this.$chain.length) ? this.$chain.shift().apply(this, arguments) : false;
  766. },
  767. clearChain: function() {
  768. this.$chain.empty();
  769. return this;
  770. }
  771. });
  772. var Events = new Class({
  773. $events: {},
  774. addEvent: function(type, fn, internal) {
  775. type = Events.removeOn(type);
  776. if (fn != $empty) {
  777. this.$events[type] = this.$events[type] || [];
  778. this.$events[type].include(fn);
  779. if (internal) fn.internal = true;
  780. }
  781. return this;
  782. },
  783. addEvents: function(events) {
  784. for (var type in events) this.addEvent(type, events[type]);
  785. return this;
  786. },
  787. fireEvent: function(type, args, delay) {
  788. type = Events.removeOn(type);
  789. if (!this.$events || !this.$events[type]) return this;
  790. this.$events[type].each(function(fn) {
  791. fn.create({ 'bind': this, 'delay': delay, 'arguments': args })();
  792. }, this);
  793. return this;
  794. },
  795. removeEvent: function(type, fn) {
  796. type = Events.removeOn(type);
  797. if (!this.$events[type]) return this;
  798. if (!fn.internal) this.$events[type].erase(fn);
  799. return this;
  800. },
  801. removeEvents: function(events) {
  802. var type;
  803. if ($type(events) == 'object') {
  804. for (type in events) this.removeEvent(type, events[type]);
  805. return this;
  806. }
  807. if (events) events = Events.removeOn(events);
  808. for (type in this.$events) {
  809. if (events && events != type) continue;
  810. var fns = this.$events[type];
  811. for (var i = fns.length; i--; i) this.removeEvent(type, fns[i]);
  812. }
  813. return this;
  814. }
  815. });
  816. Events.removeOn = function(string) {
  817. return string.replace(/^on([A-Z])/, function(full, first) {
  818. return first.toLowerCase();
  819. });
  820. };
  821. var Options = new Class({
  822. setOptions: function() {
  823. this.options = $merge.run([this.options].extend(arguments));
  824. if (!this.addEvent) return this;
  825. for (var option in this.options) {
  826. if ($type(this.options[option]) != 'function' || !(/^on[A-Z]/).test(option)) continue;
  827. this.addEvent(option, this.options[option]);
  828. delete this.options[option];
  829. }
  830. return this;
  831. }
  832. });
  833. /*
  834. ---
  835. name: Browser
  836. description: The Browser Core. Contains Browser initialization, Window and Document, and the Browser Hash.
  837. license: MIT-style license.
  838. requires: [Native, $util]
  839. provides: [Browser, Window, Document, $exec]
  840. ...
  841. */
  842. var Browser = $merge({
  843. Engine: { name: 'unknown', version: 0 },
  844. Platform: { name: (window.orientation != undefined) ? 'ipod' : (navigator.platform.match(/mac|win|linux/i) || ['other'])[0].toLowerCase() },
  845. Features: { xpath: !!(document.evaluate), air: !!(window.runtime), query: !!(document.querySelector) },
  846. Plugins: {},
  847. Engines: {
  848. presto: function() {
  849. return (!window.opera) ? false : ((arguments.callee.caller) ? 960 : ((document.getElementsByClassName) ? 950 : 925));
  850. },
  851. trident: function() {
  852. return (!window.ActiveXObject) ? false : ((window.XMLHttpRequest) ? ((document.querySelectorAll) ? 6 : 5) : 4);
  853. },
  854. webkit: function() {
  855. return (navigator.taintEnabled) ? false : ((Browser.Features.xpath) ? ((Browser.Features.query) ? 525 : 420) : 419);
  856. },
  857. gecko: function() {
  858. return (!document.getBoxObjectFor && window.mozInnerScreenX == null) ? false : ((document.getElementsByClassName) ? 19 : 18);
  859. }
  860. }
  861. }, Browser || {});
  862. Browser.Platform[Browser.Platform.name] = true;
  863. Browser.detect = function() {
  864. for (var engine in this.Engines) {
  865. var version = this.Engines[engine]();
  866. if (version) {
  867. this.Engine = { name: engine, version: version };
  868. this.Engine[engine] = this.Engine[engine + version] = true;
  869. break;
  870. }
  871. }
  872. return { name: engine, version: version };
  873. };
  874. Browser.detect();
  875. Browser.Request = function() {
  876. return $try(function() {
  877. return new XMLHttpRequest();
  878. }, function() {
  879. return new ActiveXObject('MSXML2.XMLHTTP');
  880. }, function() {
  881. return new ActiveXObject('Microsoft.XMLHTTP');
  882. });
  883. };
  884. Browser.Features.xhr = !!(Browser.Request());
  885. Browser.Plugins.Flash = (function() {
  886. var version = ($try(function() {
  887. return navigator.plugins['Shockwave Flash'].description;
  888. }, function() {
  889. return new ActiveXObject('ShockwaveFlash.ShockwaveFlash').GetVariable('$version');
  890. }) || '0 r0').match(/\d+/g);
  891. return { version: parseInt(version[0] || 0 + '.' + version[1], 10) || 0, build: parseInt(version[2], 10) || 0 };
  892. })();
  893. function $exec(text) {
  894. if (!text) return text;
  895. if (window.execScript) {
  896. window.execScript(text);
  897. } else {
  898. var script = document.createElement('script');
  899. script.setAttribute('type', 'text/javascript');
  900. script[(Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerText' : 'text'] = text;
  901. document.head.appendChild(script);
  902. document.head.removeChild(script);
  903. }
  904. return text;
  905. };
  906. Native.UID = 1;
  907. var $uid = (Browser.Engine.trident) ? function(item) {
  908. return (item.uid || (item.uid = [Native.UID++]))[0];
  909. } : function(item) {
  910. return item.uid || (item.uid = Native.UID++);
  911. };
  912. var Window = new Native({
  913. name: 'Window',
  914. legacy: (Browser.Engine.trident) ? null : window.Window,
  915. initialize: function(win) {
  916. $uid(win);
  917. if (!win.Element) {
  918. win.Element = $empty;
  919. if (Browser.Engine.webkit) win.document.createElement("iframe"); //fixes safari 2
  920. win.Element.prototype = (Browser.Engine.webkit) ? window["[[DOMElement.prototype]]"] : {};
  921. }
  922. win.document.window = win;
  923. return $extend(win, Window.Prototype);
  924. },
  925. afterImplement: function(property, value) {
  926. window[property] = Window.Prototype[property] = value;
  927. }
  928. });
  929. Window.Prototype = { $family: { name: 'window'} };
  930. new Window(window);
  931. var Document = new Native({
  932. name: 'Document',
  933. legacy: (Browser.Engine.trident) ? null : window.Document,
  934. initialize: function(doc) {
  935. $uid(doc);
  936. doc.head = doc.getElementsByTagName('head')[0];
  937. doc.html = doc.getElementsByTagName('html')[0];
  938. if (Browser.Engine.trident && Browser.Engine.version <= 4) $try(function() {
  939. doc.execCommand("BackgroundImageCache", false, true);
  940. });
  941. if (Browser.Engine.trident) doc.window.attachEvent('onunload', function() {
  942. doc.window.detachEvent('onunload', arguments.callee);
  943. doc.head = doc.html = doc.window = null;
  944. });
  945. return $extend(doc, Document.Prototype);
  946. },
  947. afterImplement: function(property, value) {
  948. document[property] = Document.Prototype[property] = value;
  949. }
  950. });
  951. Document.Prototype = { $family: { name: 'document'} };
  952. new Document(document);
  953. /*
  954. ---
  955. name: Element
  956. description: One of the most important items in MooTools. Contains the dollar function, the dollars function, and an handful of cross-browser, time-saver methods to let you easily work with HTML Elements.
  957. license: MIT-style license.
  958. requires: [Window, Document, Array, String, Function, Number, Hash]
  959. provides: [Element, Elements, $, $$, Iframe]
  960. ...
  961. */
  962. var Element = new Native({
  963. name: 'Element',
  964. legacy: window.Element,
  965. initialize: function(tag, props) {
  966. var konstructor = Element.Constructors.get(tag);
  967. if (konstructor) return konstructor(props);
  968. if (typeof tag == 'string') return document.newElement(tag, props);
  969. return document.byid(tag).set(props);
  970. },
  971. afterImplement: function(key, value) {
  972. Element.Prototype[key] = value;
  973. if (Array[key]) return;
  974. Elements.implement(key, function() {
  975. var items = [], elements = true;
  976. for (var i = 0, j = this.length; i < j; i++) {
  977. var returns = this[i][key].apply(this[i], arguments);
  978. items.push(returns);
  979. if (elements) elements = ($type(returns) == 'element');
  980. }
  981. return (elements) ? new Elements(items) : items;
  982. });
  983. }
  984. });
  985. Element.Prototype = { $family: { name: 'element'} };
  986. Element.Constructors = new Hash;
  987. var IFrame = new Native({
  988. name: 'IFrame',
  989. generics: false,
  990. initialize: function() {
  991. var params = Array.link(arguments, { properties: Object.type, iframe: $defined });
  992. var props = params.properties || {};
  993. var iframe = document.byid(params.iframe);
  994. var onload = props.onload || $empty;
  995. delete props.onload;
  996. props.id = props.name = $pick(props.id, props.name, iframe ? (iframe.id || iframe.name) : 'IFrame_' + $time());
  997. iframe = new Element(iframe || 'iframe', props);
  998. var onFrameLoad = function() {
  999. var host = $try(function() {
  1000. return iframe.contentWindow.location.host;
  1001. });
  1002. if (!host || host == window.location.host) {
  1003. var win = new Window(iframe.contentWindow);
  1004. new Document(iframe.contentWindow.document);
  1005. $extend(win.Element.prototype, Element.Prototype);
  1006. }
  1007. onload.call(iframe.contentWindow, iframe.contentWindow.document);
  1008. };
  1009. var contentWindow = $try(function() {
  1010. return iframe.contentWindow;
  1011. });
  1012. ((contentWindow && contentWindow.document.body) || window.frames[props.id]) ? onFrameLoad() : iframe.addListener('load', onFrameLoad);
  1013. return iframe;
  1014. }
  1015. });
  1016. var Elements = new Native({
  1017. initialize: function(elements, options) {
  1018. options = $extend({ ddup: true, cash: true }, options);
  1019. elements = elements || [];
  1020. if (options.ddup || options.cash) {
  1021. var uniques = {}, returned = [];
  1022. for (var i = 0, l = elements.length; i < l; i++) {
  1023. var el = document.byid(elements[i], !options.cash);
  1024. if (options.ddup) {
  1025. if (uniques[el.uid]) continue;
  1026. uniques[el.uid] = true;
  1027. }
  1028. if (el) returned.push(el);
  1029. }
  1030. elements = returned;
  1031. }
  1032. return (options.cash) ? $extend(elements, this) : elements;
  1033. }
  1034. });
  1035. Elements.implement({
  1036. filter: function(filter, bind) {
  1037. if (!filter) return this;
  1038. return new Elements(Array.filter(this, (typeof filter == 'string') ? function(item) {
  1039. return item.match(filter);
  1040. } : filter, bind));
  1041. }
  1042. });
  1043. (function() {
  1044. /*<ltIE8>*/
  1045. var createElementAcceptsHTML;
  1046. try {
  1047. var x = document.createElement('<input name=x>');
  1048. createElementAcceptsHTML = (x.name == 'x');
  1049. } catch (e) { }
  1050. var escapeQuotes = function(html) {
  1051. return ('' + html).replace(/&/g, '&amp;').replace(/"/g, '&quot;');
  1052. };
  1053. /*</ltIE8>*/
  1054. Document.implement({
  1055. newElement: function(tag, props) {
  1056. if (props && props.checked != null) props.defaultChecked = props.checked;
  1057. /*<ltIE8>*/// Fix for readonly name and type properties in IE < 8
  1058. if (createElementAcceptsHTML && props) {
  1059. tag = '<' + tag;
  1060. if (props.name) tag += ' name="' + escapeQuotes(props.name) + '"';
  1061. if (props.type) tag += ' type="' + escapeQuotes(props.type) + '"';
  1062. tag += '>';
  1063. delete props.name;
  1064. delete props.type;
  1065. }
  1066. /*</ltIE8>*/
  1067. return this.id(this.createElement(tag)).set(props);
  1068. },
  1069. newTextNode: function(text) {
  1070. return this.createTextNode(text);
  1071. },
  1072. getDocument: function() {
  1073. return this;
  1074. },
  1075. getWindow: function() {
  1076. return this.window;
  1077. },
  1078. /* CMS
  1079. 'id' was replaced with 'byid'
  1080. END CMS */
  1081. byid: (function() {
  1082. var types = {
  1083. string: function(id, nocash, doc) {
  1084. id = doc.getElementById(id);
  1085. return (id) ? types.element(id, nocash) : null;
  1086. },
  1087. element: function(el, nocash) {
  1088. $uid(el);
  1089. if (!nocash && !el.$family && !(/^object|embed$/i).test(el.tagName)) {
  1090. var proto = Element.Prototype;
  1091. for (var p in proto) el[p] = proto[p];
  1092. };
  1093. return el;
  1094. },
  1095. object: function(obj, nocash, doc) {
  1096. if (obj.toElement) return types.element(obj.toElement(doc), nocash);
  1097. return null;
  1098. }
  1099. };
  1100. types.textnode = types.whitespace = types.window = types.document = $arguments(0);
  1101. return function(el, nocash, doc) {
  1102. if (el && el.$family && el.uid) return el;
  1103. var type = $type(el);
  1104. return (types[type]) ? types[type](el, nocash, doc || document) : null;
  1105. };
  1106. })()
  1107. });
  1108. })();
  1109. if (window.$ == null) Window.implement({
  1110. $: function(el, nc) {
  1111. return document.byid(el, nc, this.document);
  1112. }
  1113. });
  1114. Window.implement({
  1115. $$: function(selector) {
  1116. if (arguments.length == 1 && typeof selector == 'string') return this.document.getElements(selector);
  1117. var elements = [];
  1118. var args = Array.flatten(arguments);
  1119. for (var i = 0, l = args.length; i < l; i++) {
  1120. var item = args[i];
  1121. switch ($type(item)) {
  1122. case 'element': elements.push(item); break;
  1123. case 'string': elements.extend(this.document.getElements(item, true));
  1124. }
  1125. }
  1126. return new Elements(elements);
  1127. },
  1128. getDocument: function() {
  1129. return this.document;
  1130. },
  1131. getWindow: function() {
  1132. return this;
  1133. }
  1134. });
  1135. Native.implement([Element, Document], {
  1136. getElement: function(selector, nocash) {
  1137. return document.byid(this.getElements(selector, true)[0] || null, nocash);
  1138. },
  1139. getElements: function(tags, nocash) {
  1140. tags = tags.split(',');
  1141. var elements = [];
  1142. var ddup = (tags.length > 1);
  1143. tags.each(function(tag) {
  1144. var partial = this.getElementsByTagName(tag.trim());
  1145. (ddup) ? elements.extend(partial) : elements = partial;
  1146. }, this);
  1147. return new Elements(elements, { ddup: ddup, cash: !nocash });
  1148. }
  1149. });
  1150. (function() {
  1151. var collected = {}, storage = {};
  1152. var props = { input: 'checked', option: 'selected', textarea: (Browser.Engine.webkit && Browser.Engine.version < 420) ? 'innerHTML' : 'value' };
  1153. var get = function(uid) {
  1154. return (storage[uid] || (storage[uid] = {}));
  1155. };
  1156. var clean = function(item, retain) {
  1157. if (!item) return;
  1158. var uid = item.uid;
  1159. if (retain !== true) retain = false;
  1160. if (Browser.Engine.trident) {
  1161. if (item.clearAttributes) {
  1162. var clone = retain && item.cloneNode(false);
  1163. item.clearAttributes();
  1164. if (clone) item.mergeAttributes(clone);
  1165. } else if (item.removeEvents) {
  1166. item.removeEvents();
  1167. }
  1168. if ((/object/i).test(item.tagName)) {
  1169. for (var p in item) {
  1170. if (typeof item[p] == 'function') item[p] = $empty;
  1171. }
  1172. Element.dispose(item);
  1173. }
  1174. }
  1175. if (!uid) return;
  1176. collected[uid] = storage[uid] = null;
  1177. };
  1178. var purge = function() {
  1179. Hash.each(collected, clean);
  1180. if (Browser.Engine.trident) $A(document.getElementsByTagName('object')).each(clean);
  1181. if (window.CollectGarbage) CollectGarbage();
  1182. collected = storage = null;
  1183. };
  1184. var walk = function(element, walk, start, match, all, nocash) {
  1185. var el = element[start || walk];
  1186. var elements = [];
  1187. while (el) {
  1188. if (el.nodeType == 1 && (!match || Element.match(el, match))) {
  1189. if (!all) return document.byid(el, nocash);
  1190. elements.push(el);
  1191. }
  1192. el = el[walk];
  1193. }
  1194. return (all) ? new Elements(elements, { ddup: false, cash: !nocash }) : null;
  1195. };
  1196. var attributes = {
  1197. 'html': 'innerHTML',
  1198. 'class': 'className',
  1199. 'for': 'htmlFor',
  1200. 'defaultValue': 'defaultValue',
  1201. 'text': (Browser.Engine.trident || (Browser.Engine.webkit && Browser.Engine.version < 420)) ? 'innerText' : 'textContent'
  1202. };
  1203. var bools = ['compact', 'nowrap', 'ismap', 'declare', 'noshade', 'checked', 'disabled', 'readonly', 'multiple', 'selected', 'noresize', 'defer'];
  1204. var camels = ['value', 'type', 'defaultValue', 'accessKey', 'cellPadding', 'cellSpacing', 'colSpan', 'frameBorder', 'maxLength', 'readOnly', 'rowSpan', 'tabIndex', 'useMap'];
  1205. bools = bools.associate(bools);
  1206. Hash.extend(attributes, bools);
  1207. Hash.extend(attributes, camels.associate(camels.map(String.toLowerCase)));
  1208. var inserters = {
  1209. before: function(context, element) {
  1210. if (element.parentNode) element.parentNode.insertBefore(context, element);
  1211. },
  1212. after: function(context, element) {
  1213. if (!element.parentNode) return;
  1214. var next = element.nextSibling;
  1215. (next) ? element.parentNode.insertBefore(context, next) : element.parentNode.appendChild(context);
  1216. },
  1217. bottom: function(context, element) {
  1218. element.appendChild(context);
  1219. },
  1220. top: function(context, element) {
  1221. var first = element.firstChild;
  1222. (first) ? element.insertBefore(context, first) : element.appendChild(context);
  1223. }
  1224. };
  1225. inserters.inside = inserters.bottom;
  1226. Hash.each(inserters, function(inserter, where) {
  1227. where = where.capitalize();
  1228. Element.implement('inject' + where, function(el) {
  1229. inserter(this, document.byid(el, true));
  1230. return this;
  1231. });
  1232. Element.implement('grab' + where, function(el) {
  1233. inserter(document.byid(el, true), this);
  1234. return this;
  1235. });
  1236. });
  1237. Element.implement({
  1238. set: function(prop, value) {
  1239. switch ($type(prop)) {
  1240. case 'object':
  1241. for (var p in prop) this.set(p, prop[p]);
  1242. break;
  1243. case 'string':
  1244. var property = Element.Properties.get(prop);
  1245. (property && property.set) ? property.set.apply(this, Array.slice(arguments, 1)) : this.setProperty(prop, value);
  1246. }
  1247. return this;
  1248. },
  1249. get: function(prop) {
  1250. var property = Element.Properties.get(prop);
  1251. return (property && property.get) ? property.get.apply(this, Array.slice(arguments, 1)) : this.getProperty(prop);
  1252. },
  1253. erase: function(prop) {
  1254. var property = Element.Properties.get(prop);
  1255. (property && property.erase) ? property.erase.apply(this) : this.removeProperty(prop);
  1256. return this;
  1257. },
  1258. setProperty: function(attribute, value) {
  1259. var key = attributes[attribute];
  1260. if (value == undefined) return this.removeProperty(attribute);
  1261. if (key && bools[attribute]) value = !!value;
  1262. (key) ? this[key] = value : this.setAttribute(attribute, '' + value);
  1263. return this;
  1264. },
  1265. setProperties: function(attributes) {
  1266. for (var attribute in attributes) this.setProperty(attribute, attributes[attribute]);
  1267. return this;
  1268. },
  1269. getProperty: function(attribute) {
  1270. var key = attributes[attribute];
  1271. var value = (key) ? this[key] : this.getAttribute(attribute, 2);
  1272. return (bools[attribute]) ? !!value : (key) ? value : value || null;
  1273. },
  1274. getProperties: function() {
  1275. var args = $A(arguments);
  1276. return args.map(this.getProperty, this).associate(args);
  1277. },
  1278. removeProperty: function(attribute) {
  1279. var key = attributes[attribute];
  1280. (key) ? this[key] = (key && bools[attribute]) ? false : '' : this.removeAttribute(attribute);
  1281. return this;
  1282. },
  1283. removeProperties: function() {
  1284. Array.each(arguments, this.removeProperty, this);
  1285. return this;
  1286. },
  1287. hasClass: function(className) {
  1288. return this.className.contains(className, ' ');
  1289. },
  1290. addClass: function(className) {
  1291. if (!this.hasClass(className)) this.className = (this.className + ' ' + className).clean();
  1292. return this;
  1293. },
  1294. removeClass: function(className) {
  1295. this.className = this.className.replace(new RegExp('(^|\\s)' + className + '(?:\\s|$)'), '$1');
  1296. return this;
  1297. },
  1298. toggleClass: function(className) {
  1299. return this.hasClass(className) ? this.removeClass(className) : this.addClass(className);
  1300. },
  1301. adopt: function() {
  1302. Array.flatten(arguments).each(function(element) {
  1303. element = document.byid(element, true);
  1304. if (element) this.appendChild(element);
  1305. }, this);
  1306. return this;
  1307. },
  1308. appendText: function(text, where) {
  1309. return this.grab(this.getDocument().newTextNode(text), where);
  1310. },
  1311. grab: function(el, where) {
  1312. inserters[where || 'bottom'](document.byid(el, true), this);
  1313. return this;
  1314. },
  1315. inject: function(el, where) {
  1316. inserters[where || 'bottom'](this, document.byid(el, true));
  1317. return this;
  1318. },
  1319. replaces: function(el) {
  1320. el = document.byid(el, true);
  1321. el.parentNode.replaceChild(this, el);
  1322. return this;
  1323. },
  1324. wraps: function(el, where) {
  1325. el = document.byid(el, true);
  1326. return this.replaces(el).grab(el, where);
  1327. },
  1328. getPrevious: function(match, nocash) {
  1329. return walk(this, 'previousSibling', null, match, false, nocash);
  1330. },
  1331. getAllPrevious: function(match, nocash) {
  1332. return walk(this, 'previousSibling', null, match, true, nocash);
  1333. },
  1334. getNext: function(match, nocash) {
  1335. return walk(this, 'nextSibling', null, match, false, nocash);
  1336. },
  1337. getAllNext: function(match, nocash) {
  1338. return walk(this, 'nextSibling', null, match, true, nocash);
  1339. },
  1340. getFirst: function(match, nocash) {
  1341. return walk(this, 'nextSibling', 'firstChild', match, false, nocash);
  1342. },
  1343. getLast: function(match, nocash) {
  1344. return walk(this, 'previousSibling', 'lastChild', match, false, nocash);
  1345. },
  1346. getParent: function(match, nocash) {
  1347. return walk(this, 'parentNode', null, match, false, nocash);
  1348. },
  1349. getParents: function(match, nocash) {
  1350. return walk(this, 'parentNode', null, match, true, nocash);
  1351. },
  1352. getSiblings: function(match, nocash) {
  1353. return this.getParent().getChildren(match, nocash).erase(this);
  1354. },
  1355. getChildren: function(match, nocash) {
  1356. return walk(this, 'nextSibling', 'firstChild', match, true, nocash);
  1357. },
  1358. getWindow: function() {
  1359. return this.ownerDocument.window;
  1360. },
  1361. getDocument: function() {
  1362. return this.ownerDocument;
  1363. },
  1364. getElementById: function(id, nocash) {
  1365. var el = this.ownerDocument.getElementById(id);
  1366. if (!el) return null;
  1367. for (var parent = el.parentNode; parent != this; parent = parent.parentNode) {
  1368. if (!parent) return null;
  1369. }
  1370. return document.byid(el, nocash);
  1371. },
  1372. getSelected: function() {
  1373. return new Elements($A(this.options).filter(function(option) {
  1374. return option.selected;
  1375. }));
  1376. },
  1377. getComputedStyle: function(property) {
  1378. if (this.currentStyle) return this.currentStyle[property.camelCase()];
  1379. var computed = this.getDocument().defaultView.getComputedStyle(this, null);
  1380. return (computed) ? computed.getPropertyValue([property.hyphenate()])