Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Oct 5th, 2012  |  syntax: None  |  size: 57.63 KB  |  hits: 44  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. //     Zepto.js
  2. //     (c) 2010, 2011 Thomas Fuchs
  3. //     Zepto.js may be freely distributed under the MIT license.
  4.  
  5. (function(undefined){
  6.   if (String.prototype.trim === undefined) // fix for iOS 3.2
  7.     String.prototype.trim = function(){ return this.replace(/^\s+/, '').replace(/\s+$/, '') };
  8.  
  9.   // For iOS 3.x
  10.   // from https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/reduce
  11.   if (Array.prototype.reduce === undefined)
  12.     Array.prototype.reduce = function(fun){
  13.       if(this === void 0 || this === null) throw new TypeError();
  14.       var t = Object(this), len = t.length >>> 0, k = 0, accumulator;
  15.       if(typeof fun != 'function') throw new TypeError();
  16.       if(len == 0 && arguments.length == 1) throw new TypeError();
  17.  
  18.       if(arguments.length >= 2)
  19.        accumulator = arguments[1];
  20.       else
  21.         do{
  22.           if(k in t){
  23.             accumulator = t[k++];
  24.             break;
  25.           }
  26.           if(++k >= len) throw new TypeError();
  27.         } while (true);
  28.  
  29.       while (k < len){
  30.         if(k in t) accumulator = fun.call(undefined, accumulator, t[k], k, t);
  31.         k++;
  32.       }
  33.       return accumulator;
  34.     };
  35.  
  36. })();
  37. //     Zepto.js
  38. //     (c) 2010, 2011 Thomas Fuchs
  39. //     Zepto.js may be freely distributed under the MIT license.
  40.  
  41. var Zepto = (function() {
  42.   var undefined, key, $$, classList, emptyArray = [], slice = emptyArray.slice,
  43.     document = window.document,
  44.     elementDisplay = {}, classCache = {},
  45.     getComputedStyle = document.defaultView.getComputedStyle,
  46.     cssNumber = { 'column-count': 1, 'columns': 1, 'font-weight': 1, 'line-height': 1,'opacity': 1, 'z-index': 1, 'zoom': 1 },
  47.     fragmentRE = /^\s*<(\w+)[^>]*>/,
  48.     elementTypes = [1, 9, 11],
  49.     adjacencyOperators = [ 'after', 'prepend', 'before', 'append' ],
  50.     table = document.createElement('table'),
  51.     tableRow = document.createElement('tr'),
  52.     containers = {
  53.       'tr': document.createElement('tbody'),
  54.       'tbody': table, 'thead': table, 'tfoot': table,
  55.       'td': tableRow, 'th': tableRow,
  56.       '*': document.createElement('div')
  57.     },
  58.     readyRE = /complete|loaded|interactive/,
  59.     classSelectorRE = /^\.([\w-]+)$/,
  60.     idSelectorRE = /^#([\w-]+)$/,
  61.     tagSelectorRE = /^[\w-]+$/;
  62.  
  63.   function isF(value) { return ({}).toString.call(value) == "[object Function]" }
  64.   function isO(value) { return value instanceof Object }
  65.   function isA(value) { return value instanceof Array }
  66.   function likeArray(obj) { return typeof obj.length == 'number' }
  67.  
  68.   function compact(array) { return array.filter(function(item){ return item !== undefined && item !== null }) }
  69.   function flatten(array) { return array.length > 0 ? [].concat.apply([], array) : array }
  70.   function camelize(str)  { return str.replace(/-+(.)?/g, function(match, chr){ return chr ? chr.toUpperCase() : '' }) }
  71.   function dasherize(str){
  72.     return str.replace(/::/g, '/')
  73.            .replace(/([A-Z]+)([A-Z][a-z])/g, '$1_$2')
  74.            .replace(/([a-z\d])([A-Z])/g, '$1_$2')
  75.            .replace(/_/g, '-')
  76.            .toLowerCase();
  77.   }
  78.   function uniq(array)    { return array.filter(function(item,index,array){ return array.indexOf(item) == index }) }
  79.  
  80.   function classRE(name){
  81.     return name in classCache ?
  82.       classCache[name] : (classCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)'));
  83.   }
  84.  
  85.   function maybeAddPx(name, value) { return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value; }
  86.  
  87.   function defaultDisplay(nodeName) {
  88.     var element, display;
  89.     if (!elementDisplay[nodeName]) {
  90.       element = document.createElement(nodeName);
  91.       document.body.appendChild(element);
  92.       display = getComputedStyle(element, '').getPropertyValue("display");
  93.       element.parentNode.removeChild(element);
  94.       display == "none" && (display = "block");
  95.       elementDisplay[nodeName] = display;
  96.     }
  97.     return elementDisplay[nodeName];
  98.   }
  99.  
  100.   function fragment(html, name) {
  101.     if (name === undefined) {
  102.       if (!fragmentRE.test(html)) return document.createTextNode(html);
  103.       name = RegExp.$1;
  104.     }
  105.     if (!(name in containers)) name = '*';
  106.     var container = containers[name];
  107.     container.innerHTML = '' + html;
  108.     return slice.call(container.childNodes);
  109.   }
  110.  
  111.   function Z(dom, selector){
  112.     dom = dom || emptyArray;
  113.     dom.__proto__ = Z.prototype;
  114.     dom.selector = selector || '';
  115.     return dom;
  116.   }
  117.  
  118.   function $(selector, context){
  119.     if (!selector) return Z();
  120.     if (context !== undefined) return $(context).find(selector);
  121.     else if (isF(selector)) return $(document).ready(selector);
  122.     else if (selector instanceof Z) return selector;
  123.     else {
  124.       var dom;
  125.       if (isA(selector)) dom = compact(selector);
  126.       else if (elementTypes.indexOf(selector.nodeType) >= 0 || selector === window)
  127.         dom = [selector], selector = null;
  128.       else if (fragmentRE.test(selector))
  129.         dom = fragment(selector.trim(), RegExp.$1), selector = null;
  130.       else if (selector.nodeType && selector.nodeType == 3) dom = [selector];
  131.       else dom = $$(document, selector);
  132.       return Z(dom, selector);
  133.     }
  134.   }
  135.  
  136.    $.extend = function(target){
  137.       var args, deep=true;
  138.       if ( typeof target === 'boolean' ) {
  139.         target = arguments[1];
  140.         args = slice.call(arguments, 2);
  141.       } else {
  142.         deep = false;
  143.         args = slice.call(arguments, 1);
  144.       }
  145.       args.forEach(function(source) {
  146.         for (var key in source) {
  147.  
  148.           if ( $.isObject(source[key]) && deep && !source.nodeName ) {
  149.             target[key] = $.isObject(target[key]) ? target[key] : {};
  150.             $.extend(true, target[key], source[key]);
  151.           } else {
  152.             target[key] = source[key];
  153.           }
  154.         }
  155.       })
  156.       return target;
  157.   }
  158.  
  159.   function attemptQuerySelectorAll(element, selector) {
  160.     try {
  161.       var results = element.querySelectorAll(selector);
  162.       return slice.call(results);
  163.     } catch(e) {
  164.       return [selector];
  165.     }
  166.   }
  167.  
  168.   $.qsa = $$ = function(element, selector){
  169.     var found;
  170.     if (element === document && idSelectorRE.test(selector)) {
  171.       found = element.getElementById(RegExp.$1);
  172.       return found && [found] || [];
  173.     } else if (classSelectorRE.test(selector)) {
  174.       return slice.call(element.getElementsByClassName(RegExp.$1));
  175.     } else if (tagSelectorRE.test(selector)) {
  176.       return slice.call(element.getElementsByTagName(selector));
  177.     } else {
  178.       return attemptQuerySelectorAll(element, selector);
  179.     }
  180.   }
  181.  
  182.   function filtered(nodes, selector){
  183.     return selector === undefined ? $(nodes) : $(nodes).filter(selector);
  184.   }
  185.  
  186.   function funcArg(context, arg, idx, payload){
  187.    return isF(arg) ? arg.call(context, idx, payload) : arg;
  188.   }
  189.  
  190.   $.isFunction = isF;
  191.   $.isObject = isO;
  192.   $.isArray = isA;
  193.  
  194.   $.map = function(elements, callback) {
  195.     var value, values = [], i, key;
  196.     if (likeArray(elements))
  197.       for (i = 0; i < elements.length; i++) {
  198.         value = callback(elements[i], i);
  199.         if (value != null) values.push(value);
  200.       }
  201.     else
  202.       for (key in elements) {
  203.         value = callback(elements[key], key);
  204.         if (value != null) values.push(value);
  205.       }
  206.     return flatten(values);
  207.   }
  208.  
  209.   $.each = function(elements, callback) {
  210.     var i, key;
  211.     if (likeArray(elements))
  212.       for(i = 0; i < elements.length; i++) {
  213.         if(callback.call(elements[i], i, elements[i]) === false) return elements;
  214.       }
  215.     else
  216.       for(key in elements) {
  217.         if(callback.call(elements[key], key, elements[key]) === false) return elements;
  218.       }
  219.     return elements;
  220.   }
  221.  
  222.   $.fn = {
  223.     forEach: emptyArray.forEach,
  224.     reduce: emptyArray.reduce,
  225.     push: emptyArray.push,
  226.     indexOf: emptyArray.indexOf,
  227.     concat: emptyArray.concat,
  228.     map: function(fn){
  229.       return $.map(this, function(el, i){ return fn.call(el, i, el) });
  230.     },
  231.     slice: function(){
  232.       return $(slice.apply(this, arguments));
  233.     },
  234.     ready: function(callback){
  235.       if (readyRE.test(document.readyState)) callback($);
  236.       else document.addEventListener('DOMContentLoaded', function(){ callback($) }, false);
  237.       return this;
  238.     },
  239.     get: function(idx){ return idx === undefined ? this : this[idx] },
  240.     size: function(){ return this.length },
  241.     remove: function () {
  242.       return this.each(function () {
  243.         if (this.parentNode != null) {
  244.           this.parentNode.removeChild(this);
  245.         }
  246.       });
  247.     },
  248.     each: function(callback){
  249.       this.forEach(function(el, idx){ callback.call(el, idx, el) });
  250.       return this;
  251.     },
  252.     filter: function(selector){
  253.       return $([].filter.call(this, function(element){
  254.         if (selector === ':visible') {
  255.           var width = element.offsetWidth;
  256.           var height = element.offsetHeight;
  257.           var isHidden = (width === 0 && height === 0) || $(element).css("display") === "none";
  258.           return !isHidden;
  259.         }
  260.         return element.parentNode && $$(element.parentNode, selector).indexOf(element) >= 0;
  261.       }));
  262.     },
  263.     end: function(){
  264.       return this.prevObject || $();
  265.     },
  266.     andSelf:function(){
  267.       return this.add(this.prevObject || $())
  268.     },
  269.     add:function(selector,context){
  270.       return $(uniq(this.concat($(selector,context))));
  271.     },
  272.     is: function(selector){
  273.       return this.length > 0 && $(this[0]).filter(selector).length > 0;
  274.     },
  275.     not: function(selector){
  276.       var nodes=[];
  277.       if (isF(selector) && selector.call !== undefined)
  278.         this.each(function(idx){
  279.           if (!selector.call(this,idx)) nodes.push(this);
  280.         });
  281.       else {
  282.         var excludes = typeof selector == 'string' ? this.filter(selector) :
  283.           (likeArray(selector) && isF(selector.item)) ? slice.call(selector) : $(selector);
  284.         this.forEach(function(el){
  285.           if (excludes.indexOf(el) < 0) nodes.push(el);
  286.         });
  287.       }
  288.       return $(nodes);
  289.     },
  290.     eq: function(idx){
  291.       return idx === -1 ? this.slice(idx) : this.slice(idx, + idx + 1);
  292.     },
  293.     first: function(){ var el = this[0]; return el && !isO(el) ? el : $(el) },
  294.     last: function(){ var el = this[this.length - 1]; return el && !isO(el) ? el : $(el) },
  295.     find: function(selector){
  296.       var result;
  297.       if (this.length == 1) result = $$(this[0], selector);
  298.       else result = this.map(function(){ return $$(this, selector) });
  299.       return $(result);
  300.     },
  301.     closest: function(selector, context){
  302.       var node = this[0], candidates = $$(context || document, selector);
  303.       if (!candidates.length) node = null;
  304.       while (node && candidates.indexOf(node) < 0)
  305.         node = node !== context && node !== document && node.parentNode;
  306.       return $(node);
  307.     },
  308.     parents: function(selector){
  309.       var ancestors = [], nodes = this;
  310.       while (nodes.length > 0)
  311.         nodes = $.map(nodes, function(node){
  312.           if ((node = node.parentNode) && node !== document && ancestors.indexOf(node) < 0) {
  313.             ancestors.push(node);
  314.             return node;
  315.           }
  316.         });
  317.       return filtered(ancestors, selector);
  318.     },
  319.     parent: function(selector){
  320.       return filtered(uniq(this.pluck('parentNode')), selector);
  321.     },
  322.     children: function(selector){
  323.       return filtered(this.map(function(){ return slice.call(this.children) }), selector);
  324.     },
  325.     siblings: function(selector){
  326.       return filtered(this.map(function(i, el){
  327.         return slice.call(el.parentNode.children).filter(function(child){ return child!==el });
  328.       }), selector);
  329.     },
  330.     empty: function(){ return this.each(function(){ this.innerHTML = '' }) },
  331.     pluck: function(property){ return this.map(function(){ return this[property] }) },
  332.     show: function(){
  333.       return this.each(function() {
  334.         this.style.display == "none" && (this.style.display = null);
  335.         if (getComputedStyle(this, '').getPropertyValue("display") == "none") {
  336.           this.style.display = defaultDisplay(this.nodeName)
  337.         }
  338.       })
  339.     },
  340.     replaceWith: function(newContent) {
  341.       return this.each(function() {
  342.         $(this).before(newContent).remove();
  343.       });
  344.     },
  345.     wrap: function(newContent) {
  346.       return this.each(function() {
  347.         $(this).wrapAll($(newContent)[0].cloneNode(false));
  348.       });
  349.     },
  350.     wrapAll: function(newContent) {
  351.       if (this[0]) {
  352.         $(this[0]).before(newContent = $(newContent));
  353.         newContent.append(this);
  354.       }
  355.       return this;
  356.     },
  357.     unwrap: function(){
  358.       this.parent().each(function(){
  359.         $(this).replaceWith($(this).children());
  360.       });
  361.       return this;
  362.     },
  363.     hide: function(){
  364.       return this.css("display", "none")
  365.     },
  366.     toggle: function(setting){
  367.       return (setting === undefined ? this.css("display") == "none" : setting) ? this.show() : this.hide();
  368.     },
  369.     prev: function(){ return $(this.pluck('previousElementSibling')) },
  370.     next: function(){ return $(this.pluck('nextElementSibling')) },
  371.     html: function(html){
  372.       return html === undefined ?
  373.         (this.length > 0 ? this[0].innerHTML : null) :
  374.         this.each(function (idx) {
  375.           var originHtml = this.innerHTML;
  376.           $(this).empty().append( funcArg(this, html, idx, originHtml) );
  377.         });
  378.     },
  379.     text: function(text){
  380.       return text === undefined ?
  381.         (this.length > 0 ? this[0].textContent : null) :
  382.         this.each(function(){ this.textContent = text });
  383.     },
  384.     attr: function(name, value){
  385.       var res;
  386.       return (typeof name == 'string' && value === undefined) ?
  387.         (this.length == 0 ? undefined :
  388.           (name == 'value' && this[0].nodeName == 'INPUT') ? this.val() :
  389.           (!(res = this[0].getAttribute(name)) && name in this[0]) ? this[0][name] : res
  390.         ) :
  391.         this.each(function(idx){
  392.           if (isO(name)) for (key in name) this.setAttribute(key, name[key])
  393.           else this.setAttribute(name, funcArg(this, value, idx, this.getAttribute(name)));
  394.         });
  395.     },
  396.     removeAttr: function(name) {
  397.       return this.each(function() { this.removeAttribute(name); });
  398.     },
  399.     data: function(name, value){
  400.       return this.attr('data-' + name, value);
  401.     },
  402.     val: function(value){
  403.       return (value === undefined) ?
  404.         (this.length > 0 ? this[0].value : null) :
  405.         this.each(function(idx){
  406.           this.value = funcArg(this, value, idx, this.value);
  407.         });
  408.     },
  409.     offset: function(){
  410.       if(this.length==0) return null;
  411.       var obj = this[0].getBoundingClientRect();
  412.       return {
  413.         left: obj.left + window.pageXOffset,
  414.         top: obj.top + window.pageYOffset,
  415.         width: obj.width,
  416.         height: obj.height
  417.       };
  418.     },
  419.     css: function(property, value){
  420.       if (value === undefined && typeof property == 'string') {
  421.         return(
  422.           this.length == 0
  423.             ? undefined
  424.             : this[0].style[camelize(property)] || getComputedStyle(this[0], '').getPropertyValue(property)
  425.         );
  426.       }
  427.       var css = '';
  428.       for (key in property) css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';';
  429.       if (typeof property == 'string') css = dasherize(property) + ":" + maybeAddPx(property, value);
  430.       return this.each(function() { this.style.cssText += ';' + css });
  431.     },
  432.     index: function(element){
  433.       return element ? this.indexOf($(element)[0]) : this.parent().children().indexOf(this[0]);
  434.     },
  435.     hasClass: function(name){
  436.       if (this.length < 1) return false;
  437.       else return classRE(name).test(this[0].className);
  438.     },
  439.     addClass: function(name){
  440.       return this.each(function(idx) {
  441.         classList = [];
  442.         var cls = this.className, newName = funcArg(this, name, idx, cls);
  443.         newName.split(/\s+/g).forEach(function(klass) {
  444.           if (!$(this).hasClass(klass)) {
  445.             classList.push(klass)
  446.           }
  447.         }, this);
  448.         classList.length && (this.className += (cls ? " " : "") + classList.join(" "))
  449.       });
  450.     },
  451.     removeClass: function(name){
  452.       return this.each(function(idx) {
  453.         if(name === undefined)
  454.           return this.className = '';
  455.         classList = this.className;
  456.         funcArg(this, name, idx, classList).split(/\s+/g).forEach(function(klass) {
  457.           classList = classList.replace(classRE(klass), " ")
  458.         });
  459.         this.className = classList.trim()
  460.       });
  461.     },
  462.     toggleClass: function(name, when){
  463.       return this.each(function(idx){
  464.         var newName = funcArg(this, name, idx, this.className);
  465.         (when === undefined ? !$(this).hasClass(newName) : when) ?
  466.           $(this).addClass(newName) : $(this).removeClass(newName);
  467.       });
  468.     }
  469.   };
  470.  
  471.   'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){
  472.     var fn = $.fn[property];
  473.     $.fn[property] = function() {
  474.       var ret = fn.apply(this, arguments);
  475.       ret.prevObject = this;
  476.       return ret;
  477.     }
  478.   });
  479.  
  480.   ['width', 'height'].forEach(function(dimension){
  481.     $.fn[dimension] = function(value) {
  482.       var offset, Dimension = dimension.replace(/./, function(m) { return m[0].toUpperCase() });
  483.       if (value === undefined) return this[0] == window ? window['inner' + Dimension] :
  484.         this[0] == document ? document.documentElement['offset' + Dimension] :
  485.         (offset = this.offset()) && offset[dimension];
  486.       else return this.each(function(idx){
  487.         var el = $(this);
  488.         el.css(dimension, funcArg(this, value, idx, el[dimension]()));
  489.       });
  490.     }
  491.   });
  492.  
  493.   function insert(operator, target, node) {
  494.     var parent = (operator % 2) ? target : target.parentNode;
  495.     parent && parent.insertBefore(node,
  496.       !operator ? target.nextSibling :      // after
  497.       operator == 1 ? parent.firstChild :   // prepend
  498.       operator == 2 ? target :              // before
  499.       null);                                // append
  500.   }
  501.  
  502.   function traverseNode (node, fun) {
  503.     fun(node);
  504.     for (var key in node.childNodes) {
  505.       traverseNode(node.childNodes[key], fun);
  506.     }
  507.   }
  508.  
  509.   adjacencyOperators.forEach(function(key, operator) {
  510.     $.fn[key] = function(){
  511.       var nodes = $.map(arguments, function(html) {
  512.         return isO(html) ? html : fragment(html);
  513.       });
  514.       if (nodes.length < 1) return this;
  515.       var size = this.length, copyByClone = size > 1, inReverse = operator < 2;
  516.  
  517.       return this.each(function(index, target){
  518.         for (var i = 0; i < nodes.length; i++) {
  519.           var node = nodes[inReverse ? nodes.length-i-1 : i];
  520.           traverseNode(node, function (node) {
  521.             if (node.nodeName != null && node.nodeName.toUpperCase() === 'SCRIPT' && (!node.type || node.type === 'text/javascript')) {
  522.               window['eval'].call(window, node.innerHTML);
  523.             }
  524.           });
  525.           if (copyByClone && index < size - 1) node = node.cloneNode(true);
  526.           insert(operator, target, node);
  527.         }
  528.       });
  529.     };
  530.  
  531.     var reverseKey = (operator % 2) ? key+'To' : 'insert'+(operator ? 'Before' : 'After');
  532.     $.fn[reverseKey] = function(html) {
  533.       $(html)[key](this);
  534.       return this;
  535.     };
  536.   });
  537.  
  538.   Z.prototype = $.fn;
  539.  
  540.   return $;
  541. })();
  542.  
  543. window.Zepto = Zepto;
  544. '$' in window || (window.$ = Zepto);
  545. //     Zepto.js
  546. //     (c) 2010, 2011 Thomas Fuchs
  547. //     Zepto.js may be freely distributed under the MIT license.
  548.  
  549. (function($){
  550.   var $$ = $.qsa, handlers = {}, _zid = 1, specialEvents={};
  551.  
  552.   specialEvents.click = specialEvents.mousedown = specialEvents.mouseup = specialEvents.mousemove = 'MouseEvents';
  553.  
  554.   function zid(element) {
  555.     return element._zid || (element._zid = _zid++);
  556.   }
  557.   function findHandlers(element, event, fn, selector) {
  558.     event = parse(event);
  559.     if (event.ns) var matcher = matcherFor(event.ns);
  560.     return (handlers[zid(element)] || []).filter(function(handler) {
  561.       return handler
  562.         && (!event.e  || handler.e == event.e)
  563.         && (!event.ns || matcher.test(handler.ns))
  564.         && (!fn       || handler.fn == fn)
  565.         && (!selector || handler.sel == selector);
  566.     });
  567.   }
  568.   function parse(event) {
  569.     var parts = ('' + event).split('.');
  570.     return {e: parts[0], ns: parts.slice(1).sort().join(' ')};
  571.   }
  572.   function matcherFor(ns) {
  573.     return new RegExp('(?:^| )' + ns.replace(' ', ' .* ?') + '(?: |$)');
  574.   }
  575.  
  576.   function eachEvent(events, fn, iterator){
  577.     if ($.isObject(events)) $.each(events, iterator);
  578.     else events.split(/\s/).forEach(function(type){ iterator(type, fn) });
  579.   }
  580.  
  581.   function add(element, events, fn, selector, getDelegate){
  582.     var id = zid(element), set = (handlers[id] || (handlers[id] = []));
  583.     eachEvent(events, fn, function(event, fn){
  584.       var delegate = getDelegate && getDelegate(fn, event),
  585.         callback = delegate || fn;
  586.       var proxyfn = function (event) {
  587.         if (callback) {
  588.           var result = callback.apply(element, [event].concat(event.data));
  589.           if (result === false) event.preventDefault();
  590.           return result;
  591.         }
  592.       };
  593.       var handler = $.extend(parse(event), {fn: fn, proxy: proxyfn, sel: selector, del: delegate, i: set.length});
  594.       set.push(handler);
  595.       if (element.addEventListener) {
  596.          element.addEventListener(handler.e, proxyfn, false);
  597.       }
  598.     });
  599.   }
  600.   function remove(element, events, fn, selector){
  601.     var id = zid(element);
  602.     eachEvent(events || '', fn, function(event, fn){
  603.       findHandlers(element, event, fn, selector).forEach(function(handler){
  604.         delete handlers[id][handler.i];
  605.         element.removeEventListener(handler.e, handler.proxy, false);
  606.       });
  607.     });
  608.   }
  609.  
  610.   $.event = { add: add, remove: remove }
  611.  
  612.   $.fn.bind = function(event, callback){
  613.     return this.each(function(){
  614.       add(this, event, callback);
  615.     });
  616.   };
  617.   $.fn.unbind = function(event, callback){
  618.     return this.each(function(){
  619.       remove(this, event, callback);
  620.     });
  621.   };
  622.   $.fn.one = function(event, callback){
  623.     return this.each(function(i, element){
  624.       add(this, event, callback, null, function(fn, type){
  625.         return function(){
  626.           var result = fn.apply(element, arguments);
  627.           remove(element, type, fn);
  628.           return result;
  629.         }
  630.       });
  631.     });
  632.   };
  633.  
  634.   var returnTrue = function(){return true},
  635.       returnFalse = function(){return false},
  636.       eventMethods = {
  637.         preventDefault: 'isDefaultPrevented',
  638.         stopImmediatePropagation: 'isImmediatePropagationStopped',
  639.         stopPropagation: 'isPropagationStopped'
  640.       };
  641.   function createProxy(event) {
  642.     var proxy = $.extend({originalEvent: event}, event);
  643.     $.each(eventMethods, function(name, predicate) {
  644.       proxy[name] = function(){
  645.         this[predicate] = returnTrue;
  646.         return event[name].apply(event, arguments);
  647.       };
  648.       proxy[predicate] = returnFalse;
  649.     })
  650.     return proxy;
  651.   }
  652.  
  653.   // emulates the 'defaultPrevented' property for browsers that have none
  654.   function fix(event) {
  655.     if (!('defaultPrevented' in event)) {
  656.       event.defaultPrevented = false;
  657.       var prevent = event.preventDefault;
  658.       event.preventDefault = function() {
  659.         this.defaultPrevented = true;
  660.         prevent.call(this);
  661.       }
  662.     }
  663.   }
  664.  
  665.   $.fn.delegate = function(selector, event, callback){
  666.     return this.each(function(i, element){
  667.       add(element, event, callback, selector, function(fn){
  668.         return function(e){
  669.           var evt, match = $(e.target).closest(selector, element).get(0);
  670.           if (match) {
  671.             evt = $.extend(createProxy(e), {currentTarget: match, liveFired: element});
  672.             return fn.apply(match, [evt].concat([].slice.call(arguments, 1)));
  673.           }
  674.         }
  675.       });
  676.     });
  677.   };
  678.   $.fn.undelegate = function(selector, event, callback){
  679.     return this.each(function(){
  680.       remove(this, event, callback, selector);
  681.     });
  682.   }
  683.  
  684.   $.fn.live = function(event, callback){
  685.     $(document.body).delegate(this.selector, event, callback);
  686.     return this;
  687.   };
  688.   $.fn.die = function(event, callback){
  689.     $(document.body).undelegate(this.selector, event, callback);
  690.     return this;
  691.   };
  692.  
  693.   $.fn.on = function(event, selector, callback){
  694.     return selector === undefined || $.isFunction(selector) ?
  695.       this.bind(event, selector) : this.delegate(selector, event, callback);
  696.   };
  697.   $.fn.off = function(event, selector, callback){
  698.     return selector === undefined || $.isFunction(selector) ?
  699.       this.unbind(event, selector) : this.undelegate(selector, event, callback);
  700.   };
  701.  
  702.   $.fn.trigger = function(event, data){
  703.     if (typeof event == 'string') event = $.Event(event);
  704.     fix(event);
  705.     event.data = data;
  706.     return this.each(function(){
  707.       if (this.dispatchEvent) {
  708.         try {
  709.           this.dispatchEvent(event);
  710.         } catch(e) {}
  711.       }
  712.     });
  713.   };
  714.  
  715.   // triggers event handlers on current element just as if an event occurred,
  716.   // doesn't trigger an actual event, doesn't bubble
  717.   $.fn.triggerHandler = function(event, data){
  718.     var e, result;
  719.     this.each(function(i, element){
  720.       e = createProxy(typeof event == 'string' ? $.Event(event) : event);
  721.       e.data = data; e.target = element;
  722.       $.each(findHandlers(element, event.type || event), function(i, handler){
  723.         result = handler.proxy(e);
  724.         if (e.isImmediatePropagationStopped()) return false;
  725.       });
  726.     });
  727.     return result;
  728.   };
  729.  
  730.   // shortcut methods for `.bind(event, fn)` for each event type
  731.   ('focusin focusout load resize scroll unload click dblclick '+
  732.   'mousedown mouseup mousemove mouseover mouseout '+
  733.   'change select keydown keypress keyup error').split(' ').forEach(function(event) {
  734.     $.fn[event] = function(callback){ return this.bind(event, callback) };
  735.   });
  736.  
  737.   ['focus', 'blur'].forEach(function(name) {
  738.     $.fn[name] = function(callback) {
  739.       if (callback) this.bind(name, callback);
  740.       else if (this.length) try { this.get(0)[name]() } catch(e){};
  741.       return this;
  742.     };
  743.   });
  744.  
  745.   $.Event = function(type, props) {
  746.     var event = document.createEvent(specialEvents[type] || 'Events'), bubbles = true;
  747.     if (props) for (var name in props) (name == 'bubbles') ? (bubbles = !!props[name]) : (event[name] = props[name]);
  748.     event.initEvent(type, bubbles, true, null, null, null, null, null, null, null, null, null, null, null, null);
  749.     return event;
  750.   };
  751.  
  752. })(Zepto);
  753. //     Zepto.js
  754. //     (c) 2010, 2011 Thomas Fuchs
  755. //     Zepto.js may be freely distributed under the MIT license.
  756.  
  757. (function($){
  758.   function detect(ua){
  759.     var os = (this.os = {}), browser = (this.browser = {}),
  760.       webkit = ua.match(/WebKit\/([\d.]+)/),
  761.       android = ua.match(/(Android)\s+([\d.]+)/),
  762.       ipad = ua.match(/(iPad).*OS\s([\d_]+)/),
  763.       iphone = !ipad && ua.match(/(iPhone\sOS)\s([\d_]+)/),
  764.       webos = ua.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),
  765.       touchpad = webos && ua.match(/TouchPad/),
  766.       blackberry = ua.match(/(BlackBerry).*Version\/([\d.]+)/);
  767.  
  768.     if (webkit) browser.version = webkit[1];
  769.     browser.webkit = !!webkit;
  770.  
  771.     if (android) os.android = true, os.version = android[2];
  772.     if (iphone) os.ios = true, os.version = iphone[2].replace(/_/g, '.'), os.iphone = true;
  773.     if (ipad) os.ios = true, os.version = ipad[2].replace(/_/g, '.'), os.ipad = true;
  774.     if (webos) os.webos = true, os.version = webos[2];
  775.     if (touchpad) os.touchpad = true;
  776.     if (blackberry) os.blackberry = true, os.version = blackberry[2];
  777.   }
  778.  
  779.   // ### $.os
  780.   //
  781.   // Object containing information about browser platform
  782.   //
  783.   // *Example:*
  784.   //
  785.   //     $.os.ios      // => true if running on Apple iOS
  786.   //     $.os.android  // => true if running on Android
  787.   //     $.os.webos    // => true if running on HP/Palm WebOS
  788.   //     $.os.touchpad // => true if running on a HP TouchPad
  789.   //     $.os.version  // => string with a version number, e.g.
  790.   //                         "4.0", "3.1.1", "2.1", etc.
  791.   //     $.os.iphone   // => true if running on iPhone
  792.   //     $.os.ipad     // => true if running on iPad
  793.   //     $.os.blackberry // => true if running on BlackBerry
  794.   //
  795.   // ### $.browser
  796.   //
  797.   // *Example:*
  798.   //
  799.   //     $.browser.webkit  // => true if the browser is WebKit-based
  800.   //     $.browser.version // => WebKit version string
  801.   detect.call($, navigator.userAgent);
  802.  
  803.   // make available to unit tests
  804.   $.__detect = detect;
  805.  
  806. })(Zepto);
  807. //     Zepto.js
  808. //     (c) 2010, 2011 Thomas Fuchs
  809. //     Zepto.js may be freely distributed under the MIT license.
  810.  
  811. (function($, undefined){
  812.   var prefix = '', eventPrefix, endEventName, endAnimationName,
  813.     vendors = {Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS'},
  814.     document = window.document, testEl = document.createElement('div'),
  815.     supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;
  816.  
  817.   function downcase(str) { return str.toLowerCase() }
  818.   function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) };
  819.  
  820.   $.each(vendors, function(vendor, event){
  821.     if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
  822.       prefix = '-' + downcase(vendor) + '-';
  823.       eventPrefix = event;
  824.       return false;
  825.     }
  826.   });
  827.  
  828.   $.fx = {
  829.     off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
  830.     cssPrefix: prefix,
  831.     transitionEnd: normalizeEvent('TransitionEnd'),
  832.     animationEnd: normalizeEvent('AnimationEnd')
  833.   };
  834.  
  835.   $.fn.animate = function(properties, duration, ease, callback){
  836.     if ($.isObject(duration))
  837.       ease = duration.easing, callback = duration.complete, duration = duration.duration;
  838.     if (duration) duration = duration / 1000;
  839.     return this.anim(properties, duration, ease, callback);
  840.   };
  841.  
  842.   $.fn.anim = function(properties, duration, ease, callback){
  843.     var transforms, cssProperties = {}, key, that = this, wrappedCallback, endEvent = $.fx.transitionEnd;
  844.     if (duration === undefined) duration = 0.4;
  845.     if ($.fx.off) duration = 0;
  846.  
  847.     if (typeof properties == 'string') {
  848.       // keyframe animation
  849.       cssProperties[prefix + 'animation-name'] = properties;
  850.       cssProperties[prefix + 'animation-duration'] = duration + 's';
  851.       endEvent = $.fx.animationEnd;
  852.     } else {
  853.       // CSS transitions
  854.       for (key in properties)
  855.         if (supportedTransforms.test(key)) {
  856.           transforms || (transforms = []);
  857.           transforms.push(key + '(' + properties[key] + ')');
  858.         }
  859.         else cssProperties[key] = properties[key];
  860.  
  861.       if (transforms) cssProperties[prefix + 'transform'] = transforms.join(' ');
  862.       if (!$.fx.off) cssProperties[prefix + 'transition'] = 'all ' + duration + 's ' + (ease || '');
  863.     }
  864.  
  865.     wrappedCallback = function(){
  866.       var props = {};
  867.       props[prefix + 'transition'] = props[prefix + 'animation-name'] = 'none';
  868.       $(this).css(props);
  869.       callback && callback.call(this);
  870.     }
  871.     if (duration > 0) this.one(endEvent, wrappedCallback);
  872.  
  873.     setTimeout(function() {
  874.       that.css(cssProperties);
  875.       if (duration <= 0) setTimeout(function() {
  876.         that.each(function(){ wrappedCallback.call(this) });
  877.       }, 0);
  878.     }, 0);
  879.  
  880.     return this;
  881.   };
  882.  
  883.   testEl = null;
  884. })(Zepto);
  885. //     Zepto.js
  886. //     (c) 2010, 2011 Thomas Fuchs
  887. //     Zepto.js may be freely distributed under the MIT license.
  888.  
  889. (function($){
  890.   var jsonpID = 0,
  891.       isObject = $.isObject,
  892.       document = window.document,
  893.       key,
  894.       name;
  895.  
  896.   // trigger a custom event and return false if it was cancelled
  897.   function triggerAndReturn(context, eventName, data) {
  898.     var event = $.Event(eventName);
  899.     $(context).trigger(event, data);
  900.     return !event.defaultPrevented;
  901.   }
  902.  
  903.   // trigger an Ajax "global" event
  904.   function triggerGlobal(settings, context, eventName, data) {
  905.     if (settings.global) return triggerAndReturn(context || document, eventName, data);
  906.   }
  907.  
  908.   // Number of active Ajax requests
  909.   $.active = 0;
  910.  
  911.   function ajaxStart(settings) {
  912.     if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart');
  913.   }
  914.   function ajaxStop(settings) {
  915.     if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop');
  916.   }
  917.  
  918.   // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable
  919.   function ajaxBeforeSend(xhr, settings) {
  920.     var context = settings.context;
  921.     if (settings.beforeSend.call(context, xhr, settings) === false ||
  922.         triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false)
  923.       return false;
  924.  
  925.     triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]);
  926.   }
  927.   function ajaxSuccess(data, xhr, settings) {
  928.     var context = settings.context, status = 'success';
  929.     settings.success.call(context, data, status, xhr);
  930.     triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]);
  931.     ajaxComplete(status, xhr, settings);
  932.   }
  933.   // type: "timeout", "error", "abort", "parsererror"
  934.   function ajaxError(error, type, xhr, settings) {
  935.     var context = settings.context;
  936.     settings.error.call(context, xhr, type, error);
  937.     triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error]);
  938.     ajaxComplete(type, xhr, settings);
  939.   }
  940.   // status: "success", "notmodified", "error", "timeout", "abort", "parsererror"
  941.   function ajaxComplete(status, xhr, settings) {
  942.     var context = settings.context;
  943.     settings.complete.call(context, xhr, status);
  944.     triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]);
  945.     ajaxStop(settings);
  946.   }
  947.  
  948.   // Empty function, used as default callback
  949.   function empty() {}
  950.  
  951.   // ### $.ajaxJSONP
  952.   //
  953.   // Load JSON from a server in a different domain (JSONP)
  954.   //
  955.   // *Arguments:*
  956.   //
  957.   //     options — object that configure the request,
  958.   //               see avaliable options below
  959.   //
  960.   // *Avaliable options:*
  961.   //
  962.   //     url     — url to which the request is sent
  963.   //     success — callback that is executed if the request succeeds
  964.   //     error   — callback that is executed if the server drops error
  965.   //     context — in which context to execute the callbacks in
  966.   //
  967.   // *Example:*
  968.   //
  969.   //     $.ajaxJSONP({
  970.   //        url:     'http://example.com/projects?callback=?',
  971.   //        success: function (data) {
  972.   //            projects.push(json);
  973.   //        }
  974.   //     });
  975.   //
  976.   $.ajaxJSONP = function(options){
  977.     var callbackName = 'jsonp' + (++jsonpID),
  978.       script = document.createElement('script'),
  979.       abort = function(){
  980.         $(script).remove();
  981.         if (callbackName in window) window[callbackName] = empty;
  982.         ajaxComplete(xhr, options, 'abort');
  983.       },
  984.       xhr = { abort: abort }, abortTimeout;
  985.  
  986.     window[callbackName] = function(data){
  987.       clearTimeout(abortTimeout);
  988.       $(script).remove();
  989.       delete window[callbackName];
  990.       ajaxSuccess(data, xhr, options);
  991.     };
  992.  
  993.     script.src = options.url.replace(/=\?/, '=' + callbackName);
  994.     $('head').append(script);
  995.  
  996.     if (options.timeout > 0) abortTimeout = setTimeout(function(){
  997.         xhr.abort();
  998.         ajaxComplete(xhr, options, 'timeout');
  999.       }, options.timeout);
  1000.  
  1001.     return xhr;
  1002.   };
  1003.  
  1004.   // ### $.ajaxSettings
  1005.   //
  1006.   // AJAX settings
  1007.   //
  1008.   $.ajaxSettings = {
  1009.     // Default type of request
  1010.     type: 'GET',
  1011.     // Callback that is executed before request
  1012.     beforeSend: empty,
  1013.     // Callback that is executed if the request succeeds
  1014.     success: empty,
  1015.     // Callback that is executed the the server drops error
  1016.     error: empty,
  1017.     // Callback that is executed on request complete (both: error and success)
  1018.     complete: empty,
  1019.     // The context for the callbacks
  1020.     context: null,
  1021.     // Whether to trigger "global" Ajax events
  1022.     global: true,
  1023.     // Transport
  1024.     xhr: function () {
  1025.       return new window.XMLHttpRequest();
  1026.     },
  1027.     // MIME types mapping
  1028.     accepts: {
  1029.       script: 'text/javascript, application/javascript',
  1030.       json:   'application/json',
  1031.       xml:    'application/xml, text/xml',
  1032.       html:   'text/html',
  1033.       text:   'text/plain'
  1034.     },
  1035.     // Custom fields
  1036.     xhrFields: {},
  1037.     // Whether the request is to another domain
  1038.     crossDomain: false,
  1039.     // Default timeout
  1040.     timeout: 0
  1041.   };
  1042.  
  1043.   // ### $.ajax
  1044.   //
  1045.   // Perform AJAX request
  1046.   //
  1047.   // *Arguments:*
  1048.   //
  1049.   //     options — object that configure the request,
  1050.   //               see avaliable options below
  1051.   //
  1052.   // *Avaliable options:*
  1053.   //
  1054.   //     type ('GET')          — type of request GET / POST
  1055.   //     url (window.location) — url to which the request is sent
  1056.   //     data                  — data to send to server,
  1057.   //                             can be string or object
  1058.   //     dataType ('json')     — what response type you accept from
  1059.   //                             the server:
  1060.   //                             'json', 'xml', 'html', or 'text'
  1061.   //     timeout (0)           — request timeout
  1062.   //     beforeSend            — callback that is executed before
  1063.   //                             request send
  1064.   //     complete              — callback that is executed on request
  1065.   //                             complete (both: error and success)
  1066.   //     success               — callback that is executed if
  1067.   //                             the request succeeds
  1068.   //     error                 — callback that is executed if
  1069.   //                             the server drops error
  1070.   //     context               — in which context to execute the
  1071.   //                             callbacks in
  1072.   //
  1073.   // *Example:*
  1074.   //
  1075.   //     $.ajax({
  1076.   //        type:       'POST',
  1077.   //        url:        '/projects',
  1078.   //        data:       { name: 'Zepto.js' },
  1079.   //        dataType:   'html',
  1080.   //        timeout:    100,
  1081.   //        context:    $('body'),
  1082.   //        success:    function (data) {
  1083.   //            this.append(data);
  1084.   //        },
  1085.   //        error:    function (xhr, type) {
  1086.   //            alert('Error!');
  1087.   //        }
  1088.   //     });
  1089.   //
  1090.   $.ajax = function(options){
  1091.     var settings = $.extend({}, options || {});
  1092.     for (key in $.ajaxSettings) if (settings[key] === undefined) settings[key] = $.ajaxSettings[key];
  1093.  
  1094.     ajaxStart(settings);
  1095.  
  1096.     if (!settings.crossDomain) settings.crossDomain = /^([\w-]+:)?\/\/([^\/]+)/.test(settings.url) &&
  1097.       RegExp.$2 != window.location.host;
  1098.  
  1099.     if (/=\?/.test(settings.url)) return $.ajaxJSONP(settings);
  1100.  
  1101.     if (!settings.url) settings.url = window.location.toString();
  1102.     if (settings.data && !settings.contentType) settings.contentType = 'application/x-www-form-urlencoded';
  1103.     if (isObject(settings.data)) settings.data = $.param(settings.data);
  1104.  
  1105.     if (settings.type.match(/get/i) && settings.data) {
  1106.       var queryString = settings.data;
  1107.       if (settings.url.match(/\?.*=/)) {
  1108.         queryString = '&' + queryString;
  1109.       } else if (queryString[0] != '?') {
  1110.         queryString = '?' + queryString;
  1111.       }
  1112.       settings.url += queryString;
  1113.     }
  1114.  
  1115.     var mime = settings.accepts[settings.dataType],
  1116.         baseHeaders = { },
  1117.         protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol,
  1118.         xhr = $.ajaxSettings.xhr(), abortTimeout;
  1119.  
  1120.     if (!settings.crossDomain) baseHeaders['X-Requested-With'] = 'XMLHttpRequest';
  1121.     if (mime) baseHeaders['Accept'] = mime;
  1122.     settings.headers = $.extend(baseHeaders, settings.headers || {});
  1123.  
  1124.     xhr.onreadystatechange = function(){
  1125.       if (xhr.readyState == 4) {
  1126.         clearTimeout(abortTimeout);
  1127.         var result, error = false;
  1128.         if ((xhr.status >= 200 && xhr.status < 300) || (xhr.status == 0 && protocol == 'file:')) {
  1129.           if (mime == 'application/json' && !(/^\s*$/.test(xhr.responseText))) {
  1130.             try { result = JSON.parse(xhr.responseText); }
  1131.             catch (e) { error = e; }
  1132.           }
  1133.           else result = xhr.responseText;
  1134.           if (error) ajaxError(error, 'parsererror', xhr, settings);
  1135.           else ajaxSuccess(result, xhr, settings);
  1136.         } else {
  1137.           ajaxError(null, 'error', xhr, settings);
  1138.         }
  1139.       }
  1140.     };
  1141.  
  1142.     xhr.open(settings.type, settings.url, true);
  1143.     //if (settings.withCredentials) xhr.withCredentials = true;
  1144.     if (settings.xhrFields) {
  1145.       for (var field in settings.xhrFields) {
  1146.         xhr[field] = settings.xhrFields[field];
  1147.       }
  1148.     }
  1149.  
  1150.     if (settings.contentType) settings.headers['Content-Type'] = settings.contentType;
  1151.     for (name in settings.headers) xhr.setRequestHeader(name, settings.headers[name]);
  1152.  
  1153.     if (ajaxBeforeSend(xhr, settings) === false) {
  1154.       xhr.abort();
  1155.       return false;
  1156.     }
  1157.  
  1158.     if (settings.timeout > 0) abortTimeout = setTimeout(function(){
  1159.         xhr.onreadystatechange = empty;
  1160.         xhr.abort();
  1161.         ajaxError(null, 'timeout', xhr, settings);
  1162.       }, settings.timeout);
  1163.     if (settings.data === '') settings.data = null;
  1164.     xhr.send(settings.data);
  1165.     return xhr;
  1166.   };
  1167.  
  1168.   // ### $.get
  1169.   //
  1170.   // Load data from the server using a GET request
  1171.   //
  1172.   // *Arguments:*
  1173.   //
  1174.   //     url     — url to which the request is sent
  1175.   //     success — callback that is executed if the request succeeds
  1176.   //
  1177.   // *Example:*
  1178.   //
  1179.   //     $.get(
  1180.   //        '/projects/42',
  1181.   //        function (data) {
  1182.   //            $('body').append(data);
  1183.   //        }
  1184.   //     );
  1185.   //
  1186.   $.get = function(url, success){ return $.ajax({ url: url, success: success }) };
  1187.  
  1188.   // ### $.post
  1189.   //
  1190.   // Load data from the server using POST request
  1191.   //
  1192.   // *Arguments:*
  1193.   //
  1194.   //     url        — url to which the request is sent
  1195.   //     [data]     — data to send to server, can be string or object
  1196.   //     [success]  — callback that is executed if the request succeeds
  1197.   //     [dataType] — type of expected response
  1198.   //                  'json', 'xml', 'html', or 'text'
  1199.   //
  1200.   // *Example:*
  1201.   //
  1202.   //     $.post(
  1203.   //        '/projects',
  1204.   //        { name: 'Zepto.js' },
  1205.   //        function (data) {
  1206.   //            $('body').append(data);
  1207.   //        },
  1208.   //        'html'
  1209.   //     );
  1210.   //
  1211.   $.post = function(url, data, success, dataType){
  1212.     if ($.isFunction(data)) dataType = dataType || success, success = data, data = null;
  1213.     return $.ajax({ type: 'POST', url: url, data: data, success: success, dataType: dataType });
  1214.   };
  1215.  
  1216.   // ### $.getJSON
  1217.   //
  1218.   // Load JSON from the server using GET request
  1219.   //
  1220.   // *Arguments:*
  1221.   //
  1222.   //     url     — url to which the request is sent
  1223.   //     success — callback that is executed if the request succeeds
  1224.   //
  1225.   // *Example:*
  1226.   //
  1227.   //     $.getJSON(
  1228.   //        '/projects/42',
  1229.   //        function (json) {
  1230.   //            projects.push(json);
  1231.   //        }
  1232.   //     );
  1233.   //
  1234.   $.getJSON = function(url, success){
  1235.     return $.ajax({ url: url, success: success, dataType: 'json' });
  1236.   };
  1237.  
  1238.   // ### $.fn.load
  1239.   //
  1240.   // Load data from the server into an element
  1241.   //
  1242.   // *Arguments:*
  1243.   //
  1244.   //     url     — url to which the request is sent
  1245.   //     [success] — callback that is executed if the request succeeds
  1246.   //
  1247.   // *Examples:*
  1248.   //
  1249.   //     $('#project_container').get(
  1250.   //        '/projects/42',
  1251.   //        function () {
  1252.   //            alert('Project was successfully loaded');
  1253.   //        }
  1254.   //     );
  1255.   //
  1256.   //     $('#project_comments').get(
  1257.   //        '/projects/42 #comments',
  1258.   //        function () {
  1259.   //            alert('Comments was successfully loaded');
  1260.   //        }
  1261.   //     );
  1262.   //
  1263.   $.fn.load = function(url, success){
  1264.     if (!this.length) return this;
  1265.     var self = this, parts = url.split(/\s/), selector;
  1266.     if (parts.length > 1) url = parts[0], selector = parts[1];
  1267.     $.get(url, function(response){
  1268.       self.html(selector ?
  1269.         $(document.createElement('div')).html(response).find(selector).html()
  1270.         : response);
  1271.       success && success.call(self);
  1272.     });
  1273.     return this;
  1274.   };
  1275.  
  1276.   var escape = encodeURIComponent;
  1277.  
  1278.   function serialize(params, obj, traditional, scope){
  1279.     var array = $.isArray(obj);
  1280.     $.each(obj, function(key, value) {
  1281.       if (scope) key = traditional ? scope : scope + '[' + (array ? '' : key) + ']';
  1282.       // handle data in serializeArray() format
  1283.       if (!scope && array) params.add(value.name, value.value);
  1284.       // recurse into nested objects
  1285.       else if (traditional ? $.isArray(value) : isObject(value))
  1286.         serialize(params, value, traditional, key);
  1287.       else params.add(key, value);
  1288.     });
  1289.   }
  1290.  
  1291.   // ### $.param
  1292.   //
  1293.   // Encode object as a string of URL-encoded key-value pairs
  1294.   //
  1295.   // *Arguments:*
  1296.   //
  1297.   //     obj — object to serialize
  1298.   //     [traditional] — perform shallow serialization
  1299.   //
  1300.   // *Example:*
  1301.   //
  1302.   //     $.param( { name: 'Zepto.js', version: '0.6' } );
  1303.   //
  1304.   $.param = function(obj, traditional){
  1305.     var params = [];
  1306.     params.add = function(k, v){ this.push(escape(k) + '=' + escape(v)) };
  1307.     serialize(params, obj, traditional);
  1308.     return params.join('&').replace('%20', '+');
  1309.   };
  1310. })(Zepto);
  1311. //     Zepto.js
  1312. //     (c) 2010, 2011 Thomas Fuchs
  1313. //     Zepto.js may be freely distributed under the MIT license.
  1314.  
  1315. (function ($) {
  1316.  
  1317.   // ### $.fn.serializeArray
  1318.   //
  1319.   // Encode a set of form elements as an array of names and values
  1320.   //
  1321.   // *Example:*
  1322.   //
  1323.   //     $('#login_form').serializeArray();
  1324.   //
  1325.   //  returns
  1326.   //
  1327.   //     [
  1328.   //         {
  1329.   //             name: 'email',
  1330.   //             value: 'koss@nocorp.me'
  1331.   //         },
  1332.   //         {
  1333.   //             name: 'password',
  1334.   //             value: '123456'
  1335.   //         }
  1336.   //     ]
  1337.   //
  1338.   $.fn.serializeArray = function () {
  1339.     var result = [], el;
  1340.     $( Array.prototype.slice.call(this.get(0).elements) ).each(function () {
  1341.       el = $(this);
  1342.       var type = el.attr('type');
  1343.       if (
  1344.         !this.disabled && type != 'submit' && type != 'reset' && type != 'button' &&
  1345.         ((type != 'radio' && type != 'checkbox') || this.checked)
  1346.       ) {
  1347.         result.push({
  1348.           name: el.attr('name'),
  1349.           value: el.val()
  1350.         });
  1351.       }
  1352.     });
  1353.     return result;
  1354.   };
  1355.  
  1356.   // ### $.fn.serialize
  1357.   //
  1358.   //
  1359.   // Encode a set of form elements as a string for submission
  1360.   //
  1361.   // *Example:*
  1362.   //
  1363.   //     $('#login_form').serialize();
  1364.   //
  1365.   //  returns
  1366.   //
  1367.   //     "email=koss%40nocorp.me&password=123456"
  1368.   //
  1369.   $.fn.serialize = function () {
  1370.     var result = [];
  1371.     this.serializeArray().forEach(function (elm) {
  1372.       result.push( encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value) );
  1373.     });
  1374.     return result.join('&');
  1375.   };
  1376.  
  1377.   // ### $.fn.submit
  1378.   //
  1379.   // Bind or trigger the submit event for a form
  1380.   //
  1381.   // *Examples:*
  1382.   //
  1383.   // To bind a handler for the submit event:
  1384.   //
  1385.   //     $('#login_form').submit(function (e) {
  1386.   //         alert('Form was submitted!');
  1387.   //         e.preventDefault();
  1388.   //     });
  1389.   //
  1390.   // To trigger form submit:
  1391.   //
  1392.   //     $('#login_form').submit();
  1393.   //
  1394.   $.fn.submit = function (callback) {
  1395.     if (callback) this.bind('submit', callback)
  1396.     else if (this.length) {
  1397.       var event = $.Event('submit');
  1398.       this.eq(0).trigger(event);
  1399.       if (!event.defaultPrevented) this.get(0).submit()
  1400.     }
  1401.     return this;
  1402.   }
  1403.  
  1404. })(Zepto);
  1405.  
  1406. (function($) {
  1407.   var data = {}, dataAttr = $.fn.data,
  1408.     uuid = $.uuid = +new Date(),
  1409.     exp  = $.expando = 'Zepto' + uuid;
  1410.  
  1411.   function getData(node, name) {
  1412.     var id = node[exp], store = id && data[id];
  1413.     return name === undefined ? store || setData(node) :
  1414.       (store && store[name]) || dataAttr.call($(node), name);
  1415.   }
  1416.  
  1417.   function setData(node, name, value) {
  1418.     var id = node[exp] || (node[exp] = ++uuid),
  1419.       store = data[id] || (data[id] = {});
  1420.     if (name !== undefined) store[name] = value;
  1421.     return store;
  1422.   };
  1423.  
  1424.   $.fn.data = function(name, value) {
  1425.     return value === undefined ?
  1426.       this.length == 0 ? undefined : getData(this[0], name) :
  1427.       this.each(function(idx){
  1428.         setData(this, name, $.isFunction(value) ?
  1429.                 value.call(this, idx, getData(this, name)) : value);
  1430.       });
  1431.   };
  1432. })(Zepto);
  1433.  
  1434.  
  1435. (function($) {
  1436.   // Used by dateinput
  1437.   $.expr = {':': {}};
  1438.  
  1439.   // Used by bootstrap
  1440.   $.support = {
  1441.     opacity: true
  1442.   };
  1443.  
  1444.   // Used by dateinput
  1445.   $.fn.clone = function() {
  1446.       var ret = $();
  1447.       this.each(function(){
  1448.           ret.push(this.cloneNode(true));
  1449.       });
  1450.       return ret;
  1451.   };
  1452.  
  1453.   // Used by util.js
  1454.   // Create scrollLeft and scrollTop methods
  1455.   ["Left", "Top"].forEach(function(name, i) {
  1456.     var method = "scroll" + name;
  1457.  
  1458.     function isWindow( obj ) {
  1459.         return obj && typeof obj === "object" && "setInterval" in obj;
  1460.     }
  1461.  
  1462.     function getWindow( elem ) {
  1463.       return isWindow( elem ) ? elem : elem.nodeType === 9 ? elem.defaultView || elem.parentWindow : false;
  1464.     }
  1465.  
  1466.     $.fn[ method ] = function( val ) {
  1467.       var elem, win;
  1468.  
  1469.       if ( val === undefined ) {
  1470.  
  1471.         elem = this[ 0 ];
  1472.  
  1473.         if ( !elem ) {
  1474.           return null;
  1475.         }
  1476.  
  1477.         win = getWindow( elem );
  1478.  
  1479.         // Return the scroll offset
  1480.         return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
  1481.             win.document.documentElement[ method ] ||
  1482.             win.document.body[ method ] :
  1483.             elem[ method ];
  1484.       }
  1485.  
  1486.       // Set the scroll offset
  1487.       this.each(function() {
  1488.         win = getWindow( this );
  1489.  
  1490.         if ( win ) {
  1491.           var xCoord = !i ? val : $( win ).scrollLeft();
  1492.           var yCoord = i ? val : $( win ).scrollTop();
  1493.           win.scrollTo(xCoord, yCoord);
  1494.         } else {
  1495.           this[ method ] = val;
  1496.         }
  1497.       });
  1498.     }
  1499.   });
  1500.  
  1501.  
  1502.   // Used by colorslider.js
  1503.   ['width', 'height'].forEach(function(dimension) {
  1504.     var offset, Dimension = dimension.replace(/./, function(m) { return m[0].toUpperCase() });
  1505.     $.fn['outer' + Dimension] = function(margin) {
  1506.       var elem = this;
  1507.       if (elem) {
  1508.         var size = elem[dimension]();
  1509.         var sides = {'width': ['left', 'right'], 'height': ['top', 'bottom']};
  1510.         sides[dimension].forEach(function(side) {
  1511.           if (margin) size += parseInt(elem.css('margin-' + side), 10);
  1512.         });
  1513.         return size;
  1514.       } else {
  1515.         return null;
  1516.       }
  1517.     };
  1518.   });
  1519.  
  1520.   // Used by bootstrap
  1521.   $.proxy = function( fn, context ) {
  1522.     if ( typeof context === "string" ) {
  1523.       var tmp = fn[ context ];
  1524.       context = fn;
  1525.       fn = tmp;
  1526.     }
  1527.  
  1528.     // Quick check to determine if target is callable, in the spec
  1529.     // this throws a TypeError, but we will just return undefined.
  1530.     if ( !$.isFunction( fn ) ) {
  1531.       return undefined;
  1532.     }
  1533.  
  1534.     // Simulated bind
  1535.     var args = Array.prototype.slice.call( arguments, 2 ),
  1536.       proxy = function() {
  1537.         return fn.apply( context, args.concat( Array.prototype.slice.call( arguments ) ) );
  1538.       };
  1539.  
  1540.     // Set the guid of unique handler to the same of original handler, so it can be removed
  1541.     proxy.guid = fn.guid = fn.guid || proxy.guid || $.guid++;
  1542.  
  1543.     return proxy;
  1544.   };
  1545.  
  1546.   // Used by timeago
  1547.   var nativeTrim = String.prototype.trim;
  1548.   $.trim = function(str, characters){
  1549.     if (!characters && nativeTrim) {
  1550.       return nativeTrim.call(str);
  1551.     }
  1552.     characters = defaultToWhiteSpace(characters);
  1553.     return str.replace(new RegExp('\^[' + characters + ']+|[' + characters + ']+$', 'g'), '');
  1554.   };
  1555.  
  1556.   // Functionality
  1557.   $.fn.preload = function() {
  1558.       this.each(function(){
  1559.           $('<img/>')[0].src = this;
  1560.       });
  1561.   };
  1562.  
  1563.   // Used by util.js
  1564.   var rtable = /^t(?:able|d|h)$/i,
  1565.   rroot = /^(?:body|html)$/i;
  1566.   $.fn.position = function() {
  1567.     if ( !this[0] ) {
  1568.       return null;
  1569.     }
  1570.  
  1571.     var elem = this[0],
  1572.  
  1573.     // Get *real* offsetParent
  1574.     offsetParent = this.offsetParent(),
  1575.     // Get correct offsets
  1576.     offset       = this.offset(),
  1577.     parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
  1578.  
  1579.     // Subtract element margins
  1580.     // note: when an element has margin: auto the offsetLeft and marginLeft
  1581.     // are the same in Safari causing offset.left to incorrectly be 0
  1582.     offset.top  -= parseFloat( $(elem).css("margin-top") ) || 0;
  1583.     offset.left -= parseFloat( $(elem).css("margin-left") ) || 0;
  1584.  
  1585.     // Add offsetParent borders
  1586.     parentOffset.top  += parseFloat( $(offsetParent[0]).css("border-top-width") ) || 0;
  1587.     parentOffset.left += parseFloat( $(offsetParent[0]).css("border-left-width") ) || 0;
  1588.  
  1589.     // Subtract the two offsets
  1590.     return {
  1591.       top:  offset.top  - parentOffset.top,
  1592.       left: offset.left - parentOffset.left
  1593.     };
  1594.   };
  1595.  
  1596.   $.fn.offsetParent = function() {
  1597.     var ret = $();
  1598.     this.each(function(){
  1599.       var offsetParent = this.offsetParent || document.body;
  1600.       while ( offsetParent && (!rroot.test(offsetParent.nodeName) && $(offsetParent).css("position") === "static") ) {
  1601.         offsetParent = offsetParent.offsetParent;
  1602.       }
  1603.       ret.push(offsetParent);
  1604.     });
  1605.     return ret;
  1606.   };
  1607.  
  1608.   // For dateinput
  1609.   Event.prototype.isDefaultPrevented = function() {
  1610.     return this.defaultPrevented;
  1611.   };
  1612. })(Zepto);
  1613.  
  1614. //     Zepto.js
  1615. //     (c) 2010, 2011 Thomas Fuchs
  1616. //     Zepto.js may be freely distributed under the MIT license.
  1617.  
  1618. (function($, undefined){
  1619.   var prefix = '', eventPrefix, endEventName, endAnimationName,
  1620.     vendors = {Webkit: 'webkit', Moz: '', O: 'o', ms: 'MS'},
  1621.     document = window.document, testEl = document.createElement('div'),
  1622.     supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i;
  1623.     cachedAnimation = {};
  1624.  
  1625.   function downcase(str) { return str.toLowerCase() }
  1626.   function normalizeEvent(name) { return eventPrefix ? eventPrefix + name : downcase(name) };
  1627.  
  1628.   $.each(vendors, function(vendor, event){
  1629.     if (testEl.style[vendor + 'TransitionProperty'] !== undefined) {
  1630.       prefix = '-' + downcase(vendor) + '-';
  1631.       eventPrefix = event;
  1632.       return false;
  1633.     }
  1634.   });
  1635.  
  1636.   $.fx = {
  1637.     off: (eventPrefix === undefined && testEl.style.transitionProperty === undefined),
  1638.     cssPrefix: prefix,
  1639.     transitionEnd: normalizeEvent('TransitionEnd'),
  1640.     animationEnd: normalizeEvent('AnimationEnd')
  1641.   };
  1642.  
  1643.   $.fn.animate = function(properties, duration, ease, callback){
  1644.     if ($.isObject(duration))
  1645.       ease = duration.easing, callback = duration.complete, duration = duration.duration;
  1646.     if (duration) duration = duration / 1000;
  1647.     return this.anim(properties, duration, ease, callback);
  1648.   };
  1649.  
  1650.   $.fn.stop = function(){
  1651.     if(cachedAnimation.callback && cachedAnimation.endEvent){
  1652.       this.one(cachedAnimation.endEvent, cachedAnimation.callback);
  1653.     }
  1654.     cachedAnimation = {};
  1655.     return this;
  1656.   }
  1657.  
  1658.   $.fn.anim = function(properties, duration, ease, callback){
  1659.     var transforms, cssProperties = {}, key, that = this, wrappedCallback, endEvent = $.fx.transitionEnd;
  1660.     if (duration === undefined) duration = 0.4;
  1661.     if ($.fx.off) duration = 0;
  1662.  
  1663.     if (typeof properties == 'string') {
  1664.       // keyframe animation
  1665.       cssProperties[prefix + 'animation-name'] = properties;
  1666.       cssProperties[prefix + 'animation-duration'] = duration + 's';
  1667.       endEvent = $.fx.animationEnd;
  1668.     } else {
  1669.       // CSS transitions
  1670.       for (key in properties)
  1671.         if (supportedTransforms.test(key)) {
  1672.           transforms || (transforms = []);
  1673.           transforms.push(key + '(' + properties[key] + ')');
  1674.         }
  1675.         else cssProperties[key] = properties[key];
  1676.  
  1677.       if (transforms) cssProperties[prefix + 'transform'] = transforms.join(' ');
  1678.       if (!$.fx.off) cssProperties[prefix + 'transition'] = 'all ' + duration + 's ' + (ease || '');
  1679.     }
  1680.  
  1681.     wrappedCallback = function(){
  1682.       var props = {};
  1683.       props[prefix + 'transition'] = props[prefix + 'animation-name'] = 'none';
  1684.       $(this).css(props);
  1685.       callback && callback.call(this);
  1686.     }
  1687.     cachedAnimation.endEvent = endEvent;
  1688.     cachedAnimation.callback = callback;
  1689.     if (duration > 0) this.one(cachedAnimation.endEvent, cachedAnimation.callback);
  1690.  
  1691.     setTimeout(function() {
  1692.       that.css(cssProperties);
  1693.       if (duration <= 0) setTimeout(function() {
  1694.         that.each(function(){ wrappedCallback.call(this) });
  1695.       }, 0);
  1696.     }, 0);
  1697.  
  1698.     return this;
  1699.   };
  1700.  
  1701.   testEl = null;
  1702. })(Zepto);
  1703.  
  1704.  
  1705. //     Zepto.js
  1706. //     (c) 2010, 2011 Thomas Fuchs
  1707. //     Zepto.js may be freely distributed under the MIT license.
  1708.  
  1709. (function($, undefined){
  1710.   var document = window.document, docElem = document.documentElement,
  1711.     origShow = $.fn.show, origHide = $.fn.hide, origToggle = $.fn.toggle,
  1712.     speeds = { _default: 400, fast: 200, slow: 600 };
  1713.  
  1714.   function translateSpeed(speed) {
  1715.     return typeof speed == 'number' ? speed : (speeds[speed] || speeds._default);
  1716.   }
  1717.  
  1718.   function anim(el, speed, opacity, scale, callback) {
  1719.     if (typeof speed == 'function' && !callback) callback = speed, speed = undefined;
  1720.     var props = { opacity: opacity };
  1721.     if (scale) {
  1722.       if ($.fx.transforms3d) props.scale3d = scale + ',1';
  1723.       else props.scale = scale;
  1724.       el.css($.fx.cssPrefix + 'transform-origin', '0 0');
  1725.     }
  1726.     return el.anim(props, translateSpeed(speed) / 1000, null, callback);
  1727.   }
  1728.  
  1729.   function hide(el, speed, scale, callback) {
  1730.     return anim(el, speed, 0, scale, function(){
  1731.       origHide.call($(this));
  1732.       callback && callback.call(this);
  1733.     });
  1734.   }
  1735.  
  1736.   $.fn.show = function(speed, callback) {
  1737.     origShow.call(this);
  1738.     if (speed === undefined) speed = 0;
  1739.     else this.css('opacity', 0);
  1740.     return anim(this, speed, 1, '1,1', callback);
  1741.   };
  1742.  
  1743.   $.fn.hide = function(speed, callback) {
  1744.     if (speed === undefined) return origHide.call(this);
  1745.     else return hide(this, speed, '0,0', callback);
  1746.   }
  1747.  
  1748.   $.fn.toggle = function(speed, callback) {
  1749.     if (speed === undefined || typeof speed == 'boolean') return origToggle.call(this, speed);
  1750.     else return this[this.css('display') == 'none' ? 'show' : 'hide'](speed, callback);
  1751.   };
  1752.  
  1753.   $.fn.fadeTo = function(speed, opacity, callback) {
  1754.     return anim(this, speed, opacity, null, callback);
  1755.   };
  1756.  
  1757.   $.fn.fadeIn = function(speed, callback) {
  1758.     var target = this.css('opacity')
  1759.     if (target > 0) this.css('opacity', 0)
  1760.     else target = 1
  1761.     return origShow.call(this).fadeTo(speed, target, callback);
  1762.   };
  1763.  
  1764.   $.fn.fadeOut = function(speed, callback) {
  1765.     return hide(this, speed, null, callback);
  1766.   };
  1767.  
  1768.   $.fn.fadeToggle = function(speed, callback) {
  1769.     var hidden = this.css('opacity') == 0 || this.css('display') == 'none';
  1770.     return this[hidden ? 'fadeIn' : 'fadeOut'](speed, callback);
  1771.   };
  1772.  
  1773.   $.extend($.fx, {
  1774.     speeds: speeds,
  1775.     // feature detection for 3D transforms adapted from Modernizr
  1776.     transforms3d: (function(props){
  1777.       var ret = false;
  1778.       $.each(props, function(i, prop){
  1779.         if (docElem.style[prop] !== undefined) {
  1780.           ret = i != 1 || webkitTransforms3d();
  1781.           return false;
  1782.         }
  1783.       });
  1784.       return ret;
  1785.     })('perspectiveProperty WebkitPerspective MozPerspective OPerspective msPerspective'.split(' '))
  1786.   });
  1787.  
  1788.   function webkitTransforms3d() {
  1789.     var ret, div = document.createElement('div'),
  1790.       testEl = document.createElement('div'),
  1791.       css = '@media (-webkit-transform-3d){#zeptotest{left:9px;position:absolute}}',
  1792.       style = ['&shy;', '<style>', css, '</style>'].join('');
  1793.  
  1794.     div.innerHTML += style;
  1795.     testEl.id = 'zeptotest';
  1796.     div.appendChild(testEl);
  1797.     docElem.appendChild(div);
  1798.     ret = testEl.offsetLeft === 9;
  1799.     div.parentNode.removeChild(div);
  1800.     return ret;
  1801.   }
  1802. })(Zepto);