quo.debug.js 36 KB

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