Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

update Zepto, fix history popstate woes

  • Loading branch information...
commit 7245dd436d10a5eb73d5df5edd32c3a8198f02a3 1 parent 8434e8b
@mislav authored
Showing with 53 additions and 91 deletions.
  1. +4 −8 app.rb
  2. +47 −67 public/app.js
  3. +2 −16 public/zepto.min.js
View
12 app.rb
@@ -418,7 +418,7 @@ def photos_by_tag(tag)
!!!
%title&= @title
%meta{ 'http-equiv' => 'content-type', content: 'text/html; charset=utf-8' }
-%meta{ name: 'viewport', content: 'initial-scale=1.0; maximum-scale=1.0; user-scalable=0;' }
+%meta{ name: 'viewport', content: 'initial-scale=1.0, maximum-scale=1.0, user-scalable=no' }
%link{ rel: 'apple-touch-icon', href: '/apple-touch-icon.png' }
%link{ rel: 'favicon', href: '/favicon.ico' }
/ %meta{ name: 'apple-mobile-web-app-capable', content: 'yes' }
@@ -487,13 +487,9 @@ def photos_by_tag(tag)
(<a href="/users/mislav" title="Mislav's photos">photos</a>)
:javascript
- var src, script
- if (navigator.userAgent.match(/WebKit\b/)) src = '/zepto.min.js'
- else src = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'
- script = document.createElement('script')
- script.src = src
- script.async = 'async'
- document.body.appendChild(script)
+ document.write('<script src=' +
+ ('__proto__' in {} ? '/zepto' : 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery') +
+ '.min.js><\/script>')
%script{ src: '/app.js' }
View
114 public/app.js
@@ -17,22 +17,7 @@ function preload(src, fn) {
return true
}
-var readyInterval
-
-function ready(name, fn) {
- if (window[name]) {
- fn(window[name])
- return true
- }
- else if (!readyInterval) {
- readyInterval = setInterval(function() {
- if (ready(name, fn)) clearInterval(readyInterval)
- }, 50)
- }
- else return false
-}
-
-ready('$', function($) {
+Zepto(function($) {
var svg = $.browser && $.browser.webkit
if (!svg) {
@@ -50,27 +35,20 @@ ready('$', function($) {
var val = field.val(), text = field.attr('placeholder')
if (!val || val === text) field.val(text).addClass('placeholder')
}
-
- $('input[placeholder], textarea[placeholder]')
- .bind('focusin', function(e) {
+
+ $('input[placeholder], textarea[placeholder]').on({
+ focusin: function(e) {
var input = $(this)
if (input.val() === input.attr('placeholder')) input.val('').removeClass('placeholder')
- })
- .bind('focusout', function(e) {
+ },
+ focusout: function(e) {
emulatePlaceholder($(this))
- })
- .each(function() {
- emulatePlaceholder($(this))
- })
+ }
+ }).each(function(){ emulatePlaceholder($(this)) })
}
- $('form').live('submit', function() {
- var select = $(this).find('select[name=filter]')
- if (select.get(0) && !select.get(0).selectedIndex) select.attr('disabled', 'disabled')
- })
-
function viewPhoto(item) {
- if (typeof item == "string") item = $('#media_' + item)
+ if (typeof item == "string") item = $('*[id^="media_' + item + '"]')
if (!item.get(0) || item.hasClass('active')) return
var thumb = item.find('.thumb')
@@ -78,7 +56,7 @@ ready('$', function($) {
thumb.removeClass('loading')
var container = $('#photos').addClass('lightbox')
item.addClass('active').find('.full img').attr('src', img.src)
- pushPhotoState(item.attr('id').split('_')[1])
+ pushPhotoState(item.attr('id').replace(/\w+?_/, ''))
if ($.os && $.os.iphone) scrollTo(0, container.offset().top - 8);
}
@@ -101,22 +79,20 @@ ready('$', function($) {
if (location.hash != hash) {
if (history.pushState) history.pushState({ photo: photoID }, "", hash)
else location.hash = hash
- trackPageview(url + hash)
+ trackPageview()
}
} else {
if (history.pushState) {
history.pushState({ photo: null, closed: true }, "", url)
- trackPageview(url)
+ trackPageview()
}
else location.href = url
}
}
- function trackPageview(url) {
- if (url.indexOf('://') >= 0) url = url.split(/:\/\/[^\/]+/)[1]
- if (url.indexOf('?') < 0) url = url.replace('#p', '/p')
- if (window._gaq) _gaq.push(['_trackPageview', url])
- else if (window.console) console.log('trackPageview: ' + url)
+ function trackPageview() {
+ if (window._gauges) _gauges.push(['track'])
+ else if (window.console) console.log('trackPageview: ' + location.toString())
}
function hashchange(e) {
@@ -125,36 +101,40 @@ ready('$', function($) {
}
if (history.pushState) {
- $(window).bind('popstate', function(e) {
- trackPageview(location.href)
- if (e.state && e.state.photo) viewPhoto(e.state.photo)
- else closePhoto()
- })
+ setTimeout(function(){
+ $(window).on('popstate', function(e) {
+ trackPageview()
+ if (e.state) {
+ if (e.state.photo) viewPhoto(e.state.photo)
+ else closePhoto()
+ }
+ else hashchange()
+ })
+ }, 1000) // http://code.google.com/p/chromium/issues/detail?id=63040#c11
} else {
- $(window).bind('hashchange', hashchange)
+ $(window).on('hashchange', hashchange)
}
hashchange()
- $('#photos a.thumb').live('click', function(e) {
- e.preventDefault()
- this.blur()
- viewPhoto($(this).closest('li'))
- })
-
- $('#photos a[href="#close"], #photos .full img').live('click', function(e) {
- e.preventDefault()
- var url = location.href.split('#')[0]
- pushPhotoState(null)
- closePhoto()
- })
-
- $('#photos .pagination a').live('click', function(e) {
- e.preventDefault()
- $(this).find('span').text('Loading...')
- var item = $(this).closest('.pagination')
- $.get($(this).attr('href'), function(body) {
- item.remove()
- $('#photos').append(body)
+ $('#photos')
+ .on('click', 'a.thumb', function(e){
+ e.preventDefault()
+ try { this.blur() } catch(e) { }
+ viewPhoto($(this).closest('li'))
+ })
+ .on('click', 'a[href="#close"], .full img', function(e){
+ e.preventDefault()
+ var url = location.href.split('#')[0]
+ pushPhotoState(null)
+ closePhoto()
+ })
+ .on('click', '.pagination a', function(e){
+ e.preventDefault()
+ $(this).find('span').text('Loading...')
+ var item = $(this).closest('.pagination')
+ $.get($(this).attr('href'), function(body) {
+ item.remove()
+ $('#photos').append(body)
+ })
})
- })
-})
+})
View
18 public/zepto.min.js
@@ -1,16 +1,2 @@
-var Zepto=function(){function i(a){return a.filter(function(b){return b!==k&&b!==null})}function h(a,b){this.dom=a||[];this.selector=b||""}function c(a,b){return a==e?new h:b!==k?c(b).find(a):new h(i(a instanceof h?a.dom:a instanceof Array?a:a instanceof Element||a===window?[a]:l(e,a)),a)}var g=[].slice,e=document,f={append:"beforeEnd",prepend:"afterBegin",before:"beforeBegin",after:"afterEnd"},d,j,k,l;if(String.prototype.trim===k)String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,
-"")};c.extend=function(a,b){for(d in b)a[d]=b[d]};c.qsa=l=function(a,b){return g.call(a.querySelectorAll(b))};camelize=function(a){return a.replace(/-+(.)?/g,function(b,m){return m?m.toUpperCase():""})};c.fn={ready:function(a){e.addEventListener("DOMContentLoaded",a,false);return this},compact:function(){this.dom=i(this.dom);return this},get:function(a){return a===k?this.dom:this.dom[a]},remove:function(){return this.each(function(a){a.parentNode.removeChild(a)})},each:function(a){this.dom.forEach(a);
-return this},filter:function(a){return c(this.dom.filter(function(b){return l(b.parentNode,a).indexOf(b)>=0}))},is:function(a){return this.dom.length>0&&c(this.dom[0]).filter(a).dom.length>0},first:function(){this.dom=i([this.dom[0]]);return this},find:function(a){return c(this.dom.map(function(b){return l(b,a)}).reduce(function(b,m){return b.concat(m)},[]))},closest:function(a){var b=this.dom[0].parentNode;for(a=l(e,a);b&&a.indexOf(b)<0;)b=b.parentNode;return c(b&&b!==e?b:[])},pluck:function(a){return this.dom.map(function(b){return b[a]})},
-show:function(){return this.css("display","block")},hide:function(){return this.css("display","none")},prev:function(){return c(this.pluck("previousElementSibling"))},next:function(){return c(this.pluck("nextElementSibling"))},html:function(a){return a===k?this.dom.length>0?this.dom[0].innerHTML:null:this.each(function(b){b.innerHTML=a})},text:function(a){return a===k?this.dom.length>0?this.dom[0].innerText:null:this.each(function(b){b.innerText=a})},attr:function(a,b){return typeof a=="string"&&
-b===k?this.dom.length>0?this.dom[0].getAttribute(a)||undefined:null:this.each(function(m){if(typeof a=="object")for(d in a)m.setAttribute(d,a[d]);else m.setAttribute(a,b)})},offset:function(){var a=this.dom[0].getBoundingClientRect();return{left:a.left+e.body.scrollLeft,top:a.top+e.body.scrollTop,width:a.width,height:a.height}},css:function(a,b){if(b===k&&typeof a=="string")return this.dom[0].style[camelize(a)];j="";for(d in a)j+=d+":"+a[d]+";";if(typeof a=="string")j=a+":"+b;return this.each(function(m){m.style.cssText+=
-";"+j})},index:function(a){return this.dom.indexOf(c(a).get(0))},hasClass:function(a){return RegExp("(^|\\s)"+a+"(\\s|$)").test(this.dom[0].className)},addClass:function(a){return this.each(function(b){!c(b).hasClass(a)&&(b.className+=(b.className?" ":"")+a)})},removeClass:function(a){return this.each(function(b){b.className=b.className.replace(RegExp("(^|\\s)"+a+"(\\s|$)")," ").trim()})}};["width","height"].forEach(function(a){c.fn[a]=function(){return this.offset()[a]}});for(d in f)c.fn[d]=function(a){return function(b){return this.each(function(m){m["insertAdjacent"+
-(b instanceof Element?"Element":"HTML")](a,b)})}}(f[d]);h.prototype=c.fn;return c}();"$"in window||(window.$=Zepto);
-(function(i){function h(f,d,j){return e.filter(function(k){return k&&k.el===f&&(!d||k.ev===d)&&(!j||k.fn===j)})}var c=document,g=i.qsa,e=[];i.event={add:function(f,d,j){d.split(/\s/).forEach(function(k){e.push({ev:k,el:f,fn:j,i:e.length});f.addEventListener(k,j,false)})},remove:function(f,d,j){(d||"").split(/\s/).forEach(function(k){h(f,k,j).forEach(function(l){e[l.i]=null;f.removeEventListener(l.ev,l.fn,false)})})}};i.fn.bind=function(f,d){return this.each(function(j){i.event.add(j,f,d)})};i.fn.unbind=
-function(f,d){return this.each(function(j){i.event.remove(j,f,d)})};i.fn.delegate=function(f,d,j){return this.each(function(k){i.event.add(k,d,function(l){for(var a=l.target,b=g(k,f);a&&b.indexOf(a)<0;)a=a.parentNode;a&&a!==k&&a!==c&&j.call(a,l)},false)})};i.fn.live=function(f,d){i(c.body).delegate(this.selector,f,d);return this};i.fn.trigger=function(f){return this.each(function(d){var j;d.dispatchEvent(j=c.createEvent("Events"),j.initEvent(f,true,false))})}})(Zepto);
-(function(i){function h(g){var e={},f=g.match(/(Android)\s+([\d.]+)/),d=g.match(/(iPhone\sOS)\s([\d_]+)/),j=g.match(/(iPad).*OS\s([\d_]+)/);g=g.match(/(webOS)\/([\d.]+)/);if(f){e.android=true;e.version=f[2]}if(d){e.ios=true;e.version=d[2].replace(/_/g,".");e.iphone=true}if(j){e.ios=true;e.version=j[2].replace(/_/g,".");e.ipad=true}if(g){e.webos=true;e.version=g[2]}return e}i.os=h(navigator.userAgent);i.__detect=h;var c=navigator.userAgent.match(/WebKit\/([\d.]+)/);i.browser={webkit:!!c,version:(c||
-[])[1]}})(Zepto);(function(i){i.fn.anim=function(h,c,g){var e=[],f,d;for(d in h)d==="opacity"?f=h[d]:e.push(d+"("+h[d]+")");return this.css({"-webkit-transition":"all "+(c||0.5)+"s "+(g||""),"-webkit-transform":e.join(" "),opacity:f})}})(Zepto);
-(function(i){var h={},c;i(document).ready(function(){i(document.body).bind("touchstart",function(g){var e=Date.now(),f=e-(h.last||e);h.target="tagName"in g.touches[0].target?g.touches[0].target:g.touches[0].target.parentNode;c&&clearTimeout(c);h.x1=g.touches[0].pageX;if(f>0&&f<=250)h.isDoubleTap=true;h.last=e}).bind("touchmove",function(g){h.x2=g.touches[0].pageX}).bind("touchend",function(){if(h.isDoubleTap){i(h.target).trigger("doubleTap");h={}}else if(h.x2>0){Math.abs(h.x1-h.x2)>30&&i(h.target).trigger("swipe");
-h.x1=h.x2=h.last=0}else if("last"in h)c=setTimeout(function(){c=null;i(h.target).trigger("tap");h={}},250)}).bind("touchcancel",function(){h={}})});["swipe","doubleTap","tap"].forEach(function(g){i.fn[g]=function(e){return this.bind(g,e)}})})(Zepto);
-(function(i){function h(c,g,e,f,d){f=f||null;var j=new XMLHttpRequest;if(e instanceof Function)j.onreadystatechange=function(){if(j.readyState==4&&(j.status==200||j.status==0))e(j.responseText)};j.open(c,g,true);d&&j.setRequestHeader("Accept",d);if(f instanceof Object){f=JSON.stringify(f);j.setRequestHeader("Content-Type","application/json")}j.setRequestHeader("X-Requested-With","XMLHttpRequest");j.send(f)}i.get=function(c,g){h("GET",c,g)};i.post=function(c,g,e,f){if(g instanceof Function){f=f||e;
-e=g;g=null}h("POST",c,e,g,f)};i.getJSON=function(c,g){i.get(c,function(e){g(JSON.parse(e))})};i.fn.load=function(c,g){var e=this,f=c.split(/\s/),d;if(!this.dom.length)return this;if(f.length>1){c=f[0];d=f[1]}i.get(c,function(j){e.html(d?i(document.createElement("div")).html(j).find(d).html():j);g&&g()});return this}})(Zepto);
-(function(i){var h=[],c;i.fn.remove=function(){return this.each(function(g){if(g.tagName=="IMG"){h.push(g);g.src="data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs=";c&&clearTimeout(c);c=setTimeout(function(){h=[]},6E4)}g.parentNode.removeChild(g)})}})(Zepto);
+/* Zepto v1.0rc1-16-g04cfc12 - polyfill zepto event detect ajax - zeptojs.com/license */
+(function(a){String.prototype.trim===a&&(String.prototype.trim=function(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}),Array.prototype.reduce===a&&(Array.prototype.reduce=function(b){if(this===void 0||this===null)throw new TypeError;var c=Object(this),d=c.length>>>0,e=0,f;if(typeof b!="function")throw new TypeError;if(d==0&&arguments.length==1)throw new TypeError;if(arguments.length>=2)f=arguments[1];else do{if(e in c){f=c[e++];break}if(++e>=d)throw new TypeError}while(!0);while(e<d)e in c&&(f=b.call(a,f,c[e],e,c)),e++;return f})})();var Zepto=function(){function B(a){return w.call(a)=="[object Function]"}function C(a){return a instanceof Object}function D(a){return C(a)&&a.__proto__==Object.prototype}function E(a){return a instanceof Array}function F(a){return typeof a.length=="number"}function G(b){return b.filter(function(b){return b!==a&&b!==null})}function H(a){return a.length>0?[].concat.apply([],a):a}function I(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function J(a){return a in i?i[a]:i[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function K(a,b){return typeof b=="number"&&!k[I(a)]?b+"px":b}function L(a){var b,c;return h[a]||(b=g.createElement(a),g.body.appendChild(b),c=j(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),h[a]=c),h[a]}function M(b,d){return d===a?c(b):c(b).filter(d)}function N(a,b,c,d){return B(b)?b.call(a,c,d):b}function O(a,b,d){var e=a%2?b:b.parentNode;e?e.insertBefore(d,a?a==1?e.firstChild:a==2?b:null:b.nextSibling):c(d).remove()}function P(a,b){b(a);for(var c in a.childNodes)P(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=window.document,h={},i={},j=g.defaultView.getComputedStyle,k={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,n=[1,3,8,9,11],o=["after","prepend","before","append"],p=g.createElement("table"),q=g.createElement("tr"),r={tr:g.createElement("tbody"),tbody:p,thead:p,tfoot:p,td:q,th:q,"*":g.createElement("div")},s=/complete|loaded|interactive/,t=/^\.([\w-]+)$/,u=/^#([\w-]+)$/,v=/^[\w-]+$/,w={}.toString,x={},y,z,A=g.createElement("div");return x.matches=function(a,b){if(!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=A).appendChild(a),d=~x.qsa(e,b).indexOf(a),f&&A.removeChild(a),d},y=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},z=function(a){return a.filter(function(b,c){return a.indexOf(b)==c})},x.fragment=function(b,d){b.replace&&(b=b.replace(m,"<$1></$2>")),d===a&&(d=l.test(b)&&RegExp.$1),d in r||(d="*");var e=r[d];return e.innerHTML=""+b,c.each(f.call(e.childNodes),function(){e.removeChild(this)})},x.Z=function(a,b){return a=a||[],a.__proto__=arguments.callee.prototype,a.selector=b||"",a},x.isZ=function(a){return a instanceof x.Z},x.init=function(b,d){if(!b)return x.Z();if(B(b))return c(g).ready(b);if(x.isZ(b))return b;var e;if(E(b))e=G(b);else if(D(b))e=[c.extend({},b)],b=null;else if(n.indexOf(b.nodeType)>=0||b===window)e=[b],b=null;else if(l.test(b))e=x.fragment(b.trim(),RegExp.$1),b=null;else{if(d!==a)return c(d).find(b);e=x.qsa(g,b)}return x.Z(e,b)},c=function(a,b){return x.init(a,b)},c.extend=function(c){return f.call(arguments,1).forEach(function(d){for(b in d)d[b]!==a&&(c[b]=d[b])}),c},x.qsa=function(a,b){var c;return a===g&&u.test(b)?(c=a.getElementById(RegExp.$1))?[c]:e:a.nodeType!==1&&a.nodeType!==9?e:f.call(t.test(b)?a.getElementsByClassName(RegExp.$1):v.test(b)?a.getElementsByTagName(b):a.querySelectorAll(b))},c.isFunction=B,c.isObject=C,c.isArray=E,c.isPlainObject=D,c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.trim=function(a){return a.trim()},c.uuid=0,c.map=function(a,b){var c,d=[],e,f;if(F(a))for(e=0;e<a.length;e++)c=b(a[e],e),c!=null&&d.push(c);else for(f in a)c=b(a[f],f),c!=null&&d.push(c);return H(d)},c.each=function(a,b){var c,d;if(F(a)){for(c=0;c<a.length;c++)if(b.call(a[c],c,a[c])===!1)return a}else for(d in a)if(b.call(a[d],d,a[d])===!1)return a;return a},c.fn={forEach:e.forEach,reduce:e.reduce,push:e.push,indexOf:e.indexOf,concat:e.concat,map:function(a){return c.map(this,function(b,c){return a.call(b,c,b)})},slice:function(){return c(f.apply(this,arguments))},ready:function(a){return s.test(g.readyState)?a(c):g.addEventListener("DOMContentLoaded",function(){a(c)},!1),this},get:function(b){return b===a?f.call(this):this[b]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(a){return this.forEach(function(b,c){a.call(b,c,b)}),this},filter:function(a){return B(a)?this.not(this.not(a)):c([].filter.call(this,function(b){return x.matches(b,a)}))},add:function(a,b){return c(z(this.concat(c(a,b))))},is:function(a){return this.length>0&&x.matches(this[0],a)},not:function(b){var d=[];if(B(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):F(b)&&B(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!C(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!C(a)?a:c(a)},find:function(a){var b;return this.length==1?b=x.qsa(this[0],a):b=this.map(function(){return x.qsa(this,a)}),c(b)},closest:function(a,b){var d=this[0];while(d&&!x.matches(d,a))d=d!==b&&d!==g&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&a!==g&&b.indexOf(a)<0)return b.push(a),a});return M(b,a)},parent:function(a){return M(z(this.pluck("parentNode")),a)},children:function(a){return M(this.map(function(){return f.call(this.children)}),a)},siblings:function(a){return M(this.map(function(a,b){return f.call(b.parentNode.children).filter(function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return this.map(function(){return this[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=null),j(this,"").getPropertyValue("display")=="none"&&(this.style.display=L(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){return this.each(function(){c(this).wrapAll(c(a)[0].cloneNode(!1))})},wrapAll:function(a){return this[0]&&(c(this[0]).before(a=c(a)),a.append(this)),this},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return c(this.map(function(){return this.cloneNode(!0)}))},hide:function(){return this.css("display","none")},toggle:function(b){return(b===a?this.css("display")=="none":b)?this.show():this.hide()},prev:function(a){return c(this.pluck("previousElementSibling")).filter(a||"*")},next:function(a){return c(this.pluck("nextElementSibling")).filter(a||"*")},html:function(b){return b===a?this.length>0?this[0].innerHTML:null:this.each(function(a){var d=this.innerHTML;c(this).empty().append(N(this,b,a,d))})},text:function(b){return b===a?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(C(c))for(b in c)this.setAttribute(b,c[b]);else this.setAttribute(c,N(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&this.removeAttribute(a)})},prop:function(b,c){return c===a?this[0]?this[0][b]:a:this.each(function(a){this[b]=N(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+I(b),c);return d!==null?d:a},val:function(b){return b===a?this.length>0?this[0].multiple?c(this[0]).find("option").filter(function(a){return this.selected}).pluck("value"):this[0].value:a:this.each(function(a){this.value=N(this,b,a,this.value)})},offset:function(){if(this.length==0)return null;var a=this[0].getBoundingClientRect();return{left:a.left+window.pageXOffset,top:a.top+window.pageYOffset,width:a.width,height:a.height}},css:function(c,d){if(d===a&&typeof c=="string")return this.length==0?a:this[0].style[y(c)]||j(this[0],"").getPropertyValue(c);var e="";for(b in c)typeof c[b]=="string"&&c[b]==""?this.each(function(){this.style.removeProperty(I(b))}):e+=I(b)+":"+K(b,c[b])+";";return typeof c=="string"&&(d==""?this.each(function(){this.style.removeProperty(I(c))}):e=I(c)+":"+K(c,d)),this.each(function(){this.style.cssText+=";"+e})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return this.length<1?!1:J(a).test(this[0].className)},addClass:function(a){return this.each(function(b){d=[];var e=this.className,f=N(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&(this.className+=(e?" ":"")+d.join(" "))})},removeClass:function(b){return this.each(function(c){if(b===a)return this.className="";d=this.className,N(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(J(a)," ")}),this.className=d.trim()})},toggleClass:function(b,d){return this.each(function(e){var f=N(this,b,e,this.className);(d===a?!c(this).hasClass(f):d)?c(this).addClass(f):c(this).removeClass(f)})}},["width","height"].forEach(function(b){c.fn[b]=function(d){var e,f=b.replace(/./,function(a){return a[0].toUpperCase()});return d===a?this[0]==window?window["inner"+f]:this[0]==g?g.documentElement["offset"+f]:(e=this.offset())&&e[b]:this.each(function(a){var e=c(this);e.css(b,N(this,d,a,e[b]()))})}}),o.forEach(function(a,b){c.fn[a]=function(){var a=c.map(arguments,function(a){return C(a)?a:x.fragment(a)});if(a.length<1)return this;var d=this.length,e=d>1,f=b<2;return this.each(function(c,g){for(var h=0;h<a.length;h++){var i=a[f?a.length-h-1:h];P(i,function(a){a.nodeName!=null&&a.nodeName.toUpperCase()==="SCRIPT"&&(!a.type||a.type==="text/javascript")&&window.eval.call(window,a.innerHTML)}),e&&c<d-1&&(i=i.cloneNode(!0)),O(b,g,i)}})},c.fn[b%2?a+"To":"insert"+(b?"Before":"After")]=function(b){return c(b)[a](this),this}}),x.Z.prototype=c.fn,x.camelize=y,x.uniq=z,c.zepto=x,c}();window.Zepto=Zepto,"$"in window||(window.$=Zepto),function(a){function f(a){return a._zid||(a._zid=d++)}function g(a,b,d,e){b=h(b);if(b.ns)var g=i(b.ns);return(c[f(a)]||[]).filter(function(a){return a&&(!b.e||a.e==b.e)&&(!b.ns||g.test(a.ns))&&(!d||f(a.fn)===f(d))&&(!e||a.sel==e)})}function h(a){var b=(""+a).split(".");return{e:b[0],ns:b.slice(1).sort().join(" ")}}function i(a){return new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)")}function j(b,c,d){a.isObject(b)?a.each(b,d):b.split(/\s/).forEach(function(a){d(a,c)})}function k(b,d,e,g,i,k){k=!!k;var l=f(b),m=c[l]||(c[l]=[]);j(d,e,function(c,d){var e=i&&i(d,c),f=e||d,j=function(a){var c=f.apply(b,[a].concat(a.data));return c===!1&&a.preventDefault(),c},l=a.extend(h(c),{fn:d,proxy:j,sel:g,del:e,i:m.length});m.push(l),b.addEventListener(l.e,j,k)})}function l(a,b,d,e){var h=f(a);j(b||"",d,function(b,d){g(a,b,d,e).forEach(function(b){delete c[h][b.i],a.removeEventListener(b.e,b.proxy,!1)})})}function p(b){var c=a.extend({originalEvent:b},b);return a.each(o,function(a,d){c[a]=function(){return this[d]=m,b[a].apply(b,arguments)},c[d]=n}),c}function q(a){if(!("defaultPrevented"in a)){a.defaultPrevented=!1;var b=a.preventDefault;a.preventDefault=function(){this.defaultPrevented=!0,b.call(this)}}}var b=a.zepto.qsa,c={},d=1,e={};e.click=e.mousedown=e.mouseup=e.mousemove="MouseEvents",a.event={add:k,remove:l},a.proxy=function(b,c){if(a.isFunction(b)){var d=function(){return b.apply(c,arguments)};return d._zid=f(b),d}if(typeof c=="string")return a.proxy(b[c],b);throw new TypeError("expected function")},a.fn.bind=function(a,b){return this.each(function(){k(this,a,b)})},a.fn.unbind=function(a,b){return this.each(function(){l(this,a,b)})},a.fn.one=function(a,b){return this.each(function(c,d){k(this,a,b,null,function(a,b){return function(){var c=a.apply(d,arguments);return l(d,b,a),c}})})};var m=function(){return!0},n=function(){return!1},o={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};a.fn.delegate=function(b,c,d){var e=!1;if(c=="blur"||c=="focus")a.iswebkit?c=c=="blur"?"focusout":c=="focus"?"focusin":c:e=!0;return this.each(function(f,g){k(g,c,d,b,function(c){return function(d){var e,f=a(d.target).closest(b,g).get(0);if(f)return e=a.extend(p(d),{currentTarget:f,liveFired:g}),c.apply(f,[e].concat([].slice.call(arguments,1)))}},e)})},a.fn.undelegate=function(a,b,c){return this.each(function(){l(this,b,c,a)})},a.fn.live=function(b,c){return a(document.body).delegate(this.selector,b,c),this},a.fn.die=function(b,c){return a(document.body).undelegate(this.selector,b,c),this},a.fn.on=function(b,c,d){return c==undefined||a.isFunction(c)?this.bind(b,c||d):this.delegate(c,b,d)},a.fn.off=function(b,c,d){return c==undefined||a.isFunction(c)?this.unbind(b,c||d):this.undelegate(c,b,d)},a.fn.trigger=function(b,c){return typeof b=="string"&&(b=a.Event(b)),q(b),b.data=c,this.each(function(){"dispatchEvent"in this&&this.dispatchEvent(b)})},a.fn.triggerHandler=function(b,c){var d,e;return this.each(function(f,h){d=p(typeof b=="string"?a.Event(b):b),d.data=c,d.target=h,a.each(g(h,b.type||b),function(a,b){e=b.proxy(d);if(d.isImmediatePropagationStopped())return!1})}),e},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout change select keydown keypress keyup error".split(" ").forEach(function(b){a.fn[b]=function(a){return this.bind(b,a)}}),["focus","blur"].forEach(function(b){a.fn[b]=function(a){if(a)this.bind(b,a);else if(this.length)try{this.get(0)[b]()}catch(c){}return this}}),a.Event=function(a,b){var c=document.createEvent(e[a]||"Events"),d=!0;if(b)for(var f in b)f=="bubbles"?d=!!b[f]:c[f]=b[f];return c.initEvent(a,d,!0,null,null,null,null,null,null,null,null,null,null,null,null),c}}(Zepto),function(a){function b(a){var b=this.os={},c=this.browser={},d=a.match(/WebKit\/([\d.]+)/),e=a.match(/(Android)\s+([\d.]+)/),f=a.match(/(iPad).*OS\s([\d_]+)/),g=!f&&a.match(/(iPhone\sOS)\s([\d_]+)/),h=a.match(/(webOS|hpwOS)[\s\/]([\d.]+)/),i=h&&a.match(/TouchPad/),j=a.match(/Kindle\/([\d.]+)/),k=a.match(/Silk\/([\d._]+)/),l=a.match(/(BlackBerry).*Version\/([\d.]+)/);if(c.webkit=!!d)c.version=d[1];e&&(b.android=!0,b.version=e[2]),g&&(b.ios=b.iphone=!0,b.version=g[2].replace(/_/g,".")),f&&(b.ios=b.ipad=!0,b.version=f[2].replace(/_/g,".")),h&&(b.webos=!0,b.version=h[2]),i&&(b.touchpad=!0),l&&(b.blackberry=!0,b.version=l[2]),j&&(b.kindle=!0,b.version=j[1]),k&&(c.silk=!0,c.version=k[1]),!k&&b.android&&a.match(/Kindle Fire/)&&(c.silk=!0)}b.call(a,navigator.userAgent),a.__detect=b}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.defaultPrevented}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c){var d=c.context,e="success";c.success.call(d,a,e,b),triggerGlobal(c,d,"ajaxSuccess",[b,c,a]),ajaxComplete(e,b,c)}function ajaxError(a,b,c,d){var e=d.context;d.error.call(e,c,b,a),triggerGlobal(d,e,"ajaxError",[c,d,a]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){isObject(a.data)&&(a.data=$.param(a.data)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data))}function serialize(a,b,c,d){var e=$.isArray(b);$.each(b,function(b,f){d&&(b=c?d:d+"["+(e?"":b)+"]"),!d&&e?a.add(f.name,f.value):(c?$.isArray(f):isObject(f))?serialize(a,f,c,b):a.add(b,f)})}var jsonpID=0,isObject=$.isObject,document=window.document,key,name,rscript=/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a){var b="jsonp"+ ++jsonpID,c=document.createElement("script"),d=function(){$(c).remove(),b in window&&(window[b]=empty),ajaxComplete("abort",e,a)},e={abort:d},f;return a.error&&(c.onerror=function(){e.abort(),a.error()}),window[b]=function(d){clearTimeout(f),$(c).remove(),delete window[b],ajaxSuccess(d,e,a)},serializeData(a),c.src=a.url.replace(/=\?/,"="+b),$("head").append(c),a.timeout>0&&(f=setTimeout(function(){e.abort(),ajaxComplete("timeout",e,a)},a.timeout)),e},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0},$.ajax=function(options){var settings=$.extend({},options||{});for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host);var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,"callback=?")),$.ajaxJSONP(settings);settings.url||(settings.url=window.location.toString()),serializeData(settings);var mime=settings.accepts[dataType],baseHeaders={},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=$.ajaxSettings.xhr(),abortTimeout;settings.crossDomain||(baseHeaders["X-Requested-With"]="XMLHttpRequest"),mime&&(baseHeaders.Accept=mime,mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime));if(settings.contentType||settings.data&&settings.type.toUpperCase()!="GET")baseHeaders["Content-Type"]=settings.contentType||"application/x-www-form-urlencoded";settings.headers=$.extend(baseHeaders,settings.headers||{}),xhr.onreadystatechange=function(){if(xhr.readyState==4){clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:JSON.parse(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings):ajaxSuccess(result,xhr,settings)}else ajaxError(null,"error",xhr,settings)}};var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async);for(name in settings.headers)xhr.setRequestHeader(name,settings.headers[name]);return ajaxBeforeSend(xhr,settings)===!1?(xhr.abort(),!1):(settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr)},$.get=function(a,b){return $.ajax({url:a,success:b})},$.post=function(a,b,c,d){return $.isFunction(b)&&(d=d||c,c=b,b=null),$.ajax({type:"POST",url:a,data:b,success:c,dataType:d})},$.getJSON=function(a,b){return $.ajax({url:a,success:b,dataType:"json"})},$.fn.load=function(a,b){if(!this.length)return this;var c=this,d=a.split(/\s/),e;return d.length>1&&(a=d[0],e=d[1]),$.get(a,function(a){c.html(e?$(document.createElement("div")).html(a.replace(rscript,"")).find(e).html():a),b&&b.call(c)}),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace("%20","+")}}(Zepto);
Please sign in to comment.
Something went wrong with that request. Please try again.