upjs-rails 0.8.2 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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,l,c,p,f,d,m,h,v,g,y,b,w,k,x,C,T,S,E,P,A,D,O,U,F,z,M,j,W,L,N,I,H,q,G,J,R,X,K,V,B,Q,_,Z,Y,tn,nn,en,rn,on,un,an,sn,ln,cn,pn,fn,dn,mn,hn,vn,gn,yn,bn,wn,kn,$n,xn,Cn,Tn,Sn,En;return Z=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))}},E=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)},G=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},rn=function(t,n){var e,r,o;return e=null,J(t)?(e=$("<a>").attr({href:t}).get(0),D(e.hostname)&&(e.href=e.href)):e=Sn(t),r=e.protocol+"//"+e.hostname,G(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,"/"!==o[0]&&(o="/"+o),(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},en=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},d=function(t,n){var e;return e=document.createElement(t),H(n)&&(e.innerHTML=n),e},g=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.debug.apply(console,[e].concat(t.call(n)))},En=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.warn.apply(console,[e].concat(t.call(n)))},w=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=wn(e),n=pn($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),new Error(r)},r=/\%[odisf]/g,wn=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+")"})},h=function(t){var n,e,r,o,u,i,a;for(g("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},m=function(t){var n,e,r,o,u,i,a,s,l,c,p,f;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},f=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=d("body",r[1]),s.appendChild(e),(p=t.match(f))&&(a=d("head"),s.appendChild(a),c=d("title",p[1]),a.appendChild(c)),s):d("div",t)},x=$.extend,Cn=$.trim,V=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},b=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},$n=function(t,n){var e,r,o,u;for(u=[],e=r=0,o=t-1;o>=0?o>=r:r>=o;e=o>=0?++r:--r)u.push(n(e));return u},N=function(t){return null===t},R=function(t){return void 0===t},U=function(t){return!R(t)},L=function(t){return R(t)||N(t)},M=function(t){return!L(t)},D=function(t){return L(t)||I(t)&&0===V(t).length||0===t.length},pn=function(t,n){return null==n&&(n=H),n(t)?t:null},H=function(t){return!D(t)},z=function(t){return"function"==typeof t},J=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},I=function(t){return j(t)||"function"==typeof t},F=function(t){return!(!t||1!==t.nodeType)},W=function(t){return t instanceof jQuery},q=function(t){return I(t)&&z(t.then)},O=function(t){return q(t)&&z(t.resolve)},P=function(t){return M(t)?t:void 0},A=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},xn=function(t){return Array.prototype.slice.call(t)},p=function(t){return A(t)?t.slice():x({},t)},Sn=function(t){return W(t)?t.get(0):t},Y=function(t,n){return x(p(t),n)},ln=function(t,n){var e,r,o,u;if(o=t?p(t):{},n)for(r in n)e=n[r],u=o[r],M(u)?I(e)&&I(u)&&(o[r]=ln(u,e)):o[r]=e;return o},sn=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,z(i)&&(i=i()),M(i)){u=i;break}return u},y=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},s=function(t){return yn(t,M)},Tn=function(t){var n;return n={},yn(t,function(t){return n.hasOwnProperty(t)?!1:n[t]=!0})},yn=function(t,n){var e;return e=[],b(t,function(t){return n(t)?e.push(t):void 0}),e},fn=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}(),y(o,H)},nn=function(t){return setTimeout(t,0)},B=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},gn=Z(function(){var t,n,e;return t=$("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),t.appendTo(document.body),n=t.get(0),e=n.offsetWidth-n.clientWidth,t.remove(),e}),un=function(t){var n;return n=void 0,function(){return null!=t&&(n=t()),t=void 0,n}},kn=function(t,n,e){var r,o;return o=t.css(V(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):un(r)},S=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),D(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},v=function(t,n,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=ln(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":V(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=S(o),l=kn(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),vn())},e="up-animation-promise",T=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},_=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},f=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},cn=function(t){var n,e;return e=_(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)},C=function(t,n){return t.find(n).addBack(n)},k=function(t){return 27===t.keyCode},c=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},Q=function(t){return t.getResponseHeader("X-Up-Location")},tn=function(t){return t.getResponseHeader("X-Up-Method")},an=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},X=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},K=function(t){var n;return n=R(t.button)||0===t.button,n&&X(t)},hn=function(){var t;return t=$.Deferred(),t.resolve(),t},vn=function(){return hn().promise()},on=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},mn=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return b(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},bn=function(t,n){var e,r,o;r=[];for(e in n)o=n[e],r.push(L(t.attr(e))?t.attr(e,o):void 0);return r},dn=function(t,n){var e;return e=t.indexOf(n),e>=0?(t.splice(e,1),n):void 0},l=function(t){var n,e;return null==t&&(t={}),e={reset:function(){var r,o,u,i;for(i=p(Object.getOwnPropertyNames(e)),r=0,u=i.length;u>r;r++)o=i[r],c(n,o)||delete e[o];return e.update(p(t))},update:function(n){var r,o,u;o=[];for(r in n)u=n[r],o.push(t.hasOwnProperty(r)?e[r]=u:w("Unknown setting %o",r));return o}},n=Object.getOwnPropertyNames(e),e.reset(),e},{presentAttr:fn,createElement:d,normalizeUrl:rn,normalizeMethod:en,createElementFromHtml:m,$createElementFromSelector:n,createSelectorFromElement:h,get:E,ajax:o,extend:x,copy:p,merge:Y,options:ln,option:sn,error:w,debug:g,warn:En,each:b,times:$n,detect:y,select:yn,compact:s,uniq:Tn,last:B,isNull:N,isDefined:U,isUndefined:R,isGiven:M,isMissing:L,isPresent:H,isBlank:D,presence:pn,isObject:I,isFunction:z,isString:J,isElement:F,isJQuery:W,isPromise:q,isDeferred:O,isHash:j,ifGiven:P,isUnmodifiedKeyEvent:X,isUnmodifiedMouseEvent:K,nullJquery:on,unwrap:Sn,nextFrame:nn,measure:_,temporaryCss:kn,cssAnimate:v,finishCssAnimate:T,forceCompositing:S,prependGhost:cn,escapePressed:k,copyAttributes:f,findWithSelf:C,contains:c,isArray:A,toArray:xn,castsToTrue:i,castsToFalse:u,locationFromXhr:Q,methodFromXhr:tn,clientSize:a,only:an,trim:Cn,keys:V,resolvedPromise:vn,resolvedDeferred:hn,resolvableWhen:mn,setMissingAttrs:bn,remove:dn,memoize:Z,scrollbarWidth:gn,config:l}}()}.call(this),function(){up.browser=function(){var t,n,e,r,o,u,i,a,s;return a=up.util,i=function(t,n){var e,r,o,u,i,s;return null==n&&(n={}),i=a.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(s=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",a.isDefined(r)&&a.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),s&&e.attr("target",s),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},s=function(){return location.href},r=function(){var t,n,e,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(n=window.console).info||(n.info=s),(e=window.console).error||(e.error=s),(r=window.console).debug||(r.debug=s),(o=window.console).warn||(o.warn=s),(u=window.console).group||(u.group=s),(i=window.console).groupCollapsed||(i.groupCollapsed=s),(a=window.console).groupEnd||(a.groupEnd=s)},e=a.memoize(function(){return a.isDefined(history.pushState)}),t=a.memoize(function(){return"transition"in document.documentElement.style}),n=a.memoize(function(){return"oninput"in document.createElement("input")}),o=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||a.error("jQuery %o found, but Up.js requires 1.9+",o)},u=a.memoize(function(){return a.isDefined(document.addEventListener)}),{url:s,ensureConsoleExists:r,loadPage:i,canPushState:e,canCssAnimation:t,canInputEvent:n,isSupported:u,ensureRecentJquery:o}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s,l;return l=up.util,n={},r={},i=function(){return n=l.copy(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]=l.copy(t));return o},u=function(t,n){var r,o,u,i;for(i=t.split(" "),o=0,u=i.length;u>o;o++)r=i[o],e(r).push(n);return function(){return s(t,n)}},s=function(t,n){var r,o,u,i,a;for(i=t.split(" "),a=[],o=0,u=i.length;u>o;o++)r=i[o],a.push(l.remove(e(r),n));return a},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],l.debug("Emitting event %o with args %o",o,n),r=e(o),l.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,off:s,emit:o}}()}.call(this),function(){up.viewport=function(){var t,n,e,r,o,u,i,a;return a=up.util,n=a.config({duration:0,viewSelector:"body, .up-modal, [up-viewport]",easing:"swing"}),o=function(){return n.reset()},t="up-scroll-promise",i=function(e,o,u){var i,s,l,c,p;return i=$(e),u=a.options(u),l=a.option(u.duration,n.duration),c=a.option(u.easing,n.easing),r(i),l>0?(s=$.Deferred(),i.data(t,s),s.then(function(){return i.removeData(t),i.finish()}),p={scrollTop:o},i.animate(p,{duration:l,easing:c,complete:function(){return s.resolve()}}),s):(i.scrollTop(o),a.resolvedDeferred())},r=function(n){return $(n).each(function(){var n;return(n=$(this).data(t))?n.resolve():void 0})},u=function(t,n){var r,o,u,s,l,c,p,f,d,m,h,v;return n=a.options(n),r=$(t),o=e(r,n.view),v=o.is("body"),h=v?a.clientSize().height:o.height(),m=o.scrollTop(),f=m,d=v?0:m,l=function(){return f},p=function(){return f+h-1},u=a.measure(r,{relative:!0}),s=u.top+d,c=s+u.height-1,c>p()&&(f+=c-p()),s<l()&&(f=s),f!==m?i(o,f,n):a.resolvedDeferred()},e=function(t,e){var r,o;return r=void 0,a.isJQuery(e)?r=e:(o=a.presence(e)||n.viewSelector,r=t.closest(o)),r.length||a.error("Could not find view to scroll for %o (tried selectors %o)",t,viewSelectors),r},up.bus.on("framework:reset",o),{reveal:u,scroll:i,finishScrolling:r,defaults:n.update}}(),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,v,g,y;return y=up.util,h=function(t,n){var e;return e=$(t),y.isPresent(n)&&(n=y.normalizeUrl(n)),e.attr("up-source",n)},v=function(t){var n;return n=$(t).closest("[up-source]"),y.presence(n.attr("up-source"))||up.browser.url()},f=function(t,n,e){var r,o,u;return e=y.options(e),u=y.presence(t)?t:y.createSelectorFromElement($(t)),up.browser.canPushState()||y.castsToFalse(e.history)?(o={url:n,method:e.method,selector:u,cache:e.cache,preload:e.preload},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=y.locationFromXhr(a))&&(y.debug("Location from server: %o",s),l={url:s,method:y.methodFromXhr(a),selector:u},up.proxy.alias(o,l),n=s),(y.isMissing(e.history)||y.castsToTrue(e.history))&&(e.history=n),(y.isMissing(e.source)||y.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:i(u,t,e)}),r.fail(y.error),r):(e.preload||up.browser.loadPage(n,y.only(e,"method")),y.resolvedPromise())},i=function(t,n,e){var o,u,i,a,p,f,d,m;for(e=y.options(e,{historyMethod:"push"}),y.castsToFalse(e.history)&&(e.history=null),y.castsToFalse(e.scroll)&&(e.scroll=null),e.source=y.option(e.source,e.history),f=l(n),e.title||(e.title=f.title()),p=s(t,e),d=[],i=0,a=p.length;a>i;i++)m=p[i],u=r(m.selector),o=f.find(m.selector),d.push(c(u,e).then(function(){return g(u,o,m.pseudoClass,m.transition,e)}));return d},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var n;return n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),y.error(n,t)},l=function(t){var n;return n=y.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):y.error("Could not find selector %o in response %o",e,t)}}},c=function(t,n){return up.motion.finish(t),m(t,n.scroll)},m=function(t,n){return n?up.reveal(t,{view:n}):y.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)),h(n,e.source),t(n),up.ready(n)},g=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()),y.copyAttributes(r,t),e(a,i),up.animate(r,u,i)):n(t,{animation:function(){return r.insertBefore(t),e(r,i),t.is("body")&&"none"!==u&&y.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})},s=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),y.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]||y.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=y.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},a=function(t){var n;return n=".up-ghost, .up-destroying",0===t.closest(n).length},o=function(t){var n,e,r,o,u,i;for(o=$(t).get(),e=null,u=0,i=o.length;i>u;u++)if(r=o[u],n=$(r),a(n)){e=n;break}return e},n=function(t,n){var e,r,o;return e=$(t),n=y.options(n,{animation:"none"}),r=up.motion.animateOptions(n),e.addClass("up-destroying"),y.isPresent(n.url)&&up.history.push(n.url),y.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),o=y.presence(n.animation,y.isPromise)||up.motion.animate(e,n.animation,r),o.then(function(){return e.remove()})},p=function(t,n){var e;return n=y.options(n,{cache:!1}),e=n.url||v(t),f(t,e,n)},d=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return h(document.body,up.browser.url())}),{replace:f,reload:p,destroy:n,implant:i,reset:d,first:o}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset,up.first=up.flow.first}.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)},i=[],s=null,u=function(){var n,e,r;return r=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=n.pop(),e=g.options(n[0],{batch:!1}),i.push({selector:r,callback:u,batch:e.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying compiler %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},o=function(t){var n,e,o,a;for(g.debug("Compiling fragment %o",t),a=[],e=0,o=i.length;o>e;e++)u=i[e],n=g.findWithSelf(t,u.selector),a.push(n.length?u.batch?r(u,n,n.get()):n.each(function(){return r(u,$(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(i)},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),i=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",o),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{compiler:u,on:p,ready:m,onEscape:d,data:a}}(),up.compiler=up.magic.compiler,up.on=up.magic.on,up.ready=up.magic.ready,up.awaken=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],up.util.warn("up.awaken has been renamed to up.compiler and will be removed in a future version"),up.compiler.apply(up,n)}}.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,o={},a={},y={},s={},i=b.config({duration:300,delay:0,easing:"ease"}),m=function(){return o=b.copy(a),y=b.copy(s),i.reset()},n=function(t,r,o){var i;return i=$(t),c(i),o=e(o),b.isFunction(r)?u(r(i,o),r):b.isString(r)?n(i,l(r),o):b.isHash(r)?b.cssAnimate(i,r,o):b.error("Unknown animation type %o",r)},e=function(t,n){var e;return null==n&&(n=null),t=b.options(t),e={},e.easing=b.option(t.easing,null!=n?n.attr("up-easing"):void 0,i.easing),e.duration=Number(b.option(t.duration,null!=n?n.attr("up-duration"):void 0,i.duration)),e.delay=Number(b.option(t.delay,null!=n?n.attr("up-delay"):void 0,i.delay)),e},l=function(t){return o[t]||b.error("Unknown animation %o",r)},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"}),a=b.temporaryCss(e,{display:"none"}),i=r(u,o),n.data(t,i),e.data(t,i),i.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),a()}),i},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},u=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,r,i,a){var s,l,p,m,v;return up.browser.canCssAnimation()?(a=e(a),l=$(t),s=$(r),c(l),c(s),"none"===i?d():(v=b.presence(i,b.isFunction)||y[i])?w(l,s,function(t,n){return u(v(t,n,a),i)}):(p=o[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},r=function(t,n){return o[t]=n},v=function(){return a=b.copy(o),s=b.copy(y)},h=b.resolvableWhen,d=b.resolvedDeferred,r("none",d),r("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),r("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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,animateOptions:e,finish:c,transition:g,animation:r,defaults:i.update,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,x,C,T,S,E,P,A,D,O,U;return U=up.util,a=void 0,t=void 0,T=void 0,u=void 0,x=void 0,i=void 0,d=U.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5}),c=function(){return clearTimeout(T),T=null},l=function(){return clearTimeout(u),u=null},E=function(){return a={},t=null,c(),l(),x=0,d.reset(),i=!1},E(),s=function(t){return k(t),[t.url,t.method,t.data,t.selector].join("|")},O=function(){var t,n,e;return t=U.keys(a),t.length>d.cacheSize&&(n=null,e=null,U.each(t,function(t){var r,o;return r=a[t],o=r.timestamp,!e||e>o?(n=t,e=o):void 0}),n)?delete a[n]:void 0},D=function(){return(new Date).valueOf()},k=function(t){return t._normalized||(t.method=U.normalizeMethod(t.method),t.url&&(t.url=U.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},r=function(t,n){var e;return U.debug("Aliasing %o to %o",t,n),(e=m(t))?P(n,e):void 0},e=function(t){var n,e,r,o,u;return n=U.castsToTrue(t.cache),e=U.castsToFalse(t.cache),u=U.only(t,"url","method","data","selector","_normalized"),r=!0,g(u)||n?(o=m(u))&&!e?r="pending"===o.state():(o=y(u),P(u,o)):(f(),o=y(u)),r&&!t.preload&&(w(),o.then(b)),o},n=["GET","OPTIONS","HEAD"],h=function(){return 0===x},o=function(){return x>0},w=function(){var t,n;return n=h(),x+=1,n?(t=function(){return o()?(up.bus.emit("proxy:busy"),i=!0):void 0},d.busyDelay>0?u=setTimeout(t,d.busyDelay):t()):void 0},b=function(){return x-=1,h()&&i?(up.bus.emit("proxy:idle"),i=!1):void 0},y=function(t){var n;return up.bus.emit("proxy:load",t),n=U.ajax(t),n.then(function(){return up.bus.emit("proxy:receive",t)}),n},g=function(t){return k(t),U.contains(n,t.method)},v=function(t){var n;return n=D()-t.timestamp,n<d.cacheExpiry},m=function(t){var n,e;return n=s(t),(e=a[n])?v(e)?(U.debug("Cache hit for %o (%o)",t.url,t),e):(U.debug("Discarding stale cache entry for %o (%o)",t.url,t),void S(t)):void U.debug("Cache miss for %o (%o)",t.url,t)},P=function(t,n){var e;return O(),e=s(t),n.timestamp=D(),a[e]=n,n},S=function(t){var n;return n=s(t),delete a[n]},f=function(){return a={}},p=function(n){var e,r;return r=parseInt(U.presentAttr(n,"up-delay"))||d.preloadDelay,n.is(t)?void 0:(t=n,c(),e=function(){return C(n)},A(e,r))},A=function(t,n){return T=setTimeout(t,n)},C=function(t,n){var e,r;return e=$(t),n=U.options(n),r=up.link.followMethod(e,n),g({method:r})?(U.debug("Preloading %o",e),n.preload=!0,up.link.follow(e,n)):(U.debug("Won't preload %o due to unsafe method %o",e,r),U.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:p(n)}),up.bus.on("framework:reset",E),{preload:C,ajax:e,get:m,set:P,alias:r,clear:f,remove:S,idle:h,busy:o,defaults:d.update}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,n){return u.debug("Visiting "+t),up.replace("body",t,n)},follow=function(t,n){var e,r,o;return e=$(t),n=u.options(n),o=u.option(e.attr("up-href"),e.attr("href")),r=u.option(n.target,e.attr("up-target"),"body"),n.transition=u.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=u.option(n.history,e.attr("up-history")),n.scroll=u.option(n.scroll,e.attr("up-scroll"),"body"),n.cache=u.option(n.cache,e.attr("up-cache")),n.method=followMethod(e,n),n=u.merge(n,up.motion.animateOptions(n,e)),up.replace(r,o,n)},followMethod=function(t,n){return n=u.options(n),u.option(n.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,n){return shouldProcessLinkEvent(t,n)?(t.preventDefault(),follow(n)):void 0}),childClicked=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-href]"),r.length&&n.find(r).length},shouldProcessLinkEvent=function(t,n){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,n)},up.on("click","a[up-follow], [up-href][up-follow]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.compiler("[up-expand]",function(t){var n,e,r,o,i,a,s,l;for(o=t.find("a, [up-href]").get(0),o||u.error("No link to expand within %o",t),l=/^up-/,a={},a["up-href"]=$(o).attr("href"),s=o.attributes,e=0,r=s.length;r>e;e++)n=s[e],i=n.name,i.match(l)&&(a[i]=n.value);return u.isGiven(a["up-target"])||(a["up-follow"]=""),u.setMissingAttrs(t,a),t.removeAttr("up-expand")}),up.compiler("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},u.isBlank(e)||u.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,u.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,childClicked:childClicked,followMethod:followMethod}}(),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,d,m;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),o=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),a=u.option(n.history,e.attr("up-history"),!0),p=u.option(n.transition,e.attr("up-transition")),i=u.option(n.failTransition,e.attr("up-fail-transition"),p),s=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),r=up.motion.animateOptions(n,e),m=u.option(n.cache,e.attr("up-cache")),d=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(a)?(l={url:d,method:s,data:e.serialize(),selector:c,cache:m},f=function(t){var n;return d=a?u.castsToFalse(a)?!1:u.isString(a)?a:(n=u.locationFromXhr(t))?n:"GET"===l.type?l.url+"?"+l.data:void 0:void 0,u.option(d,!1)},up.proxy.ajax(l).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){var o;return o=u.merge(r,{history:f(e),transition:p}),up.flow.implant(c,t,o)}).fail(function(t){var n,e;return e=t.responseText,n=u.merge(r,{transition:i}),up.flow.implant(o,e,n)})):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.compiler("[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,d,m;return d=up.util,u=void 0,e=d.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"}),c=function(){return n(),e.reset()},p=function(t,n,e){var r,o;return o=d.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};
2
- 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 d.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r),a(n)},a=function(t){var n,e,r,o,u,i,a;if(e=d.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)},i=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,n,e){var r,o;return o=d.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),r=d.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),l(),o.hide(),o},m=function(t,n,e,r,o){return n.show(),p(t,n,e),up.animate(n,r,o)},s=function(t,r){var u,i,a,s,l,c,p,f,h;return u=$(t),r=d.options(r),h=d.option(r.url,u.attr("href")),p=d.option(r.target,u.attr("up-popup"),"body"),c=d.option(r.position,u.attr("up-position"),e.position),s=d.option(r.animation,u.attr("up-animation"),e.openAnimation),f=d.option(r.sticky,u.is("[up-sticky]")),l=up.browser.canPushState()?d.option(r.history,u.attr("up-history"),!1):!1,a=up.motion.animateOptions(r,u),n(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},n=function(t){var n;return n=$(".up-popup"),n.length?(t=d.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),u=void 0,up.destroy(n,t)):d.resolvedPromise()},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(i(),n())},r=function(t){var n;return n=$(t),n.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():s(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){var e;return r(n)?(e=n.attr("up-source"))?u=e: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",c),{open:s,close:n,source:f,defaults:e.update,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,r=m.config({maxWidth:void 0,minWidth:void 0,width:void 0,height:void 0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",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>'}}),i=void 0,c=function(){return e(),i=void 0,r.reset()},d=function(){var t;return t=r.template,m.isFunction(t)?t(r):t},l=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t){var n,e,r,o;return r=$(d()),t.sticky&&r.attr("up-sticky",""),r.attr("up-previous-url",up.browser.url()),r.attr("up-previous-title",document.title),e=r.find(".up-modal-dialog"),m.isPresent(t.width)&&e.css("width",t.width),m.isPresent(t.maxWidth)&&e.css("max-width",t.maxWidth),m.isPresent(t.height)&&e.css("height",t.height),n=r.find(".up-modal-content"),o=m.$createElementFromSelector(t.selector),o.appendTo(n),r.appendTo(document.body),l(),r.hide(),r},h=void 0,p=function(){var t,n,e;return e=m.scrollbarWidth(),t=parseInt($("body").css("padding-right")),n=e+t,h=m.temporaryCss($("body"),{"padding-right":n+"px","overflow-y":"hidden"})},v=function(t,n,e){var r;return up.bus.emit("modal:open"),p(),t.show(),r=up.animate(t,n,e),r.then(function(){return up.bus.emit("modal:opened")}),r},s=function(){var n,o,i,a,s,l,c,p,f,d,h,g,y;return s=1<=arguments.length?t.call(arguments,0):[],!m.isObject(s[0])||m.isElement(s[0])||m.isJQuery(s[0])?(n=$(s[0]),f=s[1]):(n=m.nullJquery(),f=s[0]),f=m.options(f),g=m.option(f.url,n.attr("up-href"),n.attr("href")),d=m.option(f.target,n.attr("up-modal"),"body"),y=m.option(f.width,n.attr("up-width"),r.width),p=m.option(f.maxWidth,n.attr("up-max-width"),r.maxWidth),l=m.option(f.height,n.attr("up-height"),r.height),a=m.option(f.animation,n.attr("up-animation"),r.openAnimation),h=m.option(f.sticky,n.is("[up-sticky]")),c=up.browser.canPushState()?m.option(f.history,n.attr("up-history"),!0):!1,i=up.motion.animateOptions(f,n),e(),o=u({selector:d,width:y,maxWidth:p,height:l,sticky:h}),up.replace(d,g,{history:c,insert:function(){return v(o,a,i)}})},f=function(){return i},e=function(t){var n,e;return n=$(".up-modal"),n.length?(t=m.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),i=void 0,up.bus.emit("modal:close"),e=up.destroy(n,t),e.then(function(){return h(),up.bus.emit("modal:closed")}),e):m.resolvedPromise()},n=function(){return $(".up-modal").is("[up-sticky]")?void 0:(a(),e())},o=function(t){var n;return n=$(t),n.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():s(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-modal-dialog").length||n.closest("[up-modal]").length?void 0:e()}),up.bus.on("fragment:ready",function(t){var e;if(o(t)){if(e=t.attr("up-source"))return i=e}else if(!up.popup.contains(t))return n()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-modal")?e():void 0}),up.bus.on("framework:reset",c),{open:s,close:e,source:f,defaults:r.update,contains: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 position %o",e)}}(),n.attr("up-position",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,p;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),p=o.option(u.position,i.attr("up-position"),"top"),l=o.option(u.animation,i.attr("up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=n(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[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,m,h,v;return m=up.util,u=m.config({currentClass:"up-current"}),c=function(){return u.reset()},i=function(){var t;return t=u.currentClass,m.contains(t,"up-current")||(t+=" up-current"),t},t="up-active",n=["a","[up-href]","[up-alias]"],r=n.join(", "),o=function(){var t,e,r;for(r=[],t=0,e=n.length;e>t;t++)d=n[t],r.push(d+"[up-instant]");return r}().join(", "),e="."+t,l=function(t){return m.isPresent(t)?m.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},f=function(t){var n,e,r,o,u,i,a,s,c,p;for(s=[],i=["href","up-href","up-alias"],e=0,o=i.length;o>e;e++)if(n=i[e],c=m.presentAttr(t,n))for(p="up-alias"===n?c.split(" "):[c],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=l(a),s.push(a));return s},v=function(t){var n,e,r,o;return t=m.compact(t),r=function(t){return"*"===t.substr(-1)?e(t.slice(0,-1)):n(t)},n=function(n){return m.contains(t,n)},e=function(n){return m.detect(t,function(t){return 0===t.indexOf(n)})},o=function(t){return m.detect(t,r)},{matchesAny:o}},s=function(){var t,n;return t=v([l(up.browser.url()),l(up.modal.source()),l(up.popup.source())]),n=i(),m.each($(r),function(e){var r,o;return r=$(e),o=f(r),t.matchesAny(o)?r.addClass(n):r.removeClass(n)})},p=function(n){return h(),n=a(n),n.addClass(t)},a=function(t){return m.presence(t.parents(r))||t},h=function(){return $(e).removeClass(t)},up.on("click",r,function(t,n){return m.isUnmodifiedMouseEvent(t)&&!n.is("[up-instant]")?p(n):void 0}),up.on("mousedown",o,function(t,n){return m.isUnmodifiedMouseEvent(t)?p(n):void 0}),up.bus.on("fragment:ready",function(){return h(),s()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?s():void 0}),up.bus.on("framework:reset",c),{defaults:u.update}}()}.call(this),function(){up.slot=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-slot]").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,x,C,T,E,S,P,A,D,O,U,F,M,z,W,j,N,I,L,q,H,J,G,B,R,X,K,Q,V,_,Z,Y,tn,nn,en,rn,on,un,an,sn,ln,cn,pn,fn,dn,mn,hn,vn,gn,yn,bn,wn,kn,$n,xn,Cn,Tn,En,Sn,Pn,An,Dn,On,Un;return nn=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))}},P=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)},B=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},an=function(t,n){var e,r,o;return e=null,R(t)?(e=$("<a>").attr({href:t}).get(0),U(e.hostname)&&(e.href=e.href)):e=An(t),r=e.protocol+"//"+e.hostname,B(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,"/"!==o[0]&&(o="/"+o),(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},un=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},d=function(t,n){var e;return e=document.createElement(t),J(n)&&(e.innerHTML=n),e},g=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.debug.apply(console,[e].concat(t.call(n)))},Un=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.warn.apply(console,[e].concat(t.call(n)))},k=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=Cn(e),n=mn($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),new Error(r)},r=/\%[odisf]/g,Cn=function(t){var n,e,o;return o=t[0],n=0,e=50,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='"'+r+'"'):"number"===o?r=r.toString():(r=JSON.stringify(r),r.length>e&&(r=r.substr(0,e)+"\u2026")),r})},h=function(t){var n,e,r,o,u,i,a;for(g("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},m=function(t){var n,e,r,o,u,i,a,s,l,c,p,f;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},f=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=d("body",r[1]),s.appendChild(e),(p=t.match(f))&&(a=d("head"),s.appendChild(a),c=d("title",p[1]),a.appendChild(c)),s):d("div",t)},C=$.extend,Pn=$.trim,V=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},b=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},Y=b,A=function(t){return t},En=function(t,n){var e,r,o,u;for(u=[],e=r=0,o=t-1;o>=0?o>=r:r>=o;e=o>=0?++r:--r)u.push(n(e));return u},q=function(t){return null===t},X=function(t){return void 0===t},M=function(t){return!X(t)},L=function(t){return X(t)||q(t)},j=function(t){return!L(t)},U=function(t){return L(t)||H(t)&&0===V(t).length||0===t.length},mn=function(t,n){return null==n&&(n=J),n(t)?t:null},J=function(t){return!U(t)},W=function(t){return"function"==typeof t},R=function(t){return"string"==typeof t},N=function(t){return"object"==typeof t&&!!t},H=function(t){return N(t)||"function"==typeof t},z=function(t){return!(!t||1!==t.nodeType)},I=function(t){return t instanceof jQuery},G=function(t){return H(t)&&W(t.then)},F=function(t){return G(t)&&W(t.resolve)},D=function(t){return j(t)?t:void 0},O=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Sn=function(t){return Array.prototype.slice.call(t)},p=function(t){return O(t)?t.slice():C({},t)},An=function(t){return I(t)?t.get(0):t},en=function(t,n){return C(p(t),n)},fn=function(t,n){var e,r,o,u;if(o=t?p(t):{},n)for(r in n)e=n[r],u=o[r],j(u)?H(e)&&H(u)&&(o[r]=fn(u,e)):o[r]=e;return o},pn=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,W(i)&&(i=i()),j(i)){u=i;break}return u},y=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},s=function(t){return kn(t,j)},Dn=function(t){var n;return n={},kn(t,function(t){return n.hasOwnProperty(t)?!1:n[t]=!0})},kn=function(t,n){var e;return e=[],b(t,function(t){return n(t)?e.push(t):void 0}),e},hn=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}(),y(o,J)},on=function(t){return setTimeout(t,0)},_=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},wn=nn(function(){var t,n,e;return t=$("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),t.appendTo(document.body),n=t.get(0),e=n.offsetWidth-n.clientWidth,t.remove(),e}),ln=function(t){var n;return n=void 0,function(){return null!=t&&(n=t()),t=void 0,n}},Tn=function(t,n,e){var r,o;return o=t.css(V(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):ln(r)},S=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),U(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},v=function(t,n,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=fn(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":V(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=S(o),l=Tn(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),bn())},e="up-animation-promise",E=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},tn=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},f=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},dn=function(t){var n,e;return e=tn(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)},T=function(t,n){return t.find(n).addBack(n)},x=function(t){return 27===t.keyCode},xn=function(t,n){return 0===t.indexOf(n)},w=function(t,n){return t.indexOf(n)===t.length-n.length},c=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},Z=function(t){return t.getResponseHeader("X-Up-Location")},rn=function(t){return t.getResponseHeader("X-Up-Method")},cn=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},K=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},Q=function(t){var n;return n=X(t.button)||0===t.button,n&&K(t)},yn=function(){var t;return t=$.Deferred(),t.resolve(),t},bn=function(){return yn().promise()},sn=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},gn=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return b(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},$n=function(t,n){var e,r,o;r=[];for(e in n)o=n[e],r.push(L(t.attr(e))?t.attr(e,o):void 0);return r},vn=function(t,n){var e;return e=t.indexOf(n),e>=0?(t.splice(e,1),n):void 0},l=function(t){var n,e;return null==t&&(t={}),e={reset:function(){var r,o,u,i;for(i=p(Object.getOwnPropertyNames(e)),r=0,u=i.length;u>r;r++)o=i[r],c(n,o)||delete e[o];return e.update(p(t))},update:function(n){var r,o;null==n&&(n={});for(r in n)o=n[r],t.hasOwnProperty(r)?e[r]=o:k("Unknown setting %o",r);return e}},n=Object.getOwnPropertyNames(e),e.reset(),e},On=function(t){var n,e;return t=An(t),n=t.parentNode,e=Sn(t.childNodes),b(e,function(e){return n.insertBefore(e,t)}),n.removeChild(t)},{presentAttr:hn,createElement:d,normalizeUrl:an,normalizeMethod:un,createElementFromHtml:m,$createElementFromSelector:n,createSelectorFromElement:h,get:P,ajax:o,extend:C,copy:p,merge:en,options:fn,option:pn,error:k,debug:g,warn:Un,each:b,map:Y,identity:A,times:En,detect:y,select:kn,compact:s,uniq:Dn,last:_,isNull:q,isDefined:M,isUndefined:X,isGiven:j,isMissing:L,isPresent:J,isBlank:U,presence:mn,isObject:H,isFunction:W,isString:R,isElement:z,isJQuery:I,isPromise:G,isDeferred:F,isHash:N,ifGiven:D,isUnmodifiedKeyEvent:K,isUnmodifiedMouseEvent:Q,nullJquery:sn,unJquery:An,nextFrame:on,measure:tn,temporaryCss:Tn,cssAnimate:v,finishCssAnimate:E,forceCompositing:S,prependGhost:dn,escapePressed:x,copyAttributes:f,findWithSelf:T,contains:c,startsWith:xn,endsWith:w,isArray:O,toArray:Sn,castsToTrue:i,castsToFalse:u,locationFromXhr:Z,methodFromXhr:rn,clientSize:a,only:cn,trim:Pn,keys:V,resolvedPromise:bn,resolvedDeferred:yn,resolvableWhen:gn,setMissingAttrs:$n,remove:vn,memoize:nn,scrollbarWidth:wn,config:l,unwrapElement:On}}()}.call(this),function(){up.browser=function(){var t,n,e,r,o,u,i,a,s;return a=up.util,i=function(t,n){var e,r,o,u,i,s;return null==n&&(n={}),i=a.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(s=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",a.isDefined(r)&&a.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),s&&e.attr("target",s),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},s=function(){return location.href},r=function(){var t,n,e,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(n=window.console).info||(n.info=s),(e=window.console).error||(e.error=s),(r=window.console).debug||(r.debug=s),(o=window.console).warn||(o.warn=s),(u=window.console).group||(u.group=s),(i=window.console).groupCollapsed||(i.groupCollapsed=s),(a=window.console).groupEnd||(a.groupEnd=s)},e=a.memoize(function(){return a.isDefined(history.pushState)}),t=a.memoize(function(){return"transition"in document.documentElement.style}),n=a.memoize(function(){return"oninput"in document.createElement("input")}),o=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||a.error("jQuery %o found, but Up.js requires 1.9+",o)},u=a.memoize(function(){return a.isDefined(document.addEventListener)}),{url:s,ensureConsoleExists:r,loadPage:i,canPushState:e,canCssAnimation:t,canInputEvent:n,isSupported:u,ensureRecentJquery:o}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s,l;return l=up.util,n={},r={},i=function(){return n=l.copy(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]=l.copy(t));return o},u=function(t,n){var r,o,u,i;for(i=t.split(" "),o=0,u=i.length;u>o;o++)r=i[o],e(r).push(n);return function(){return s(t,n)}},s=function(t,n){var r,o,u,i,a;for(i=t.split(" "),a=[],o=0,u=i.length;u>o;o++)r=i[o],a.push(l.remove(e(r),n));return a},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],l.debug("Emitting event %o with args %o",o,n),r=e(o),l.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,off:s,emit:o}}()}.call(this),function(){var t=[].slice;up.layout=function(){var n,e,r,o,u,i,a,s,l;return l=up.util,e=l.config({duration:0,viewport:"body, .up-modal, [up-viewport]",fixedTop:"[up-fixed~=top]",fixedBottom:"[up-fixed~=bottom]",snap:50,easing:"swing"}),i=function(){return e.reset()},n="up-scroll-promise",s=function(t,r,u){var i,a,s,c,p;return i=$(t),u=l.options(u),s=l.option(u.duration,e.duration),c=l.option(u.easing,e.easing),o(i),s>0?(a=$.Deferred(),i.data(n,a),a.then(function(){return i.removeData(n),i.finish()}),p={scrollTop:r},i.animate(p,{duration:s,easing:c,complete:function(){return a.resolve()}}),a):(i.scrollTop(r),l.resolvedDeferred())},o=function(t){return $(t).each(function(){var t;return(t=$(this).data(n))?t.resolve():void 0})},u=function(){var n,r,o,u;return o=function(t,n){var e,r;return e=$(t),r=e.css(n),"0"===r||l.endsWith(r,"px")||l.error("Fixed element must have an anchor position in px, but was %o",r),parseInt(r)+e.height()},r=function(){var t,n,r,i;for(r=$(e.fixedTop),i=[],t=0,n=r.length;n>t;t++)u=r[t],i.push(o(u,"top"));return i}(),n=function(){var t,n,r,i;for(r=$(e.fixedBottom),i=[],t=0,n=r.length;n>t;t++)u=r[t],i.push(o(u,"bottom"));return i}(),{top:Math.max.apply(Math,[0].concat(t.call(r))),bottom:Math.max.apply(Math,[0].concat(t.call(n)))}},a=function(t,n){var o,i,a,c,p,f,d,m,h,v,g,y,b,w;return n=l.options(n),o=$(t),i=r(o,n.viewport),y=l.option(n.snap,e.snap),w=i.is("body"),b=w?l.clientSize().height:i.height(),h=i.scrollTop(),f=h,m=void 0,d=void 0,w?(d=u(),m=0):(d={top:0,bottom:0},m=h),v=function(){return f+d.top},g=function(){return f+b-d.bottom-1},a=l.measure(o,{relative:!0}),c=a.top+m,p=c+a.height-1,p>g()&&(f+=p-g()),c<v()&&(f=c-d.top),y>f&&(f=0),f!==h?s(i,f,n):l.resolvedDeferred()},r=function(t,n){var r,o;return r=void 0,l.isJQuery(n)?r=n:(o=l.presence(n)||e.viewport,r=t.closest(o)),r.length||l.error("Could not find viewport for %o",t),r},up.bus.on("framework:reset",i),{reveal:a,scroll:s,finishScrolling:o,defaults:e.update}}(),up.scroll=up.layout.scroll,up.reveal=up.layout.reveal}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,m=function(t,n){var e;return e=$(t),g.isPresent(n)&&(n=g.normalizeUrl(n)),e.attr("up-source",n)},h=function(t){var n;return n=$(t).closest("[up-source]"),g.presence(n.attr("up-source"))||up.browser.url()},p=function(t,n,e){var r,o,u;return e=g.options(e),u=g.presence(t)?t:g.createSelectorFromElement($(t)),up.browser.canPushState()||g.castsToFalse(e.history)?(o={url:n,method:e.method,selector:u,cache:e.cache,preload:e.preload},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=g.locationFromXhr(a))&&(g.debug("Location from server: %o",s),l={url:s,method:g.methodFromXhr(a),selector:u},up.proxy.alias(o,l),n=s),(g.isMissing(e.history)||g.castsToTrue(e.history))&&(e.history=n),(g.isMissing(e.source)||g.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:i(u,t,e)}),r.fail(g.error),r):(e.preload||up.browser.loadPage(n,g.only(e,"method")),g.resolvedPromise())},i=function(t,n,e){var o,u,i,a,c,p,f,d;for(e=g.options(e,{historyMethod:"push"}),g.castsToFalse(e.history)&&(e.history=null),g.castsToFalse(e.scroll)&&(e.scroll=!1),e.source=g.option(e.source,e.history),p=l(n),e.title||(e.title=p.title()),c=s(t,e),f=[],i=0,a=c.length;a>i;i++)d=c[i],u=r(d.selector),o=p.find(d.selector).first(),f.push(v(u,o,d.pseudoClass,d.transition,e));return f},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var n;return n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),g.error(n,t)},l=function(t){var n;return n=g.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):g.error("Could not find selector %o in response %o",e,t)}}},d=function(t,n){var e;return e=n.scroll,e!==!1?up.reveal(t,{viewport:e}):g.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)),m(n,e.source),t(n),up.ready(n)},v=function(t,r,o,u,i){var a,s;return u||(u="none"),up.motion.finish(t),o?(s="before"===o?"prepend":"append",a=r.contents().wrap('<span class="up-insertion"></span>').parent(),t[s](a),g.copyAttributes(r,t),e(a.children(),i),d(a,i).then(function(){return up.animate(a,u,i)}).then(function(){g.unwrapElement(a)})):d(t,i).then(function(){return n(t,{animation:function(){return r.insertBefore(t),e(r,i),t.is("body")&&"none"!==u&&g.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})})},s=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),g.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]||g.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=g.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},a=function(t){var n;return n=".up-ghost, .up-destroying",0===t.closest(n).length},o=function(t){var n,e,r,o,u,i;for(o=$(t).get(),e=null,u=0,i=o.length;i>u;u++)if(r=o[u],n=$(r),a(n)){e=n;break}return e},n=function(t,n){var e,r,o;return e=$(t),n=g.options(n,{animation:"none"}),r=up.motion.animateOptions(n),e.addClass("up-destroying"),g.isPresent(n.url)&&up.history.push(n.url),g.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),o=g.presence(n.animation,g.isPromise)||up.motion.animate(e,n.animation,r),o.then(function(){return e.remove()}),o},c=function(t,n){var e;return n=g.options(n,{cache:!1}),e=n.url||h(t),p(t,e,n)},f=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return m(document.body,up.browser.url())}),{replace:p,reload:c,destroy:n,implant:i,reset:f,first:o}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset,up.first=up.flow.first}.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)},i=[],s=null,u=function(){var n,e,r;return r=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=n.pop(),e=g.options(n[0],{batch:!1}),i.push({selector:r,callback:u,batch:e.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying compiler %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},o=function(t){var n,e,o,a;for(g.debug("Compiling fragment %o",t),a=[],e=0,o=i.length;o>e;e++)u=i[e],n=g.findWithSelf(t,u.selector),a.push(n.length?u.batch?r(u,n,n.get()):n.each(function(){return r(u,$(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(i)},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),i=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",o),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{compiler:u,on:p,ready:m,onEscape:d,data:a}}(),up.compiler=up.magic.compiler,up.on=up.magic.on,up.ready=up.magic.ready,up.awaken=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],up.util.warn("up.awaken has been renamed to up.compiler and will be removed in a future version"),up.compiler.apply(up,n)}}.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,o={},a={},y={},s={},i=b.config({duration:300,delay:0,easing:"ease"}),m=function(){return o=b.copy(a),y=b.copy(s),i.reset()},n=function(t,r,o){var i;return i=$(t),c(i),o=e(o),b.isFunction(r)?u(r(i,o),r):b.isString(r)?n(i,l(r),o):b.isHash(r)?b.cssAnimate(i,r,o):b.error("Unknown animation type %o",r)},e=function(t,n){var e;return null==n&&(n=null),t=b.options(t),e={},e.easing=b.option(t.easing,null!=n?n.attr("up-easing"):void 0,i.easing),e.duration=Number(b.option(t.duration,null!=n?n.attr("up-duration"):void 0,i.duration)),e.delay=Number(b.option(t.delay,null!=n?n.attr("up-delay"):void 0,i.delay)),e},l=function(t){return o[t]||b.error("Unknown animation %o",r)},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"}),a=b.temporaryCss(e,{display:"none"}),i=r(u,o),n.data(t,i),e.data(t,i),i.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),a()}),i},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},u=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,r,i,a){var s,l,p,m,v;return up.browser.canCssAnimation()?(a=e(a),l=$(t),s=$(r),c(l),c(s),"none"===i?d():(v=b.presence(i,b.isFunction)||y[i])?w(l,s,function(t,n){return u(v(t,n,a),i)}):(p=o[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},r=function(t,n){return o[t]=n},v=function(){return a=b.copy(o),s=b.copy(y)},h=b.resolvableWhen,d=b.resolvedDeferred,r("none",d),r("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),r("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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)}),r("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,animateOptions:e,finish:c,transition:g,animation:r,defaults:i.update,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,x,C,T,E,S,P,A,D,O,U;return U=up.util,a=void 0,t=void 0,T=void 0,u=void 0,x=void 0,i=void 0,d=U.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5}),c=function(){return clearTimeout(T),T=null},l=function(){return clearTimeout(u),u=null},S=function(){return a={},t=null,c(),l(),x=0,d.reset(),i=!1},S(),s=function(t){return k(t),[t.url,t.method,t.data,t.selector].join("|")},O=function(){var t,n,e;return t=U.keys(a),t.length>d.cacheSize&&(n=null,e=null,U.each(t,function(t){var r,o;return r=a[t],o=r.timestamp,!e||e>o?(n=t,e=o):void 0}),n)?delete a[n]:void 0},D=function(){return(new Date).valueOf()},k=function(t){return t._normalized||(t.method=U.normalizeMethod(t.method),t.url&&(t.url=U.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},r=function(t,n){var e;return U.debug("Aliasing %o to %o",t,n),(e=m(t))?P(n,e):void 0},e=function(t){var n,e,r,o,u;return n=U.castsToTrue(t.cache),e=U.castsToFalse(t.cache),u=U.only(t,"url","method","data","selector","_normalized"),r=!0,g(u)||n?(o=m(u))&&!e?r="pending"===o.state():(o=y(u),P(u,o)):(f(),o=y(u)),r&&!t.preload&&(w(),o.then(b)),o},n=["GET","OPTIONS","HEAD"],h=function(){return 0===x},o=function(){return x>0},w=function(){var t,n;return n=h(),x+=1,n?(t=function(){return o()?(up.bus.emit("proxy:busy"),i=!0):void 0},d.busyDelay>0?u=setTimeout(t,d.busyDelay):t()):void 0},b=function(){return x-=1,h()&&i?(up.bus.emit("proxy:idle"),i=!1):void 0},y=function(t){var n;return up.bus.emit("proxy:load",t),n=U.ajax(t),n.then(function(){return up.bus.emit("proxy:receive",t)}),n},g=function(t){return k(t),U.contains(n,t.method)},v=function(t){var n;return n=D()-t.timestamp,n<d.cacheExpiry},m=function(t){var n,e;return n=s(t),(e=a[n])?v(e)?(U.debug("Cache hit for %o (%o)",t.url,t),e):(U.debug("Discarding stale cache entry for %o (%o)",t.url,t),void E(t)):void U.debug("Cache miss for %o (%o)",t.url,t)},P=function(t,n){var e;return O(),e=s(t),n.timestamp=D(),a[e]=n,n},E=function(t){var n;return n=s(t),delete a[n]},f=function(){return a={}},p=function(n){var e,r;return r=parseInt(U.presentAttr(n,"up-delay"))||d.preloadDelay,n.is(t)?void 0:(t=n,c(),e=function(){return C(n)},A(e,r))},A=function(t,n){return T=setTimeout(t,n)},C=function(t,n){var e,r;return e=$(t),n=U.options(n),r=up.link.followMethod(e,n),g({method:r})?(U.debug("Preloading %o",e),n.preload=!0,up.link.follow(e,n)):(U.debug("Won't preload %o due to unsafe method %o",e,r),U.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:p(n)}),up.bus.on("framework:reset",S),{preload:C,ajax:e,get:m,set:P,alias:r,clear:f,remove:E,idle:h,busy:o,defaults:d.update}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,n){var e;return n=u.options(n),e=u.option(n.target,"body"),up.replace(e,t,n)},follow=function(t,n){var e,r,o;return e=$(t),n=u.options(n),o=u.option(e.attr("up-href"),e.attr("href")),r=u.option(n.target,e.attr("up-target"),"body"),n.transition=u.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=u.option(n.history,e.attr("up-history")),n.scroll=u.option(n.scroll,e.attr("up-scroll"),"body"),n.cache=u.option(n.cache,e.attr("up-cache")),n.method=followMethod(e,n),n=u.merge(n,up.motion.animateOptions(n,e)),up.replace(r,o,n)},followMethod=function(t,n){return n=u.options(n),u.option(n.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,n){return shouldProcessLinkEvent(t,n)?(t.preventDefault(),follow(n)):void 0}),childClicked=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-href]"),r.length&&n.find(r).length},shouldProcessLinkEvent=function(t,n){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,n)},up.on("click","a[up-follow], [up-href][up-follow]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.compiler("[up-expand]",function(t){var n,e,r,o,i,a,s,l;for(o=t.find("a, [up-href]").get(0),o||u.error("No link to expand within %o",t),l=/^up-/,a={},a["up-href"]=$(o).attr("href"),s=o.attributes,e=0,r=s.length;r>e;e++)n=s[e],i=n.name,i.match(l)&&(a[i]=n.value);return u.isGiven(a["up-target"])||(a["up-follow"]=""),u.setMissingAttrs(t,a),t.removeAttr("up-expand")}),up.compiler("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},u.isBlank(e)||u.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,u.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,childClicked:childClicked,followMethod:followMethod}}(),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,d,m;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),o=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),a=u.option(n.history,e.attr("up-history"),!0),p=u.option(n.transition,e.attr("up-transition")),i=u.option(n.failTransition,e.attr("up-fail-transition"),p),s=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),r=up.motion.animateOptions(n,e),m=u.option(n.cache,e.attr("up-cache")),d=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(a)?(l={url:d,method:s,data:e.serialize(),selector:c,cache:m},f=function(t){var n;return d=a?u.castsToFalse(a)?!1:u.isString(a)?a:(n=u.locationFromXhr(t))?n:"GET"===l.type?l.url+"?"+l.data:void 0:void 0,u.option(d,!1)},up.proxy.ajax(l).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){var o;return o=u.merge(r,{history:f(e),transition:p}),up.flow.implant(c,t,o)}).fail(function(t){var n,e;return e=t.responseText,n=u.merge(r,{transition:i}),up.flow.implant(o,e,n)})):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;
2
+ 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.compiler("[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,d,m;return d=up.util,u=void 0,e=d.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"}),c=function(){return n(),e.reset()},p=function(t,n,e){var r,o;return o=d.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 d.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r),a(n)},a=function(t){var n,e,r,o,u,i,a;if(e=d.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)},i=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,n,e){var r,o;return o=d.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),r=d.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),l(),o.hide(),o},m=function(t,n,e,r,o){return n.show(),p(t,n,e),up.animate(n,r,o)},s=function(t,r){var u,i,a,s,l,c,p,f,h;return u=$(t),r=d.options(r),h=d.option(r.url,u.attr("href")),p=d.option(r.target,u.attr("up-popup"),"body"),c=d.option(r.position,u.attr("up-position"),e.position),s=d.option(r.animation,u.attr("up-animation"),e.openAnimation),f=d.option(r.sticky,u.is("[up-sticky]")),l=up.browser.canPushState()?d.option(r.history,u.attr("up-history"),!1):!1,a=up.motion.animateOptions(r,u),n(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},n=function(t){var n;return n=$(".up-popup"),n.length?(t=d.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),u=void 0,up.destroy(n,t)):d.resolvedPromise()},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(i(),n())},r=function(t){var n;return n=$(t),n.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():s(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){var e;return r(n)?(e=n.attr("up-source"))?u=e: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",c),{open:s,close:n,source:f,defaults:e.update,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,r=m.config({maxWidth:void 0,minWidth:void 0,width:void 0,height:void 0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",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>'}}),i=void 0,c=function(){return e(),i=void 0,r.reset()},d=function(){var t;return t=r.template,m.isFunction(t)?t(r):t},l=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t){var n,e,r,o;return r=$(d()),t.sticky&&r.attr("up-sticky",""),r.attr("up-previous-url",up.browser.url()),r.attr("up-previous-title",document.title),e=r.find(".up-modal-dialog"),m.isPresent(t.width)&&e.css("width",t.width),m.isPresent(t.maxWidth)&&e.css("max-width",t.maxWidth),m.isPresent(t.height)&&e.css("height",t.height),n=r.find(".up-modal-content"),o=m.$createElementFromSelector(t.selector),o.appendTo(n),r.appendTo(document.body),l(),r.hide(),r},h=void 0,p=function(){var t,n,e;return e=m.scrollbarWidth(),t=parseInt($("body").css("padding-right")),n=e+t,h=m.temporaryCss($("body"),{"padding-right":n+"px","overflow-y":"hidden"})},v=function(t,n,e){var r;return up.bus.emit("modal:open"),p(),t.show(),r=up.animate(t,n,e),r.then(function(){return up.bus.emit("modal:opened")}),r},s=function(){var n,o,i,a,s,l,c,p,f,d,h,g,y;return s=1<=arguments.length?t.call(arguments,0):[],!m.isObject(s[0])||m.isElement(s[0])||m.isJQuery(s[0])?(n=$(s[0]),f=s[1]):(n=m.nullJquery(),f=s[0]),f=m.options(f),g=m.option(f.url,n.attr("up-href"),n.attr("href")),d=m.option(f.target,n.attr("up-modal"),"body"),y=m.option(f.width,n.attr("up-width"),r.width),p=m.option(f.maxWidth,n.attr("up-max-width"),r.maxWidth),l=m.option(f.height,n.attr("up-height"),r.height),a=m.option(f.animation,n.attr("up-animation"),r.openAnimation),h=m.option(f.sticky,n.is("[up-sticky]")),c=up.browser.canPushState()?m.option(f.history,n.attr("up-history"),!0):!1,i=up.motion.animateOptions(f,n),e(),o=u({selector:d,width:y,maxWidth:p,height:l,sticky:h}),up.replace(d,g,{history:c,insert:function(){return v(o,a,i)}})},f=function(){return i},e=function(t){var n,e;return n=$(".up-modal"),n.length?(t=m.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),i=void 0,up.bus.emit("modal:close"),e=up.destroy(n,t),e.then(function(){return h(),up.bus.emit("modal:closed")}),e):m.resolvedPromise()},n=function(){return $(".up-modal").is("[up-sticky]")?void 0:(a(),e())},o=function(t){var n;return n=$(t),n.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():s(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-modal-dialog").length||n.closest("[up-modal]").length?void 0:e()}),up.bus.on("fragment:ready",function(t){var e;if(o(t)){if(e=t.attr("up-source"))return i=e}else if(!up.popup.contains(t))return n()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-modal")?e():void 0}),up.bus.on("framework:reset",c),{open:s,close:e,source:f,defaults:r.update,contains: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 position %o",e)}}(),n.attr("up-position",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,p;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),p=o.option(u.position,i.attr("up-position"),"top"),l=o.option(u.animation,i.attr("up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=n(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[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,m,h,v;return m=up.util,u=m.config({currentClass:"up-current"}),c=function(){return u.reset()},i=function(){var t;return t=u.currentClass,m.contains(t,"up-current")||(t+=" up-current"),t},t="up-active",n=["a","[up-href]","[up-alias]"],r=n.join(", "),o=function(){var t,e,r;for(r=[],t=0,e=n.length;e>t;t++)d=n[t],r.push(d+"[up-instant]");return r}().join(", "),e="."+t,l=function(t){return m.isPresent(t)?m.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},f=function(t){var n,e,r,o,u,i,a,s,c,p;for(s=[],i=["href","up-href","up-alias"],e=0,o=i.length;o>e;e++)if(n=i[e],c=m.presentAttr(t,n))for(p="up-alias"===n?c.split(" "):[c],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=l(a),s.push(a));return s},v=function(t){var n,e,r,o;return t=m.compact(t),r=function(t){return"*"===t.substr(-1)?e(t.slice(0,-1)):n(t)},n=function(n){return m.contains(t,n)},e=function(n){return m.detect(t,function(t){return 0===t.indexOf(n)})},o=function(t){return m.detect(t,r)},{matchesAny:o}},s=function(){var t,n;return t=v([l(up.browser.url()),l(up.modal.source()),l(up.popup.source())]),n=i(),m.each($(r),function(e){var r,o;return r=$(e),o=f(r),t.matchesAny(o)?r.addClass(n):r.removeClass(n)})},p=function(n){return h(),n=a(n),n.addClass(t)},a=function(t){return m.presence(t.parents(r))||t},h=function(){return $(e).removeClass(t)},up.on("click",r,function(t,n){return m.isUnmodifiedMouseEvent(t)&&!n.is("[up-instant]")?p(n):void 0}),up.on("mousedown",o,function(t,n){return m.isUnmodifiedMouseEvent(t)?p(n):void 0}),up.bus.on("fragment:ready",function(){return h(),s()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?s():void 0}),up.bus.on("framework:reset",c),{defaults:u.update}}()}.call(this),function(){up.slot=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-slot]").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);
@@ -0,0 +1,5 @@
1
+ defaults = up.layout.defaults()
2
+
3
+ up.layout.defaults
4
+ fixedTop: "#{defaults.fixedTop}, .navbar-fixed-top"
5
+ fixedBottom: "#{defaults.fixedBottom}, .navbar-fixed-bottom"
@@ -9,8 +9,3 @@ up.modal.defaults
9
9
  </div>
10
10
  </div>
11
11
  """
12
-
13
- # BS use the class `active` to highlight the current section
14
- # of a navigation bar.
15
- up.navigation.defaults
16
- currentClass: 'active'
@@ -0,0 +1,4 @@
1
+ # BS use the class `active` to highlight the current section
2
+ # of a navigation bar.
3
+ up.navigation.defaults
4
+ currentClass: 'active'
@@ -2,7 +2,7 @@
2
2
  #= require up/util
3
3
  #= require up/browser
4
4
  #= require up/bus
5
- #= require up/viewport
5
+ #= require up/layout
6
6
  #= require up/flow
7
7
  #= require up/magic
8
8
  #= require up/history
@@ -48,7 +48,11 @@ up.flow = (->
48
48
  If omitted or true, the `url` argument will be used.
49
49
  If set to `false`, the history will remain unchanged.
50
50
  @param {String|Boolean} [options.source=true]
51
- @param {String} [options.scroll='body']
51
+ @param {String} [options.scroll]
52
+ Up.js will try to [reveal](/up.layout#up.reveal) the element being updated, by
53
+ scrolling its containing viewport. Set this option to `false` to prevent any scrolling.
54
+
55
+ If omitted, this will use the [default from `up.layout`](/up.layout#up.layout.defaults).
52
56
  @param {Boolean} [options.cache]
53
57
  Whether to use a [cached response](/up.proxy) if available.
54
58
  @param {String} [options.historyMethod='push']
@@ -131,7 +135,7 @@ up.flow = (->
131
135
  options.history = null
132
136
 
133
137
  if u.castsToFalse(options.scroll)
134
- options.scroll = null
138
+ options.scroll = false
135
139
 
136
140
  options.source = u.option(options.source, options.history)
137
141
  response = parseResponse(html)
@@ -139,9 +143,8 @@ up.flow = (->
139
143
 
140
144
  for step in parseImplantSteps(selector, options)
141
145
  $old = findOldFragment(step.selector)
142
- $new = response.find(step.selector)
143
- prepareForReplacement($old, options).then ->
144
- swapElements($old, $new, step.pseudoClass, step.transition, options)
146
+ $new = response.find(step.selector).first()
147
+ swapElements($old, $new, step.pseudoClass, step.transition, options)
145
148
 
146
149
  findOldFragment = (selector) ->
147
150
  # Prefer to replace fragments in an open popup or modal
@@ -167,16 +170,10 @@ up.flow = (->
167
170
  else
168
171
  u.error("Could not find selector %o in response %o", selector, html)
169
172
 
170
- prepareForReplacement = ($element, options) ->
171
- # Ensure that all transitions and animations have completed.
172
- up.motion.finish($element)
173
- # Make sure the old element is visible in the viewport
174
- # to mimick browser behavior during a page switch.
175
- reveal($element, options.scroll)
176
-
177
- reveal = ($element, view) ->
178
- if view # empty strings are falsish in Javascript
179
- up.reveal($element, view: view)
173
+ reveal = ($element, options) ->
174
+ viewport = options.scroll
175
+ if viewport != false
176
+ up.reveal($element, viewport: viewport)
180
177
  else
181
178
  u.resolvedDeferred()
182
179
 
@@ -195,33 +192,50 @@ up.flow = (->
195
192
 
196
193
  swapElements = ($old, $new, pseudoClass, transition, options) ->
197
194
  transition ||= 'none'
195
+
196
+ # Ensure that all transitions and animations have completed.
197
+ up.motion.finish($old)
198
+
198
199
  if pseudoClass
199
200
  insertionMethod = if pseudoClass == 'before' then 'prepend' else 'append'
200
- # Keep a reference to the children append/prepend because
201
- # we need to compile them further down. Note that since we're
202
- # prepending/appending instead of rpelacing, `$new` will not
203
- # actually be inserted into the DOM, only its children.
204
- $addedChildren = $new.children()
205
- # Insert contents() instead of $children since contents()
206
- # also includes text nodes.
207
- $old[insertionMethod]($new.contents())
201
+
202
+ # Text nodes are wrapped in a .up-insertion container so we can
203
+ # animate them and measure their position/size for scrolling.
204
+ # This is not possible for container-less text nodes.
205
+ $wrapper = $new.contents().wrap('<span class="up-insertion"></span>').parent()
206
+
207
+ # Note that since we're prepending/appending instead of replacing,
208
+ # `$new` will not actually be inserted into the DOM, only its children.
209
+ $old[insertionMethod]($wrapper)
210
+
208
211
  u.copyAttributes($new, $old)
209
- elementsInserted($addedChildren, options)
210
- # Since we're adding content instead of replacing, we'll only
211
- # animate $new instead of morphing between $old and $new
212
- up.animate($new, transition, options)
212
+ elementsInserted($wrapper.children(), options)
213
+
214
+ # Show the first element that was being prepended/appended.
215
+ reveal($wrapper, options)
216
+ .then ->
217
+ # Since we're adding content instead of replacing, we'll only
218
+ # animate $new instead of morphing between $old and $new
219
+ return up.animate($wrapper, transition, options)
220
+ .then ->
221
+ u.unwrapElement($wrapper)
222
+ return
213
223
  else
214
- # Wrap the replacement as a destroy animation, so $old will
215
- # get marked as .up-destroying right away.
216
- destroy $old, animation: ->
217
- # Don't insert the new element after the old element.
218
- # For some reason this will make the browser scroll to the
219
- # bottom of the new element.
220
- $new.insertBefore($old)
221
- elementsInserted($new, options)
222
- if $old.is('body') && transition != 'none'
223
- u.error('Cannot apply transitions to body-elements (%o)', transition)
224
- up.morph($old, $new, transition, options)
224
+ # Make sure the old element is visible before replacing it.
225
+ # This mimicks what the browser does during a full page load.
226
+ reveal($old, options)
227
+ .then ->
228
+ # Wrap the replacement as a destroy animation, so $old will
229
+ # get marked as .up-destroying right away.
230
+ destroy $old, animation: ->
231
+ # Don't insert the new element after the old element.
232
+ # For some reason this will make the browser scroll to the
233
+ # bottom of the new element.
234
+ $new.insertBefore($old)
235
+ elementsInserted($new, options)
236
+ if $old.is('body') && transition != 'none'
237
+ u.error('Cannot apply transitions to body-elements (%o)', transition)
238
+ up.morph($old, $new, transition, options)
225
239
 
226
240
  parseImplantSteps = (selector, options) ->
227
241
  transitionString = options.transition || options.animation || 'none'
@@ -301,8 +315,8 @@ up.flow = (->
301
315
  animationPromise = u.presence(options.animation, u.isPromise) ||
302
316
  up.motion.animate($element, options.animation, animateOptions)
303
317
  animationPromise.then -> $element.remove()
304
-
305
-
318
+ animationPromise
319
+
306
320
  ###*
307
321
  Replaces the given selector or element with a fresh copy
308
322
  fetched from the server.
@@ -0,0 +1,330 @@
1
+ ###*
2
+ Viewport scrolling
3
+ ==================
4
+
5
+ This modules contains functions to scroll the viewport and reveal contained elements.
6
+
7
+ @class up.layout
8
+ ###
9
+ up.layout = (->
10
+
11
+ u = up.util
12
+
13
+ ###*
14
+
15
+
16
+ @method up.layout.defaults
17
+ @param {String} [options.viewport]
18
+ @param {String} [options.fixedTop]
19
+ @param {String} [options.fixedBottom]
20
+ @param {Number} [options.duration]
21
+ @param {String} [options.easing]
22
+ @param {Number} [options.snap]
23
+ ###
24
+ config = u.config
25
+ duration: 0
26
+ viewport: 'body, .up-modal, [up-viewport]'
27
+ fixedTop: '[up-fixed~=top]'
28
+ fixedBottom: '[up-fixed~=bottom]'
29
+ snap: 50
30
+ easing: 'swing'
31
+
32
+ reset = ->
33
+ config.reset()
34
+
35
+ SCROLL_PROMISE_KEY = 'up-scroll-promise'
36
+
37
+ ###*
38
+ Scrolls the given viewport to the given Y-position.
39
+
40
+ A "viewport" is an element that has scrollbars, e.g. `<body>` or
41
+ a container with `overflow-x: scroll`.
42
+
43
+ \#\#\#\# Example
44
+
45
+ This will scroll a `<div class="main">...</div>` to a Y-position of 100 pixels:
46
+
47
+ up.scoll('.main', 100);
48
+
49
+ \#\#\#\# Animating the scrolling motion
50
+
51
+ The scrolling can (optionally) be animated.
52
+
53
+ up.scoll('.main', 100, {
54
+ easing: 'swing',
55
+ duration: 250
56
+ });
57
+
58
+ If the given viewport is already in a scroll animation when `up.scroll`
59
+ is called a second time, the previous animation will instantly jump to the
60
+ last frame before the next animation is started.
61
+
62
+ @protected
63
+ @method up.scroll
64
+ @param {String|Element|jQuery} viewport
65
+ The container element to scroll.
66
+ @param {Number} scrollPos
67
+ The absolute number of pixels to set the scroll position to.
68
+ @param {Number}[options.duration]
69
+ The number of miliseconds for the scrolling's animation.
70
+ @param {String}[options.easing]
71
+ The timing function that controls the acceleration for the scrolling's animation.
72
+ @return {Deferred}
73
+ A promise that will be resolved when the scrolling ends.
74
+ ###
75
+ scroll = (viewport, scrollTop, options) ->
76
+ $view = $(viewport)
77
+ options = u.options(options)
78
+ duration = u.option(options.duration, config.duration)
79
+ easing = u.option(options.easing, config.easing)
80
+
81
+ finishScrolling($view)
82
+
83
+ if duration > 0
84
+ deferred = $.Deferred()
85
+
86
+ $view.data(SCROLL_PROMISE_KEY, deferred)
87
+ deferred.then ->
88
+ $view.removeData(SCROLL_PROMISE_KEY)
89
+ # Since we're scrolling using #animate, #finish can be
90
+ # used to jump to the last frame:
91
+ # https://api.jquery.com/finish/
92
+ $view.finish()
93
+
94
+ targetProps =
95
+ scrollTop: scrollTop
96
+
97
+ $view.animate targetProps,
98
+ duration: duration,
99
+ easing: easing,
100
+ complete: -> deferred.resolve()
101
+
102
+ deferred
103
+ else
104
+ $view.scrollTop(scrollTop)
105
+ u.resolvedDeferred()
106
+
107
+ ###*
108
+ @method up.viewport.finishScrolling
109
+ @private
110
+ ###
111
+ finishScrolling = (elementOrSelector) ->
112
+ $(elementOrSelector).each ->
113
+ if existingScrolling = $(this).data(SCROLL_PROMISE_KEY)
114
+ existingScrolling.resolve()
115
+
116
+ measureObstruction = ->
117
+
118
+ measurePosition = (obstructor, cssAttr) ->
119
+ $obstructor = $(obstructor)
120
+ anchorPosition = $obstructor.css(cssAttr)
121
+ unless anchorPosition == '0' or u.endsWith(anchorPosition, 'px')
122
+ u.error("Fixed element must have an anchor position in px, but was %o", anchorPosition)
123
+ parseInt(anchorPosition) + $obstructor.height()
124
+
125
+ fixedTopBottoms = for obstructor in $(config.fixedTop)
126
+ measurePosition(obstructor, 'top')
127
+
128
+ fixedBottomTops = for obstructor in $(config.fixedBottom)
129
+ measurePosition(obstructor, 'bottom')
130
+
131
+ top: Math.max(0, fixedTopBottoms...)
132
+ bottom: Math.max(0, fixedBottomTops...)
133
+
134
+ ###*
135
+ Scroll's the given element's viewport so the element
136
+ is visible for the user.
137
+
138
+ By default Up.js will always reveal an element before
139
+ updating it with Javascript functions like [`up.replace`](/up.flow#up.replace)
140
+ or UJS behavior like [`[up-target]`](/up.link#up-target).
141
+
142
+ \#\#\#\# How Up.js finds the viewport
143
+
144
+ The viewport (the container that is going to be scrolled)
145
+ is the closest parent of the element that is either:
146
+
147
+ - the currently open [modal](/up.modal)
148
+ - an element with the attribute `[up-viewport]`
149
+ - the `<body>` element
150
+ - an element matching the selector you have configured using `up.viewport.defaults({ viewSelector: 'my-custom-selector' })`
151
+
152
+ \#\#\#\# Fixed elements obstruction the viewport
153
+
154
+ Many applications have a navigation bar fixed to the top or bottom,
155
+ obstructing the view on an element.
156
+
157
+ To make `up.aware` of these fixed elements you can either:
158
+
159
+ - give the element an attribute [`up-fixed="top"`](#up-fixed-top) or [`up-fixed="bottom"`](up-fixed-bottom)
160
+ - [configure default options](#up.layout.defaults) for `fixedTop` or `fixedBottom`
161
+
162
+ @method up.reveal
163
+ @param {String|Element|jQuery} element
164
+ @param {String|Element|jQuery} [options.viewport]
165
+ @param {Number} [options.duration]
166
+ @param {String} [options.easing]
167
+ @param {String} [options.snap]
168
+ @return {Deferred}
169
+ A promise that will be resolved when the element is revealed.
170
+ ###
171
+ reveal = (elementOrSelector, options) ->
172
+ options = u.options(options)
173
+ $element = $(elementOrSelector)
174
+ $viewport = findViewport($element, options.viewport)
175
+
176
+ snap = u.option(options.snap, config.snap)
177
+
178
+ viewportIsBody = $viewport.is('body')
179
+ viewportHeight = if viewportIsBody then u.clientSize().height else $viewport.height()
180
+ originalScrollPos = $viewport.scrollTop()
181
+ newScrollPos = originalScrollPos
182
+
183
+ offsetShift = undefined
184
+ obstruction = undefined
185
+
186
+ if viewportIsBody
187
+ obstruction = measureObstruction()
188
+ # Within the body, $.position will always return the distance
189
+ # from the document top and *not* the distance of the viewport
190
+ # top. This is what the calculations below expect, so don't shift.
191
+ offsetShift = 0
192
+ else
193
+ obstruction = { top: 0, bottom: 0 }
194
+ # When the scrolled element is not <body> but instead a container
195
+ # with overflow-y: scroll, $.position returns the position the
196
+ # viewport's top edge instead of the first row of the canvas buffer.
197
+ # http://codepen.io/anon/pen/jPojGE
198
+ offsetShift = originalScrollPos
199
+
200
+ predictFirstVisibleRow = -> newScrollPos + obstruction.top
201
+ predictLastVisibleRow = -> newScrollPos + viewportHeight - obstruction.bottom - 1
202
+
203
+ elementDims = u.measure($element, relative: true)
204
+ firstElementRow = elementDims.top + offsetShift
205
+ lastElementRow = firstElementRow + elementDims.height - 1
206
+
207
+ if lastElementRow > predictLastVisibleRow()
208
+ # Try to show the full height of the element
209
+ newScrollPos += (lastElementRow - predictLastVisibleRow())
210
+
211
+ if firstElementRow < predictFirstVisibleRow()
212
+ # If the full element does not fit, scroll to the first row
213
+ newScrollPos = firstElementRow - obstruction.top
214
+
215
+ if newScrollPos < snap
216
+ newScrollPos = 0
217
+
218
+ if newScrollPos != originalScrollPos
219
+ scroll($viewport, newScrollPos, options)
220
+ else
221
+ u.resolvedDeferred()
222
+
223
+ ###*
224
+ @private
225
+ @method up.viewport.findViewport
226
+ ###
227
+ findViewport = ($element, viewportSelectorOrElement) ->
228
+ $viewport = undefined
229
+ # If someone has handed as a jQuery element, that's the
230
+ # view period.
231
+ if u.isJQuery(viewportSelectorOrElement)
232
+ $viewport = viewportSelectorOrElement
233
+ else
234
+ vieportSelector = u.presence(viewportSelectorOrElement) || config.viewport
235
+ $viewport = $element.closest(vieportSelector)
236
+
237
+ $viewport.length or u.error("Could not find viewport for %o", $element)
238
+ $viewport
239
+
240
+ ###*
241
+ Marks this element as a scrolling container. Apply this ttribute if your app uses
242
+ a custom panel layout with fixed positioning instead of scrolling `<body>`.
243
+
244
+ [`up.reveal`](/up.reveal) will always try to scroll the viewport closest
245
+ to the element that is being revealed. By default this is the `<body>` element.
246
+
247
+ \#\#\#\# Example
248
+
249
+ Here is an example for a layout for an e-mail client, showing a list of e-mails
250
+ on the left side and the e-mail text on the right side:
251
+
252
+ .side {
253
+ position: fixed;
254
+ top: 0;
255
+ bottom: 0;
256
+ left: 0;
257
+ width: 100px;
258
+ overflow-y: scroll;
259
+ }
260
+
261
+ .main {
262
+ position: fixed;
263
+ top: 0;
264
+ bottom: 0;
265
+ left: 100px;
266
+ right: 0;
267
+ overflow-y: scroll;
268
+ }
269
+
270
+ This would be the HTML (notice the `up-viewport` attribute):
271
+
272
+ <div class=".side" up-viewport>
273
+ <a href="/emails/5001" up-target=".main">Re: Your invoice</a>
274
+ <a href="/emails/2023" up-target=".main">Quote for services</a>
275
+ <a href="/emails/9002" up-target=".main">Fwd: Room reservation</a>
276
+ </div>
277
+
278
+ <div class="main" up-viewport>
279
+ <h1>Re: Your Invoice</h1>
280
+ <p>
281
+ Lorem ipsum dolor sit amet, consetetur sadipscing elitr.
282
+ Stet clita kasd gubergren, no sea takimata sanctus est.
283
+ </p>
284
+ </div>
285
+
286
+ @method [up-viewport]
287
+ @ujs
288
+ ###
289
+
290
+ ###*
291
+ Marks this element as a navigation fixed to the top edge of the screen
292
+ using `position: fixed`.
293
+
294
+ [`up.reveal`](/up.reveal) is aware of fixed elements and will scroll
295
+ the viewport far enough so the revealed element is fully visible.
296
+
297
+ Example:
298
+
299
+ <div class="top-nav" up-fixed="top">...</div>
300
+
301
+ @method [up-fixed=top]
302
+ @ujs
303
+ ###
304
+
305
+ ###*
306
+ Marks this element as a navigation fixed to the bottom edge of the screen
307
+ using `position: fixed`.
308
+
309
+ [`up.reveal`](/up.reveal) is aware of fixed elements and will scroll
310
+ the viewport far enough so the revealed element is fully visible.
311
+
312
+ Example:
313
+
314
+ <div class="bottom-nav" up-fixed="bottom">...</div>
315
+
316
+ @method [up-fixed=bottom]
317
+ @ujs
318
+ ###
319
+
320
+ up.bus.on 'framework:reset', reset
321
+
322
+ reveal: reveal
323
+ scroll: scroll
324
+ finishScrolling: finishScrolling
325
+ defaults: config.update
326
+
327
+ )()
328
+
329
+ up.scroll = up.layout.scroll
330
+ up.reveal = up.layout.reveal