PageRenderTime 57ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 1ms

/vendors/quo/quo.debug.js

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