quo.debug.js 39 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333
  1. /*
  2. QuoJS 2.2.0
  3. http://quojs.tapquo.com
  4. Copyright (C) 2011,2012 Javi Jiménez Villar (@soyjavi)
  5. Permission is hereby granted, free of charge, to any person obtaining a
  6. copy of this software and associated documentation files (the "Software"),
  7. to deal in the Software without restriction, including without limitation
  8. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9. and/or sell copies of the Software, and to permit persons to whom the
  10. Software is furnished to do so, subject to the following conditions:
  11. The above copyright notice and this permission notice shall be included in
  12. all copies or substantial portions of the Software.
  13. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  18. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  19. DEALINGS IN THE SOFTWARE.
  20. */
  21. (function() {
  22. var Quo;
  23. Quo = (function() {
  24. var $$, EMPTY_ARRAY, Q;
  25. EMPTY_ARRAY = [];
  26. Q = function(dom, selector) {
  27. dom = dom || EMPTY_ARRAY;
  28. dom.__proto__ = Q.prototype;
  29. dom.selector = selector || '';
  30. return dom;
  31. };
  32. $$ = function(selector, children) {
  33. var dom;
  34. if (!selector) {
  35. return Q();
  36. } else {
  37. dom = $$.getDOMObject(selector, children);
  38. if (children) {
  39. selector += ' ' + children;
  40. }
  41. return Q(dom, selector);
  42. }
  43. };
  44. $$.extend = function(target) {
  45. Array.prototype.slice.call(arguments, 1).forEach(function(source) {
  46. var key, _results;
  47. _results = [];
  48. for (key in source) {
  49. _results.push(target[key] = source[key]);
  50. }
  51. return _results;
  52. });
  53. return target;
  54. };
  55. Q.prototype = $$.fn = {};
  56. return $$;
  57. })();
  58. window.Quo = Quo;
  59. "$$" in window || (window.$$ = Quo);
  60. }).call(this);
  61. // Generated by CoffeeScript 1.4.0
  62. /*
  63. QuoJS 2.2.0
  64. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  65. http://quojs.tapquo.com
  66. */
  67. (function() {
  68. (function($$) {
  69. var EMPTY_ARRAY, HTML_CONTAINERS, IS_HTML_FRAGMENT, OBJECT_PROTOTYPE, TABLE, TABLE_ROW, _compact, _flatten;
  70. EMPTY_ARRAY = [];
  71. OBJECT_PROTOTYPE = Object.prototype;
  72. IS_HTML_FRAGMENT = /^\s*<(\w+|!)[^>]*>/;
  73. TABLE = document.createElement('table');
  74. TABLE_ROW = document.createElement('tr');
  75. HTML_CONTAINERS = {
  76. "tr": document.createElement("tbody"),
  77. "tbody": TABLE,
  78. "thead": TABLE,
  79. "tfoot": TABLE,
  80. "td": TABLE_ROW,
  81. "th": TABLE_ROW,
  82. "*": document.createElement("div")
  83. };
  84. $$.toType = function(obj) {
  85. return OBJECT_PROTOTYPE.toString.call(obj).match(/\s([a-z|A-Z]+)/)[1].toLowerCase();
  86. };
  87. $$.isOwnProperty = function(object, property) {
  88. return OBJECT_PROTOTYPE.hasOwnProperty.call(object, property);
  89. };
  90. $$.getDOMObject = function(selector, children) {
  91. var domain, elementTypes, type;
  92. domain = null;
  93. elementTypes = [1, 9, 11];
  94. type = $$.toType(selector);
  95. if (type === "array") {
  96. domain = _compact(selector);
  97. } else if (type === "string" && IS_HTML_FRAGMENT.test(selector)) {
  98. domain = $$.fragment(selector.trim(), RegExp.$1);
  99. selector = null;
  100. } else if (type === "string") {
  101. domain = $$.query(document, selector);
  102. if (children) {
  103. if (domain.length === 1) {
  104. domain = $$.query(domain[0], children);
  105. } else {
  106. domain = $$.map(function() {
  107. return $$.query(domain, children);
  108. });
  109. }
  110. }
  111. } else if (elementTypes.indexOf(selector.nodeType) >= 0 || selector === window) {
  112. domain = [selector];
  113. selector = null;
  114. }
  115. return domain;
  116. };
  117. $$.map = function(elements, callback) {
  118. var i, key, value, values;
  119. values = [];
  120. i = void 0;
  121. key = void 0;
  122. if ($$.toType(elements) === "array") {
  123. i = 0;
  124. while (i < elements.length) {
  125. value = callback(elements[i], i);
  126. if (value != null) {
  127. values.push(value);
  128. }
  129. i++;
  130. }
  131. } else {
  132. for (key in elements) {
  133. value = callback(elements[key], key);
  134. if (value != null) {
  135. values.push(value);
  136. }
  137. }
  138. }
  139. return _flatten(values);
  140. };
  141. $$.each = function(elements, callback) {
  142. var i, key;
  143. i = void 0;
  144. key = void 0;
  145. if ($$.toType(elements) === "array") {
  146. i = 0;
  147. while (i < elements.length) {
  148. if (callback.call(elements[i], i, elements[i]) === false) {
  149. return elements;
  150. }
  151. i++;
  152. }
  153. } else {
  154. for (key in elements) {
  155. if (callback.call(elements[key], key, elements[key]) === false) {
  156. return elements;
  157. }
  158. }
  159. }
  160. return elements;
  161. };
  162. $$.mix = function() {
  163. var arg, argument, child, len, prop;
  164. child = {};
  165. arg = 0;
  166. len = arguments.length;
  167. while (arg < len) {
  168. argument = arguments[arg];
  169. for (prop in argument) {
  170. if ($$.isOwnProperty(argument, prop) && argument[prop] !== undefined) {
  171. child[prop] = argument[prop];
  172. }
  173. }
  174. arg++;
  175. }
  176. return child;
  177. };
  178. $$.fragment = function(markup, tag) {
  179. var container;
  180. if (tag == null) {
  181. tag = "*";
  182. }
  183. if (!(tag in HTML_CONTAINERS)) {
  184. tag = "*";
  185. }
  186. container = HTML_CONTAINERS[tag];
  187. container.innerHTML = "" + markup;
  188. return $$.each(Array.prototype.slice.call(container.childNodes), function() {
  189. return container.removeChild(this);
  190. });
  191. };
  192. $$.fn.map = function(fn) {
  193. return $$.map(this, function(el, i) {
  194. return fn.call(el, i, el);
  195. });
  196. };
  197. $$.fn.instance = function(property) {
  198. return this.map(function() {
  199. return this[property];
  200. });
  201. };
  202. $$.fn.filter = function(selector) {
  203. return $$([].filter.call(this, function(element) {
  204. return element.parentNode && $$.query(element.parentNode, selector).indexOf(element) >= 0;
  205. }));
  206. };
  207. $$.fn.forEach = EMPTY_ARRAY.forEach;
  208. $$.fn.indexOf = EMPTY_ARRAY.indexOf;
  209. _compact = function(array) {
  210. return array.filter(function(item) {
  211. return item !== void 0 && item !== null;
  212. });
  213. };
  214. _flatten = function(array) {
  215. if (array.length > 0) {
  216. return [].concat.apply([], array);
  217. } else {
  218. return array;
  219. }
  220. };
  221. })(Quo);
  222. }).call(this);
  223. // Generated by CoffeeScript 1.4.0
  224. /*
  225. QuoJS 2.2.0
  226. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  227. http://quojs.tapquo.com
  228. */
  229. (function() {
  230. (function($$) {
  231. $$.fn.attr = function(name, value) {
  232. if ($$.toType(name) === "string" && value === void 0) {
  233. return this[0].getAttribute(name);
  234. } else {
  235. return this.each(function() {
  236. return this.setAttribute(name, value);
  237. });
  238. }
  239. };
  240. $$.fn.data = function(name, value) {
  241. return this.attr("data-" + name, value);
  242. };
  243. $$.fn.val = function(value) {
  244. if ($$.toType(value) === "string") {
  245. return this.each(function() {
  246. return this.value = value;
  247. });
  248. } else {
  249. if (this.length > 0) {
  250. return this[0].value;
  251. } else {
  252. return null;
  253. }
  254. }
  255. };
  256. $$.fn.show = function() {
  257. return this.style("display", "block");
  258. };
  259. $$.fn.hide = function() {
  260. return this.style("display", "none");
  261. };
  262. $$.fn.height = function() {
  263. var offset;
  264. offset = this.offset();
  265. return offset.height;
  266. };
  267. $$.fn.width = function() {
  268. var offset;
  269. offset = this.offset();
  270. return offset.width;
  271. };
  272. $$.fn.offset = function() {
  273. var bounding;
  274. bounding = this[0].getBoundingClientRect();
  275. return {
  276. left: bounding.left + window.pageXOffset,
  277. top: bounding.top + window.pageYOffset,
  278. width: bounding.width,
  279. height: bounding.height
  280. };
  281. };
  282. $$.fn.remove = function() {
  283. return this.each(function() {
  284. if (this.parentNode != null) {
  285. return this.parentNode.removeChild(this);
  286. }
  287. });
  288. };
  289. })(Quo);
  290. }).call(this);
  291. // Generated by CoffeeScript 1.4.0
  292. /*
  293. QuoJS 2.2.0
  294. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  295. http://quojs.tapquo.com
  296. */
  297. (function() {
  298. (function($$) {
  299. var IS_WEBKIT, SUPPORTED_OS, _current, _detectBrowser, _detectEnvironment, _detectOS, _detectScreen;
  300. _current = null;
  301. IS_WEBKIT = /WebKit\/([\d.]+)/;
  302. SUPPORTED_OS = {
  303. Android: /(Android)\s+([\d.]+)/,
  304. ipad: /(iPad).*OS\s([\d_]+)/,
  305. iphone: /(iPhone\sOS)\s([\d_]+)/,
  306. blackberry: /(BlackBerry).*Version\/([\d.]+)/,
  307. webos: /(webOS|hpwOS)[\s\/]([\d.]+)/
  308. };
  309. $$.isMobile = function() {
  310. _current = _current || _detectEnvironment();
  311. return _current.isMobile;
  312. };
  313. $$.environment = function() {
  314. _current = _current || _detectEnvironment();
  315. return _current;
  316. };
  317. $$.isOnline = function() {
  318. return navigator.onLine;
  319. };
  320. _detectEnvironment = function() {
  321. var environment, user_agent;
  322. user_agent = navigator.userAgent;
  323. environment = {};
  324. environment.browser = _detectBrowser(user_agent);
  325. environment.os = _detectOS(user_agent);
  326. environment.isMobile = !!environment.os;
  327. environment.screen = _detectScreen();
  328. return environment;
  329. };
  330. _detectBrowser = function(user_agent) {
  331. var is_webkit;
  332. is_webkit = user_agent.match(IS_WEBKIT);
  333. if (is_webkit) {
  334. return is_webkit[0];
  335. } else {
  336. return user_agent;
  337. }
  338. };
  339. _detectOS = function(user_agent) {
  340. var detected_os, os, supported;
  341. detected_os = null;
  342. for (os in SUPPORTED_OS) {
  343. supported = user_agent.match(SUPPORTED_OS[os]);
  344. if (supported) {
  345. detected_os = {
  346. name: (os === "iphone" || os === "ipad" ? "ios" : os),
  347. version: supported[2].replace("_", ".")
  348. };
  349. break;
  350. }
  351. }
  352. return detected_os;
  353. };
  354. _detectScreen = function() {
  355. return {
  356. width: window.innerWidth,
  357. height: window.innerHeight
  358. };
  359. };
  360. })(Quo);
  361. }).call(this);
  362. // Generated by CoffeeScript 1.4.0
  363. /*
  364. QuoJS 2.2.0
  365. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  366. http://quojs.tapquo.com
  367. */
  368. (function() {
  369. (function($$) {
  370. var _createElement;
  371. $$.fn.text = function(value) {
  372. if (value || $$.toType(value) === "number") {
  373. return this.each(function() {
  374. return this.textContent = value;
  375. });
  376. } else {
  377. return this[0].textContent;
  378. }
  379. };
  380. $$.fn.html = function(value) {
  381. var type;
  382. type = $$.toType(value);
  383. if (value || type === "number" || type === "null") {
  384. return this.each(function() {
  385. if (type === "string" || type === "number" || type === "null") {
  386. return this.innerHTML = value;
  387. } else {
  388. this.innerHTML = null;
  389. return this.appendChild(value);
  390. }
  391. });
  392. } else {
  393. return this[0].innerHTML;
  394. }
  395. };
  396. $$.fn.append = function(value) {
  397. return this.each(function() {
  398. if ($$.toType(value) === "string") {
  399. if (value) {
  400. return this.appendChild(_createElement(value));
  401. }
  402. } else {
  403. return this.insertBefore(value);
  404. }
  405. });
  406. };
  407. $$.fn.prepend = function(value) {
  408. return this.each(function() {
  409. var parent;
  410. if ($$.toType(value) === "string") {
  411. return this.innerHTML = value + this.innerHTML;
  412. } else {
  413. parent = this.parentNode;
  414. return parent.insertBefore(value, parent.firstChild);
  415. }
  416. });
  417. };
  418. $$.fn.replaceWith = function(content) {
  419. return this.each(function() {
  420. var parent;
  421. if ($$.toType(content) === "string") {
  422. content = _createElement(content);
  423. }
  424. parent = this.parentNode;
  425. if (parent) {
  426. parent.insertBefore(content, this);
  427. }
  428. return $$(this).remove();
  429. });
  430. };
  431. $$.fn.empty = function() {
  432. return this.each(function() {
  433. this.innerHTML = null;
  434. });
  435. };
  436. _createElement = function(content) {
  437. var div;
  438. div = document.createElement("div");
  439. div.innerHTML = content;
  440. return div.firstChild;
  441. };
  442. })(Quo);
  443. }).call(this);
  444. // Generated by CoffeeScript 1.4.0
  445. /*
  446. QuoJS 2.2.0
  447. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  448. http://quojs.tapquo.com
  449. */
  450. (function() {
  451. (function($$) {
  452. var PARENT_NODE, _filtered, _findAncestors;
  453. PARENT_NODE = "parentNode";
  454. $$.query = function(domain, selector) {
  455. var dom_elements;
  456. dom_elements = domain.querySelectorAll(selector);
  457. dom_elements = Array.prototype.slice.call(dom_elements);
  458. return dom_elements;
  459. };
  460. $$.fn.find = function(selector) {
  461. var result;
  462. if (this.length === 1) {
  463. result = Quo.query(this[0], selector);
  464. } else {
  465. result = this.map(function() {
  466. return Quo.query(this, selector);
  467. });
  468. }
  469. return $$(result);
  470. };
  471. $$.fn.parent = function(selector) {
  472. var ancestors;
  473. ancestors = (selector ? _findAncestors(this) : this.instance(PARENT_NODE));
  474. return _filtered(ancestors, selector);
  475. };
  476. $$.fn.siblings = function(selector) {
  477. var siblings_elements;
  478. siblings_elements = this.map(function(index, element) {
  479. return Array.prototype.slice.call(element.parentNode.children).filter(function(child) {
  480. return child !== element;
  481. });
  482. });
  483. return _filtered(siblings_elements, selector);
  484. };
  485. $$.fn.children = function(selector) {
  486. var children_elements;
  487. children_elements = this.map(function() {
  488. return Array.prototype.slice.call(this.children);
  489. });
  490. return _filtered(children_elements, selector);
  491. };
  492. $$.fn.get = function(index) {
  493. if (index === undefined) {
  494. return this;
  495. } else {
  496. return this[index];
  497. }
  498. };
  499. $$.fn.first = function() {
  500. return $$(this[0]);
  501. };
  502. $$.fn.last = function() {
  503. return $$(this[this.length - 1]);
  504. };
  505. $$.fn.closest = function(selector, context) {
  506. var candidates, node;
  507. node = this[0];
  508. candidates = $$(selector);
  509. if (!candidates.length) {
  510. node = null;
  511. }
  512. while (node && candidates.indexOf(node) < 0) {
  513. node = node !== context && node !== document && node.parentNode;
  514. }
  515. return $$(node);
  516. };
  517. $$.fn.each = function(callback) {
  518. this.forEach(function(element, index) {
  519. return callback.call(element, index, element);
  520. });
  521. return this;
  522. };
  523. _findAncestors = function(nodes) {
  524. var ancestors;
  525. ancestors = [];
  526. while (nodes.length > 0) {
  527. nodes = $$.map(nodes, function(node) {
  528. if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
  529. ancestors.push(node);
  530. return node;
  531. }
  532. });
  533. }
  534. return ancestors;
  535. };
  536. _filtered = function(nodes, selector) {
  537. if (selector === undefined) {
  538. return $$(nodes);
  539. } else {
  540. return $$(nodes).filter(selector);
  541. }
  542. };
  543. })(Quo);
  544. }).call(this);
  545. // Generated by CoffeeScript 1.4.0
  546. /*
  547. QuoJS 2.2.0
  548. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  549. http://quojs.tapquo.com
  550. */
  551. (function() {
  552. (function($$) {
  553. var _computedStyle, _existsClass;
  554. $$.fn.addClass = function(name) {
  555. return this.each(function() {
  556. if (!_existsClass(name, this.className)) {
  557. this.className += " " + name;
  558. return this.className = this.className.trim();
  559. }
  560. });
  561. };
  562. $$.fn.removeClass = function(name) {
  563. return this.each(function() {
  564. if (!name) {
  565. return this.className = "";
  566. } else {
  567. if (_existsClass(name, this.className)) {
  568. return this.className = this.className.replace(name, " ").replace(/\s+/g, " ").trim();
  569. }
  570. }
  571. });
  572. };
  573. $$.fn.toggleClass = function(name) {
  574. return this.each(function() {
  575. if (_existsClass(name, this.className)) {
  576. return this.className = this.className.replace(name, " ");
  577. } else {
  578. this.className += " " + name;
  579. return this.className = this.className.trim();
  580. }
  581. });
  582. };
  583. $$.fn.hasClass = function(name) {
  584. return _existsClass(name, this[0].className);
  585. };
  586. $$.fn.style = function(property, value) {
  587. if (!value) {
  588. return this[0].style[property] || _computedStyle(this[0], property);
  589. } else {
  590. return this.each(function() {
  591. return this.style[property] = value;
  592. });
  593. }
  594. };
  595. _existsClass = function(name, className) {
  596. var classes;
  597. classes = className.split(/\s+/g);
  598. return classes.indexOf(name) >= 0;
  599. };
  600. _computedStyle = function(element, property) {
  601. return document.defaultView.getComputedStyle(element, "")[property];
  602. };
  603. })(Quo);
  604. }).call(this);
  605. // Generated by CoffeeScript 1.4.0
  606. /*
  607. QuoJS 2.2.0
  608. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  609. http://quojs.tapquo.com
  610. */
  611. (function() {
  612. (function($$) {
  613. var DEFAULT, JSONP_ID, MIME_TYPES, _isJsonP, _parseResponse, _xhrError, _xhrForm, _xhrHeaders, _xhrStatus, _xhrSuccess, _xhrTimeout;
  614. DEFAULT = {
  615. TYPE: "GET",
  616. MIME: "json"
  617. };
  618. MIME_TYPES = {
  619. script: "text/javascript, application/javascript",
  620. json: "application/json",
  621. xml: "application/xml, text/xml",
  622. html: "text/html",
  623. text: "text/plain"
  624. };
  625. JSONP_ID = 0;
  626. $$.ajaxSettings = {
  627. type: DEFAULT.TYPE,
  628. async: true,
  629. success: {},
  630. error: {},
  631. context: null,
  632. dataType: DEFAULT.MIME,
  633. headers: {},
  634. xhr: function() {
  635. return new window.XMLHttpRequest();
  636. },
  637. crossDomain: false,
  638. timeout: 0
  639. };
  640. $$.ajax = function(options) {
  641. var abortTimeout, settings, xhr;
  642. settings = $$.mix($$.ajaxSettings, options);
  643. if (settings.type === DEFAULT.TYPE) {
  644. settings.url += $$.serializeParameters(settings.data, "?");
  645. } else {
  646. settings.data = $$.serializeParameters(settings.data);
  647. }
  648. if (_isJsonP(settings.url)) {
  649. return $$.jsonp(settings);
  650. }
  651. xhr = settings.xhr();
  652. xhr.onreadystatechange = function() {
  653. if (xhr.readyState === 4) {
  654. clearTimeout(abortTimeout);
  655. return _xhrStatus(xhr, settings);
  656. }
  657. };
  658. xhr.open(settings.type, settings.url, settings.async);
  659. _xhrHeaders(xhr, settings);
  660. if (settings.timeout > 0) {
  661. abortTimeout = setTimeout(function() {
  662. return _xhrTimeout(xhr, settings);
  663. }, settings.timeout);
  664. }
  665. try {
  666. xhr.send(settings.data);
  667. } catch (error) {
  668. xhr = error;
  669. _xhrError("Resource not found", xhr, settings);
  670. }
  671. if (settings.async) {
  672. return xhr;
  673. } else {
  674. return _parseResponse(xhr, settings);
  675. }
  676. };
  677. $$.jsonp = function(settings) {
  678. var abortTimeout, callbackName, script, xhr;
  679. if (settings.async) {
  680. callbackName = "jsonp" + (++JSONP_ID);
  681. script = document.createElement("script");
  682. xhr = {
  683. abort: function() {
  684. $$(script).remove();
  685. if (callbackName in window) {
  686. return window[callbackName] = {};
  687. }
  688. }
  689. };
  690. abortTimeout = void 0;
  691. window[callbackName] = function(response) {
  692. clearTimeout(abortTimeout);
  693. $$(script).remove();
  694. delete window[callbackName];
  695. return _xhrSuccess(response, xhr, settings);
  696. };
  697. script.src = settings.url.replace(RegExp("=\\?"), "=" + callbackName);
  698. $$("head").append(script);
  699. if (settings.timeout > 0) {
  700. abortTimeout = setTimeout(function() {
  701. return _xhrTimeout(xhr, settings);
  702. }, settings.timeout);
  703. }
  704. return xhr;
  705. } else {
  706. return console.error("QuoJS.ajax: Unable to make jsonp synchronous call.");
  707. }
  708. };
  709. $$.get = function(url, data, success, dataType) {
  710. return $$.ajax({
  711. url: url,
  712. data: data,
  713. success: success,
  714. dataType: dataType
  715. });
  716. };
  717. $$.post = function(url, data, success, dataType) {
  718. return _xhrForm("POST", url, data, success, dataType);
  719. };
  720. $$.put = function(url, data, success, dataType) {
  721. return _xhrForm("PUT", url, data, success, dataType);
  722. };
  723. $$["delete"] = function(url, data, success, dataType) {
  724. return _xhrForm("DELETE", url, data, success, dataType);
  725. };
  726. $$.json = function(url, data, success) {
  727. return $$.ajax({
  728. url: url,
  729. data: data,
  730. success: success,
  731. dataType: DEFAULT.MIME
  732. });
  733. };
  734. $$.serializeParameters = function(parameters, character) {
  735. var parameter, serialize;
  736. if (character == null) {
  737. character = "";
  738. }
  739. serialize = character;
  740. for (parameter in parameters) {
  741. if (parameters.hasOwnProperty(parameter)) {
  742. if (serialize !== character) {
  743. serialize += "&";
  744. }
  745. serialize += parameter + "=" + parameters[parameter];
  746. }
  747. }
  748. if (serialize === character) {
  749. return "";
  750. } else {
  751. return serialize;
  752. }
  753. };
  754. _xhrStatus = function(xhr, settings) {
  755. if ((xhr.status >= 200 && xhr.status < 300) || xhr.status === 0) {
  756. if (settings.async) {
  757. _xhrSuccess(_parseResponse(xhr, settings), xhr, settings);
  758. }
  759. } else {
  760. _xhrError("QuoJS.ajax: Unsuccesful request", xhr, settings);
  761. }
  762. };
  763. _xhrSuccess = function(response, xhr, settings) {
  764. settings.success.call(settings.context, response, xhr);
  765. };
  766. _xhrError = function(type, xhr, settings) {
  767. settings.error.call(settings.context, type, xhr, settings);
  768. };
  769. _xhrHeaders = function(xhr, settings) {
  770. var header;
  771. if (settings.contentType) {
  772. settings.headers["Content-Type"] = settings.contentType;
  773. }
  774. if (settings.dataType) {
  775. settings.headers["Accept"] = MIME_TYPES[settings.dataType];
  776. }
  777. for (header in settings.headers) {
  778. xhr.setRequestHeader(header, settings.headers[header]);
  779. }
  780. };
  781. _xhrTimeout = function(xhr, settings) {
  782. xhr.onreadystatechange = {};
  783. xhr.abort();
  784. _xhrError("QuoJS.ajax: Timeout exceeded", xhr, settings);
  785. };
  786. _xhrForm = function(method, url, data, success, dataType) {
  787. return $$.ajax({
  788. type: method,
  789. url: url,
  790. data: data,
  791. success: success,
  792. dataType: dataType,
  793. contentType: "application/x-www-form-urlencoded"
  794. });
  795. };
  796. _parseResponse = function(xhr, settings) {
  797. var response;
  798. response = xhr.responseText;
  799. if (response) {
  800. if (settings.dataType === DEFAULT.MIME) {
  801. try {
  802. response = JSON.parse(response);
  803. } catch (error) {
  804. response = error;
  805. _xhrError("QuoJS.ajax: Parse Error", xhr, settings);
  806. }
  807. } else {
  808. if (settings.dataType === "xml") {
  809. response = xhr.responseXML;
  810. }
  811. }
  812. }
  813. return response;
  814. };
  815. _isJsonP = function(url) {
  816. return RegExp("=\\?").test(url);
  817. };
  818. })(Quo);
  819. }).call(this);
  820. // Generated by CoffeeScript 1.4.0
  821. /*
  822. QuoJS 2.2.0
  823. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  824. http://quojs.tapquo.com
  825. */
  826. (function() {
  827. (function($$) {
  828. var READY_EXPRESSION, SHORTCUTS, SHORTCUTS_EVENTS;
  829. READY_EXPRESSION = /complete|loaded|interactive/;
  830. SHORTCUTS = ["touch", "tap"];
  831. SHORTCUTS_EVENTS = {
  832. touch: "touchstart",
  833. tap: "tap"
  834. };
  835. SHORTCUTS.forEach(function(event) {
  836. $$.fn[event] = function(callback) {
  837. return $$(document.body).delegate(this.selector, SHORTCUTS_EVENTS[event], callback);
  838. };
  839. return this;
  840. });
  841. $$.fn.on = function(event, selector, callback) {
  842. if (selector === undefined || $$.toType(selector) === "function") {
  843. return this.bind(event, selector);
  844. } else {
  845. return this.delegate(selector, event, callback);
  846. }
  847. };
  848. $$.fn.off = function(event, selector, callback) {
  849. if (selector === undefined || $$.toType(selector) === "function") {
  850. return this.unbind(event, selector);
  851. } else {
  852. return this.undelegate(selector, event, callback);
  853. }
  854. };
  855. $$.fn.ready = function(callback) {
  856. if (READY_EXPRESSION.test(document.readyState)) {
  857. callback($$);
  858. } else {
  859. $$.fn.addEvent(document, "DOMContentLoaded", function() {
  860. return callback($$);
  861. });
  862. }
  863. return this;
  864. };
  865. })(Quo);
  866. }).call(this);
  867. // Generated by CoffeeScript 1.4.0
  868. /*
  869. QuoJS 2.2.0
  870. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  871. http://quojs.tapquo.com
  872. */
  873. (function() {
  874. (function($$) {
  875. var ELEMENT_ID, EVENTS_DESKTOP, EVENT_METHODS, HANDLERS, _createProxy, _createProxyCallback, _environmentEvent, _findHandlers, _getElementId, _subscribe, _unsubscribe;
  876. ELEMENT_ID = 1;
  877. HANDLERS = {};
  878. EVENT_METHODS = {
  879. preventDefault: "isDefaultPrevented",
  880. stopImmediatePropagation: "isImmediatePropagationStopped",
  881. stopPropagation: "isPropagationStopped"
  882. };
  883. EVENTS_DESKTOP = {
  884. touchstart: "mousedown",
  885. touchmove: "mousemove",
  886. touchend: "mouseup",
  887. tap: "click",
  888. doubletap: "dblclick",
  889. orientationchange: "resize"
  890. };
  891. $$.Event = function(type, touch) {
  892. var event, property;
  893. event = document.createEvent("Events");
  894. event.initEvent(type, true, true, null, null, null, null, null, null, null, null, null, null, null, null);
  895. if (touch) {
  896. for (property in touch) {
  897. event[property] = touch[property];
  898. }
  899. }
  900. return event;
  901. };
  902. $$.fn.bind = function(event, callback) {
  903. return this.each(function() {
  904. _subscribe(this, event, callback);
  905. });
  906. };
  907. $$.fn.unbind = function(event, callback) {
  908. return this.each(function() {
  909. _unsubscribe(this, event, callback);
  910. });
  911. };
  912. $$.fn.delegate = function(selector, event, callback) {
  913. return this.each(function(i, element) {
  914. _subscribe(element, event, callback, selector, function(fn) {
  915. return function(e) {
  916. var evt, match;
  917. match = $$(e.target).closest(selector, element).get(0);
  918. if (match) {
  919. evt = $$.extend(_createProxy(e), {
  920. currentTarget: match,
  921. liveFired: element
  922. });
  923. return fn.apply(match, [evt].concat([].slice.call(arguments, 1)));
  924. }
  925. };
  926. });
  927. });
  928. };
  929. $$.fn.undelegate = function(selector, event, callback) {
  930. return this.each(function() {
  931. _unsubscribe(this, event, callback, selector);
  932. });
  933. };
  934. $$.fn.trigger = function(event, touch) {
  935. if ($$.toType(event) === "string") {
  936. event = $$.Event(event, touch);
  937. }
  938. return this.each(function() {
  939. this.dispatchEvent(event);
  940. });
  941. };
  942. $$.fn.addEvent = function(element, event_name, callback) {
  943. if (element.addEventListener) {
  944. return element.addEventListener(event_name, callback, false);
  945. } else if (element.attachEvent) {
  946. return element.attachEvent("on" + event_name, callback);
  947. } else {
  948. return element["on" + event_name] = callback;
  949. }
  950. };
  951. $$.fn.removeEvent = function(element, event_name, callback) {
  952. if (element.removeEventListener) {
  953. return element.removeEventListener(event_name, callback, false);
  954. } else if (element.detachEvent) {
  955. return element.detachEvent("on" + event_name, callback);
  956. } else {
  957. return element["on" + event_name] = null;
  958. }
  959. };
  960. _subscribe = function(element, event, callback, selector, delegate_callback) {
  961. var delegate, element_handlers, element_id, handler;
  962. event = _environmentEvent(event);
  963. element_id = _getElementId(element);
  964. element_handlers = HANDLERS[element_id] || (HANDLERS[element_id] = []);
  965. delegate = delegate_callback && delegate_callback(callback, event);
  966. handler = {
  967. event: event,
  968. callback: callback,
  969. selector: selector,
  970. proxy: _createProxyCallback(delegate, callback, element),
  971. delegate: delegate,
  972. index: element_handlers.length
  973. };
  974. element_handlers.push(handler);
  975. return $$.fn.addEvent(element, handler.event, handler.proxy);
  976. };
  977. _unsubscribe = function(element, event, callback, selector) {
  978. var element_id;
  979. event = _environmentEvent(event);
  980. element_id = _getElementId(element);
  981. return _findHandlers(element_id, event, callback, selector).forEach(function(handler) {
  982. delete HANDLERS[element_id][handler.index];
  983. return $$.fn.removeEvent(element, handler.event, handler.proxy);
  984. });
  985. };
  986. _getElementId = function(element) {
  987. return element._id || (element._id = ELEMENT_ID++);
  988. };
  989. _environmentEvent = function(event) {
  990. var environment_event;
  991. environment_event = ($$.isMobile() ? event : EVENTS_DESKTOP[event]);
  992. return environment_event || event;
  993. };
  994. _createProxyCallback = function(delegate, callback, element) {
  995. var proxy;
  996. callback = delegate || callback;
  997. proxy = function(event) {
  998. var result;
  999. result = callback.apply(element, [event].concat(event.data));
  1000. if (result === false) {
  1001. event.preventDefault();
  1002. }
  1003. return result;
  1004. };
  1005. return proxy;
  1006. };
  1007. _findHandlers = function(element_id, event, fn, selector) {
  1008. return (HANDLERS[element_id] || []).filter(function(handler) {
  1009. return handler && (!event || handler.event === event) && (!fn || handler.fn === fn) && (!selector || handler.selector === selector);
  1010. });
  1011. };
  1012. _createProxy = function(event) {
  1013. var proxy;
  1014. proxy = $$.extend({
  1015. originalEvent: event
  1016. }, event);
  1017. $$.each(EVENT_METHODS, function(name, method) {
  1018. proxy[name] = function() {
  1019. this[method] = function() {
  1020. return true;
  1021. };
  1022. return event[name].apply(event, arguments);
  1023. };
  1024. return proxy[method] = function() {
  1025. return false;
  1026. };
  1027. });
  1028. return proxy;
  1029. };
  1030. })(Quo);
  1031. }).call(this);
  1032. // Generated by CoffeeScript 1.4.0
  1033. /*
  1034. QuoJS 2.2.0
  1035. (c) 2011, 2012 Javi Jiménez Villar (@soyjavi)
  1036. http://quojs.tapquo.com
  1037. */
  1038. (function() {
  1039. (function($$) {
  1040. var CURRENT_TOUCH, FIRST_TOUCH, GESTURE, GESTURES, HOLD_DELAY, TOUCH_TIMEOUT, _angle, _capturePinch, _captureRotation, _cleanGesture, _distance, _fingersPosition, _getTouches, _hold, _isSwipe, _listenTouches, _onTouchEnd, _onTouchMove, _onTouchStart, _parentIfText, _swipeDirection, _trigger;
  1041. GESTURE = {};
  1042. FIRST_TOUCH = [];
  1043. CURRENT_TOUCH = [];
  1044. TOUCH_TIMEOUT = void 0;
  1045. HOLD_DELAY = 650;
  1046. GESTURES = ["doubleTap", "hold", "swipe", "swiping", "swipeLeft", "swipeRight", "swipeUp", "swipeDown", "rotate", "rotating", "rotateLeft", "rotateRight", "pinch", "pinching", "pinchIn", "pinchOut", "drag", "dragLeft", "dragRight", "dragUp", "dragDown"];
  1047. GESTURES.forEach(function(event) {
  1048. $$.fn[event] = function(callback) {
  1049. return this.on(event, callback);
  1050. };
  1051. });
  1052. $$(document).ready(function() {
  1053. return _listenTouches();
  1054. });
  1055. _listenTouches = function() {
  1056. var environment;
  1057. environment = $$(document.body);
  1058. environment.bind("touchstart", _onTouchStart);
  1059. environment.bind("touchmove", _onTouchMove);
  1060. environment.bind("touchend", _onTouchEnd);
  1061. return environment.bind("touchcancel", _cleanGesture);
  1062. };
  1063. _onTouchStart = function(event) {
  1064. var delta, fingers, now, touches;
  1065. now = Date.now();
  1066. delta = now - (GESTURE.last || now);
  1067. TOUCH_TIMEOUT && clearTimeout(TOUCH_TIMEOUT);
  1068. touches = _getTouches(event);
  1069. fingers = touches.length;
  1070. FIRST_TOUCH = _fingersPosition(touches, fingers);
  1071. GESTURE.el = $$(_parentIfText(touches[0].target));
  1072. GESTURE.fingers = fingers;
  1073. GESTURE.last = now;
  1074. if (fingers === 1) {
  1075. GESTURE.isDoubleTap = delta > 0 && delta <= 250;
  1076. return setTimeout(_hold, HOLD_DELAY);
  1077. } else if (fingers === 2) {
  1078. GESTURE.initial_angle = parseInt(_angle(FIRST_TOUCH), 10);
  1079. GESTURE.initial_distance = parseInt(_distance(FIRST_TOUCH), 10);
  1080. GESTURE.angle_difference = 0;
  1081. return GESTURE.distance_difference = 0;
  1082. }
  1083. };
  1084. _onTouchMove = function(event) {
  1085. var fingers, touches;
  1086. if (GESTURE.el) {
  1087. touches = _getTouches(event);
  1088. fingers = touches.length;
  1089. if (fingers === GESTURE.fingers) {
  1090. CURRENT_TOUCH = _fingersPosition(touches, fingers);
  1091. if (_isSwipe(event)) {
  1092. _trigger("swiping");
  1093. }
  1094. if (fingers === 2) {
  1095. _captureRotation();
  1096. _capturePinch();
  1097. event.preventDefault();
  1098. }
  1099. } else {
  1100. _cleanGesture();
  1101. }
  1102. }
  1103. return true;
  1104. };
  1105. _isSwipe = function(event) {
  1106. var move_horizontal, move_vertical, ret;
  1107. ret = false;
  1108. if (CURRENT_TOUCH[0]) {
  1109. move_horizontal = Math.abs(FIRST_TOUCH[0].x - CURRENT_TOUCH[0].x) > 30;
  1110. move_vertical = Math.abs(FIRST_TOUCH[0].y - CURRENT_TOUCH[0].y) > 30;
  1111. ret = GESTURE.el && (move_horizontal || move_vertical);
  1112. }
  1113. return ret;
  1114. };
  1115. _onTouchEnd = function(event) {
  1116. var anyevent, drag_direction, pinch_direction, rotation_direction, swipe_direction;
  1117. if (GESTURE.isDoubleTap) {
  1118. _trigger("doubleTap");
  1119. return _cleanGesture();
  1120. } else if (GESTURE.fingers === 1) {
  1121. if (_isSwipe()) {
  1122. _trigger("swipe");
  1123. swipe_direction = _swipeDirection(FIRST_TOUCH[0].x, CURRENT_TOUCH[0].x, FIRST_TOUCH[0].y, CURRENT_TOUCH[0].y);
  1124. _trigger("swipe" + swipe_direction);
  1125. return _cleanGesture();
  1126. } else {
  1127. _trigger("tap");
  1128. return TOUCH_TIMEOUT = setTimeout(_cleanGesture, 250);
  1129. }
  1130. } else if (GESTURE.fingers === 2) {
  1131. anyevent = false;
  1132. if (GESTURE.angle_difference !== 0) {
  1133. _trigger("rotate", {
  1134. angle: GESTURE.angle_difference
  1135. });
  1136. rotation_direction = GESTURE.angle_difference > 0 ? "rotateRight" : "rotateLeft";
  1137. _trigger(rotation_direction, {
  1138. angle: GESTURE.angle_difference
  1139. });
  1140. anyevent = true;
  1141. }
  1142. if (GESTURE.distance_difference !== 0) {
  1143. _trigger("pinch", {
  1144. angle: GESTURE.distance_difference
  1145. });
  1146. pinch_direction = GESTURE.distance_difference > 0 ? "pinchOut" : "pinchIn";
  1147. _trigger(pinch_direction, {
  1148. distance: GESTURE.distance_difference
  1149. });
  1150. anyevent = true;
  1151. }
  1152. if (!anyevent && CURRENT_TOUCH[0]) {
  1153. if (Math.abs(FIRST_TOUCH[0].x - CURRENT_TOUCH[0].x) > 10 || Math.abs(FIRST_TOUCH[0].y - CURRENT_TOUCH[0].y) > 10) {
  1154. _trigger("drag");
  1155. drag_direction = _swipeDirection(FIRST_TOUCH[0].x, CURRENT_TOUCH[0].x, FIRST_TOUCH[0].y, CURRENT_TOUCH[0].y);
  1156. _trigger("drag" + drag_direction);
  1157. }
  1158. }
  1159. return _cleanGesture();
  1160. }
  1161. };
  1162. _fingersPosition = function(touches, fingers) {
  1163. var i, result;
  1164. result = [];
  1165. i = 0;
  1166. while (i < fingers) {
  1167. result.push({
  1168. x: touches[i].pageX,
  1169. y: touches[i].pageY
  1170. });
  1171. i++;
  1172. }
  1173. return result;
  1174. };
  1175. _captureRotation = function() {
  1176. var angle, diff, i, symbol;
  1177. angle = parseInt(_angle(CURRENT_TOUCH), 10);
  1178. diff = parseInt(GESTURE.initial_angle - angle, 10);
  1179. if (Math.abs(diff) > 20 || GESTURE.angle_difference !== 0) {
  1180. i = 0;
  1181. symbol = GESTURE.angle_difference < 0 ? "-" : "+";
  1182. while (Math.abs(diff - GESTURE.angle_difference) > 90 && i++ < 10) {
  1183. eval("diff " + symbol + "= 180;");
  1184. }
  1185. GESTURE.angle_difference = parseInt(diff, 10);
  1186. return _trigger("rotating", {
  1187. angle: GESTURE.angle_difference
  1188. });
  1189. }
  1190. };
  1191. _capturePinch = function() {
  1192. var diff, distance;
  1193. distance = parseInt(_distance(CURRENT_TOUCH), 10);
  1194. diff = GESTURE.initial_distance - distance;
  1195. if (Math.abs(diff) > 10) {
  1196. GESTURE.distance_difference = diff;
  1197. return _trigger("pinching", {
  1198. distance: diff
  1199. });
  1200. }
  1201. };
  1202. _trigger = function(type, params) {
  1203. if (GESTURE.el) {
  1204. params = params || {};
  1205. if (CURRENT_TOUCH[0]) {
  1206. params.iniTouch = (GESTURE.fingers > 1 ? FIRST_TOUCH : FIRST_TOUCH[0]);
  1207. params.currentTouch = (GESTURE.fingers > 1 ? CURRENT_TOUCH : CURRENT_TOUCH[0]);
  1208. }
  1209. return GESTURE.el.trigger(type, params);
  1210. }
  1211. };
  1212. _cleanGesture = function(event) {
  1213. FIRST_TOUCH = [];
  1214. CURRENT_TOUCH = [];
  1215. GESTURE = {};
  1216. return clearTimeout(TOUCH_TIMEOUT);
  1217. };
  1218. _angle = function(touches_data) {
  1219. var A, B, angle;
  1220. A = touches_data[0];
  1221. B = touches_data[1];
  1222. angle = Math.atan((B.y - A.y) * -1 / (B.x - A.x)) * (180 / Math.PI);
  1223. if (angle < 0) {
  1224. return angle + 180;
  1225. } else {
  1226. return angle;
  1227. }
  1228. };
  1229. _distance = function(touches_data) {
  1230. var A, B;
  1231. A = touches_data[0];
  1232. B = touches_data[1];
  1233. return Math.sqrt((B.x - A.x) * (B.x - A.x) + (B.y - A.y) * (B.y - A.y)) * -1;
  1234. };
  1235. _getTouches = function(event) {
  1236. if ($$.isMobile()) {
  1237. return event.touches;
  1238. } else {
  1239. return [event];
  1240. }
  1241. };
  1242. _parentIfText = function(node) {
  1243. if ("tagName" in node) {
  1244. return node;
  1245. } else {
  1246. return node.parentNode;
  1247. }
  1248. };
  1249. _swipeDirection = function(x1, x2, y1, y2) {
  1250. var xDelta, yDelta;
  1251. xDelta = Math.abs(x1 - x2);
  1252. yDelta = Math.abs(y1 - y2);
  1253. if (xDelta >= yDelta) {
  1254. if (x1 - x2 > 0) {
  1255. return "Left";
  1256. } else {
  1257. return "Right";
  1258. }
  1259. } else {
  1260. if (y1 - y2 > 0) {
  1261. return "Up";
  1262. } else {
  1263. return "Down";
  1264. }
  1265. }
  1266. };
  1267. _hold = function() {
  1268. if (GESTURE.last && (Date.now() - GESTURE.last >= HOLD_DELAY)) {
  1269. return _trigger("hold");
  1270. }
  1271. };
  1272. })(Quo);
  1273. }).call(this);