upjs-rails 0.4.2 → 0.4.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/dist/up.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w,k,C,x,S,T,E,P,A,D,F,U,j,z,O,M,H,I,N,q,W,G,L,X,R,V,_,J,B,Q,Z,K,Y,tn,nn,en,rn,on,un,an,sn,cn,ln,pn,fn,dn,mn,hn;return S=function(t,n){return n=n||{},n.url=t,o(n)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},q=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},Z=function(t,n){var e,r,o;return e=W(t)?$("<a>").attr({href:t}).get(0):hn(t),r=e.protocol+"//"+e.hostname,q(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},Q=function(t){return t?t.toUpperCase():"GET"},n=function(t){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v;for(p=t.split(/[ >]/),r=null,l=d=0,h=p.length;h>d;l=++d){for(i=p[l],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,m=0,v=u.length;v>m;m++)switch(a=u[m],a[0]){case".":o.push(a.substr(1));break;case"#":c=a.substr(1);break;default:f=a}s="<"+f,o.length&&(s+=' class="'+o.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===l&&(r=n),e=n}return r},p=function(t,n){var e;return e=document.createElement(t),I(n)&&(e.innerHTML=n),e},h=function(){var n,e,o,u,i,a;if(n=1<=arguments.length?t.call(arguments,0):[],n=dn(n),o=n.shift(),o="[UP] "+o,u=(null!=(a=o.match(r))?a.length:void 0)||0,F(X(n))&&u<n.length&&(e=n.pop()),i=console.debug.apply(console,[o].concat(t.call(n))),e){console.groupCollapsed();try{i=e()}finally{console.groupEnd()}}return i},y=function(){var n,e,r;throw e=1<=arguments.length?t.call(arguments,0):[],e[0]="[UP] "+e[0],console.error.apply(console,e),r=pn(e),n=en($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),r},r=/\%[odisf]/g,pn=function(t){var n,e,o;return o=t[0],n=0,e=30,o.replace(r,function(){var r,o;return n+=1,r=t[n],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>e&&(r=r.substr(0,e)+"\u2026"),'"'+r+'"'):"number"===o?r.toString():"("+o+")"})},d=function(t){var n,e,r,o,u,i,a;for(h("Creating selector from element %o",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),u=t.prop("tagName").toLowerCase(),r&&(u+="#"+r),i=0,a=e.length;a>i;i++)o=e[i],u+="."+o;return u},f=function(t){var n,e,r,o,u,i,a,s,c,l,f,d;return c=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(c("head")+n+c("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(c("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=p("body",r[1]),s.appendChild(e),(f=t.match(d))&&(a=p("head"),s.appendChild(a),l=p("title",f[1]),a.appendChild(l)),s):p("div",t)},w=$.extend,mn=$.trim,L=Object.keys||function(t){var n,e,r,o;for(e=[],r=0,o=t.length;o>r;r++)n=t[r],t.hasOwnProperty(n)&&e.push(n);return e},g=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},M=function(t){return null===t},G=function(t){return void 0===t},D=function(t){return!G(t)},O=function(t){return G(t)||M(t)},U=function(t){return!O(t)},P=function(t){return O(t)||H(t)&&0===L(t).length||0===t.length},en=function(t,n){return null==n&&(n=I),n(t)?t:null},I=function(t){return!P(t)},F=function(t){return"function"==typeof t},W=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},H=function(t){return j(t)||"function"==typeof t},z=function(t){return t instanceof jQuery},N=function(t){return H(t)&&F(t.then)},A=function(t){return N(t)&&F(t.resolve)},T=function(t){return U(t)?t:void 0},E=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},dn=function(t){return Array.prototype.slice.call(t)},c=function(t){return E(t)?t.slice():w({},t)},hn=function(t){return z(t)?t.get(0):t},_=function(t,n){return w(c(t),n)},tn=function(t,n){var e,r,o,u;if(o=t?c(t):{},n)for(r in n)e=n[r],u=o[r],U(u)?H(e)&&H(u)&&(o[r]=tn(u,e)):o[r]=e;return o},Y=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],r=null,u=0,i=e.length;i>u;u++)if(n=e[u],o=n,F(o)&&(o=o()),I(o)){r=o;break}return r},v=function(t,n){var e,r,o,u;for(r=null,o=0,u=t.length;u>o;o++)if(e=t[o],n(e)){r=e;break}return r},sn=function(t,n){var e;return e=[],g(t,function(t){return n(t)?e.push(t):void 0}),e},rn=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),v(o,I)},B=function(t){return setTimeout(t,0)},X=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},fn=function(t,n,e){var r,o;return o=t.css(L(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},x=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),P(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},m=function(t,n,r){var o,u,i,a,s,c;return o=$(t),up.browser.canCssAnimation()?(r=tn(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":L(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=x(o),c=fn(o,a),o.css(n),u.then(s),u.then(c),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),an())},e="up-animation-promise",C=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},V=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=a(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},l=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},nn=function(t){var n,e;return e=V(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},k=function(t,n){return t.find(n).addBack(n)},b=function(t){return 27===t.keyCode},s=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},R=function(t){return t.getResponseHeader("X-Up-Location")},J=function(t){return t.getResponseHeader("X-Up-Method")},K=function(){var n,e,r,o,u,i;for(o=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],n={},u=0,i=r.length;i>u;u++)e=r[u],o.hasOwnProperty(e)&&(n[e]=o[e]);return n},un=function(){var t;return t=$.Deferred(),t.resolve(),t},an=function(){return un().promise()},on=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return g(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},cn=function(t,n){var e,r,o;o=[];for(e in n)r=n[e],o.push(O(t.attr(e))?t.attr(e,r):void 0);return o},ln=function(t){var n,e,r,o,u,i,a,s;for(u={},n=function(t){return u[r(t)]},e=function(t){return v(t,n)},o=function(t){return u[r(t)]=!0},r=function(t){return"_"+t},a=0,s=t.length;s>a;a++)i=t[a],o(i);return{put:o,includes:n,includesAny:e}},{presentAttr:rn,createElement:p,normalizeUrl:Z,normalizeMethod:Q,createElementFromHtml:f,$createElementFromSelector:n,createSelectorFromElement:d,get:S,ajax:o,extend:w,copy:c,merge:_,options:tn,option:Y,error:y,debug:h,each:g,detect:v,select:sn,last:X,isNull:M,isDefined:D,isUndefined:G,isGiven:U,isMissing:O,isPresent:I,isBlank:P,presence:en,isObject:H,isFunction:F,isString:W,isJQuery:z,isPromise:N,isDeferred:A,isHash:j,ifGiven:T,unwrap:hn,nextFrame:B,measure:V,temporaryCss:fn,cssAnimate:m,finishCssAnimate:C,forceCompositing:x,prependGhost:nn,escapePressed:b,copyAttributes:l,findWithSelf:k,contains:s,isArray:E,toArray:dn,castsToTrue:i,castsToFalse:u,locationFromXhr:R,methodFromXhr:J,clientSize:a,only:K,trim:mn,keys:L,resolvedPromise:an,resolvedDeferred:un,resolvableWhen:on,setMissingAttrs:cn,stringSet:ln}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,c,l;return c=up.util,a=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=c.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",c.isDefined(r)&&c.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},l=function(){return location.href},o=function(){var t,n,e,r,o,u,i,a;return window.console||(window.console={}),t=function(){},(n=window.console).log||(n.log=t),(e=window.console).info||(e.info=t),(r=window.console).error||(r.error=t),(o=window.console).debug||(o.debug=t),(u=window.console).group||(u.group=t),(i=window.console).groupCollapsed||(i.groupCollapsed=t),(a=window.console).groupEnd||(a.groupEnd=t)},s=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=s(function(){return c.isDefined(history.pushState)}),n=s(function(){return"transition"in document.documentElement.style}),e=s(function(){return"oninput"in document.createElement("input")}),u=function(){var t,n,e,r,o;return o=$.fn.jquery,r=o.split("."),n=parseInt(r[0]),e=parseInt(r[1]),t=n>=2||1===n&&e>=9,t||c.error("jQuery %o found, but Up.js requires 1.9+",o)},i=s(function(){return c.isDefined(document.addEventListener)}),{url:l,ensureConsoleExists:o,loadPage:a,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:i,ensureRecentJquery:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s;return s=up.util,n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=s.copy(t));return o},i=function(){return n=s.copy(r)},u=function(t,n){return e(t).push(n)},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],s.debug("Emitting event %o with args %o",o,n),r=e(o),s.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,c,l,p;return p=up.util,s=function(t,n){var e;return e=$(t),p.isPresent(n)&&(n=p.normalizeUrl(n)),e.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),p.presence(n.attr("up-source"))||up.browser.url()},i=function(t,n,e){var o,u,i;return e=p.options(e),i=p.presence(t)?t:p.createSelectorFromElement($(t)),up.browser.canPushState()||p.castsToFalse(e.history)?(u={url:n,method:e.method,selector:i},o=up.proxy.ajax(u),o.done(function(t,o,a){var s,c;return(s=p.locationFromXhr(a))&&(p.debug("Location from server: %o",s),c={url:s,method:p.methodFromXhr(a),selector:i},up.proxy.alias(u,c),n=s),(p.isMissing(e.history)||p.castsToTrue(e.history))&&(e.history=n),(p.isMissing(e.source)||p.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:r(i,t,e)}),o.fail(p.error),o):void(e.preload||up.browser.loadPage(n,p.only(e,"method")))},r=function(t,n,e){var r,u,i,a,s,c,f,d,m,h;for(e=p.options(e,{historyMethod:"push"}),"false"===e.history&&(e.history=null),e.source=p.option(e.source,e.history),a=p.createElementFromHtml(n),e.title||(e.title=null!=(d=a.querySelector("title"))?d.textContent:void 0),m=o(t,e),h=[],c=0,f=m.length;f>c;c++)s=m[c],up.motion.finish(s.selector),u=p.presence($(".up-popup "+s.selector))||p.presence($(".up-modal "+s.selector))||p.presence($(s.selector))||p.error("Could not find selector %o in current body HTML",s.selector),(i=a.querySelector(s.selector))?(r=$(i),h.push(l(u,r,s.pseudoClass,s.transition,e))):h.push(p.error("Could not find selector %o in response %o",s.selector,n));return h},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),s(n,e.source),t(n),up.ready(n)},l=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),p.copyAttributes(r,t),e(a,i),up.animate(r,u)):n(t,{animation:function(){return r.insertAfter(t),e(r,i),t.is("body")&&"none"!==u&&p.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u)}})},o=function(t,n){var e,r,o,u,i,a,s,c,l,f,d;for(s=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),p.isPresent(s)&&(c=s.split(e)),d=[],o=l=0,f=r.length;f>l;o=++l)u=r[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||p.last(c),d.push({selector:i[1],pseudoClass:i[2],transition:a});return d},t=function(t){var n,e;return e="[autofocus]:last",n=p.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var e,r;return e=$(t),n=p.options(n,{animation:"none"}),e.addClass("up-destroying"),p.isPresent(n.url)&&up.history.push(n.url),p.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),r=p.presence(n.animation,p.isPromise)||up.motion.animate(e,n.animation),r.then(function(){return e.remove()})},u=function(t){var n;return n=c(t),i(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:i,reload:u,destroy:n,implant:r,reset:a}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g;return g=up.util,n="up-destroyable",e="up-destroyer",f=[],c=null,p=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},u=[],s=null,o=function(){var n,e,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(e=n.pop(),r=g.options(n[0],{batch:!1}),u.push({selector:o,callback:e,batch:r.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying awakener %o on %o",t.selector,o),u=t.callback.apply(o,[r,a(r)]),g.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},i=function(t){var n,e,o,i,a;for(g.debug("Compiling fragment %o",t),a=[],o=0,i=u.length;i>o;o++)e=u[o],n=g.findWithSelf(t,e.selector),a.push(n.length?e.batch?r(e,n,n.get()):n.each(function(){return r(e,$(this),this)}):void 0);return a},l=function(t){return g.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},a=function(t){var n,e;return n=$(t),e=n.attr("up-data"),g.isString(e)&&""!==g.trim(e)?JSON.parse(e):{}},v=function(){return c=g.copy(f),s=g.copy(u)},h=function(){var t,n,e,r;for(n=0,e=f.length;e>n;n++)t=f[n],g.contains(c,t)||(r=$(document)).off.apply(r,t);return f=g.copy(c),u=g.copy(s)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},d=function(t){return p("keydown","body",function(n){return g.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",i),up.bus.on("fragment:destroy",l),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{awaken:o,on:p,ready:m,onEscape:d,data:a}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,(null!=n?n.fromUp:void 0)?(u.debug("Restoring state %o (now on "+up.browser.url()+")",n),up.visit(up.browser.url(),{historyMethod:"replace"})):u.debug("Discarding unknown state %o",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w;return b=up.util,u={duration:300,delay:0,easing:"ease"},r={},i={},y={},a={},s=function(t){return b.extend(u,t)},n=function(t,e,r){var i;return i=$(t),l(i),r=b.options(r,u),b.isFunction(e)?o(e(i,r),e):b.isString(e)?n(i,c(e),r):b.isHash(e)?b.cssAnimate(i,e,r):b.error("Unknown animation type %o",e)},c=function(t){return r[t]||b.error("Unknown animation %o",e)},t="up-ghosting-promise",w=function(n,e,r){var o,u,i,a;return u=null,o=null,b.temporaryCss(e,{display:"none"},function(){return u=b.prependGhost(n).addClass("up-destroying")}),b.temporaryCss(n,{display:"none"},function(){return o=b.prependGhost(e)}),n.css({visibility:"hidden"}),i=b.temporaryCss(e,{display:"none"}),a=r(u,o),n.data(t,a),e.data(t,a),a.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),i()}),a},l=function(t){return $(t).each(function(){var t;return t=$(this),b.finishCssAnimate(t),p(t)})},p=function(n){var e;return(e=n.data(t))?(b.debug("Canceling existing ghosting on %o",n),"function"==typeof e.resolve?e.resolve():void 0):void 0},o=function(t,n){return b.isDeferred(t)?t:b.error("Did not return a promise with .then and .resolve methods: %o",n)},f=function(t,e,i,a){var s,c,p,m,v;return up.browser.canCssAnimation()?(a=b.options(u),c=$(t),s=$(e),l(c),l(s),"none"===i?d():(v=b.presence(i,b.isFunction)||y[i])?w(c,s,function(t,n){return o(v(t,n,a),i)}):(p=r[i])?(c.hide(),n(s,p,a)):b.isString(i)&&i.indexOf("/")>=0?(m=i.split("/"),v=function(t,e,r){return h(n(t,m[0],r),n(e,m[1],r))},f(c,s,v,a)):b.error("Unknown transition %o",i)):b.resolvedDeferred()},g=function(t,n){return y[t]=n},e=function(t,n){return r[t]=n},v=function(){return i=b.copy(r),a=b.copy(y)},m=function(){return r=b.copy(i),y=b.copy(a)},h=b.resolvableWhen,d=b.resolvedDeferred,e("none",d),e("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),e("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),e("move-to-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),e("move-from-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),e("move-from-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),e("move-from-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),e("move-to-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),e("move-from-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),e("roll-down",function(t,e){var r,o;return r=t.height(),o=b.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),g("none",d),g("move-left",function(t,e,r){return h(n(t,"move-to-left",r),n(e,"move-from-right",r))}),g("move-right",function(t,e,r){return h(n(t,"move-to-right",r),n(e,"move-from-left",r))}),g("move-up",function(t,e,r){return h(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),g("move-down",function(t,e,r){return h(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),g("cross-fade",function(t,e,r){return h(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",v),up.bus.on("framework:reset",m),{morph:f,animate:n,finish:l,transition:g,animation:e,defaults:s,none:d,when:h}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.proxy=function(){var t,n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w,k,$,C,x,S;return c={preloadDelay:50,cacheSize:70,cacheExpiry:3e5},l=function(t){return S.extend(c,t)},o={},S=up.util,t=null,p=null,u=function(t){return v(t),[t.url,t.method,t.selector].join("|")},x=function(){var t,n,e;return t=S.keys(o),t.length>c.cacheSize&&(n=null,e=null,S.each(t,function(t){var r,u;return r=o[t],u=r.timestamp,!e||e>u?(n=t,e=u):void 0}),n)?delete o[n]:void 0},$=function(){return(new Date).valueOf()},v=function(t){return!S.isHash(t),t._requestNormalized||(t.method=S.normalizeMethod(t.method),t.url&&(t.url=S.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._requestNormalized=!0),t},r=function(t,n){var e;return S.debug("Aliasing %o to %o",t,n),(e=d(t))?w(n,e):void 0},e=function(t){var n;return h(t)?(n=d(t))?C(n):(n=S.ajax(t),w(t,n)):(s(),n=S.ajax(t)),n},n=["GET","OPTIONS","HEAD"],h=function(t){return v(t),S.contains(n,t.method)},f=function(t){return h(t)||S.error("Won't preload non-GET request %o",t)},m=function(t){var n;return n=$()-t.timestamp,n<c.cacheExpiry},C=function(t){return t.timestamp=$()},d=function(t){var n,e;return n=u(t),(e=o[n])?m(e)?(S.debug("Cache hit for %o (%o)",t.url,t),e):(S.debug("Discarding stale cache entry for %o (%o)",t.url,t),void y(t)):void S.debug("Cache miss for %o (%o)",t.url,t)},w=function(t,n){var e;return x(),e=u(t),o[e]=n,C(n),n},y=function(t){var n;return n=u(t),delete o[n]},s=function(){return o={}},a=function(n){var e,r;return r=parseInt(S.presentAttr(n,"up-delay"))||c.preloadDelay,n.is(t)?void 0:(t=n,i(),e=function(){return g(n)},k(e,r))},k=function(t,n){return p=setTimeout(t,n)},i=function(){return clearTimeout(p),p=null},g=function(t,n){return n=S.options(),f(n),S.debug("Preloading %o",t),n.preload=!0,up.link.follow(t,n)},b=function(){return i(),o={}},up.bus.on("framework:reset",b),up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:a(up.link.resolve(n))}),{preload:g,ajax:e,get:d,set:w,alias:r,clear:s,defaults:l}}()}.call(this),function(){up.link=function(){var t,n,e,r,o;return r=up.util,o=function(t,n){return r.debug("Visiting "+t),up.replace("body",t,n)},n=function(t,n){var e,o,u;return e=$(t),n=r.options(n),u=r.option(e.attr("href"),e.attr("up-follow")),o=r.option(n.target,e.attr("up-target"),"body"),n.transition=r.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=r.option(n.history,e.attr("up-history")),up.replace(o,u,n)},e=function(t){var n,e;return n=$(t),e=n.attr("up-follow"),n.is("a")||r.isPresent(e)&&!r.castsToTrue(e)?n:n.find("a:first")},up.on("click","a[up-target]",function(t,e){return t.preventDefault(),e.is("[up-instant]")?void 0:n(e)}),up.on("mousedown","a[up-target][up-instant]",function(t,e){return 1===t.which?(t.preventDefault(),n(e)):void 0}),t=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-follow]"),r.length&&n.find(r).length},up.on("click","[up-follow]",function(r,o){return t(r,o)||(r.preventDefault(),o.is("[up-instant]"))?void 0:n(e(o))}),up.on("mousedown","[up-follow][up-instant]",function(r,o){return t(r,o)||1!==r.which?void 0:(r.preventDefault(),n(e(o)))}),up.awaken("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},r.isBlank(e)||r.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,r.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{visit:o,follow:n,resolve:e,childClicked:t}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,c,l,p,f;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),r=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),i=u.option(n.history,e.attr("up-history"),!0),l=u.option(n.transition,e.attr("up-transition")),o=u.option(n.failTransition,e.attr("up-fail-transition")),a=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),f=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(i)?(s={url:f,type:a,data:e.serialize(),selector:c},p=function(t){var n;return f=i?"false"===i?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){return up.flow.implant(c,t,{history:p(e),transition:l})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(r,n,{transition:o})})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("up.observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,c,l;return c=up.util,e={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(e,t)},a=function(t,n,e){var r,o;return o=c.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return c.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r),u(n)},u=function(t){var n,e,r,o,u,i,a;if(e=c.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},r=function(t,n,e){var r,o;return o=c.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),r=c.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),o.hide(),o},l=function(t,n,e,r){return n.show(),a(t,n,e),up.animate(n,r)},i=function(t,o){var u,i,a,s,p,f,d,m;return u=$(t),o=c.options(o),m=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),p=c.option(o.origin,u.attr("up-origin"),e.origin),a=c.option(o.animation,u.attr("up-animation"),e.openAnimation),d=c.option(o.sticky,u.is("[up-sticky]")),s=up.browser.canPushState()?c.option(o.history,u.attr("up-history"),!1):!1,n(),i=r(u,f,d),up.replace(f,m,{history:s,insert:function(){return l(u,i,p,a)}})},s=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=c.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():i(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,e,r,o,u,i,a,s,c;return s=up.util,e={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return s.extend(e,t)},a=function(){var t;return t=e.template,s.isFunction(t)?t(e):t},r=function(t,n,e,r){var o,u,i,c;return i=$(a()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),s.isPresent(n)&&u.css("width",n),s.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),i.appendTo(document.body),i.hide(),i},c=function(t,n){return t.show(),up.animate(t,n)},u=function(t,o){var u,i,a,l,p,f,d,m,h;return u=$(t),o=s.options(o),m=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),e.width),l=s.option(o.height,u.attr("up-height"),e.height),a=s.option(o.animation,u.attr("up-animation"),e.openAnimation),d=s.option(o.sticky,u.is("[up-sticky]")),p=up.browser.canPushState()?s.option(o.history,u.attr("up-history"),!0):!1,n(),i=r(f,h,l,d),up.replace(f,m,{history:p,insert:function(){return c(i,a)}})},i=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-modal"),n.length?(t=s.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:n()},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():u(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:i,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,c,l;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),l=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),r(i,a,l),up.animate(a,s,u)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,c,l;
2
- return c=up.util,t="up-active",n="up-current",r="a[href], a[up-target], [up-follow], [up-modal], [up-popup], [up-source]",e="."+t,i=function(t){return c.isPresent(t)?c.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},s=function(t){var n,e,r,o,u,a,s;if(o=[],n=up.link.resolve(t))for(s=["href","up-follow","up-source"],u=0,a=s.length;a>u;u++)e=s[u],(r=c.presentAttr(n,e))&&(r=i(r),o.push(r));return o},u=function(){var t;return t=c.stringSet([i(up.browser.url()),i(up.modal.source()),i(up.popup.source())]),c.each($(r),function(e){var r,o;return r=$(e),o=s(r),t.includesAny(o)?r.addClass(n):r.removeClass(n)})},a=function(n){return l(),n=o(n),n.addClass(t)},o=function(t){return c.presence(t.parents(r))||t},l=function(){return $(e).removeClass(t)},up.on("click",r,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return l(),u()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?u():void 0})}()}.call(this),function(){up.marker=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.ensureRecentJquery(),up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
1
+ (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,C,x,T,S,E,A,P,D,U,F,j,z,M,O,H,I,N,q,W,G,L,X,R,V,B,J,_,K,Q,Z,Y,tn,nn,en,rn,on,un,an,sn,ln,cn,pn,fn,dn,mn,hn,vn,gn;return T=function(t,n){return n=n||{},n.url=t,o(n)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},q=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},Y=function(t,n){var e,r,o;return e=W(t)?$("<a>").attr({href:t}).get(0):gn(t),r=e.protocol+"//"+e.hostname,q(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},Z=function(t){return t?t.toUpperCase():"GET"},n=function(t){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v;for(h=t.split(/[ >]/),r=null,c=p=0,d=h.length;d>p;c=++p){for(i=h[c],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),v="div",o=[],l=null,f=0,m=u.length;m>f;f++)switch(a=u[f],a[0]){case".":o.push(a.substr(1));break;case"#":l=a.substr(1);break;default:v=a}s="<"+v,o.length&&(s+=' class="'+o.join(" ")+'"'),l&&(s+=' id="'+l+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===c&&(r=n),e=n}return r},p=function(t,n){var e;return e=document.createElement(t),I(n)&&(e.innerHTML=n),e},h=function(){var n,e,o,u,i,a;if(n=1<=arguments.length?t.call(arguments,0):[],n=hn(n),o=n.shift(),o="[UP] "+o,u=(null!=(i=o.match(r))?i.length:void 0)||0,U(V(n))&&u<n.length&&(e=n.pop()),a=console.debug.apply(console,[o].concat(t.call(n))),e){console.groupCollapsed();try{a=e()}finally{console.groupEnd()}}return a},y=function(){var n,e,r;throw e=1<=arguments.length?t.call(arguments,0):[],e[0]="[UP] "+e[0],console.error.apply(console,e),r=dn(e),n=on($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),r},r=/\%[odisf]/g,dn=function(t){var n,e,o;return o=t[0],n=0,e=30,o.replace(r,function(){var r,o;return n+=1,r=t[n],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>e&&(r=r.substr(0,e)+"\u2026"),'"'+r+'"'):"number"===o?r.toString():"("+o+")"})},d=function(t){var n,e,r,o,u,i,a;for(h("Creating selector from element %o",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),a=t.prop("tagName").toLowerCase(),r&&(a+="#"+r),o=0,i=e.length;i>o;o++)u=e[o],a+="."+u;return a},f=function(t){var n,e,r,o,u,i,a,s,l,c,f,d;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(l("head")+n+l("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(l("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=p("body",r[1]),s.appendChild(e),(f=t.match(d))&&(a=p("head"),s.appendChild(a),c=p("title",f[1]),a.appendChild(c)),s):p("div",t)},w=$.extend,vn=$.trim,R=Object.keys||function(t){var n,e,r,o;for(o=[],n=0,r=t.length;r>n;n++)e=t[n],t.hasOwnProperty(e)&&o.push(e);return o},g=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},O=function(t){return null===t},G=function(t){return void 0===t},D=function(t){return!G(t)},M=function(t){return G(t)||O(t)},F=function(t){return!M(t)},A=function(t){return M(t)||H(t)&&0===R(t).length||0===t.length},on=function(t,n){return null==n&&(n=I),n(t)?t:null},I=function(t){return!A(t)},U=function(t){return"function"==typeof t},W=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},H=function(t){return j(t)||"function"==typeof t},z=function(t){return t instanceof jQuery},N=function(t){return H(t)&&U(t.then)},P=function(t){return N(t)&&U(t.resolve)},S=function(t){return F(t)?t:void 0},E=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},hn=function(t){return Array.prototype.slice.call(t)},l=function(t){return E(t)?t.slice():w({},t)},gn=function(t){return z(t)?t.get(0):t},_=function(t,n){return w(l(t),n)},en=function(t,n){var e,r,o,u;if(o=t?l(t):{},n)for(r in n)e=n[r],u=o[r],F(u)?H(e)&&H(u)&&(o[r]=en(u,e)):o[r]=e;return o},nn=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],u=null,r=0,o=e.length;o>r;r++)if(n=e[r],i=n,U(i)&&(i=i()),I(i)){u=i;break}return u},v=function(t,n){var e,r,o,u;for(u=null,r=0,o=t.length;o>r;r++)if(e=t[r],n(e)){u=e;break}return u},cn=function(t,n){var e;return e=[],g(t,function(t){return n(t)?e.push(t):void 0}),e},un=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),v(o,I)},Q=function(t){return setTimeout(t,0)},V=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},mn=function(t,n,e){var r,o;return o=t.css(R(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},x=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),A(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},m=function(t,n,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=en(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":R(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=x(o),l=mn(o,a),o.css(n),u.then(s),u.then(l),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),ln())},e="up-animation-promise",C=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},J=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=a(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},c=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},rn=function(t){var n,e;return e=J(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},k=function(t,n){return t.find(n).addBack(n)},b=function(t){return 27===t.keyCode},s=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},B=function(t){return t.getResponseHeader("X-Up-Location")},K=function(t){return t.getResponseHeader("X-Up-Method")},tn=function(){var n,e,r,o,u,i;for(i=arguments[0],o=2<=arguments.length?t.call(arguments,1):[],n={},e=0,u=o.length;u>e;e++)r=o[e],i.hasOwnProperty(r)&&(n[r]=i[r]);return n},L=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},X=function(t){return 0===t.button&&L(t)},sn=function(){var t;return t=$.Deferred(),t.resolve(),t},ln=function(){return sn().promise()},an=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return g(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},pn=function(t,n){var e,r,o;r=[];for(e in n)o=n[e],r.push(M(t.attr(e))?t.attr(e,o):void 0);return r},fn=function(t){var n,e,r,o,u,i,a,s;for(a={},n=function(t){return a[o(t)]},e=function(t){return v(t,n)},i=function(t){return a[o(t)]=!0},o=function(t){return"_"+t},r=0,u=t.length;u>r;r++)s=t[r],i(s);return{put:i,includes:n,includesAny:e}},{presentAttr:un,createElement:p,normalizeUrl:Y,normalizeMethod:Z,createElementFromHtml:f,$createElementFromSelector:n,createSelectorFromElement:d,get:T,ajax:o,extend:w,copy:l,merge:_,options:en,option:nn,error:y,debug:h,each:g,detect:v,select:cn,last:V,isNull:O,isDefined:D,isUndefined:G,isGiven:F,isMissing:M,isPresent:I,isBlank:A,presence:on,isObject:H,isFunction:U,isString:W,isJQuery:z,isPromise:N,isDeferred:P,isHash:j,ifGiven:S,isUnmodifiedKeyEvent:L,isUnmodifiedMouseEvent:X,unwrap:gn,nextFrame:Q,measure:J,temporaryCss:mn,cssAnimate:m,finishCssAnimate:C,forceCompositing:x,prependGhost:rn,escapePressed:b,copyAttributes:c,findWithSelf:k,contains:s,isArray:E,toArray:hn,castsToTrue:i,castsToFalse:u,locationFromXhr:B,methodFromXhr:K,clientSize:a,only:tn,trim:vn,keys:R,resolvedPromise:ln,resolvedDeferred:sn,resolvableWhen:an,setMissingAttrs:pn,stringSet:fn}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,l,c;return l=up.util,a=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=l.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",l.isDefined(r)&&l.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},c=function(){return location.href},o=function(){var t,n,e,r,o,u,i,a;return window.console||(window.console={}),a=function(){},(t=window.console).log||(t.log=a),(n=window.console).info||(n.info=a),(e=window.console).error||(e.error=a),(r=window.console).debug||(r.debug=a),(o=window.console).group||(o.group=a),(u=window.console).groupCollapsed||(u.groupCollapsed=a),(i=window.console).groupEnd||(i.groupEnd=a)},s=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=s(function(){return l.isDefined(history.pushState)}),n=s(function(){return"transition"in document.documentElement.style}),e=s(function(){return"oninput"in document.createElement("input")}),u=function(){var t,n,e,r,o;return o=$.fn.jquery,r=o.split("."),n=parseInt(r[0]),e=parseInt(r[1]),t=n>=2||1===n&&e>=9,t||l.error("jQuery %o found, but Up.js requires 1.9+",o)},i=s(function(){return l.isDefined(document.addEventListener)}),{url:c,ensureConsoleExists:o,loadPage:a,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:i,ensureRecentJquery:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s;return s=up.util,n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=s.copy(t));return o},i=function(){return n=s.copy(r)},u=function(t,n){return e(t).push(n)},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],s.debug("Emitting event %o with args %o",o,n),r=e(o),s.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.viewport=function(){var t,n,e,r,o,u,i;return i=up.util,n={duration:0,view:"body",easing:"swing"},e=function(t){return i.extend(n,t)},t="up-scroll-promise",u=function(e,o,u){var a,s,l,c,p;return a=$(e),u=i.options(u),l=i.option(u.duration,n.duration),c=i.option(u.easing,n.easing),r(a),l>0?(s=$.Deferred(),a.data(t,s),s.then(function(){return a.removeData(t),a.finish()}),p={scrollTop:o},a.animate(p,{duration:l,easing:c,complete:function(){return s.resolve()}}),s):(a.scrollTop(o),i.resolvedDeferred())},r=function(n){return $(n).each(function(){var n;return(n=$(this).data(t))?n.resolve():void 0})},o=function(t,e){var r,o,a,s,l,c,p,f,d,m,h;return e=i.options(e),m=i.option(e.view,n.view),f=i.option(e.padding,n.padding),r=$(t),o=$(m),h=o.height(),d=o.scrollTop(),c=d,p=d+h,l=r.position().top,a=c>l-f,s=l>p-f,a||s?(d=l-f,d=Math.max(d,0),d=Math.min(d,h-1),u(o,d,e)):i.resolvedDeferred()},{reveal:o,scroll:u,finishScrolling:r,defaults:e}}(),up.scroll=up.viewport.scroll,up.reveal=up.viewport.reveal}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h;return h=up.util,f=function(t,n){var e;return e=$(t),h.isPresent(n)&&(n=h.normalizeUrl(n)),e.attr("up-source",n)},d=function(t){var n;return n=$(t).closest("[up-source]"),h.presence(n.attr("up-source"))||up.browser.url()},l=function(t,n,e){var r,u,i;return e=h.options(e),i=h.presence(t)?t:h.createSelectorFromElement($(t)),up.browser.canPushState()||h.castsToFalse(e.history)?(u={url:n,method:e.method,selector:i},r=up.proxy.ajax(u),r.done(function(t,r,a){var s,l;return(s=h.locationFromXhr(a))&&(h.debug("Location from server: %o",s),l={url:s,method:h.methodFromXhr(a),selector:i},up.proxy.alias(u,l),n=s),(h.isMissing(e.history)||h.castsToTrue(e.history))&&(e.history=n),(h.isMissing(e.source)||h.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:o(i,t,e)}),r.fail(h.error),r):void(e.preload||up.browser.loadPage(n,h.only(e,"method")))},o=function(t,n,e){var o,s,l,c,p,f,d,v;for(e=h.options(e,{historyMethod:"push"}),h.castsToFalse(e.history)&&(e.history=null),h.castsToFalse(e.scroll)&&(e.scroll=null),e.source=h.option(e.source,e.history),f=i(n),e.title||(e.title=f.title()),p=u(t,e),d=[],l=0,c=p.length;c>l;l++)v=p[l],s=r(v.selector),o=f.find(v.selector),d.push(a(s,e).then(function(){return m(s,o,v.pseudoClass,v.transition,e)}));return d},r=function(t){return h.presence($(".up-popup "+t))||h.presence($(".up-modal "+t))||h.presence($(t))||h.error("Could not find selector %o in current body HTML",t)},i=function(t){var n;return n=h.createElementFromHtml(t),{title:function(){var t;return null!=(t=n.querySelector("title"))?t.textContent:void 0},find:function(e){var r;return(r=n.querySelector(e))?$(r):h.error("Could not find selector %o in response %o",e,t)}}},a=function(t,n){return up.motion.finish(t),p(t,n.scroll)},p=function(t,n){return n?up.reveal(t,{view:n}):h.resolvedDeferred()},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),f(n,e.source),t(n),up.ready(n)},m=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),h.copyAttributes(r,t),e(a,i),up.animate(r,u)):n(t,{animation:function(){return r.insertBefore(t),e(r,i),t.is("body")&&"none"!==u&&h.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u)}})},u=function(t,n){var e,r,o,u,i,a,s,l,c,p,f;for(p=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),h.isPresent(p)&&(f=p.split(e)),a=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],l=s.match(/^(.+?)(?:\:(before|after))?$/),c=f[o]||h.last(f),a.push({selector:l[1],pseudoClass:l[2],transition:c});return a},t=function(t){var n,e;return e="[autofocus]:last",n=h.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var e,r;return e=$(t),n=h.options(n,{animation:"none"}),e.addClass("up-destroying"),h.isPresent(n.url)&&up.history.push(n.url),h.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),r=h.presence(n.animation,h.isPromise)||up.motion.animate(e,n.animation),r.then(function(){return e.remove()})},s=function(t){var n;return n=d(t),l(t,n)},c=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return f(document.body,up.browser.url())}),{replace:l,reload:s,destroy:n,implant:o,reset:c}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,n="up-destroyable",e="up-destroyer",f=[],l=null,p=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},u=[],s=null,o=function(){var n,e,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(e=n.pop(),r=g.options(n[0],{batch:!1}),u.push({selector:o,callback:e,batch:r.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying awakener %o on %o",t.selector,o),u=t.callback.apply(o,[r,a(r)]),g.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},i=function(t){var n,e,o,i,a;for(g.debug("Compiling fragment %o",t),a=[],o=0,i=u.length;i>o;o++)e=u[o],n=g.findWithSelf(t,e.selector),a.push(n.length?e.batch?r(e,n,n.get()):n.each(function(){return r(e,$(this),this)}):void 0);return a},c=function(t){return g.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},a=function(t){var n,e;return n=$(t),e=n.attr("up-data"),g.isString(e)&&""!==g.trim(e)?JSON.parse(e):{}},v=function(){return l=g.copy(f),s=g.copy(u)},h=function(){var t,n,e,r;for(n=0,e=f.length;e>n;n++)t=f[n],g.contains(l,t)||(r=$(document)).off.apply(r,t);return f=g.copy(l),u=g.copy(s)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},d=function(t){return p("keydown","body",function(n){return g.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",i),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{awaken:o,on:p,ready:m,onEscape:d,data:a}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,(null!=n?n.fromUp:void 0)?(u.debug("Restoring state %o (now on "+up.browser.url()+")",n),up.visit(up.browser.url(),{historyMethod:"replace"})):u.debug("Discarding unknown state %o",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w;return b=up.util,r={},i={},y={},a={},u={duration:300,delay:0,easing:"ease"},s=function(t){return b.extend(u,t)},n=function(t,e,r){var i;return i=$(t),c(i),r=b.options(r,u),b.isFunction(e)?o(e(i,r),e):b.isString(e)?n(i,l(e),r):b.isHash(e)?b.cssAnimate(i,e,r):b.error("Unknown animation type %o",e)},l=function(t){return r[t]||b.error("Unknown animation %o",e)},t="up-ghosting-promise",w=function(n,e,r){var o,u,i,a;return u=null,o=null,b.temporaryCss(e,{display:"none"},function(){return u=b.prependGhost(n).addClass("up-destroying")}),b.temporaryCss(n,{display:"none"},function(){return o=b.prependGhost(e)}),n.css({visibility:"hidden"}),i=b.temporaryCss(e,{display:"none"}),a=r(u,o),n.data(t,a),e.data(t,a),a.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),i()}),a},c=function(t){return $(t).each(function(){var t;return t=$(this),b.finishCssAnimate(t),p(t)})},p=function(n){var e;return(e=n.data(t))?(b.debug("Canceling existing ghosting on %o",n),"function"==typeof e.resolve?e.resolve():void 0):void 0},o=function(t,n){return b.isDeferred(t)?t:b.error("Did not return a promise with .then and .resolve methods: %o",n)},f=function(t,e,i,a){var s,l,p,m,v;return up.browser.canCssAnimation()?(a=b.options(u),l=$(t),s=$(e),c(l),c(s),"none"===i?d():(v=b.presence(i,b.isFunction)||y[i])?w(l,s,function(t,n){return o(v(t,n,a),i)}):(p=r[i])?(l.hide(),n(s,p,a)):b.isString(i)&&i.indexOf("/")>=0?(m=i.split("/"),v=function(t,e,r){return h(n(t,m[0],r),n(e,m[1],r))},f(l,s,v,a)):b.error("Unknown transition %o",i)):b.resolvedDeferred()},g=function(t,n){return y[t]=n},e=function(t,n){return r[t]=n},v=function(){return i=b.copy(r),a=b.copy(y)},m=function(){return r=b.copy(i),y=b.copy(a)},h=b.resolvableWhen,d=b.resolvedDeferred,e("none",d),e("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),e("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),e("move-to-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),e("move-from-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),e("move-from-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),e("move-from-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),e("move-to-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),e("move-from-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),e("roll-down",function(t,e){var r,o;return r=t.height(),o=b.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),g("none",d),g("move-left",function(t,e,r){return h(n(t,"move-to-left",r),n(e,"move-from-right",r))}),g("move-right",function(t,e,r){return h(n(t,"move-to-right",r),n(e,"move-from-left",r))}),g("move-up",function(t,e,r){return h(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),g("move-down",function(t,e,r){return h(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),g("cross-fade",function(t,e,r){return h(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",v),up.bus.on("framework:reset",m),{morph:f,animate:n,finish:c,transition:g,animation:e,defaults:s,none:d,when:h}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.proxy=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,$,C,x,T;return l={preloadDelay:75,cacheSize:70,cacheExpiry:3e5},c=function(t){return T.extend(l,t)},o={},T=up.util,t=null,p=null,u=function(t){return v(t),[t.url,t.method,t.selector].join("|")},x=function(){var t,n,e;return t=T.keys(o),t.length>l.cacheSize&&(n=null,e=null,T.each(t,function(t){var r,u;return r=o[t],u=r.timestamp,!e||e>u?(n=t,e=u):void 0}),n)?delete o[n]:void 0},$=function(){return(new Date).valueOf()},v=function(t){return!T.isHash(t),t._requestNormalized||(t.method=T.normalizeMethod(t.method),t.url&&(t.url=T.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._requestNormalized=!0),t},r=function(t,n){var e;return T.debug("Aliasing %o to %o",t,n),(e=d(t))?w(n,e):void 0},e=function(t){var n;return h(t)?(n=d(t))?C(n):(n=T.ajax(t),w(t,n)):(s(),n=T.ajax(t)),n},n=["GET","OPTIONS","HEAD"],h=function(t){return v(t),T.contains(n,t.method)},f=function(t){return h(t)||T.error("Won't preload non-GET request %o",t)},m=function(t){var n;return n=$()-t.timestamp,n<l.cacheExpiry},C=function(t){return t.timestamp=$()},d=function(t){var n,e;return n=u(t),(e=o[n])?m(e)?(T.debug("Cache hit for %o (%o)",t.url,t),e):(T.debug("Discarding stale cache entry for %o (%o)",t.url,t),void y(t)):void T.debug("Cache miss for %o (%o)",t.url,t)},w=function(t,n){var e;return x(),e=u(t),o[e]=n,C(n),n},y=function(t){var n;return n=u(t),delete o[n]},s=function(){return o={}},a=function(n){var e,r;return r=parseInt(T.presentAttr(n,"up-delay"))||l.preloadDelay,n.is(t)?void 0:(t=n,i(),e=function(){return g(n)},k(e,r))},k=function(t,n){return p=setTimeout(t,n)},i=function(){return clearTimeout(p),p=null},g=function(t,n){return n=T.options(),f(n),T.debug("Preloading %o",t),n.preload=!0,up.link.follow(t,n)},b=function(){return i(),o={}},up.bus.on("framework:reset",b),up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:a(up.link.resolve(n))}),{preload:g,ajax:e,get:d,set:w,alias:r,clear:s,defaults:c}}()}.call(this),function(){up.link=function(){var t,n,e,r,o,u;return o=up.util,u=function(t,n){return o.debug("Visiting "+t),up.replace("body",t,n)},e=function(t,n){var e,r,u;return e=$(t),n=o.options(n),u=o.option(e.attr("href"),e.attr("up-follow")),r=o.option(n.target,e.attr("up-target"),"body"),n.transition=o.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=o.option(n.history,e.attr("up-history")),n.scroll=o.option(n.history,e.attr("up-scroll"),"body"),up.replace(r,u,n)},r=function(t){var n,e;return n=$(t),e=n.attr("up-follow"),n.is("a")||o.isPresent(e)&&!o.castsToTrue(e)?n:n.find("a:first")},up.on("click","a[up-target]",function(t,n){return t.preventDefault(),n.is("[up-instant]")?void 0:e(n)}),up.on("mousedown","a[up-target][up-instant]",function(n,e){return t(n,e)?(n.preventDefault(),up.follow(e)):void 0}),n=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-follow]"),r.length&&n.find(r).length},t=function(t,e){return o.isUnmodifiedMouseEvent(t)&&!n(t,e)},up.on("click","[up-follow]",function(t,o){return n(t,o)||(t.preventDefault(),o.is("[up-instant]"))?void 0:e(r(o))}),up.on("mousedown","[up-follow][up-instant]",function(n,e){return t(n,e)?(n.preventDefault(),up.follow(r(e))):void 0}),up.awaken("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},o.isBlank(e)||o.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,o.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{visit:u,follow:e,resolve:r,childClicked:n}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,l,c,p,f;return e=$(t).closest("form"),n=u.options(n),l=u.option(n.target,e.attr("up-target"),"body"),r=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),i=u.option(n.history,e.attr("up-history"),!0),c=u.option(n.transition,e.attr("up-transition")),o=u.option(n.failTransition,e.attr("up-fail-transition")),a=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),f=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(i)?(s={url:f,type:a,data:e.serialize(),selector:l},p=function(t){var n;return f=i?u.castsToFalse(i)?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){return up.flow.implant(l,t,{history:p(e),transition:c})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(r,n,{transition:o})})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("up.observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=u.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f;return p=up.util,e={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return p.extend(e,t)},s=function(t,n,e){var r,o;return o=p.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return p.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r),i(n)},i=function(t){var n,e,r,o,u,i,a;if(e=p.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},l=function(){var t;return t=$(".up-popup"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},u=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},r=function(t,n,e){var r,o;return o=p.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),r=p.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),l(),o.hide(),o},f=function(t,n,e,r){return n.show(),s(t,n,e),up.animate(n,r)},a=function(t,o){var u,i,a,s,l,c,d,m;return u=$(t),o=p.options(o),m=p.option(u.attr("href")),c=p.option(o.target,u.attr("up-popup"),"body"),l=p.option(o.origin,u.attr("up-origin"),e.origin),a=p.option(o.animation,u.attr("up-animation"),e.openAnimation),d=p.option(o.sticky,u.is("[up-sticky]")),s=up.browser.canPushState()?p.option(o.history,u.attr("up-history"),!1):!1,n(),i=r(u,c,d),up.replace(c,m,{history:s,insert:function(){return f(u,i,l,a)}})},c=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=p.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():a(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:(u(),t())}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:a,close:n,source:c,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,e,r,o,u,i,a,s,l,c,p;return c=up.util,e={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return c.extend(e,t)},l=function(){var t;return t=e.template,c.isFunction(t)?t(e):t},a=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},u=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},r=function(t,n,e,r){var o,u,i,s;return i=$(l()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),c.isPresent(n)&&u.css("width",n),c.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),s=c.$createElementFromSelector(t),s.appendTo(o),i.appendTo(document.body),a(),i.hide(),i},p=function(t,n){return t.show(),up.animate(t,n)},i=function(t,o){var u,i,a,s,l,f,d,m,h;return u=$(t),o=c.options(o),m=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-modal"),"body"),h=c.option(o.width,u.attr("up-width"),e.width),s=c.option(o.height,u.attr("up-height"),e.height),a=c.option(o.animation,u.attr("up-animation"),e.openAnimation),d=c.option(o.sticky,u.is("[up-sticky]")),l=up.browser.canPushState()?c.option(o.history,u.attr("up-history"),!0):!1,n(),i=r(f,h,s,d),up.replace(f,m,{history:l,insert:function(){return p(i,a)}})},s=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")
2
+ },n=function(t){var n;return n=$(".up-modal"),n.length?(t=c.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:(u(),n())},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():i(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,l,c;return null==u&&(u={}),i=$(e),l=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),c=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(l),r(i,a,c),up.animate(a,s,u)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d;return f=up.util,t="up-active",n="up-current",e=["a[href]","a[up-target]","[up-follow]","[up-modal]","[up-popup]","[up-href]"],o=e.join(", "),u=function(){var t,n,r;for(r=[],t=0,n=e.length;n>t;t++)p=e[t],r.push(p+"[up-instant]");return r}().join(", "),r="."+t,s=function(t){return f.isPresent(t)?f.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},c=function(t){var n,e,r,o,u,i,a;if(a=[],n=up.link.resolve(t))for(u=["href","up-follow","up-href"],r=0,o=u.length;o>r;r++)e=u[r],(i=f.presentAttr(n,e))&&(i=s(i),a.push(i));return a},a=function(){var t;return t=f.stringSet([s(up.browser.url()),s(up.modal.source()),s(up.popup.source())]),f.each($(o),function(e){var r,o;return r=$(e),o=c(r),t.includesAny(o)?r.addClass(n):r.removeClass(n)})},l=function(n){return d(),n=i(n),n.addClass(t)},i=function(t){return f.presence(t.parents(o))||t},d=function(){return $(r).removeClass(t)},up.on("click",o,function(t,n){return n.is("[up-instant]")?void 0:l(n)}),up.on("mousedown",u,function(t,n){return f.isUnmodifiedMouseEvent(t)?l(n):void 0}),up.bus.on("fragment:ready",function(){return d(),a()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?a():void 0})}()}.call(this),function(){up.marker=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.ensureRecentJquery(),up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
@@ -1,7 +1,10 @@
1
1
  ###*
2
2
  Browser interface
3
3
  =================
4
-
4
+
5
+ Some browser-interfacing methods and switches that we can't currently get rid off.
6
+
7
+ @protected
5
8
  @class up.browser
6
9
  ###
7
10
  up.browser = (->
@@ -1,25 +1,44 @@
1
1
  ###*
2
2
  Framework events
3
3
  ================
4
-
5
- This class is kind-of internal and in constant flux.
6
-
7
- The framework event bus might eventually be rolled
8
- into regular document events.
9
4
 
10
- \#\#\# Available events
5
+ Up.js uses an internal event bus that you can use to hook into lifecycle events like "an HTML fragment into the DOM".
11
6
 
12
- - `app:ready`
13
- - `fragment:ready` with arguments `($fragment)`
14
- - `fragment:destroy` with arguments `($fragment)`
7
+ This internal event bus might eventually be rolled into regular events that we trigger on `document`.
8
+
9
+ \#\#\# `fragment:ready` event
10
+
11
+ This event is triggered after Up.js has inserted an HTML fragment into the DOM through mechanisms like [`[up-target]`](/up.flow#up-target) or [`up.replace`](/up.flow#up.replace):
12
+
13
+ up.bus.on('fragment:ready', function($fragment) {
14
+ console.log("Looks like we have a new %o!", $fragment);
15
+ });
16
+
17
+ The event is triggered *before* Up has compiled the fragment with your [custom behavior](/up.magic).
18
+ Upon receiving the event, Up.js will start compilation.
19
+
20
+
21
+ \#\#\# `fragment:destroy` event
22
+
23
+ This event is triggered when Up.js is destroying an HTML fragment, e.g. because it's being replaced
24
+ with a new version or because someone explicitly called [`up.destroy`](/up.flow#up.destroy):
25
+
26
+ up.bus.on('fragment:destroy', function($fragment) {
27
+ console.log("Looks like we lost %o!", $fragment);
28
+ });
29
+
30
+ After triggering this event, Up.js will remove the fragment from the DOM.
31
+ In case the fragment destruction is animated, Up.js will complete the
32
+ animation before removing the fragment from the DOM.
33
+
15
34
 
16
35
  \#\#\# Incomplete documentation!
17
36
 
18
37
  We need to work on this page:
19
38
 
20
39
  - Decide whether to refactor this into document events
21
- - Document events
22
-
40
+ - Decide whether `fragment:enter` and `fragment:leave` would be better names
41
+
23
42
 
24
43
  @class up.bus
25
44
  ###
@@ -71,8 +90,22 @@ up.bus = (->
71
90
  callbacksFor(eventName).push(handler)
72
91
 
73
92
  ###*
74
- Triggers an event.
75
-
93
+ Triggers an event over the framework bus.
94
+
95
+ All arguments will be passed as arguments to event listeners:
96
+
97
+ up.bus.on('foo:bar', function(x, y) {
98
+ console.log("Value of x is " + x);
99
+ console.log("Value of y is " + y);
100
+ });
101
+
102
+ up.bus.emit('foo:bar', 'arg1', 'arg2')
103
+
104
+ // This prints to the console:
105
+ //
106
+ // Value of x is arg1
107
+ // Value of y is arg2
108
+
76
109
  @method up.bus.emit
77
110
  @param {String} eventName
78
111
  The name of the event.
@@ -81,14 +81,16 @@ up.link = (->
81
81
  Visits the given URL without a full page load.
82
82
  This is done by fetching `url` through an AJAX request
83
83
  and replacing the current `<body>` element with the response's `<body>` element.
84
-
84
+
85
+ For example, this would fetch the `/users` URL:
86
+
87
+ up.visit('/users')
88
+
85
89
  @method up.visit
86
90
  @param {String} url
87
91
  The URL to visit.
88
92
  @param {Object} options
89
93
  See options for [`up.replace`](/up.flow#up.replace)
90
- @example
91
- up.visit('/users')
92
94
  ###
93
95
  visit = (url, options) ->
94
96
  u.debug "Visiting #{url}"
@@ -98,7 +100,16 @@ up.link = (->
98
100
  ###*
99
101
  Follows the given link via AJAX and replaces a CSS selector in the current page
100
102
  with corresponding elements from a new page fetched from the server.
101
-
103
+
104
+ Any Up.js UJS attributes on the given link will be honored. E. g. you have this link:
105
+
106
+ <a href="/users" up-target=".main">Users</a>
107
+
108
+ You can update the page's `.main` selector with the `.main` from `/users` like this:
109
+
110
+ var $link = $('a:first'); // select link with jQuery
111
+ up.follow($link);
112
+
102
113
  @method up.follow
103
114
  @param {Element|jQuery|String} link
104
115
  An element or selector which resolves to an `<a>` tag
@@ -5,17 +5,13 @@ Registering behavior and custom elements
5
5
  Up.js keeps a persistent Javascript environment during page transitions.
6
6
  To prevent memory leaks it is important to cleanly set up and tear down
7
7
  event handlers and custom elements.
8
-
8
+
9
9
  \#\#\# Incomplete documentation!
10
-
10
+
11
11
  We need to work on this page:
12
-
13
- - Explain when to use `up.on` and when to use `up.awaken`
14
- - Example for integrating an external JS lib that is not aware of Up.js
15
- - Example for defining a custom element
16
- - Tell more about memory leaks and why they don't matter
17
- so much when you have full page loads.
18
-
12
+
13
+ - Better class-level introduction for this module
14
+
19
15
  @class up.magic
20
16
  ###
21
17
  up.magic = (->
@@ -26,10 +22,50 @@ up.magic = (->
26
22
  DESTROYER_KEY = 'up-destroyer'
27
23
 
28
24
  ###*
29
- Binds an event handler to the document,
30
- which will be executed whenever the given event
31
- is triggered on the given selector.
32
-
25
+ Binds an event handler to the document, which will be executed whenever the
26
+ given event is triggered on the given selector:
27
+
28
+ up.on('click', '.button', function(event, $element) {
29
+ console.log("Someone clicked the button %o", $element);
30
+ });
31
+
32
+ This is roughly equivalent to binding a jQuery element to `document`.
33
+
34
+
35
+ \#\#\#\# Attaching structured data
36
+
37
+ In case you want to attach structured data to the event you're observing,
38
+ you can serialize the data to JSON and put it into an `[up-data]` attribute:
39
+
40
+ <span class="person" up-data="{ age: 18, name: 'Bob' }">Bob</span>
41
+ <span class="person" up-data="{ age: 22, name: 'Jim' }">Jim</span>
42
+
43
+ The JSON will parsed and handed to your event handler as a third argument:
44
+
45
+ up.on('click', '.person', function(event, $element, data) {
46
+ console.log("This is %o who is %o years old", data.name, data.age);
47
+ });
48
+
49
+
50
+ \#\#\#\# Migrating jQuery event handlers to `up.on`
51
+
52
+ Within the event handler, Up.js will bind `this` to the
53
+ native DOM element to help you migrate your existing jQuery code to
54
+ this new syntax.
55
+
56
+ So if you had this before:
57
+
58
+ $(document).on('click', '.button', function() {
59
+ $(this).something();
60
+ });
61
+
62
+ ... you can simply copy the event handler to `up.on`:
63
+
64
+ up.on('click', '.button', function() {
65
+ $(this).something();
66
+ });
67
+
68
+
33
69
  @method up.on
34
70
  @param {String} events
35
71
  A space-separated list of event names to bind.
@@ -59,6 +95,110 @@ up.magic = (->
59
95
  ###*
60
96
  Registers a function to be called whenever an element with
61
97
  the given selector is inserted into the DOM through Up.js.
98
+
99
+ This is a great way to integrate jQuery plugins.
100
+ Let's say your Javascript plugin wants you to call `lightboxify()`
101
+ on links that should open a lightbox. You decide to
102
+ do this for all links with an `[rel=lightbox]` attribute:
103
+
104
+ <a href="river.png" rel="lightbox">River</a>
105
+ <a href="ocean.png" rel="lightbox">Ocean</a>
106
+
107
+ This Javascript will do exactly that:
108
+
109
+ up.awaken('a[rel=lightbox]', function($element) {
110
+ $element.lightboxify();
111
+ });
112
+
113
+ Note that within the awakener, Up.js will bind `this` to the
114
+ native DOM element to help you migrate your existing jQuery code to
115
+ this new syntax.
116
+
117
+
118
+ \#\#\#\# Custom elements
119
+
120
+ You can also use `up.awaken` to implement custom elements like this:
121
+
122
+ <current-time></current-time>
123
+
124
+ Here is the Javascript that inserts the current time into to these elements:
125
+
126
+ up.awaken('current-time', function($element) {
127
+ var now = new Date();
128
+ $element.text(now.toString()));
129
+ });
130
+
131
+
132
+ \#\#\#\# Cleaning up after yourself
133
+
134
+ If your awakener returns a function, Up.js will use this as a *destructor* to
135
+ clean up if the element leaves the DOM. Note that in Up.js the same DOM ad Javascript environment
136
+ will persist through many page loads, so it's important to not create
137
+ [memory leaks](https://makandracards.com/makandra/31325-how-to-create-memory-leaks-in-jquery).
138
+
139
+ You should clean up after yourself whenever your awakeners have global
140
+ side effects, like a [`setInterval`](https://developer.mozilla.org/en-US/docs/Web/API/WindowTimers/setInterval)
141
+ or event handlers bound to the document root.
142
+
143
+ Here is a version of `<current-time>` that updates
144
+ the time every second, and cleans up once it's done:
145
+
146
+ up.awaken('current-time', function($element) {
147
+
148
+ function update() {
149
+ var now = new Date();
150
+ $element.text(now.toString()));
151
+ }
152
+
153
+ setInterval(update, 1000);
154
+
155
+ return function() {
156
+ clearInterval(update);
157
+ };
158
+
159
+ });
160
+
161
+ If we didn't clean up after ourselves, we would have many ticking intervals
162
+ operating on detached DOM elements after we have created and removed a couple
163
+ of `<current-time>` elements.
164
+
165
+
166
+ \#\#\#\# Attaching structured data
167
+
168
+ In case you want to attach structured data to the event you're observing,
169
+ you can serialize the data to JSON and put it into an `[up-data]` attribute.
170
+ For instance, a container for a [Google Map](https://developers.google.com/maps/documentation/javascript/tutorial)
171
+ might attach the location and names of its marker pins:
172
+
173
+ <div class="google-map" up-data="[
174
+ { lat: 48.36, lng: 10.99, title: 'Friedberg' },
175
+ { lat: 48.75, lng: 11.45, title: 'Ingolstadt' }
176
+ ]"></div>
177
+
178
+ The JSON will parsed and handed to your event handler as a second argument:
179
+
180
+ up.awaken('.google-map', function($element, pins) {
181
+
182
+ var map = new google.maps.Map($element);
183
+
184
+ pins.forEach(function(pin) {
185
+ var position = new google.maps.LatLng(pin.lat, pin.lng);
186
+ new google.maps.Marker({
187
+ position: position,
188
+ map: map,
189
+ title: pin.title
190
+ });
191
+ });
192
+
193
+ });
194
+
195
+
196
+ \#\#\#\# Migrating jQuery event handlers to `up.on`
197
+
198
+ Within the awakener, Up.js will bind `this` to the
199
+ native DOM element to help you migrate your existing jQuery code to
200
+ this new syntax.
201
+
62
202
 
63
203
  @method up.awaken
64
204
  @param {String} selector
@@ -45,13 +45,23 @@ up.util = (->
45
45
  @protected
46
46
  ###
47
47
  normalizeUrl = (urlOrAnchor, options) ->
48
- anchor = if isString(urlOrAnchor)
49
- $('<a>').attr(href: urlOrAnchor).get(0)
50
- else
51
- unwrap(urlOrAnchor)
48
+ anchor = null
49
+ if isString(urlOrAnchor)
50
+ anchor = $('<a>').attr(href: urlOrAnchor).get(0)
51
+ # In IE11 the #hostname and #port properties of such a link are empty
52
+ # strings. However, we can fix this by assigning the anchor its own
53
+ # href because computer:
54
+ # https://gist.github.com/jlong/2428561#comment-1461205
55
+ anchor.href = anchor.href if isBlank(anchor.hostname)
56
+ else
57
+ anchor = unwrap(urlOrAnchor)
52
58
  normalized = anchor.protocol + "//" + anchor.hostname
53
59
  normalized += ":#{anchor.port}" unless isStandardPort(anchor.protocol, anchor.port)
54
60
  pathname = anchor.pathname
61
+ # Some IEs don't include a leading slash in the #pathname property.
62
+ # We have seen this in IE11 and W3Schools claims it happens in IE9 or earlier
63
+ # http://www.w3schools.com/jsref/prop_anchor_pathname.asp
64
+ pathname = "/#{pathname}" unless pathname[0] == '/'
55
65
  pathname = pathname.replace(/\/$/, '') if options?.stripTrailingSlash == true
56
66
  normalized += pathname
57
67
  normalized += anchor.hash if options?.hash == true
@@ -35,7 +35,7 @@ up.viewport = (->
35
35
  @param {Number} scrollPos
36
36
  @param {String}[options.duration]
37
37
  @param {String}[options.easing]
38
- @returns {Deferred}
38
+ @return {Deferred}
39
39
  @protected
40
40
  ###
41
41
  scroll = (viewOrSelector, scrollPos, options) ->
@@ -83,7 +83,7 @@ up.viewport = (->
83
83
  @param {Number} [options.duration]
84
84
  @param {String} [options.easing]
85
85
  @param {Number} [options.padding]
86
- @returns {Deferred}
86
+ @return {Deferred}
87
87
  @protected
88
88
  ###
89
89
  reveal = (elementOrSelector, options) ->
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.4.2'
3
+ VERSION = '0.4.3'
4
4
  end
5
5
  end
@@ -3,20 +3,55 @@
3
3
  u = up.util
4
4
 
5
5
  mousedown = ($element, options) ->
6
- options = u.options(options, view: window, cancelable: true, bubbles: true)
7
- event = new MouseEvent('mousedown', options)
6
+ event = createMouseEvent('mousedown', options)
8
7
  dispatch($element, event)
9
8
 
10
9
  mouseup = ($element, options) ->
11
- options = u.options(options, view: window, cancelable: true, bubbles: true)
12
- event = new MouseEvent('mouseup', options)
10
+ event = createMouseEvent('mouseup', options)
13
11
  dispatch($element, event)
14
12
 
15
13
  click = ($element, options) ->
16
- options = u.options(options, view: window, cancelable: true, bubbles: true)
17
- event = new MouseEvent('click', options)
14
+ event = createMouseEvent('click', options)
18
15
  dispatch($element, event)
19
-
16
+
17
+ # Can't use the new MouseEvent constructor in IE11 because computer.
18
+ # http://www.codeproject.com/Tips/893254/JavaScript-Triggering-Event-Manually-in-Internet-E
19
+ createMouseEvent = (type, options) ->
20
+ options = u.options(options,
21
+ view: window,
22
+ cancelable: true,
23
+ bubbles: true,
24
+ detail: 0,
25
+ screenX: 0,
26
+ screenY: 0,
27
+ clientX: 0,
28
+ clientY: 0,
29
+ ctrlKey: false,
30
+ altKey: false,
31
+ shiftKey: false,
32
+ metaKey: false,
33
+ button: 0,
34
+ relatedTarget: null
35
+ )
36
+ event = document.createEvent('MouseEvent')
37
+ event.initMouseEvent(type,
38
+ options.view,
39
+ options.bubbles,
40
+ options.cancelable,
41
+ options.detail,
42
+ options.screenX,
43
+ options.screenY,
44
+ options.clientX,
45
+ options.clientY,
46
+ options.ctrlKey,
47
+ options.altKey,
48
+ options.shiftKey,
49
+ options.metaKey,
50
+ options.button,
51
+ options.relatedTarget
52
+ )
53
+ event
54
+
20
55
  dispatch = ($element, event) ->
21
56
  $element.each ->
22
57
  this.dispatchEvent(event)
@@ -33,4 +33,16 @@ describe 'up.util', ->
33
33
 
34
34
  it 'returns true for an object with at least one key', ->
35
35
  expect(up.util.isBlank({key: 'value'})).toBe(false)
36
-
36
+
37
+ describe '.normalizeUrl', ->
38
+
39
+ it 'normalizes a relative path', ->
40
+ expect(up.util.normalizeUrl('foo')).toBe("http://#{location.hostname}:#{location.port}/foo")
41
+
42
+ it 'normalizes an absolute path', ->
43
+ expect(up.util.normalizeUrl('/foo')).toBe("http://#{location.hostname}:#{location.port}/foo")
44
+
45
+ it 'normalizes a full URL', ->
46
+ expect(up.util.normalizeUrl('http://example.com/foo/bar')).toBe('http://example.com/foo/bar')
47
+
48
+