upjs-rails 0.17.0 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +46 -1
  3. data/dist/up.js +929 -374
  4. data/dist/up.min.js +2 -2
  5. data/lib/assets/javascripts/up/browser.js.coffee +31 -14
  6. data/lib/assets/javascripts/up/bus.js.coffee +87 -22
  7. data/lib/assets/javascripts/up/flow.js.coffee +119 -43
  8. data/lib/assets/javascripts/up/form.js.coffee +188 -57
  9. data/lib/assets/javascripts/up/link.js.coffee +57 -21
  10. data/lib/assets/javascripts/up/modal.js.coffee +77 -63
  11. data/lib/assets/javascripts/up/motion.js.coffee +10 -9
  12. data/lib/assets/javascripts/up/popup.js.coffee +54 -40
  13. data/lib/assets/javascripts/up/proxy.js.coffee +46 -17
  14. data/lib/assets/javascripts/up/rails.js.coffee +22 -4
  15. data/lib/assets/javascripts/up/syntax.js.coffee +2 -2
  16. data/lib/assets/javascripts/up/util.js.coffee +100 -16
  17. data/lib/upjs/rails/inspector.rb +3 -3
  18. data/lib/upjs/rails/version.rb +1 -1
  19. data/spec_app/Gemfile.lock +1 -4
  20. data/spec_app/app/controllers/test_controller.rb +2 -2
  21. data/spec_app/spec/controllers/test_controller_spec.rb +5 -5
  22. data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +9 -0
  23. data/spec_app/spec/javascripts/helpers/knife.js.coffee +0 -1
  24. data/spec_app/spec/javascripts/helpers/reset_path.js.coffee +4 -5
  25. data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +5 -0
  26. data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +8 -0
  27. data/spec_app/spec/javascripts/up/bus_spec.js.coffee +26 -0
  28. data/spec_app/spec/javascripts/up/flow_spec.js.coffee +203 -91
  29. data/spec_app/spec/javascripts/up/form_spec.js.coffee +244 -49
  30. data/spec_app/spec/javascripts/up/history_spec.js.coffee +8 -2
  31. data/spec_app/spec/javascripts/up/link_spec.js.coffee +83 -30
  32. data/spec_app/spec/javascripts/up/modal_spec.js.coffee +23 -17
  33. data/spec_app/spec/javascripts/up/motion_spec.js.coffee +4 -4
  34. data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +1 -1
  35. data/spec_app/spec/javascripts/up/popup_spec.js.coffee +26 -16
  36. data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +45 -13
  37. data/spec_app/spec/javascripts/up/rails_spec.js.coffee +48 -0
  38. data/spec_app/spec/javascripts/up/util_spec.js.coffee +48 -0
  39. metadata +5 -2
data/dist/up.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){window.up={}}).call(this),function(){var e=[].slice;up.util=function(t){var n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g,y,b,w,k,x,S,C,$,T,E,P,A,U,O,D,j,F,M,R,z,H,L,W,I,V,K,_,Q,q,N,X,B,G,J,Y,Z,et,tt,nt,rt,ot,ut,it,at,lt,st,ct,pt,ft,dt,mt,ht,vt,gt,yt,bt,wt,kt,xt,St,Ct,$t,Tt,Et,Pt,At,Ut,Ot,Dt,jt;return Z=function(t){var n,r;return n=void 0,r=!1,function(){var o;return o=1<=arguments.length?e.call(arguments,0):[],r?n:(r=!0,n=t.apply(null,o))}},u=function(e){return e=d(e),e.selector&&(e.headers||(e.headers={}),e.headers["X-Up-Selector"]=e.selector),t.ajax(e)},_=function(e,t){return t=t.toString(),(""===t||"80"===t)&&"http:"===e||"443"===t&&"https:"===e},ut=function(e,t){var n,r,o;return n=ft(e),r=n.protocol+"//"+n.hostname,_(n.protocol,n.port)||(r+=":"+n.port),o=n.pathname,"/"!==o[0]&&(o="/"+o),(null!=t?t.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=t?t.hash:void 0)===!0&&(r+=n.hash),(null!=t?t.search:void 0)!==!1&&(r+=n.search),r},ft=function(e){var n;return n=null,Q(e)?(n=t("<a>").attr({href:e}).get(0),U(n.hostname)&&(n.href=n.href)):n=Pt(e),n},ot=function(e){return e?e.toUpperCase():"GET"},n=function(e){var n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g;for(v=e.split(/[ >]/),o=null,p=f=0,m=v.length;m>f;p=++f){for(a=v[p],i=a.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),g="div",u=[],c=null,d=0,h=i.length;h>d;d++)switch(l=i[d],l[0]){case".":u.push(l.substr(1));break;case"#":c=l.substr(1);break;default:g=l}s="<"+g,u.length&&(s+=' class="'+u.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=t(s),r&&n.appendTo(r),0===p&&(o=n),r=n}return o},h=function(e,t){var n;return n=document.createElement(e),V(t)&&(n.innerHTML=t),n},y=function(){var t,n,r;return n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],n="[UP] "+n,(r=up.browser).puts.apply(r,["debug",n].concat(e.call(t)))},jt=function(){var t,n,r;return n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],n="[UP] "+n,(r=up.browser).puts.apply(r,["warn",n].concat(e.call(t)))},k=function(){var n,r,o,u;throw r=1<=arguments.length?e.call(arguments,0):[],r[0]="[UP] "+r[0],(u=up.browser).puts.apply(u,["error"].concat(e.call(r))),o=S.apply(null,r),n=dt(t(".up-error"))||t('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(o),new Error(o)},o=/\%[odisf]/g,S=function(){var t,n,r,u;return t=1<=arguments.length?e.call(arguments,0):[],u=t[0],n=0,r=80,u.replace(o,function(){var e,o;return n+=1,e=t[n],o=typeof e,"string"===o?(e=e.replace(/\s+/g," "),e.length>r&&(e=e.substr(0,r)+"\u2026"),e='"'+e+'"'):e="undefined"===o?"undefined":"number"===o||"function"===o?e.toString():JSON.stringify(e),e.length>r&&(e=e.substr(0,r)+" \u2026",("object"===o||"function"===o)&&(e+=" }")),e})},kt=function(e){var n,r,o,u,i,a,l,s,c,p;if(n=t(e),c=void 0,y("Creating selector from element %o",n.get(0)),p=dt(n.attr("up-id")))c="[up-id='"+p+"']";else if(u=dt(n.attr("id")))c="#"+u;else if(s=dt(n.attr("name")))c="[name='"+s+"']";else if(r=dt(n.attr("class")))for(o=r.split(" "),c="",i=0,l=o.length;l>i;i++)a=o[i],c+="."+a;else c=n.prop("tagName").toLowerCase();return c},v=function(e){var t,n,r,o,u,i,a,l,s,c,p,f;return s=function(e){return"<"+e+"(?: [^>]*)?>"},i=function(e){return"</"+e+">"},t="(?:.|\\n)*?",u=function(e){return"("+e+")"},f=new RegExp(s("head")+t+s("title")+u(t)+i("title")+t+i("body"),"i"),o=new RegExp(s("body")+u(t)+i("body"),"i"),(r=e.match(o))?(l=document.createElement("html"),n=h("body",r[1]),l.appendChild(n),(p=e.match(f))&&(a=h("head"),l.appendChild(a),c=h("title",p[1]),a.appendChild(c)),l):h("div",e)},C=t.extend,Et=t.trim,w=function(e,t){var n,r,o,u,i;for(i=[],n=o=0,u=e.length;u>o;n=++o)r=e[n],i.push(t(r,n));return i},J=w,Ct=function(e,t){var n,r,o,u;for(u=[],n=r=0,o=e-1;o>=0?o>=r:r>=o;n=o>=0?++r:--r)u.push(t(n));return u},L=function(e){return null===e},q=function(e){return void 0===e},D=function(e){return!q(e)},H=function(e){return q(e)||L(e)},M=function(e){return!H(e)},U=function(e){return H(e)||I(e)&&0===Object.keys(e).length||0===e.length},dt=function(e,t){return null==t&&(t=V),t(e)?e:void 0},V=function(e){return!U(e)},F=function(e){return"function"==typeof e},Q=function(e){return"string"==typeof e},W=function(e){return"number"==typeof e},R=function(e){return"object"==typeof e&&!!e},I=function(e){return R(e)||"function"==typeof e},j=function(e){return!(!e||1!==e.nodeType)},z=function(e){return e instanceof jQuery},K=function(e){return I(e)&&F(e.then)},O=function(e){return K(e)&&F(e.resolve)},A=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Tt=function(e){return Array.prototype.slice.call(e)},d=function(e){return A(e)?e.slice():C({},e)},Pt=function(e){return z(e)?e.get(0):e},et=function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],C.apply(null,[{}].concat(e.call(t)))},pt=function(e,t){var n,r,o,u;if(o=e?d(e):{},t)for(r in t)n=t[r],u=o[r],M(u)?I(n)&&I(u)&&(o[r]=pt(u,n)):o[r]=n;return o},ct=function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],b(t,M)},b=function(e,t){var n,r,o,u;for(u=void 0,r=0,o=e.length;o>r;r++)if(n=e[r],t(n)){u=n;break}return u},i=function(e,t){var n,r,o,u;for(u=!1,r=0,o=e.length;o>r;r++)if(n=e[r],t(n)){u=!0;break}return u},c=function(e){return wt(e,M)},At=function(e){var t;return t={},wt(e,function(e){return t.hasOwnProperty(e)?!1:t[e]=!0})},wt=function(e,t){var n;return n=[],w(e,function(e){return t(e)?n.push(e):void 0}),n},mt=function(){var t,n,r,o;return t=arguments[0],r=2<=arguments.length?e.call(arguments,1):[],o=function(){var e,o,u;for(u=[],e=0,o=r.length;o>e;e++)n=r[e],u.push(t.attr(n));return u}(),b(o,V)},rt=function(e){return setTimeout(e,0)},B=function(e){return e[e.length-1]},s=function(){var e;return e=document.documentElement,{width:e.clientWidth,height:e.clientHeight}},bt=Z(function(){var e,n,r;return e=t("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),e.appendTo(document.body),n=e.get(0),r=n.offsetWidth-n.clientWidth,e.remove(),r}),lt=function(t){var n;return n=void 0,function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],null!=t&&(n=t.apply(null,r)),t=void 0,n}},St=function(e,t,n){var r,o;return o=e.css(Object.keys(t)),e.css(t),r=function(){return e.css(o)},n?(n(),r()):lt(r)},P=function(e){var t,n;return n=e.css(["transform","-webkit-transform"]),U(n)||"none"===n.transform?(t=function(){return e.css(n)},e.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):t=function(){},t},g=function(e,n,o){var u,i,a,l,s,c;return u=t(e),o=pt(o,{duration:300,delay:0,easing:"ease"}),i=t.Deferred(),l={"transition-property":Object.keys(n).join(", "),"transition-duration":o.duration+"ms","transition-delay":o.delay+"ms","transition-timing-function":o.easing},s=P(u),c=St(u,l),u.css(n),i.then(s),i.then(c),u.data(r,i),i.then(function(){return u.removeData(r)}),a=setTimeout(function(){return i.resolve()},o.duration+o.delay),i.then(function(){return clearTimeout(a)}),i},r="up-animation-promise",T=function(e){return t(e).each(function(){var e;return(e=t(this).data(r))?e.resolve():void 0})},Y=function(e,n){var r,o,u,i,a,l;return n=pt(n,{relative:!1,inner:!1,full:!1}),n.relative?n.relative===!0?i=e.position():(r=t(n.relative),a=e.offset(),r.is(document)?i=a:(u=r.offset(),i={left:a.left-u.left,top:a.top-u.top})):i=e.offset(),o={left:i.left,top:i.top},n.inner?(o.width=e.width(),o.height=e.height()):(o.width=e.outerWidth(),o.height=e.outerHeight()),n.full&&(l=s(),o.right=l.width-(o.left+o.width),o.bottom=l.height-(o.top+o.height)),o},m=function(e,t){var n,r,o,u,i;for(u=e.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)n=u[r],i.push(n.specified?t.attr(n.name,n.value):void 0);return i},$=function(e,t){return e.find(t).addBack(t)},x=function(e){return 27===e.keyCode},f=function(e,t){return e.indexOf(t)>=0},l=function(e,t){var n;switch(n=e.attr(t)){case"false":return!1;case"true":return!0;case"":return!0;default:return n}},G=function(e){return e.getResponseHeader("X-Up-Location")},$t=function(e){return e.getResponseHeader("X-Up-Title")},tt=function(e){return e.getResponseHeader("X-Up-Method")},st=function(){var t,n,r,o,u,i;for(o=arguments[0],u=2<=arguments.length?e.call(arguments,1):[],t={},n=0,r=u.length;r>n;n++)i=u[n],o.hasOwnProperty(i)&&(t[i]=o[i]);return t},N=function(e){return!(e.metaKey||e.shiftKey||e.ctrlKey)},X=function(e){var t;return t=q(e.button)||0===e.button,t&&N(e)},gt=function(){var e;return e=t.Deferred(),e.resolve(),e},yt=function(){return gt().promise()},Ut=function(){return t.Deferred()},Ot=function(){return Ut().promise()},it=function(){return t()},vt=function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],r=t.when.apply(t,n),r.resolve=function(){return w(n,function(e){return"function"==typeof e.resolve?e.resolve():void 0})},r},xt=function(e,t){var n,r,o;r=[];for(n in t)o=t[n],r.push(H(e.attr(n))?e.attr(n,o):void 0);return r},ht=function(e,t){var n;return n=e.indexOf(t),n>=0?(e.splice(n,1),t):void 0},nt=function(e){var n,r,o,u,a,l,s;for(a={},s=[],r=[],o=0,u=e.length;u>o;o++)l=e[o],Q(l)?s.push(l):r.push(l);return a.parsed=r,s.length&&(n=s.join(", "),a.parsed.push(n)),a.select=function(){return a.find(void 0)},a.find=function(e){var n,r,o,u,i,l;for(r=it(),i=a.parsed,o=0,u=i.length;u>o;o++)l=i[o],n=e?e.find(l):t(l),r=r.add(n);return r},a.findWithSelf=function(e){var t;return t=a.find(e),a.doesMatch(e)&&(t=t.add(e)),t},a.doesMatch=function(e){var n;return n=t(e),i(a.parsed,function(e){return n.is(e)})},a.seekUp=function(e){var n,r,o;for(o=t(e),n=o,r=void 0;n.length;){if(a.doesMatch(n)){r=n;break}n=n.parent()}return r||it()},a},a=function(t){var n,r,o,u,i,a,l,s,c,p,f,m;return null==t&&(t={}),f=void 0,r=function(){return f={}},r(),l=function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],t.log?(n[0]="["+t.log+"] "+n[0],y.apply(null,n)):void 0},a=function(){return Object.keys(f)},s=function(){return H(t.size)?void 0:F(t.size)?t.size():W(t.size)?t.size:k("Invalid size config: %o",t.size)},o=function(){return H(t.expiry)?void 0:F(t.expiry)?t.expiry():W(t.expiry)?t.expiry:k("Invalid expiry config: %o",t.expiry)},c=function(e){return t.key?t.key(e):e.toString()},Et=function(){var e,t,n,r;return r=d(a()),n=s(),n&&r.length>n&&(e=null,t=null,w(r,function(n){var r,o;return r=f[n],o=r.timestamp,!t||t>o?(e=n,t=o):void 0}),e)?delete f[e]:void 0},n=function(e,t){var n;return n=u(e),D(n)?p(t,n):void 0},m=function(){return(new Date).valueOf()},p=function(e,t){var n;return n=c(e),f[n]={timestamp:m(),value:t}},ht=function(e){var t;return t=c(e),delete f[t]},i=function(e){var t,n;return t=o(),t?(n=m()-e.timestamp,n<o()):!0},u=function(e,t){var n,r;return null==t&&(t=void 0),r=c(e),(n=f[r])?i(n)?(l("Cache hit for %o",e),n.value):(l("Discarding stale cache entry for %o",e),ht(e),t):(l("Cache miss for %o",e),t)},{alias:n,get:u,set:p,remove:ht,clear:r,keys:a}},p=function(e){var t;return null==e&&(e={}),t={},t.reset=function(){return C(t,e)},t.reset(),Object.preventExtensions(t),t},Dt=function(e){var t,n;return e=Pt(e),t=e.parentNode,n=Tt(e.childNodes),w(n,function(n){return t.insertBefore(n,e)}),t.removeChild(e)},at=function(e){var t,n;for(t=void 0;(e=e.parent())&&e.length;)if(n=e.css("position"),"absolute"===n||"relative"===n||e.is("body")){t=e;break}return t},E=function(e,n){var r,o,u,i;return r=t(e),o=at(r),u=r.position(),i=o.offset(),r.css({position:"absolute",left:u.left-i.left,top:u.top-i.top+n.scrollTop(),right:"",bottom:""})},{offsetParent:at,fixedToAbsolute:E,presentAttr:mt,createElement:h,parseUrl:ft,normalizeUrl:ut,normalizeMethod:ot,createElementFromHtml:v,$createElementFromSelector:n,selectorForElement:kt,ajax:u,extend:C,copy:d,merge:et,options:pt,option:ct,error:k,debug:y,warn:jt,each:w,map:J,times:Ct,any:i,detect:b,select:wt,compact:c,uniq:At,last:B,isNull:L,isDefined:D,isUndefined:q,isGiven:M,isMissing:H,isPresent:V,isBlank:U,presence:dt,isObject:I,isFunction:F,isString:Q,isElement:j,isJQuery:z,isPromise:K,isDeferred:O,isHash:R,isUnmodifiedKeyEvent:N,isUnmodifiedMouseEvent:X,nullJQuery:it,unJQuery:Pt,nextFrame:rt,measure:Y,temporaryCss:St,cssAnimate:g,finishCssAnimate:T,forceCompositing:P,escapePressed:x,copyAttributes:m,findWithSelf:$,contains:f,isArray:A,toArray:Tt,castedAttr:l,locationFromXhr:G,titleFromXhr:$t,methodFromXhr:tt,clientSize:s,only:st,trim:Et,unresolvableDeferred:Ut,unresolvablePromise:Ot,resolvedPromise:yt,resolvedDeferred:gt,resolvableWhen:vt,setMissingAttrs:xt,remove:ht,memoize:Z,scrollbarWidth:bt,config:p,cache:a,unwrapElement:Dt,multiSelector:nt,evalConsoleTemplate:S}}($),up.error=up.util.error,up.warn=up.util.warn,up.debug=up.util.debug}.call(this),function(){var e=[].slice;up.browser=function(t){var n,r,o,u,i,a,l,s,c,p,f,d,m,h;return m=up.util,p=function(e,n){var r,o,u,i,a,l;return null==n&&(n={}),a=m.option(n.method,"get").toLowerCase(),"get"===a?location.href=e:t.rails?(l=n.target,u=t.rails.csrfToken(),o=t.rails.csrfParam(),r=t("<form method='post' action='"+e+"'></form>"),i="<input name='_method' value='"+a+"' type='hidden' />",m.isDefined(o)&&m.isDefined(u)&&(i+="<input name='"+o+"' value='"+u+"' type='hidden' />"),l&&r.attr("target",l),r.hide().append(i).appendTo("body"),r.submit()):error("Can't fake a "+a.toUpperCase()+" request without Rails UJS")},d=function(){var t,n,r;return r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],m.isDefined(console[r])||(r="log"),o()?console[r].apply(console,t):(n=m.evalConsoleTemplate.apply(m,t),console[r](n))},h=function(){return location.href},a=m.memoize(function(){return m.isUndefined(document.addEventListener)}),l=m.memoize(function(){return a()||-1!==navigator.appVersion.indexOf("MSIE 9.")}),u=m.memoize(function(){return m.isDefined(history.pushState)&&"get"===i()}),n=m.memoize(function(){return"transition"in document.documentElement.style}),r=m.memoize(function(){return"oninput"in document.createElement("input")}),o=m.memoize(function(){return!l()}),s=m.memoize(function(){var e,n,r,o;return o=t.fn.jquery,r=o.split("."),e=parseInt(r[0]),n=parseInt(r[1]),e>=2||1===e&&n>=9}),f=function(e){var t,n;return n=null!=(t=document.cookie.match(new RegExp(e+"=(\\w+)")))?t[1]:void 0,m.isPresent(n)&&(document.cookie=e+"=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/"),n},i=m.memoize(function(){return(f("_up_request_method")||"get").toLowerCase()}),c=function(){return!a()&&s()},{url:h,loadPage:p,canPushState:u,canCssTransition:n,canInputEvent:r,canLogSubstitution:o,isSupported:c,puts:d}}(jQuery)}.call(this),function(){var e=[].slice;up.bus=function(t){var n,r,o,u,i,a,l,s,c,p,f,d;return f=up.util,a=[],r=null,d=function(e){return function(n){var r;return r=n.$element||t(this),e.apply(r.get(0),[n,r,up.syntax.data(r)])}},i=function(){var n,r,o,u,i;return r=1<=arguments.length?e.call(arguments,0):[],up.browser.isSupported()?(u=f.copy(r),i=u.length-1,o=u[i],u[i]=d(o),a.push(u),n=t(document),n.on.apply(n,u),function(){return n.off.apply(n,u)}):function(){}},o=function(e,n){var r,o;return null==n&&(n={}),o=t.Event(e,n),r=n.$element||t(document),f.debug("Emitting %o on %o with props %o",e,r,n),r.trigger(o),o},l=function(){var t,n;return t=1<=arguments.length?e.call(arguments,0):[],n=o.apply(null,t),!n.isDefaultPrevented()},s=function(e){return i("keydown","body",function(t){return f.escapePressed(t)?e(t):void 0})},p=function(){return r=f.copy(a)},c=function(){var e,n,o,u;for(n=0,o=a.length;o>n;n++)e=a[n],f.contains(r,e)||(u=t(document)).off.apply(u,e);return a=f.copy(r)},u=function(){return up.emit("up:framework:reset")},n=function(){return up.browser.isSupported()?up.emit("up:framework:boot"):void 0},i("up:framework:boot",p),i("up:framework:reset",c),{on:i,emit:o,nobodyPrevents:l,onEscape:s,emitReset:u,boot:n}}(jQuery),up.on=up.bus.on,up.emit=up.bus.emit,up.reset=up.bus.emitReset,up.boot=up.bus.boot}.call(this),function(){var e=[].slice;up.syntax=function(t){var n,r,o,u,i,a,l,s,c,p,f,d,m;return m=up.util,n="up-destroyable",r="up-destroyer",a=[],s=null,i=function(){var t,n,r;return r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],up.browser.isSupported()?(i=t.pop(),n=m.options(t[0],{batch:!1}),a.push({selector:r,callback:i,batch:n.batch})):void 0},o=function(e,t,o){var u;return m.debug("Applying compiler %o on %o",e.selector,o),u=e.callback.apply(o,[t,l(t)]),m.isFunction(u)?(t.addClass(n),t.data(r,u)):void 0},u=function(e){var n,r,u,l;for(m.debug("Compiling fragment %o",e),l=[],r=0,u=a.length;u>r;r++)i=a[r],n=m.findWithSelf(e,i.selector),l.push(n.length?i.batch?o(i,n,n.get()):n.each(function(){return o(i,t(this),this)}):void 0);return l},f=function(e){return m.findWithSelf(e,"."+n).each(function(){var e,n;return e=t(this),(n=e.data(r))()})},l=function(e){var n,r;return n=t(e),r=n.attr("up-data"),m.isString(r)&&""!==m.trim(r)?JSON.parse(r):{}},d=function(){return s=m.copy(a)},p=function(){return a=m.copy(s)},c=function(e,n){var r,o;return r=t(e),o=m.options(n,{$element:r}),up.emit("up:fragment:inserted",o),r},up.on("ready",function(){return c(document.body)}),up.on("up:fragment:inserted",function(e){return u(e.$element)}),up.on("up:fragment:destroy",function(e){return f(e.$element)}),up.on("up:framework:boot",d),up.on("up:framework:reset",p),{compiler:i,hello:c,data:l}}(jQuery),up.compiler=up.syntax.compiler,up.hello=up.syntax.hello,up.ready=function(){return up.util.error("up.ready no longer exists. Please use up.hello instead.")},up.awaken=function(){return up.util.error("up.awaken no longer exists. Please use up.compiler instead.")}}.call(this),function(){up.history=function(e){var t,n,r,o,u,i,a,l,s,c,p,f,d,m,h,v;return v=up.util,n=v.config({popTargets:["body"],restoreScroll:!0}),c=void 0,i=void 0,m=function(){return n.reset(),c=void 0,i=void 0},a=function(e){return v.normalizeUrl(e,{hash:!0})},r=function(){return a(up.browser.url())},o=function(e){return a(e)===r()},l=function(e){return i&&(c=i,i=void 0),i=e},d=function(e,t){return u("replace",e,t)},p=function(e,t){return u("push",e,t)},u=function(e,n,u){var i,a;return u=v.options(u,{force:!1}),u.force||!o(n)?up.browser.canPushState()?(i=e+"State",a=t(),v.debug("Changing history to URL %o (%o)",n,e),window.history[i](a,"",n),l(r())):v.error("This browser doesn't support history.pushState"):void 0},t=function(){return{fromUp:!0}},h=function(e){var t,o;return o=r(),v.debug("Restoring state %o (now on "+o+")",e),t=n.popTargets.join(", "),up.replace(t,o,{history:!1,reveal:!1,transition:"none",saveScroll:!1,restoreScroll:n.restoreScroll})},s=function(e){var t;return v.debug("History state popped to URL %o",r()),l(r()),up.layout.saveScroll({url:c}),t=e.originalEvent.state,(null!=t?t.fromUp:void 0)?h(t):v.debug("Discarding unknown state %o",t)},up.browser.canPushState()&&(f=function(){return e(window).on("popstate",s),d(r(),{force:!0})},"undefined"!=typeof jasmine&&null!==jasmine?f():setTimeout(f,100)),up.compiler("[up-back]",function(e){return v.isPresent(c)?(v.setMissingAttrs(e,{"up-href":c,"up-restore-scroll":""}),e.removeAttr("up-back"),up.link.makeFollowable(e)):void 0}),up.on("up:framework:reset",m),{config:n,defaults:function(){return v.error("up.history.defaults(...) no longer exists. Set values on he up.history.config property instead.")},push:p,replace:d,url:r,previousUrl:function(){return c},normalizeUrl:a}}(jQuery)}.call(this),function(){var slice=[].slice;up.layout=function($){var SCROLL_PROMISE_KEY,anchoredRight,config,finishScrolling,fixedChildren,lastScrollTops,measureObstruction,reset,restoreScroll,reveal,revealOrRestoreScroll,saveScroll,scroll,scrollTops,u,viewportOf,viewportSelector,viewports,viewportsWithin;return u=up.util,config=u.config({duration:0,viewports:[document,".up-modal","[up-viewport]"],fixedTop:["[up-fixed~=top]"],fixedBottom:["[up-fixed~=bottom]"],anchoredRight:["[up-anchored~=right]","[up-fixed~=top]","[up-fixed~=bottom]","[up-fixed~=right]"],snap:50,substance:150,easing:"swing"}),lastScrollTops=u.cache({size:30,key:up.history.normalizeUrl}),reset=function(){return config.reset(),lastScrollTops.clear()},SCROLL_PROMISE_KEY="up-scroll-promise",scroll=function(e,t,n){var r,o,i,a,l;return r=$(e),n=u.options(n),i=u.option(n.duration,config.duration),a=u.option(n.easing,config.easing),finishScrolling(r),i>0?(o=$.Deferred(),r.data(SCROLL_PROMISE_KEY,o),o.then(function(){return r.removeData(SCROLL_PROMISE_KEY),r.finish()}),l={scrollTop:t},r.get(0)===document&&(r=$("html, body")),r.animate(l,{duration:i,easing:a,complete:function(){return o.resolve()}}),o):(r.scrollTop(t),u.resolvedDeferred())},finishScrolling=function(e){return $(e).each(function(){var e;return(e=$(this).data(SCROLL_PROMISE_KEY))?e.resolve():void 0})},anchoredRight=function(){return u.multiSelector(config.anchoredRight).select()},measureObstruction=function(){var e,t,n,r;return n=function(e,t){var n,r;return n=$(e),r=n.css(t),u.isPresent(r)||u.error("Fixed element %o must have a CSS attribute %o",n,t),parseInt(r)+n.height()},t=function(){var e,t,o,u;for(o=$(config.fixedTop.join(", ")),u=[],e=0,t=o.length;t>e;e++)r=o[e],u.push(n(r,"top"));return u}(),e=function(){var e,t,o,u;for(o=$(config.fixedBottom.join(", ")),u=[],e=0,t=o.length;t>e;e++)r=o[e],u.push(n(r,"bottom"));return u}(),{top:Math.max.apply(Math,[0].concat(slice.call(t))),bottom:Math.max.apply(Math,[0].concat(slice.call(e)))}},reveal=function(e,t){var n,r,o,i,a,l,s,c,p,f,d,m,h,v;return u.debug("Revealing %o",e),t=u.options(t),n=$(e),r=t.viewport?$(t.viewport):viewportOf(n),m=u.option(t.snap,config.snap),v=r.is(document),h=v?u.clientSize().height:r.height(),p=r.scrollTop(),l=p,c=void 0,s=void 0,v?(s=measureObstruction(),c=0):(s={top:0,bottom:0},c=p),f=function(){return l+s.top},d=function(){return l+h-s.bottom-1},o=u.measure(n,{relative:r}),i=o.top+c,a=i+Math.min(o.height,config.substance)-1,a>d()&&(l+=a-d()),(i<f()||t.top)&&(l=i-s.top),m>l&&(l=0),l!==p?scroll(r,l,t):u.resolvedDeferred()},viewportSelector=function(){return u.multiSelector(config.viewports)},viewportOf=function(e){var t,n;return t=$(e),n=viewportSelector().seekUp(t),n.length||u.error("Could not find viewport for %o",t),n},viewportsWithin=function(e){var t;return t=$(e),viewportSelector().findWithSelf(t)},viewports=function(){return viewportSelector().select()},scrollTops=function(){var e,t,n,r,o,u,i;for(u={},o=config.viewports,t=0,r=o.length;r>t;t++)i=o[t],e=$(i),e.length&&(n=i,i===document&&(n="document"),u[n]=e.scrollTop());return u},fixedChildren=function(e){var t,n;return null==e&&(e=void 0),e||(e=document.body),n=$(e),t=n.find("[up-fixed]"),u.isPresent(config.fixedTop)&&(t=t.add(n.find(config.fixedTop.join(", ")))),u.isPresent(config.fixedBottom)&&(t=t.add(n.find(config.fixedBottom.join(", ")))),t},saveScroll=function(e){var t,n;return null==e&&(e={}),n=u.option(e.url,up.history.url()),t=u.option(e.tops,scrollTops()),u.debug("Saving scroll positions for URL %o: %o",n,t),lastScrollTops.set(n,t)},restoreScroll=function(e){var t,n,r,o,i,a,l,s,c;null==e&&(e={}),c=up.history.url(),o=void 0,e.around?(n=viewportsWithin(e.around),t=viewportOf(e.around),o=t.add(n)):o=viewports(),s=lastScrollTops.get(c),u.debug("Restoring scroll positions for URL %o (viewports are %o, saved tops are %o)",c,o,s);for(i in s)l=s[i],a="document"===i?document:i,r=o.filter(a),scroll(r,l,{duration:0});return u.resolvedDeferred()},revealOrRestoreScroll=function(e,t){var n,r,o,i;return n=$(e),t.restoreScroll?restoreScroll({around:n}):t.reveal?(t.source&&(i=u.parseUrl(t.source),i.hash&&"#"!==i.hash&&(o=i.hash.substr(1),r=u.findWithSelf(n,"#"+o+", a[name='"+o+"']"),r.length&&(n=r))),reveal(n)):u.resolvedDeferred()},up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),reveal:reveal,scroll:scroll,finishScrolling:finishScrolling,config:config,defaults:function(){return u.error("up.layout.defaults(...) no longer exists. Set values on he up.layout.config property instead.")},viewportOf:viewportOf,viewportsWithin:viewportsWithin,viewports:viewports,scrollTops:scrollTops,saveScroll:saveScroll,restoreScroll:restoreScroll,revealOrRestoreScroll:revealOrRestoreScroll,anchoredRight:anchoredRight,fixedChildren:fixedChildren}}(jQuery),up.scroll=up.layout.scroll,up.reveal=up.layout.reveal}.call(this),function(){up.flow=function(e){var t,n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g;return g=up.util,m=function(t,n){var r;return r=e(t),g.isPresent(n)&&(n=g.normalizeUrl(n)),r.attr("up-source",n)},h=function(t){var n;return n=e(t).closest("[up-source]"),g.presence(n.attr("up-source"))||up.browser.url()},d=function(e,t){var n,r,o;return g.isString(e)?(o=e,g.contains(o,"&")&&((n=g.presence(t.origin))?(r=g.selectorForElement(n),o=o.replace(/\&/,r)):g.error("Found origin reference %o in selector %o, but options.origin is missing","&",o))):o=g.selectorForElement(e),o},f=function(e,t,n){var r,o,u;return g.debug("Replace %o with %o (options %o)",e,t,n),n=g.options(n),u=d(e,n),up.browser.canPushState()||n.history===!1?(o={url:t,method:n.method,selector:u,cache:n.cache,preload:n.preload,headers:n.headers},r=up.proxy.ajax(o),r.done(function(e,r,a){var l,s;return(l=g.locationFromXhr(a))&&(g.debug("Location from server: %o",l),s={url:l,method:g.methodFromXhr(a),selector:u},up.proxy.alias(o,s),t=l),n.history!==!1&&(n.history=t),n.source!==!1&&(n.source=t),n.title||(n.title=g.titleFromXhr(a)),n.preload?void 0:i(u,e,n)}),r.fail(g.error),r):(n.preload||up.browser.loadPage(t,g.only(n,"method")),g.unresolvablePromise())},i=function(e,t,n){var r,u,i,a,l,p,f,m,h,y;for(h=d(e,n),n=g.options(n,{historyMethod:"push",requireMatch:!0}),n.source=g.option(n.source,n.history),f=c(t,n),n.title||(n.title=f.title()),n.saveScroll!==!1&&up.layout.saveScroll(),l=s(h,n),m=[],i=0,a=l.length;a>i;i++)y=l[i],u=o(y.selector,n),r=null!=(p=f.find(y.selector))?p.first():void 0,m.push(u&&r?v(u,r,y.pseudoClass,y.transition,n):void 0);return m},o=function(e,t){return u(".up-popup "+e)||u(".up-modal "+e)||u(e)||l(e,t)},l=function(e,t){var n;return t.requireMatch?(n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),g.error(n,e)):void 0},c=function(t,n){var r;return r=g.createElementFromHtml(t),{title:function(){var e;return null!=(e=r.querySelector("title"))?e.textContent:void 0},find:function(o){var u;return(u=e.find(o,r)[0])?e(u):n.requireMatch?g.error("Could not find selector %o in response %o",o,t):void 0}}},r=function(e,n){return n.history&&(n.title&&(document.title=n.title),up.history[n.historyMethod](n.history)),n.source!==!1&&m(e,n.source),t(e),up.hello(e,{origin:n.origin})},v=function(e,t,o,u,i){var a,l;return u||(u="none"),up.motion.finish(e),o?(l="before"===o?"prepend":"append",a=t.contents().wrap('<span class="up-insertion"></span>').parent(),e[l](a),g.copyAttributes(t,e),r(a.children(),i),up.layout.revealOrRestoreScroll(a,i).then(function(){return up.animate(a,u,i)}).then(function(){g.unwrapElement(a)})):n(e,{animation:function(){return t.insertBefore(e),r(t,i),e.is("body")&&"none"!==u&&g.error("Cannot apply transitions to body-elements (%o)",u),up.morph(e,t,u,i)}})},s=function(e,t){var n,r,o,u,i,a,l,s,c,p,f,d;for(f=t.transition||t.animation||"none",n=/\ *,\ */,r=e.split(n),g.isPresent(f)&&(d=f.split(n)),l=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],c=s.match(/^(.+?)(?:\:(before|after))?$/),e=c[1],"html"===e&&(e="body"),a=c[2],p=d[o]||g.last(d),l.push({selector:e,pseudoClass:a,transition:p});return l},t=function(e){var t,n;return n="[autofocus]:last",t=g.findWithSelf(e,n),t.length&&t.get(0)!==document.activeElement?t.focus():void 0},a=function(e){var t;return t=".up-ghost, .up-destroying",0===e.closest(t).length},u=function(t){var n,r,o,u,i,l;for(u=void 0,u=g.isString(t)?e(t).get():t,r=void 0,i=0,l=u.length;l>i;i++)if(o=u[i],n=e(o),a(n)){r=n;break}return r},n=function(t,n){var r,o,u;return r=e(t),up.bus.nobodyPrevents("up:fragment:destroy",{$element:r})?(n=g.options(n,{animation:"none"}),o=up.motion.animateOptions(n),r.addClass("up-destroying"),g.isPresent(n.url)&&up.history.push(n.url),g.isPresent(n.title)&&(document.title=n.title),u=g.presence(n.animation,g.isDeferred)||up.motion.animate(r,n.animation,o),u.then(function(){return up.emit("up:fragment:destroyed",{$element:r}),r.remove()}),u):e.Deferred()},p=function(e,t){var n;return t=g.options(t,{cache:!1}),n=t.url||h(e),f(e,n,t)},up.on("ready",function(){return m(document.body,up.browser.url())}),{replace:f,reload:p,destroy:n,implant:i,first:u,resolveSelector:d}}(jQuery),up.replace=up.flow.replace,up.implant=up.flow.implant,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.first=up.flow.first}.call(this),function(){up.motion=function(e){var t,n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g,y,b,w,k,x,S,C;return S=up.util,u={},l={},x={},s={},a=S.config({duration:300,delay:0,easing:"ease",enabled:!0}),g=function(){return u=S.copy(l),x=S.copy(s),a.reset()},d=function(){return a.enabled&&up.browser.canCssTransition()},n=function(t,o,u){var a;return a=e(t),p(a),u=r(u),("none"===o||o===!1)&&h(),S.isFunction(o)?i(o(a,u),o):S.isString(o)?n(a,c(o),u):S.isHash(o)?d()?S.cssAnimate(a,o,u):(a.css(o),S.resolvedDeferred()):S.error("Unknown animation type %o",o)},r=function(e,t){var n;return null==t&&(t=null),e=S.options(e),n={},n.easing=S.option(e.easing,null!=t?t.attr("up-easing"):void 0,a.easing),n.duration=Number(S.option(e.duration,null!=t?t.attr("up-duration"):void 0,a.duration)),n.delay=Number(S.option(e.delay,null!=t?t.attr("up-delay"):void 0,a.delay)),n},c=function(e){return u[e]||S.error("Unknown animation %o",e)},t="up-ghosting-promise",C=function(e,n,r,o){var u,i,a,l,s,c,p;return l=void 0,i=void 0,s=void 0,a=void 0,u=up.layout.viewportOf(e),S.temporaryCss(n,{display:"none"},function(){return l=v(e,u),l.$ghost.addClass("up-destroying"),l.$bounds.addClass("up-destroying"),s=u.scrollTop()}),S.temporaryCss(e,{display:"none"},function(){return up.layout.revealOrRestoreScroll(n,r),i=v(n,u),a=u.scrollTop()}),l.moveTop(a-s),e.hide(),p=S.temporaryCss(n,{opacity:"0"}),c=o(l.$ghost,i.$ghost),e.data(t,c),n.data(t,c),c.then(function(){return e.removeData(t),n.removeData(t),p(),l.$bounds.remove(),i.$bounds.remove()}),c},p=function(t){return e(t).each(function(){var t;return t=e(this),S.finishCssAnimate(t),f(t)})},f=function(e){var n;return(n=e.data(t))?(S.debug("Canceling existing ghosting on %o",e),"function"==typeof n.resolve?n.resolve():void 0):void 0},i=function(e,t){return S.isDeferred(e)?e:S.error("Did not return a promise with .then and .resolve methods: %o",t)},m=function(t,o,a,l){var s,c,f,h,v,g,w;return S.debug("Morphing %o to %o (using %o)",t,o,a),c=e(t),s=e(o),v=S.only(l,"reveal","restoreScroll","source"),v=S.extend(v,r(l)),d()?(p(c),p(s),"none"===a||a===!1||(f=u[a])?(h=b(c,s,v),h.then(function(){return n(s,f||"none",l)}),h):(w=S.presence(a,S.isFunction)||x[a])?C(c,s,v,function(e,t){var n;return n=w(e,t,v),i(n,a)}):S.isString(a)&&a.indexOf("/")>=0?(g=a.split("/"),w=function(e,t,r){return y(n(e,g[0],r),n(t,g[1],r))},m(c,s,w,v)):S.error("Unknown transition %o",a)):b(c,s,v)},b=function(e,t,n){return e.hide(),up.layout.revealOrRestoreScroll(t,n)},v=function(t,n){var r,o,u,i,a,l,s,c,p;for(i=S.measure(t,{relative:!0,inner:!0}),u=t.clone(),u.find("script").remove(),u.css({position:"static"===t.css("position")?"static":"relative",top:"",right:"",bottom:"",left:"",width:"100%",height:"100%"}),u.addClass("up-ghost"),r=e('<div class="up-bounds"></div>'),r.css({position:"absolute"}),r.css(i),p=i.top,c=function(e){return 0!==e?(p+=e,r.css({top:p})):void 0},u.appendTo(r),r.insertBefore(t),c(t.offset().top-u.offset().top),o=up.layout.fixedChildren(u),l=0,s=o.length;s>l;l++)a=o[l],S.fixedToAbsolute(a,n);return{$ghost:u,$bounds:r,moveTop:c}},k=function(e,t){return x[e]=t},o=function(e,t){return u[e]=t},w=function(){return l=S.copy(u),s=S.copy(x)},y=S.resolvableWhen,h=S.resolvedDeferred,o("none",h),o("fade-in",function(e,t){return e.css({opacity:0}),n(e,{opacity:1},t)}),o("fade-out",function(e,t){return e.css({opacity:1}),n(e,{opacity:0},t)}),o("move-to-top",function(e,t){var r,o;return r=S.measure(e),o=r.top+r.height,e.css({"margin-top":"0px"}),n(e,{"margin-top":"-"+o+"px"},t)}),o("move-from-top",function(e,t){var r,o;return r=S.measure(e),o=r.top+r.height,e.css({"margin-top":"-"+o+"px"}),n(e,{"margin-top":"0px"},t)}),o("move-to-bottom",function(e,t){var r,o;return r=S.measure(e),o=S.clientSize().height-r.top,e.css({"margin-top":"0px"}),n(e,{"margin-top":o+"px"},t)}),o("move-from-bottom",function(e,t){var r,o;return r=S.measure(e),o=S.clientSize().height-r.top,e.css({"margin-top":o+"px"}),n(e,{"margin-top":"0px"},t)}),o("move-to-left",function(e,t){var r,o;return r=S.measure(e),o=r.left+r.width,e.css({"margin-left":"0px"}),n(e,{"margin-left":"-"+o+"px"},t)}),o("move-from-left",function(e,t){var r,o;return r=S.measure(e),o=r.left+r.width,e.css({"margin-left":"-"+o+"px"}),n(e,{"margin-left":"0px"},t)}),o("move-to-right",function(e,t){var r,o;return r=S.measure(e),o=S.clientSize().width-r.left,e.css({"margin-left":"0px"}),n(e,{"margin-left":o+"px"},t)}),o("move-from-right",function(e,t){var r,o;
2
- return r=S.measure(e),o=S.clientSize().width-r.left,e.css({"margin-left":o+"px"}),n(e,{"margin-left":"0px"},t)}),o("roll-down",function(e,t){var r,o;return r=e.height(),o=S.temporaryCss(e,{height:"0px",overflow:"hidden"}),n(e,{height:r+"px"},t).then(o)}),k("none",h),k("move-left",function(e,t,r){return y(n(e,"move-to-left",r),n(t,"move-from-right",r))}),k("move-right",function(e,t,r){return y(n(e,"move-to-right",r),n(t,"move-from-left",r))}),k("move-up",function(e,t,r){return y(n(e,"move-to-top",r),n(t,"move-from-bottom",r))}),k("move-down",function(e,t,r){return y(n(e,"move-to-bottom",r),n(t,"move-from-top",r))}),k("cross-fade",function(e,t,r){return y(n(e,"fade-out",r),n(t,"fade-in",r))}),up.on("up:framework:boot",w),up.on("up:framework:reset",g),{morph:m,animate:n,animateOptions:r,finish:p,transition:k,animation:o,config:a,isEnabled:d,defaults:function(){return S.error("up.motion.defaults(...) no longer exists. Set values on he up.motion.config property instead.")},none:h,when:y,prependCopy:v}}(jQuery),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){var e=[].slice;up.proxy=function(t){var n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g,y,b,w,k,x,S,C,$,T,E,P,A,U,O,D,j,F;return F=up.util,n=void 0,E=void 0,a=void 0,C=void 0,l=void 0,A=[],h=F.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5,maxRequests:4}),c=function(e){return S(e),[e.url,e.method,e.data,e.selector].join("|")},s=F.cache({size:function(){return h.cacheSize},expiry:function(){return h.cacheExpiry},key:c,log:"up.proxy"}),v=function(e){var t,n,r,o,u,i,a;for(e=S(e),n=[e],"html"!==e.selector&&(i=F.merge(e,{selector:"html"}),n.push(i),"body"!==e.selector&&(u=F.merge(e,{selector:"body"}),n.push(u))),r=0,o=n.length;o>r;r++)if(t=n[r],a=s.get(t))return a},D=s.set,U=s.remove,m=s.clear,f=function(){return clearTimeout(E),E=null},p=function(){return clearTimeout(a),a=null},O=function(){return n=null,f(),p(),C=0,h.reset(),l=!1,s.clear(),A=[]},O(),u=s.alias,S=function(e){return e._normalized||(e.method=F.normalizeMethod(e.method),e.url&&(e.url=F.normalizeUrl(e.url)),e.selector||(e.selector="body"),e._normalized=!0),e},o=function(e){var t,n,r,o,u;return t=e.cache===!0,n=e.cache===!1,u=F.only(e,"url","method","data","selector","headers","_normalized"),r=!0,y(u)||t?(o=v(u))&&!n?r="pending"===o.state():(o=k(u),D(u,o),o.fail(function(){return U(u)})):(m(),o=k(u)),r&&!e.preload&&(x(),o.always(w)),o},r=["GET","OPTIONS","HEAD"],g=function(){return 0===C},i=function(){return C>0},x=function(){var e,t;return t=g(),C+=1,t?(e=function(){return i()?(up.emit("up:proxy:busy"),l=!0):void 0},h.busyDelay>0?a=setTimeout(e,h.busyDelay):e()):void 0},w=function(){return C-=1,g()&&l?(up.emit("up:proxy:idle"),l=!1):void 0},k=function(e){return C<h.maxRequests?b(e):P(e)},P=function(e){var n,r;return F.debug("Queuing URL %o",e.url),n=t.Deferred(),r={deferred:n,request:e},A.push(r),n.promise()},b=function(e){var t;return F.debug("Loading URL %o",e.url),up.emit("up:proxy:load",e),t=F.ajax(e),t.always(function(){return up.emit("up:proxy:received",e),$()}),t},$=function(){var t,n;return(t=A.shift())?(n=b(t.request),n.done(function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],(r=t.deferred).resolve.apply(r,n)}),n.fail(function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],(r=t.deferred).reject.apply(r,n)})):void 0},y=function(e){return S(e),F.contains(r,e.method)},d=function(e){var t,r;return r=parseInt(F.presentAttr(e,"up-delay"))||h.preloadDelay,e.is(n)?void 0:(n=e,f(),t=function(){return T(e),n=null},j(t,r))},j=function(e,t){return E=setTimeout(e,t)},T=function(e,n){var r,o;return r=t(e),n=F.options(n),o=up.link.followMethod(r,n),y({method:o})?(F.debug("Preloading %o",r),n.preload=!0,up.follow(r,n)):(F.debug("Won't preload %o due to unsafe method %o",r,o),F.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(e,t){return up.link.childClicked(e,t)?void 0:d(t)}),up.on("up:framework:reset",O),{preload:T,ajax:o,get:v,alias:u,clear:m,remove:U,idle:g,busy:i,config:h,defaults:function(){return F.error("up.proxy.defaults(...) no longer exists. Set values on he up.proxy.config property instead.")}}}(jQuery)}.call(this),function(){up.link=function($){var allowDefault,childClicked,follow,followMethod,followVariantSelectors,isFollowable,makeFollowable,registerFollowVariant,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(e,t){var n;return t=u.options(t),n=u.option(t.target,"body"),up.replace(n,e,t)},follow=function(e,t){var n,r,o;return n=$(e),t=u.options(t),o=u.option(n.attr("up-href"),n.attr("href")),r=u.option(t.target,n.attr("up-target"),"body"),t.transition=u.option(t.transition,u.castedAttr(n,"up-transition"),u.castedAttr(n,"up-animation")),t.history=u.option(t.history,u.castedAttr(n,"up-history")),t.reveal=u.option(t.reveal,u.castedAttr(n,"up-reveal"),!0),t.cache=u.option(t.cache,u.castedAttr(n,"up-cache")),t.restoreScroll=u.option(t.restoreScroll,u.castedAttr(n,"up-restore-scroll")),t.method=followMethod(n,t),t.origin=u.option(t.origin,n),t=u.merge(t,up.motion.animateOptions(t,n)),up.replace(r,o,t)},followMethod=function(e,t){var n;return n=$(e),t=u.options(t),u.option(t.method,n.attr("up-method"),n.attr("data-method"),"get").toUpperCase()},childClicked=function(e,t){var n,r;return n=$(e.target),r=n.closest("a, [up-href]"),r.length&&t.find(r).length},shouldProcessLinkEvent=function(e,t){return u.isUnmodifiedMouseEvent(e)&&!childClicked(e,t)},followVariantSelectors=[],allowDefault=function(){},registerFollowVariant=function(e,t){return followVariantSelectors.push(e),up.on("click","a"+e+", [up-href]"+e,function(e,n){return shouldProcessLinkEvent(e,n)?n.is("[up-instant]")?e.preventDefault():(e.preventDefault(),t(n)):allowDefault(e)}),up.on("mousedown","a"+e+"[up-instant], [up-href]"+e+"[up-instant]",function(e,n){return shouldProcessLinkEvent(e,n)?(e.preventDefault(),t(n)):void 0})},isFollowable=function(e){return u.any(followVariantSelectors,function(t){return e.is(t)})},makeFollowable=function(e){var t;return t=$(e),isFollowable(t)?void 0:t.attr("up-follow","")},registerFollowVariant("[up-target]",function(e){return follow(e)}),registerFollowVariant("[up-follow]",function(e){return follow(e)}),up.compiler("[up-expand]",function(e){var t,n,r,o,i,a,l,s;for(o=e.find("a, [up-href]").get(0),o||u.error("No link to expand within %o",e),s=/^up-/,a={},a["up-href"]=$(o).attr("href"),l=o.attributes,n=0,r=l.length;r>n;n++)t=l[n],i=t.name,i.match(s)&&(a[i]=t.value);return u.setMissingAttrs(e,a),e.removeAttr("up-expand"),makeFollowable(e)}),up.compiler("[up-dash]",function(e){var t,n;return n=u.castedAttr(e,"up-dash"),t={"up-preload":"true","up-instant":"true"},n===!0?t["up-follow"]="":t["up-target"]=n,u.setMissingAttrs(e,t),e.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,makeFollowable:makeFollowable,shouldProcessLinkEvent:shouldProcessLinkEvent,childClicked:childClicked,followMethod:followMethod,registerFollowVariant:registerFollowVariant}}(jQuery),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){var slice=[].slice;up.form=function($){var autosubmit,config,observe,observeForm,reset,resolveValidateTarget,submit,u,validate;return u=up.util,config=u.config({validateTargets:["[up-fieldset]:has(&)","fieldset:has(&)","label:has(&)","form:has(&)"],fields:[":input"],observeDelay:0}),reset=function(){return config.reset()},submit=function(e,t){var n,r,o,i,a,l,s,c,p,f,d,m,h,v;return n=$(e).closest("form"),t=u.options(t),f=u.option(t.target,n.attr("up-target"),"body"),f=up.flow.resolveSelector(f,t),r=u.option(t.failTarget,n.attr("up-fail-target"))||u.selectorForElement(n),r=up.flow.resolveSelector(r,t),l=u.option(t.history,u.castedAttr(n,"up-history"),!0),d=u.option(t.transition,u.castedAttr(n,"up-transition")),o=u.option(t.failTransition,u.castedAttr(n,"up-fail-transition"),d),s=u.option(t.method,n.attr("up-method"),n.attr("data-method"),n.attr("method"),"post").toUpperCase(),a=u.option(t.headers,{}),c={},c.reveal=u.option(t.reveal,u.castedAttr(n,"up-reveal"),!0),c.cache=u.option(t.cache,u.castedAttr(n,"up-cache")),c.restoreScroll=u.option(t.restoreScroll,u.castedAttr(n,"up-restore-scroll")),c.origin=u.option(t.origin,n),c=u.extend(c,up.motion.animateOptions(t,n)),v=u.option(t.cache,u.castedAttr(n,"up-cache")),h=u.option(t.url,n.attr("action"),up.browser.url()),i=n.find("input[type=file]").length,t.validate&&(a["X-Up-Validate"]=t.validate,i)?u.unresolvablePromise():(n.addClass("up-active"),i||!up.browser.canPushState()&&l!==!1?(n.get(0).submit(),u.unresolvablePromise()):(p={url:h,method:s,data:n.serialize(),selector:f,cache:v,headers:a},m=function(e){var t;return h=void 0,u.isGiven(l)&&(l===!1||u.isString(l)?h=l:(t=u.locationFromXhr(e))?h=t:"GET"===p.type&&(h=p.url+"?"+p.data)),u.option(h,!1)},up.proxy.ajax(p).always(function(){return n.removeClass("up-active")}).done(function(e,t,n){var r;return r=u.merge(c,{history:m(n),transition:d}),up.flow.implant(f,e,r)}).fail(function(e){var t,n;return n=e.responseText,t=u.merge(c,{transition:o}),up.flow.implant(r,n,t)})))},observe=function(){var $element,args,callback,callbackArg,callbackPromise,callbackTimer,changeEvents,check,clearTimer,delay,knownValue,nextCallback,options,rawCallback,runNextCallback,selectorOrElement;return selectorOrElement=arguments[0],args=2<=arguments.length?slice.call(arguments,1):[],options={},callbackArg=void 0,1===args.length&&(callbackArg=args[0]),args.length>1&&(options=u.options(args[0]),callbackArg=args[1]),$element=$(selectorOrElement),options=u.options(options),delay=u.option($element.attr("up-delay"),options.delay,config.observeDelay),delay=parseInt(delay),callback=null,u.isGiven(options.change)&&up.error("up.observe now takes the change callback as the last argument"),rawCallback=u.option(u.presentAttr($element,"op-observe"),callbackArg),callback=u.isString(rawCallback)?function(value,$field){return eval(rawCallback)}:rawCallback||u.error("up.observe: No change callback given"),$element.is("form")?observeForm($element,options,callback):(knownValue=null,callbackTimer=null,callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var e;return nextCallback?(e=nextCallback(),nextCallback=null,e):void 0},check=function(){var e,t,n;return n=$element.val(),t=u.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($element.get(0),[n,$element])},e=function(){return callbackPromise.then(function(){var e;return e=runNextCallback(),callbackPromise=u.isPromise(e)?e:u.resolvedPromise()})},0===delay?e():setTimeout(e,delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$element.on(changeEvents,check),check(),function(){return $element.off(changeEvents,check),clearTimer()})},observeForm=function(e,t,n){var r,o;return r=u.multiSelector(config.fields).find(e),o=u.map(r,function(e){return observe(e,n)}),function(){var e,t,n,r;for(r=[],t=0,n=o.length;n>t;t++)e=o[t],r.push(e());return r}},autosubmit=function(e,t){return console.log("autosubmit %o",e),observe(e,t,function(e,t){var n;return n=t.closest("form"),t.addClass("up-active"),submit(n).always(function(){return t.removeClass("up-active")})})},resolveValidateTarget=function(e,t){var n;return n=u.option(t.target,e.attr("up-validate")),u.isBlank(n)&&(n||(n=u.detect(config.validateTargets,function(n){var r;return r=up.flow.resolveSelector(n,t),e.closest(r).length}))),u.isBlank(n)&&error("Could not find default validation target for %o (tried ancestors %o)",e,config.validateTargets),u.isString(n)||(n=u.selectorForElement(n)),n},validate=function(e,t){var n,r,o;return n=$(e),t=u.options(t),t.origin=n,t.target=resolveValidateTarget(n,t),t.failTarget=t.target,t.history=!1,t.headers=u.option(t.headers,{}),t.validate=n.attr("name")||"__none__",t=u.merge(t,up.motion.animateOptions(t,n)),r=n.closest("form"),o=up.submit(r,t)},up.on("submit","form[up-target]",function(e,t){return e.preventDefault(),submit(t)}),up.on("change","[up-validate]",function(e,t){return validate(t)}),up.compiler("[up-observe]",function(e){return observe(e)}),up.compiler("[up-autosubmit]",function(e){return autosubmit(e)}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),config:config,submit:submit,observe:observe,validate:validate}}(jQuery),up.submit=up.form.submit,up.observe=up.form.observe,up.autosubmit=up.form.autosubmit,up.validate=up.form.validate}.call(this),function(){up.popup=function($){var attach,autoclose,close,config,contains,coveredUrl,createHiddenPopup,currentUrl,discardHistory,ensureInViewport,rememberHistory,reset,setPosition,u,updated;return u=up.util,currentUrl=void 0,coveredUrl=function(){var e;return e=$(".up-popup"),e.attr("up-covered-url")},config=u.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right",history:!1}),reset=function(){return close(),config.reset()},setPosition=function(e,t,n){var r,o;return o=u.measure(e,{full:!0}),r=function(){switch(n){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.top+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return u.error("Unknown position %o",n)}}(),t.attr("up-position",n),t.css(r),ensureInViewport(t)},ensureInViewport=function(e){var t,n,r,o,i,a,l;if(n=u.measure(e,{full:!0}),r=null,o=null,n.right<0&&(r=-n.right),n.bottom<0&&(o=-n.bottom),n.left<0&&(r=n.left),n.top<0&&(o=n.top),r&&((i=parseInt(e.css("left")))?e.css("left",i-r):(a=parseInt(e.css("right")))&&e.css("right",a+r)),o){if(l=parseInt(e.css("top")))return e.css("top",l-o);if(t=parseInt(e.css("bottom")))return e.css("bottom",t+o)}},rememberHistory=function(){var e;return e=$(".up-popup"),e.attr("up-covered-url",up.browser.url()),e.attr("up-covered-title",document.title)},discardHistory=function(){var e;return e=$(".up-popup"),e.removeAttr("up-covered-url"),e.removeAttr("up-covered-title")},createHiddenPopup=function(e,t,n){var r,o;return o=u.$createElementFromSelector(".up-popup"),n&&o.attr("up-sticky",""),r=u.$createElementFromSelector(t),r.appendTo(o),o.appendTo(document.body),rememberHistory(),o.hide(),o},updated=function(e,t,n,r){var o,u;return o=$(".up-popup"),o.is(":hidden")?(o.show(),setPosition(e,o,t),u=up.animate(o,n,r),u.then(function(){return up.emit("up:popup:opened")})):void 0},attach=function(e,t){var n,r,o,i,a,l,s,c,p;return n=$(e),n.length||u.error("Cannot attach popup to non-existing element %o",e),t=u.options(t),p=u.option(t.url,n.attr("href")),s=u.option(t.target,n.attr("up-popup"),"body"),a=u.option(t.position,n.attr("up-position"),config.position),o=u.option(t.animation,n.attr("up-animation"),config.openAnimation),c=u.option(t.sticky,u.castedAttr(n,"up-sticky")),i=up.browser.canPushState()?u.option(t.history,u.castedAttr(n,"up-history"),config.history):!1,r=up.motion.animateOptions(t,n),close(),up.bus.nobodyPrevents("up:popup:open",{url:p})?(createHiddenPopup(n,s,c),l=up.replace(s,p,{history:i,requireMatch:!1}),l.then(function(){return updated(n,a,o,r)}),l):u.unresolvableDeferred()},close=function(e){var t,n;return t=$(".up-popup"),t.length?up.bus.nobodyPrevents("up:popup:close",{$element:t})?(e=u.options(e,{animation:config.closeAnimation,url:t.attr("up-covered-url"),title:t.attr("up-covered-title")}),currentUrl=void 0,n=up.destroy(t,e),n.then(function(){return up.emit("up:popup:closed")}),n):u.unresolvableDeferred():u.resolvedDeferred()},autoclose=function(){return $(".up-popup").is("[up-sticky]")?void 0:(discardHistory(),close())},contains=function(e){var t;return t=$(e),t.closest(".up-popup").length>0},up.link.registerFollowVariant("[up-popup]",function(e){return e.is(".up-current")?close():attach(e)}),up.on("click","body",function(e){var t;return t=$(e.target),t.closest(".up-popup").length||t.closest("[up-popup]").length?void 0:close()}),up.on("up:fragment:inserted",function(e,t){var n;if(contains(t)){if(n=t.attr("up-source"))return currentUrl=n}else if(contains(e.origin))return autoclose()}),up.bus.onEscape(function(){return close()}),up.on("click","[up-close]",function(e,t){return t.closest(".up-popup").length?(close(),e.preventDefault()):void 0}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),attach:attach,close:close,url:function(){return currentUrl},coveredUrl:coveredUrl,config:config,defaults:function(){return u.error("up.popup.defaults(...) no longer exists. Set values on he up.popup.config property instead.")},contains:contains,open:function(){return up.error("up.popup.open no longer exists. Please use up.popup.attach instead.")},source:function(){return up.error("up.popup.source no longer exists. Please use up.popup.url instead.")}}}(jQuery)}.call(this),function(){up.modal=function($){var autoclose,close,config,contains,coveredUrl,createHiddenModal,currentUrl,discardHistory,follow,open,rememberHistory,reset,shiftElements,templateHtml,u,unshiftElements,updated,visit;return u=up.util,config=u.config({maxWidth:null,minWidth:null,width:null,height:null,history:!0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",template:function(e){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+e.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}}),currentUrl=void 0,coveredUrl=function(){var e;return e=$(".up-modal"),e.attr("up-covered-url")},reset=function(){return close(),currentUrl=void 0,config.reset()},templateHtml=function(){var e;return e=config.template,u.isFunction(e)?e(config):e},rememberHistory=function(){var e;return e=$(".up-modal"),e.attr("up-covered-url",up.browser.url()),e.attr("up-covered-title",document.title)},discardHistory=function(){var e;return e=$(".up-modal"),e.removeAttr("up-covered-url"),e.removeAttr("up-covered-title")},createHiddenModal=function(e){var t,n,r,o;return r=$(templateHtml()),e.sticky&&r.attr("up-sticky",""),r.attr("up-covered-url",up.browser.url()),r.attr("up-covered-title",document.title),n=r.find(".up-modal-dialog"),u.isPresent(e.width)&&n.css("width",e.width),u.isPresent(e.maxWidth)&&n.css("max-width",e.maxWidth),u.isPresent(e.height)&&n.css("height",e.height),t=r.find(".up-modal-content"),o=u.$createElementFromSelector(e.selector),o.appendTo(t),r.appendTo(document.body),rememberHistory(),r.hide(),r},unshiftElements=[],shiftElements=function(){var e,t,n,r;return n=u.scrollbarWidth(),e=parseInt($("body").css("padding-right")),t=n+e,r=u.temporaryCss($("body"),{"padding-right":t+"px","overflow-y":"hidden"}),unshiftElements.push(r),up.layout.anchoredRight().each(function(){var e,t,r,o;return e=$(this),t=parseInt(e.css("right")),r=n+t,o=u.temporaryCss(e,{right:r}),unshiftElements.push(o)})},updated=function(e,t){var n,r;return n=$(".up-modal"),n.is(":hidden")?(shiftElements(),n.show(),r=up.animate(n,e,t),r.then(function(){return up.emit("up:modal:opened")})):void 0},follow=function(e,t){return t=u.options(t),t.$link=$(e),open(t)},visit=function(e,t){return t=u.options(t),t.url=e,open(t)},open=function(e){var t,n,r,o,i,a,l,s,c,p,f;return e=u.options(e),t=u.option(e.$link,u.nullJQuery()),p=u.option(e.url,t.attr("up-href"),t.attr("href")),s=u.option(e.target,t.attr("up-modal"),"body"),f=u.option(e.width,t.attr("up-width"),config.width),a=u.option(e.maxWidth,t.attr("up-max-width"),config.maxWidth),o=u.option(e.height,t.attr("up-height"),config.height),r=u.option(e.animation,t.attr("up-animation"),config.openAnimation),c=u.option(e.sticky,u.castedAttr(t,"up-sticky")),i=up.browser.canPushState()?u.option(e.history,u.castedAttr(t,"up-history"),config.history):!1,n=up.motion.animateOptions(e,t),close(),up.bus.nobodyPrevents("up:modal:open",{url:p})?(createHiddenModal({selector:s,width:f,maxWidth:a,height:o,sticky:c}),l=up.replace(s,p,{history:i,requireMatch:!1}),l.then(function(){return updated(r,n)}),l):u.unresolvableDeferred()},close=function(e){var t,n;return t=$(".up-modal"),t.length?up.bus.nobodyPrevents("up:modal:close",{$element:t})?(e=u.options(e,{animation:config.closeAnimation,url:t.attr("up-covered-url"),title:t.attr("up-covered-title")}),currentUrl=void 0,n=up.destroy(t,e),n.then(function(){for(var e;e=unshiftElements.pop();)e();return up.emit("up:modal:closed")}),n):u.unresolvableDeferred():u.resolvedDeferred()},autoclose=function(){return $(".up-modal").is("[up-sticky]")?void 0:(discardHistory(),close())},contains=function(e){var t;return t=$(e),t.closest(".up-modal").length>0},up.link.registerFollowVariant("[up-modal]",function(e){return event.preventDefault(),e.is(".up-current")?close():follow(e)}),up.on("click","body",function(e){var t;return t=$(e.target),t.closest(".up-modal-dialog").length||t.closest("[up-modal]").length?void 0:close()}),up.on("up:fragment:inserted",function(e,t){var n;if(contains(t)){if(n=t.attr("up-source"))return currentUrl=n}else if(!up.popup.contains(t)&&contains(e.origin))return autoclose()}),up.bus.onEscape(function(){return close()}),up.on("click","[up-close]",function(e,t){return t.closest(".up-modal").length?(close(),e.preventDefault()):void 0}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,open:function(){return up.error("up.modal.open no longer exists. Please use either up.modal.follow or up.modal.visit.")},close:close,url:function(){return currentUrl},coveredUrl:coveredUrl,config:config,defaults:function(){return u.error("up.modal.defaults(...) no longer exists. Set values on he up.modal.config property instead.")},contains:contains,source:function(){return up.error("up.popup.source no longer exists. Please use up.popup.url instead.")}}}(jQuery)}.call(this),function(){up.tooltip=function(e){var t,n,r,o,u,i,a;return a=up.util,r=a.config({position:"top",openAnimation:"fade-in",closeAnimation:"fade-out"}),u=function(){return r.reset()},i=function(e,t,n){var r,o,u;return o=a.measure(e),u=a.measure(t),r=function(){switch(n){case"top":return{left:o.left+.5*(o.width-u.width),top:o.top-u.height};case"bottom":return{left:o.left+.5*(o.width-u.width),top:o.top+o.height};default:return a.error("Unknown position %o",n)}}(),t.attr("up-position",n),t.css(r)},o=function(e){var t;return t=a.$createElementFromSelector(".up-tooltip"),a.isGiven(e.text)?t.text(e.text):t.html(e.html),t.appendTo(document.body),t},t=function(t,u){var l,s,c,p,f,d,m;return null==u&&(u={}),l=e(t),f=a.option(u.html,l.attr("up-tooltip-html")),m=a.option(u.text,l.attr("up-tooltip")),d=a.option(u.position,l.attr("up-position"),r.position),p=a.option(u.animation,a.castedAttr(l,"up-animation"),r.openAnimation),c=up.motion.animateOptions(u,l),n(),s=o({text:m,html:f}),i(l,s,d),up.animate(s,p,c)},n=function(t){var n;return n=e(".up-tooltip"),n.length?(t=a.options(t,{animation:r.closeAnimation}),t=a.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[up-tooltip], [up-tooltip-html]",function(e){return e.on("mouseover",function(){return t(e)}),e.on("mouseout",function(){return n()})}),up.on("click","body",function(){return n()}),up.on("up:framework:reset",n),up.bus.onEscape(function(){return n()}),up.on("up:framework:reset",u),{attach:t,close:n,open:function(){return a.error("up.tooltip.open no longer exists. Use up.tooltip.attach instead.")}}}(jQuery)}.call(this),function(){up.navigation=function(e){var t,n,r,o,u,i,a,l,s,c,p,f,d,m,h,v,g;return h=up.util,i=h.config({currentClasses:["up-current"]}),p=function(){return i.reset()},a=function(){var e;return e=i.currentClasses,e=e.concat(["up-current"]),e=h.uniq(e),e.join(" ")},t="up-active",n=["a","[up-href]","[up-alias]"],o=n.join(", "),u=function(){var e,t,r;for(r=[],e=0,t=n.length;t>e;e++)m=n[e],r.push(m+"[up-instant]");return r}().join(", "),r="."+t,c=function(e){return h.isPresent(e)?h.normalizeUrl(e,{search:!1,stripTrailingSlash:!0}):void 0},d=function(e){var t,n,r,o,u,i,a,l,s,p;for(l=[],i=["href","up-href","up-alias"],n=0,o=i.length;o>n;n++)if(t=i[n],s=h.presentAttr(e,t))for(p="up-alias"===t?s.split(" "):[s],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=c(a),l.push(a));return l},g=function(e){var t,n,r,o;return e=h.compact(e),r=function(e){return"*"===e.substr(-1)?n(e.slice(0,-1)):t(e)},t=function(t){return h.contains(e,t)},n=function(t){return h.detect(e,function(e){return 0===e.indexOf(t)})},o=function(e){return h.detect(e,r)},{matchesAny:o}},s=function(){var t,n;return t=g([c(up.browser.url()),c(up.modal.url()),c(up.modal.coveredUrl()),c(up.popup.url()),c(up.popup.coveredUrl())]),n=a(),h.each(e(o),function(r){var o,u;return o=e(r),u=d(o),t.matchesAny(u)?o.addClass(n):o.hasClass(n)&&0===o.closest(".up-destroying").length?o.removeClass(n):void 0})},f=function(e){return v(),e=l(e),e.addClass(t)},l=function(e){return h.presence(e.parents(o))||e},v=function(){return e(r).removeClass(t)},up.on("click",o,function(e,t){return h.isUnmodifiedMouseEvent(e)&&!t.is("[up-instant]")?f(t):void 0}),up.on("mousedown",u,function(e,t){return h.isUnmodifiedMouseEvent(e)?f(t):void 0}),up.on("up:fragment:inserted",function(){return v(),s()}),up.on("up:fragment:destroyed",function(e,t){return t.is(".up-modal, .up-popup")?s():void 0}),up.on("up:framework:reset",p),{config:i,defaults:function(){return h.error("up.navigation.defaults(...) no longer exists. Set values on he up.navigation.config property instead.")}}}(jQuery)}.call(this),function(){up.rails=function(e){var t,n;return t=up.util,n=function(e){return e.is("[up-follow], [up-target], [up-modal], [up-popup]")},up.compiler("[data-method]",function(r){return e.rails&&n(r)?(t.setMissingAttrs(r,{"up-method":r.attr("data-method")}),r.removeAttr("data-method")):void 0})}(jQuery)}.call(this),function(){up.boot()}.call(this);
1
+ (function(){window.up={}}).call(this),function(){var e=[].slice;up.util=function(t){var n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,S,x,T,$,C,E,A,P,D,U,O,F,R,M,j,z,L,I,K,N,W,_,q,H,Q,V,J,B,X,G,Y,Z,et,tt,nt,rt,ot,ut,it,at,st,lt,ct,pt,ft,dt,mt,ht,vt,gt,yt,bt,wt,kt,St,xt,Tt,$t,Ct,Et,At,Pt,Dt,Ut,Ot,Ft,Rt,Mt,jt,zt,Lt;return et=function(t){var n,r;return n=void 0,r=!1,function(){var o;return o=1<=arguments.length?e.call(arguments,0):[],r?n:(r=!0,n=t.apply(null,o))}},H=function(e,t){return t=t.toString(),(""===t||"80"===t)&&"http:"===e||"443"===t&&"https:"===e},at=function(e,t){var n,r,o;return n=mt(e),r=n.protocol+"//"+n.hostname,H(n.protocol,n.port)||(r+=":"+n.port),o=n.pathname,"/"!==o[0]&&(o="/"+o),(null!=t?t.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=t?t.hash:void 0)===!0&&(r+=n.hash),(null!=t?t.search:void 0)!==!1&&(r+=n.search),r},mt=function(e){var n;return n=null,Q(e)?(n=t("<a>").attr({href:e}).get(0),U(n.hostname)&&(n.href=n.href)):n=Ft(e),n},it=function(e){return e?e.toUpperCase():"GET"},n=function(e){var n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;for(v=e.split(/[ >]/),o=null,p=f=0,m=v.length;m>f;p=++f){for(a=v[p],i=a.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),g="div",u=[],c=null,d=0,h=i.length;h>d;d++)switch(s=i[d],s[0]){case".":u.push(s.substr(1));break;case"#":c=s.substr(1);break;default:g=s}l="<"+g,u.length&&(l+=' class="'+u.join(" ")+'"'),c&&(l+=' id="'+c+'"'),l+=">",n=t(l),r&&n.appendTo(r),0===p&&(o=n),r=n}return o},m=function(e,t){var n;return n=document.createElement(e),_(t)&&(n.innerHTML=t),n},g=function(){var t,n,r;return n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],n="[UP] "+n,(r=up.browser).puts.apply(r,["debug",n].concat(e.call(t)))},Lt=function(){var t,n,r;return n=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],n="[UP] "+n,(r=up.browser).puts.apply(r,["warn",n].concat(e.call(t)))},w=function(){var n,r,o,u;throw r=1<=arguments.length?e.call(arguments,0):[],r[0]="[UP] "+r[0],(u=up.browser).puts.apply(u,["error"].concat(e.call(r))),o=S.apply(null,r),n=ht(t(".up-error"))||t('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(o),new Error(o)},o=/\%[odisf]/g,S=function(){var t,n,r,u;return t=1<=arguments.length?e.call(arguments,0):[],u=t[0],n=0,r=80,u.replace(o,function(){var e,o;return n+=1,e=t[n],o=typeof e,"string"===o?(e=e.replace(/\s+/g," "),e.length>r&&(e=e.substr(0,r)+"\u2026"),e='"'+e+'"'):e="undefined"===o?"undefined":"number"===o||"function"===o?e.toString():JSON.stringify(e),e.length>r&&(e=e.substr(0,r)+" \u2026",("object"===o||"function"===o)&&(e+=" }")),e})},Ct=function(e){var n,r,o,u,i,a,s,l,c;if(n=t(e),l=void 0,g("Creating selector from element %o",n.get(0)),c=ht(n.attr("up-id")))l="[up-id='"+c+"']";else if(o=ht(n.attr("id")))l="#"+o;else if(s=ht(n.attr("name")))l="[name='"+s+"']";else if(r=ht(ut(n)))for(console.log("using klass!",r),l="",u=0,a=r.length;a>u;u++)i=r[u],l+="."+i;else l=n.prop("tagName").toLowerCase();return l},ut=function(e){var t,n;return t=e.attr("class")||"",n=t.split(" "),$t(n,function(e){return _(e)&&!e.match(/^up-/)})},h=function(e){var t,n,r,o,u,i,a,s,l,c,p,f;return l=function(e){return"<"+e+"(?: [^>]*)?>"},i=function(e){return"</"+e+">"},t="(?:.|\\n)*?",u=function(e){return"("+e+")"},f=new RegExp(l("head")+t+l("title")+u(t)+i("title")+t+i("body"),"i"),o=new RegExp(l("body")+u(t)+i("body"),"i"),(r=e.match(o))?(s=document.createElement("html"),n=m("body",r[1]),s.appendChild(n),(p=e.match(f))&&(a=m("head"),s.appendChild(a),c=m("title",p[1]),a.appendChild(c)),s):m("div",e)},T=t.extend,Ot=t.trim,b=function(e,t){var n,r,o,u,i;for(i=[],n=o=0,u=e.length;u>o;n=++o)r=e[n],i.push(t(r,n));return i},Y=b,Pt=function(e,t){var n,r,o,u;for(u=[],n=r=0,o=e-1;o>=0?o>=r:r>=o;n=o>=0?++r:--r)u.push(t(n));return u},K=function(e){return null===e},V=function(e){return void 0===e},F=function(e){return!V(e)},I=function(e){return V(e)||K(e)},j=function(e){return!I(e)},U=function(e){return I(e)||W(e)&&0===Object.keys(e).length||0===e.length},ht=function(e,t){return null==t&&(t=_),t(e)?e:void 0},_=function(e){return!U(e)},M=function(e){return"function"==typeof e},Q=function(e){return"string"==typeof e},N=function(e){return"number"==typeof e},z=function(e){return"object"==typeof e&&!!e},W=function(e){return z(e)||"function"==typeof e},R=function(e){return!(!e||1!==e.nodeType)},L=function(e){return e instanceof jQuery},q=function(e){return W(e)&&M(e.then)},O=function(e){return q(e)&&M(e.resolve)},D=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)},Ut=function(e){return Array.prototype.slice.call(e)},f=function(e){return D(e)?e.slice():T({},e)},Ft=function(e){return L(e)?e.get(0):e},tt=function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],T.apply(null,[{}].concat(e.call(t)))},dt=function(e,t){var n,r,o,u;if(o=e?f(e):{},t)for(r in t)n=t[r],u=o[r],j(u)?W(n)&&W(u)&&(o[r]=dt(u,n)):o[r]=n;return o},ft=function(){var t;return t=1<=arguments.length?e.call(arguments,0):[],y(t,j)},y=function(e,t){var n,r,o,u;for(u=void 0,r=0,o=e.length;o>r;r++)if(n=e[r],t(n)){u=n;break}return u},u=function(e,t){var n,r,o,u;for(u=!1,r=0,o=e.length;o>r;r++)if(n=e[r],t(n)){u=!0;break}return u},l=function(e){return $t(e,j)},Rt=function(e){var t;return t={},$t(e,function(e){return t.hasOwnProperty(e)?!1:t[e]=!0})},$t=function(e,t){var n;return n=[],b(e,function(e){return t(e)?n.push(e):void 0}),n},gt=function(e,t){return $t(e,function(e){return!t(e)})},P=function(e,t){return $t(e,function(e){return p(t,e)})},vt=function(){var t,n,r,o;return t=arguments[0],r=2<=arguments.length?e.call(arguments,1):[],o=function(){var e,o,u;for(u=[],e=0,o=r.length;o>e;e++)n=r[e],u.push(t.attr(n));return u}(),y(o,_)},ot=function(e){return setTimeout(e,0)},X=function(e){return e[e.length-1]},s=function(){var e;return e=document.documentElement,{width:e.clientWidth,height:e.clientHeight}},Tt=et(function(){var e,n,r;return e=t("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),e.appendTo(document.body),n=e.get(0),r=n.offsetWidth-n.clientWidth,e.remove(),r}),ct=function(t){var n;return n=void 0,function(){var r;return r=1<=arguments.length?e.call(arguments,0):[],null!=t&&(n=t.apply(null,r)),t=void 0,n}},At=function(e,t,n){var r,o;return o=e.css(Object.keys(t)),e.css(t),r=function(){return e.css(o)},n?(n(),r()):ct(r)},A=function(e){var t,n;return n=e.css(["transform","-webkit-transform"]),U(n)||"none"===n.transform?(t=function(){return e.css(n)},e.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):t=function(){},t},v=function(e,n,o){var u,i,a,s,l,c;return u=t(e),o=dt(o,{duration:300,delay:0,easing:"ease"}),i=t.Deferred(),s={"transition-property":Object.keys(n).join(", "),"transition-duration":o.duration+"ms","transition-delay":o.delay+"ms","transition-timing-function":o.easing},l=A(u),c=At(u,s),u.css(n),i.then(l),i.then(c),u.data(r,i),i.then(function(){return u.removeData(r)}),a=setTimeout(function(){return i.resolve()},o.duration+o.delay),i.then(function(){return clearTimeout(a)}),i},r="up-animation-promise",C=function(e){return t(e).each(function(){var e;return(e=t(this).data(r))?e.resolve():void 0})},Z=function(e,n){var r,o,u,i,a,l;return n=dt(n,{relative:!1,inner:!1,full:!1}),n.relative?n.relative===!0?i=e.position():(r=t(n.relative),a=e.offset(),r.is(document)?i=a:(u=r.offset(),i={left:a.left-u.left,top:a.top-u.top})):i=e.offset(),o={left:i.left,top:i.top},n.inner?(o.width=e.width(),o.height=e.height()):(o.width=e.outerWidth(),o.height=e.outerHeight()),n.full&&(l=s(),o.right=l.width-(o.left+o.width),o.bottom=l.height-(o.top+o.height)),o},d=function(e,t){var n,r,o,u,i;for(u=e.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)n=u[r],i.push(n.specified?t.attr(n.name,n.value):void 0);return i},$=function(e,t){return e.find(t).addBack(t)},k=function(e){return 27===e.keyCode},p=function(e,t){return e.indexOf(t)>=0},a=function(e,t){var n;switch(n=e.attr(t)){case"false":return!1;case"true":return!0;case"":return!0;default:return n}},G=function(e){return e.getResponseHeader("X-Up-Location")},Dt=function(e){return e.getResponseHeader("X-Up-Title")},nt=function(e){return e.getResponseHeader("X-Up-Method")},pt=function(){var t,n,r,o,u,i;for(o=arguments[0],u=2<=arguments.length?e.call(arguments,1):[],t={},n=0,r=u.length;r>n;n++)i=u[n],o.hasOwnProperty(i)&&(t[i]=o[i]);return t},x=function(){var t,n,r,o,u,i;for(o=arguments[0],u=2<=arguments.length?e.call(arguments,1):[],t=f(o),n=0,r=u.length;r>n;n++)i=u[n],delete t[i];return t},J=function(e){return!(e.metaKey||e.shiftKey||e.ctrlKey)},B=function(e){var t;return t=V(e.button)||0===e.button,t&&J(e)},St=function(){var e;return e=t.Deferred(),e.resolve(),e},xt=function(){return St().promise()},Mt=function(){return t.Deferred()},jt=function(){return Mt().promise()},st=function(){return t()},kt=function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],r=t.when.apply(t,n),r.resolve=function(){return b(n,function(e){return"function"==typeof e.resolve?e.resolve():void 0})},r},Et=function(e,t){var n,r,o;r=[];for(n in t)o=t[n],r.push(I(e.attr(n))?e.attr(n,o):void 0);return r},yt=function(e,t){var n;return n=e.indexOf(t),n>=0?(e.splice(n,1),t):void 0},rt=function(e){var n,r,o,i,a,s,l;for(a={},l=[],r=[],o=0,i=e.length;i>o;o++)s=e[o],Q(s)?l.push(s):r.push(s);return a.parsed=r,l.length&&(n=l.join(", "),a.parsed.push(n)),a.select=function(){return a.find(void 0)},a.find=function(e){var n,r,o,u,i,s;for(r=st(),i=a.parsed,o=0,u=i.length;u>o;o++)s=i[o],n=e?e.find(s):t(s),r=r.add(n);return r},a.findWithSelf=function(e){var t;return t=a.find(e),a.doesMatch(e)&&(t=t.add(e)),t},a.doesMatch=function(e){var n;return n=t(e),u(a.parsed,function(e){return n.is(e)})},a.seekUp=function(e){var n,r,o;for(o=t(e),n=o,r=void 0;n.length;){if(a.doesMatch(n)){r=n;break}n=n.parent()}return r||st()},a},i=function(t){var n,r,o,u,i,a,s,l,c,p,d,m;return null==t&&(t={}),d=void 0,r=function(){return d={}},r(),s=function(){var n;return n=1<=arguments.length?e.call(arguments,0):[],t.log?(n[0]="["+t.log+"] "+n[0],g.apply(null,n)):void 0},a=function(){return Object.keys(d)},l=function(){return I(t.size)?void 0:M(t.size)?t.size():N(t.size)?t.size:w("Invalid size config: %o",t.size)},o=function(){return I(t.expiry)?void 0:M(t.expiry)?t.expiry():N(t.expiry)?t.expiry:w("Invalid expiry config: %o",t.expiry)},c=function(e){return t.key?t.key(e):e.toString()},Ot=function(){var e,t,n,r;return r=f(a()),n=l(),n&&r.length>n&&(e=null,t=null,b(r,function(n){var r,o;return r=d[n],o=r.timestamp,!t||t>o?(e=n,t=o):void 0}),e)?delete d[e]:void 0},n=function(e,t){var n;return n=u(e),F(n)?p(t,n):void 0},m=function(){return(new Date).valueOf()},p=function(e,t){var n;return n=c(e),d[n]={timestamp:m(),value:t}},yt=function(e){var t;return t=c(e),delete d[t]},i=function(e){var t,n;return t=o(),t?(n=m()-e.timestamp,n<o()):!0},u=function(e,t){var n,r;return null==t&&(t=void 0),r=c(e),(n=d[r])?i(n)?(s("Cache hit for %o",e),n.value):(s("Discarding stale cache entry for %o",e),yt(e),t):(s("Cache miss for %o",e),t)},{alias:n,get:u,set:p,remove:yt,clear:r,keys:a}},c=function(e){var t;return null==e&&(e={}),t={},t.reset=function(){return T(t,e)},t.reset(),Object.preventExtensions(t),t},zt=function(e){var t,n;return e=Ft(e),t=e.parentNode,n=Ut(e.childNodes),b(n,function(n){return t.insertBefore(n,e)}),t.removeChild(e)},lt=function(e){var t,n;for(t=void 0;(e=e.parent())&&e.length;)if(n=e.css("position"),"absolute"===n||"relative"===n||e.is("body")){t=e;break}return t},E=function(e,n){var r,o,u,i;return r=t(e),o=lt(r),u=r.position(),i=o.offset(),r.css({position:"absolute",left:u.left-i.left,top:u.top-i.top+n.scrollTop(),right:"",bottom:""})},bt=function(e){var t,n,r;if(I(e))return[];if(D(e))return e;if(W(e)){n=[];for(t in e)r=e[t],n.push({name:t,value:r});return n}return w("Unknown options.data type for %o",e)},wt=function(e){var t,n;return t=bt(e),n="",_(t)&&(n+="?",b(t,function(e,t){return 0!==t&&(n+="&"),n+=encodeURIComponent(e.name)+"="+encodeURIComponent(e.value)})),n},{requestDataAsArray:bt,requestDataAsQueryString:wt,offsetParent:lt,fixedToAbsolute:E,presentAttr:vt,createElement:m,parseUrl:mt,normalizeUrl:at,normalizeMethod:it,createElementFromHtml:h,$createElementFromSelector:n,selectorForElement:Ct,extend:T,copy:f,merge:tt,options:dt,option:ft,error:w,debug:g,warn:Lt,each:b,map:Y,times:Pt,any:u,detect:y,select:$t,reject:gt,intersect:P,compact:l,uniq:Rt,last:X,isNull:K,isDefined:F,isUndefined:V,isGiven:j,isMissing:I,isPresent:_,isBlank:U,presence:ht,isObject:W,isFunction:M,isString:Q,isElement:R,isJQuery:L,isPromise:q,isDeferred:O,isHash:z,isUnmodifiedKeyEvent:J,isUnmodifiedMouseEvent:B,nullJQuery:st,unJQuery:Ft,nextFrame:ot,measure:Z,temporaryCss:At,cssAnimate:v,finishCssAnimate:C,forceCompositing:A,escapePressed:k,copyAttributes:d,findWithSelf:$,contains:p,isArray:D,toArray:Ut,castedAttr:a,locationFromXhr:G,titleFromXhr:Dt,methodFromXhr:nt,clientSize:s,only:pt,except:x,trim:Ot,unresolvableDeferred:Mt,unresolvablePromise:jt,resolvedPromise:xt,resolvedDeferred:St,resolvableWhen:kt,setMissingAttrs:Et,remove:yt,memoize:et,scrollbarWidth:Tt,config:c,cache:i,unwrapElement:zt,multiSelector:rt,evalConsoleTemplate:S}}($),up.error=up.util.error,up.warn=up.util.warn,up.debug=up.util.debug}.call(this),function(){var e=[].slice;up.browser=function(t){var n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return h=up.util,f=function(e,n){var r,o,u,i;return null==n&&(n={}),i=h.option(n.method,"get").toLowerCase(),"get"===i?location.href=e+h.requestDataAsQueryString(n.data):(r=t("<form method='post' action='"+e+"'></form>"),o=function(e){var n;return n=t('<input type="hidden">'),n.attr(e.name,e.value),n.appendTo(r)},o({name:up.proxy.config.wrapMethodParam,value:i}),(u=up.rails.csrfField())&&o(u),h.each(h.requestDataAsArray(n.data),o),r.hide().appendTo("body"),r.submit())},m=function(){var t,n,r;return r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],h.isDefined(console[r])||(r="log"),o()?console[r].apply(console,t):(n=h.evalConsoleTemplate.apply(h,t),console[r](n))},v=function(){return location.href},s=h.memoize(function(){return h.isUndefined(document.addEventListener)}),l=h.memoize(function(){return s()||-1!==navigator.appVersion.indexOf("MSIE 9.")}),u=h.memoize(function(){return h.isDefined(history.pushState)&&"get"===a()}),n=h.memoize(function(){return"transition"in document.documentElement.style}),r=h.memoize(function(){return"oninput"in document.createElement("input")}),o=h.memoize(function(){return!l()}),c=h.memoize(function(){var e,n,r,o;return o=t.fn.jquery,r=o.split("."),e=parseInt(r[0]),n=parseInt(r[1]),e>=2||1===e&&n>=9}),d=function(e){var t,n;return n=null!=(t=document.cookie.match(new RegExp(e+"=(\\w+)")))?t[1]:void 0,h.isPresent(n)&&(document.cookie=e+"=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/"),n},i=function(e){return h.isBlank(e)||i(e)?h.resolvedPromise():h.unresolvablePromise()},a=h.memoize(function(){return(d("_up_request_method")||"get").toLowerCase()}),p=function(){return!s()&&c()},{url:v,loadPage:f,confirm:i,canPushState:u,canCssTransition:n,canInputEvent:r,canLogSubstitution:o,isSupported:p,puts:m}}(jQuery)}.call(this),function(){var slice=[].slice;up.bus=function($){var boot,emit,emitReset,forgetUpDescription,live,liveUpDescriptions,nextUpDescriptionNumber,nobodyPrevents,onEscape,rememberUpDescription,restoreSnapshot,snapshot,u,unbind,upDescriptionNumber,upDescriptionToJqueryDescription,upListenerToJqueryListener;return u=up.util,liveUpDescriptions={},nextUpDescriptionNumber=0,upListenerToJqueryListener=function(e){return function(t){var n;return n=t.$element||$(this),e.apply(n.get(0),[t,n,up.syntax.data(n)])}},upDescriptionToJqueryDescription=function(e,t){var n,r,o;return n=u.copy(e),o=n.pop(),r=void 0,t?(r=upListenerToJqueryListener(o),o._asJqueryListener=r,o._descriptionNumber=++nextUpDescriptionNumber):(r=o._asJqueryListener,r||u.error("up.off: The event listener %o was never registered through up.on")),n.push(r),n},live=function(){var e,t,n;return n=1<=arguments.length?slice.call(arguments,0):[],up.browser.isSupported()?(e=upDescriptionToJqueryDescription(n,!0),rememberUpDescription(n),(t=$(document)).on.apply(t,e),function(){return unbind.apply(null,n)}):function(){}},unbind=function(){var e,t,n;return n=1<=arguments.length?slice.call(arguments,0):[],e=upDescriptionToJqueryDescription(n,!1),forgetUpDescription(n),(t=$(document)).off.apply(t,e)},rememberUpDescription=function(e){var t;return t=upDescriptionNumber(e),liveUpDescriptions[t]=e},forgetUpDescription=function(e){var t;return t=upDescriptionNumber(e),delete liveUpDescriptions[t]},upDescriptionNumber=function(e){return u.last(e)._descriptionNumber},emit=function(e,t){var n,r;return null==t&&(t={}),r=$.Event(e,t),n=t.$element||$(document),u.debug("Emitting %o on %o with props %o",e,n,t),n.trigger(r),r},nobodyPrevents=function(){var e,t;return e=1<=arguments.length?slice.call(arguments,0):[],t=emit.apply(null,e),!t.isDefaultPrevented()},onEscape=function(e){return live("keydown","body",function(t){return u.escapePressed(t)?e(t):void 0})},snapshot=function(){var e,t,n,r;for(r=[],t=0,n=liveUpDescriptions.length;n>t;t++)e=liveUpDescriptions[t],r.push(e._isDefault=!0);return r},restoreSnapshot=function(){var e,t,n,r,o;for(t=u.reject(liveUpDescriptions,function(e){return e._isDefault}),o=[],n=0,r=t.length;r>n;n++)e=t[n],o.push(unbind.apply(null,e));return o},emitReset=function(){return up.emit("up:framework:reset")},boot=function(){return up.browser.isSupported()?up.emit("up:framework:boot"):void 0},live("up:framework:boot",snapshot),live("up:framework:reset",restoreSnapshot),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),on:live,off:unbind,emit:emit,nobodyPrevents:nobodyPrevents,onEscape:onEscape,emitReset:emitReset,boot:boot}}(jQuery),up.on=up.bus.on,up.off=up.bus.off,up.emit=up.bus.emit,up.reset=up.bus.emitReset,up.boot=up.bus.boot}.call(this),function(){var e=[].slice;up.syntax=function(t){var n,r,o,u,i,a,s,l,c,p,f,d,m;return m=up.util,n="up-destroyable",r="up-destroyer",a=[],l=null,i=function(){var t,n,r;return r=arguments[0],t=2<=arguments.length?e.call(arguments,1):[],up.browser.isSupported()?(i=t.pop(),n=m.options(t[0],{batch:!1}),a.push({selector:r,callback:i,batch:n.batch})):void 0},o=function(e,t,o){var u;return m.debug("Applying compiler %o on %o",e.selector,o),u=e.callback.apply(o,[t,s(t)]),m.isFunction(u)?(t.addClass(n),t.data(r,u)):void 0},u=function(e){var n,r,u,s;for(m.debug("Compiling fragment %o",e),s=[],r=0,u=a.length;u>r;r++)i=a[r],n=m.findWithSelf(e,i.selector),s.push(n.length?i.batch?o(i,n,n.get()):n.each(function(){return o(i,t(this),this)}):void 0);return s},f=function(e){return m.findWithSelf(e,"."+n).each(function(){var e,n;return e=t(this),(n=e.data(r))()})},s=function(e){var n,r;return n=t(e),r=n.attr("up-data"),m.isString(r)&&""!==m.trim(r)?JSON.parse(r):{}},d=function(){return l=m.copy(a)},p=function(){return a=m.copy(l)},c=function(e,n){var r,o;return r=t(e),o=m.options(n,{$element:r}),up.emit("up:fragment:inserted",o),r},up.on("ready",function(){return c(document.body)}),up.on("up:fragment:inserted",function(e,t){return u(t)}),up.on("up:fragment:destroy",function(e,t){return f(t)}),up.on("up:framework:boot",d),up.on("up:framework:reset",p),{compiler:i,hello:c,data:s}}(jQuery),up.compiler=up.syntax.compiler,up.hello=up.syntax.hello,up.ready=function(){return up.util.error("up.ready no longer exists. Please use up.hello instead.")},up.awaken=function(){return up.util.error("up.awaken no longer exists. Please use up.compiler instead.")}}.call(this),function(){up.history=function(e){var t,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return v=up.util,n=v.config({popTargets:["body"],restoreScroll:!0}),c=void 0,i=void 0,m=function(){return n.reset(),c=void 0,i=void 0},a=function(e){return v.normalizeUrl(e,{hash:!0})},r=function(){return a(up.browser.url())},o=function(e){return a(e)===r()},s=function(e){return i&&(c=i,i=void 0),i=e},d=function(e,t){return u("replace",e,t)},p=function(e,t){return u("push",e,t)},u=function(e,n,u){var i,a;return u=v.options(u,{force:!1}),u.force||!o(n)?up.browser.canPushState()?(i=e+"State",a=t(),v.debug("Changing history to URL %o (%o)",n,e),window.history[i](a,"",n),s(r())):v.error("This browser doesn't support history.pushState"):void 0},t=function(){return{fromUp:!0}},h=function(e){var t,o;return o=r(),v.debug("Restoring state %o (now on "+o+")",e),t=n.popTargets.join(", "),up.replace(t,o,{history:!1,reveal:!1,transition:"none",saveScroll:!1,restoreScroll:n.restoreScroll})},l=function(e){var t;return v.debug("History state popped to URL %o",r()),s(r()),up.layout.saveScroll({url:c}),t=e.originalEvent.state,(null!=t?t.fromUp:void 0)?h(t):v.debug("Discarding unknown state %o",t)},up.browser.canPushState()&&(f=function(){return e(window).on("popstate",l),d(r(),{force:!0})},"undefined"!=typeof jasmine&&null!==jasmine?f():setTimeout(f,100)),up.compiler("[up-back]",function(e){return v.isPresent(c)?(v.setMissingAttrs(e,{"up-href":c,"up-restore-scroll":""}),e.removeAttr("up-back"),up.link.makeFollowable(e)):void 0}),up.on("up:framework:reset",m),{config:n,defaults:function(){return v.error("up.history.defaults(...) no longer exists. Set values on he up.history.config property instead.")},push:p,replace:d,url:r,previousUrl:function(){return c},normalizeUrl:a}}(jQuery)}.call(this),function(){var slice=[].slice;up.layout=function($){var SCROLL_PROMISE_KEY,anchoredRight,config,finishScrolling,fixedChildren,lastScrollTops,measureObstruction,reset,restoreScroll,reveal,revealOrRestoreScroll,saveScroll,scroll,scrollTops,u,viewportOf,viewportSelector,viewports,viewportsWithin;return u=up.util,config=u.config({duration:0,viewports:[document,".up-modal","[up-viewport]"],fixedTop:["[up-fixed~=top]"],fixedBottom:["[up-fixed~=bottom]"],anchoredRight:["[up-anchored~=right]","[up-fixed~=top]","[up-fixed~=bottom]","[up-fixed~=right]"],snap:50,substance:150,easing:"swing"}),lastScrollTops=u.cache({size:30,key:up.history.normalizeUrl}),reset=function(){return config.reset(),lastScrollTops.clear()},SCROLL_PROMISE_KEY="up-scroll-promise",scroll=function(e,t,n){var r,o,i,a,s;return r=$(e),n=u.options(n),i=u.option(n.duration,config.duration),a=u.option(n.easing,config.easing),finishScrolling(r),i>0?(o=$.Deferred(),r.data(SCROLL_PROMISE_KEY,o),o.then(function(){return r.removeData(SCROLL_PROMISE_KEY),r.finish()}),s={scrollTop:t},r.get(0)===document&&(r=$("html, body")),r.animate(s,{duration:i,easing:a,complete:function(){return o.resolve()}}),o):(r.scrollTop(t),u.resolvedDeferred())},finishScrolling=function(e){return $(e).each(function(){var e;return(e=$(this).data(SCROLL_PROMISE_KEY))?e.resolve():void 0})},anchoredRight=function(){return u.multiSelector(config.anchoredRight).select()},measureObstruction=function(){var e,t,n,r;return n=function(e,t){var n,r;return n=$(e),r=n.css(t),u.isPresent(r)||u.error("Fixed element %o must have a CSS attribute %o",n,t),parseInt(r)+n.height()},t=function(){var e,t,o,u;for(o=$(config.fixedTop.join(", ")),u=[],e=0,t=o.length;t>e;e++)r=o[e],u.push(n(r,"top"));return u}(),e=function(){var e,t,o,u;for(o=$(config.fixedBottom.join(", ")),u=[],e=0,t=o.length;t>e;e++)r=o[e],u.push(n(r,"bottom"));return u}(),{top:Math.max.apply(Math,[0].concat(slice.call(t))),bottom:Math.max.apply(Math,[0].concat(slice.call(e)))}},reveal=function(e,t){var n,r,o,i,a,s,l,c,p,f,d,m,h,v;return u.debug("Revealing %o",e),t=u.options(t),n=$(e),r=t.viewport?$(t.viewport):viewportOf(n),m=u.option(t.snap,config.snap),v=r.is(document),h=v?u.clientSize().height:r.height(),p=r.scrollTop(),s=p,c=void 0,l=void 0,v?(l=measureObstruction(),c=0):(l={top:0,bottom:0},c=p),f=function(){return s+l.top},d=function(){return s+h-l.bottom-1},o=u.measure(n,{relative:r}),i=o.top+c,a=i+Math.min(o.height,config.substance)-1,a>d()&&(s+=a-d()),(i<f()||t.top)&&(s=i-l.top),m>s&&(s=0),s!==p?scroll(r,s,t):u.resolvedDeferred()},viewportSelector=function(){return u.multiSelector(config.viewports)},viewportOf=function(e){var t,n;return t=$(e),n=viewportSelector().seekUp(t),n.length||u.error("Could not find viewport for %o",t),n},viewportsWithin=function(e){var t;return t=$(e),viewportSelector().findWithSelf(t)},viewports=function(){return viewportSelector().select()},scrollTops=function(){var e,t,n,r,o,u,i;for(u={},o=config.viewports,t=0,r=o.length;r>t;t++)i=o[t],e=$(i),e.length&&(n=i,i===document&&(n="document"),u[n]=e.scrollTop());return u},fixedChildren=function(e){var t,n;return null==e&&(e=void 0),e||(e=document.body),n=$(e),t=n.find("[up-fixed]"),u.isPresent(config.fixedTop)&&(t=t.add(n.find(config.fixedTop.join(", ")))),u.isPresent(config.fixedBottom)&&(t=t.add(n.find(config.fixedBottom.join(", ")))),t},saveScroll=function(e){var t,n;return null==e&&(e={}),n=u.option(e.url,up.history.url()),t=u.option(e.tops,scrollTops()),u.debug("Saving scroll positions for URL %o: %o",n,t),lastScrollTops.set(n,t)},restoreScroll=function(e){var t,n,r,o,i,a,s,l,c;null==e&&(e={}),c=up.history.url(),o=void 0,e.around?(n=viewportsWithin(e.around),t=viewportOf(e.around),o=t.add(n)):o=viewports(),l=lastScrollTops.get(c),u.debug("Restoring scroll positions for URL %o (viewports are %o, saved tops are %o)",c,o,l);for(i in l)s=l[i],a="document"===i?document:i,r=o.filter(a),scroll(r,s,{duration:0});return u.resolvedDeferred()},revealOrRestoreScroll=function(e,t){var n,r,o,i;return n=$(e),t.restoreScroll?restoreScroll({around:n}):t.reveal?(t.source&&(i=u.parseUrl(t.source),i.hash&&"#"!==i.hash&&(o=i.hash.substr(1),r=u.findWithSelf(n,"#"+o+", a[name='"+o+"']"),r.length&&(n=r))),reveal(n)):u.resolvedDeferred()},up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),reveal:reveal,scroll:scroll,finishScrolling:finishScrolling,config:config,defaults:function(){return u.error("up.layout.defaults(...) no longer exists. Set values on he up.layout.config property instead.")},viewportOf:viewportOf,viewportsWithin:viewportsWithin,viewports:viewports,scrollTops:scrollTops,saveScroll:saveScroll,restoreScroll:restoreScroll,revealOrRestoreScroll:revealOrRestoreScroll,anchoredRight:anchoredRight,fixedChildren:fixedChildren}}(jQuery),up.scroll=up.layout.scroll,up.reveal=up.layout.reveal}.call(this),function(){up.flow=function($){var autofocus,destroy,elementsInserted,findOldFragment,first,implant,isRealElement,oldFragmentNotFound,parseImplantSteps,parseResponse,processResponse,reload,replace,resolveSelector,setSource,source,swapElements,u;return u=up.util,setSource=function(e,t){var n;return n=$(e),u.isPresent(t)&&(t=u.normalizeUrl(t)),n.attr("up-source",t)},source=function(e){var t;return t=$(e).closest("[up-source]"),u.presence(t.attr("up-source"))||up.browser.url()},resolveSelector=function(e,t){var n,r;return u.isString(e)?(r=e,u.contains(r,"&")&&(t?(n=u.selectorForElement(t),r=r.replace(/\&/,n)):u.error("Found origin reference %o in selector %o, but options.origin is missing","&",r))):r=u.selectorForElement(e),r},replace=function(e,t,n){var r,o,i,a;return u.debug("Replace %o with %o (options %o)",e,t,n),n=u.options(n),a=resolveSelector(e,n.origin),r=u.option(n.failTarget,"body"),r=resolveSelector(r,n.origin),up.browser.canPushState()||n.history===!1?(i={url:t,method:n.method,data:n.data,target:a,failTarget:r,cache:n.cache,preload:n.preload,headers:n.headers},o=up.proxy.ajax(i),o.done(function(e,r,o){return processResponse(!0,a,t,i,o,n)}),o.fail(function(e){return processResponse(!1,r,t,i,e,n)}),o):(n.preload||up.browser.loadPage(t,u.only(n,"method","data")),u.unresolvablePromise())},processResponse=function(e,t,n,r,o,i){var a,s,l;return i.method=u.normalizeMethod(u.option(u.methodFromXhr(o),i.method)),i.title=u.option(u.titleFromXhr(o),i.title),a="GET"===i.method,(l=u.locationFromXhr(o))?(n=l,e&&(s={url:n,method:u.methodFromXhr(o),target:t},up.proxy.alias(r,s))):a&&(n+=u.requestDataAsQueryString(i.data)),e?a?(i.history===!1||u.isString(i.history)||(i.history=n),i.source===!1||u.isString(i.source)||(i.source=n)):(u.isString(i.history)||(i.history=!1),u.isString(i.source)||(i.source="keep")):(i.transition=i.failTransition,i.failTransition=void 0,a?(i.history!==!1&&(i.history=n),i.source!==!1&&(i.source=n)):(i.source="keep",i.history=!1)),i.preload?u.resolvedPromise():implant(t,o.responseText,i)},implant=function(e,t,n){var r,o,i,a,s,l,c,p,f,d,m,h;for(n=u.options(n,{historyMethod:"push",requireMatch:!0}),m=resolveSelector(e,n.origin),d=parseResponse(t,n),n.title||(n.title=d.title()),n.saveScroll!==!1&&up.layout.saveScroll(),"function"==typeof n.beforeSwap&&n.beforeSwap(o,r),a=[],c=parseImplantSteps(m,n),s=0,l=c.length;l>s;s++)h=c[s],o=findOldFragment(h.selector,n),r=null!=(p=d.find(h.selector))?p.first():void 0,o&&r&&(i=swapElements(o,r,h.pseudoClass,h.transition,n),a.push(i));return"function"==typeof n.afterSwap&&n.afterSwap(o,r),(f=up.motion).when.apply(f,a)},findOldFragment=function(e,t){return first(".up-popup "+e)||first(".up-modal "+e)||first(e)||oldFragmentNotFound(e,t)},oldFragmentNotFound=function(e,t){var n;return t.requireMatch?(n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),u.error(n,e)):void 0},parseResponse=function(e,t){var n;return n=u.createElementFromHtml(e),{title:function(){var e;return null!=(e=n.querySelector("title"))?e.textContent:void 0},find:function(r){var o;return(o=$.find(r,n)[0])?$(o):t.requireMatch?u.error("Could not find selector %o in response %o",r,e):void 0}}},elementsInserted=function(e,t){return t.history&&(t.title&&(document.title=t.title),up.history[t.historyMethod](t.history)),t.source!==!1&&setSource(e,t.source),autofocus(e),up.hello(e,{origin:t.origin})},swapElements=function(e,t,n,r,o){var i,a,s,l;return r||(r="none"),"keep"===o.source&&(o=u.merge(o,{source:source(e)})),up.motion.finish(e),n?(a="before"===n?"prepend":"append",i=t.contents().wrap('<span class="up-insertion"></span>').parent(),e[a](i),u.copyAttributes(t,e),elementsInserted(i.children(),o),s=up.layout.revealOrRestoreScroll(i,o),s=s.then(function(){return up.animate(i,r,o)}),s=s.then(function(){return u.unwrapElement(i)})):(l=function(){return t.insertBefore(e),elementsInserted(t,o),e.is("body")&&"none"!==r&&u.error("Cannot apply transitions to body-elements (%o)",r),up.morph(e,t,r,o)},destroy(e,{animation:l}))},parseImplantSteps=function(e,t){var n,r,o,i,a,s,l,c,p,f,d,m;for(d=t.transition||t.animation||"none",n=/\ *,\ */,r=e.split(n),u.isPresent(d)&&(m=d.split(n)),l=[],o=i=0,a=r.length;a>i;o=++i)c=r[o],p=c.match(/^(.+?)(?:\:(before|after))?$/),p||u.error("Could not parse selector atom %o",c),e=p[1],"html"===e&&(e="body"),s=p[2],f=m[o]||u.last(m),l.push({selector:e,pseudoClass:s,transition:f});return l},autofocus=function(e){var t,n;return n="[autofocus]:last",t=u.findWithSelf(e,n),t.length&&t.get(0)!==document.activeElement?t.focus():void 0},isRealElement=function(e){var t;return t=".up-ghost, .up-destroying",0===e.closest(t).length},first=function(e){var t,n,r,o,i,a;for(o=void 0,o=u.isString(e)?$(e).get():e,n=void 0,i=0,a=o.length;a>i;i++)if(r=o[i],t=$(r),isRealElement(t)){n=t;break}return n},destroy=function(e,t){var n,r,o;return n=$(e),up.bus.nobodyPrevents("up:fragment:destroy",{$element:n})?(t=u.options(t,{animation:!1}),r=up.motion.animateOptions(t),n.addClass("up-destroying"),u.isPresent(t.url)&&up.history.push(t.url),u.isPresent(t.title)&&(document.title=t.title),o=u.presence(t.animation,u.isDeferred)||up.motion.animate(n,t.animation,r),o.then(function(){return up.emit("up:fragment:destroyed",{$element:n}),n.remove()}),o):$.Deferred()},reload=function(e,t){var n;return t=u.options(t,{cache:!1}),n=t.url||source(e),replace(e,n,t)},up.on("ready",function(){return setSource(document.body,up.browser.url())}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),replace:replace,reload:reload,destroy:destroy,implant:implant,first:first,source:source,resolveSelector:resolveSelector}}(jQuery),up.replace=up.flow.replace,up.implant=up.flow.implant,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.first=up.flow.first}.call(this),function(){up.motion=function(e){var t,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,S,x,T;return x=up.util,u={},s={},S={},l={},a=x.config({duration:300,delay:0,easing:"ease",enabled:!0}),g=function(){return u=x.copy(s),S=x.copy(l),a.reset()},d=function(){return a.enabled&&up.browser.canCssTransition()},n=function(t,o,u){var a;return a=e(t),p(a),u=r(u),"none"===o||o===!1?h():x.isFunction(o)?i(o(a,u),o):x.isString(o)?n(a,c(o),u):x.isHash(o)?d()?x.cssAnimate(a,o,u):(a.css(o),x.resolvedDeferred()):x.error("Unknown animation type for %o",o)},r=function(e,t){var n;return null==t&&(t=null),e=x.options(e),n={},n.easing=x.option(e.easing,null!=t?t.attr("up-easing"):void 0,a.easing),n.duration=Number(x.option(e.duration,null!=t?t.attr("up-duration"):void 0,a.duration)),n.delay=Number(x.option(e.delay,null!=t?t.attr("up-delay"):void 0,a.delay)),n
2
+ },c=function(e){return u[e]||x.error("Unknown animation %o",e)},t="up-ghosting-promise",T=function(e,n,r,o){var u,i,a,s,l,c,p;return s=void 0,i=void 0,l=void 0,a=void 0,u=up.layout.viewportOf(e),x.temporaryCss(n,{display:"none"},function(){return s=v(e,u),s.$ghost.addClass("up-destroying"),s.$bounds.addClass("up-destroying"),l=u.scrollTop()}),x.temporaryCss(e,{display:"none"},function(){return up.layout.revealOrRestoreScroll(n,r),i=v(n,u),a=u.scrollTop()}),s.moveTop(a-l),e.hide(),p=x.temporaryCss(n,{opacity:"0"}),c=o(s.$ghost,i.$ghost),e.data(t,c),n.data(t,c),c.then(function(){return e.removeData(t),n.removeData(t),p(),s.$bounds.remove(),i.$bounds.remove()}),c},p=function(t){return e(t).each(function(){var t;return t=e(this),x.finishCssAnimate(t),f(t)})},f=function(e){var n;return(n=e.data(t))?(x.debug("Canceling existing ghosting on %o",e),"function"==typeof n.resolve?n.resolve():void 0):void 0},i=function(e,t){return x.isDeferred(e)?e:x.error("Did not return a promise with .then and .resolve methods: %o",t)},m=function(t,o,a,s){var l,c,f,h,v,g;return x.debug("Morphing %o to %o (using %o)",t,o,a),c=e(t),l=e(o),h=x.only(s,"reveal","restoreScroll","source"),h=x.extend(h,r(s)),d()?(p(c),p(l),"none"===a||a===!1?b(c,l,h):(f=u[a])?(b(c,l,h),n(l,f,h)):(g=x.presence(a,x.isFunction)||S[a])?T(c,l,h,function(e,t){var n;return n=g(e,t,h),i(n,a)}):x.isString(a)&&a.indexOf("/")>=0?(v=a.split("/"),g=function(e,t,r){return y(n(e,v[0],r),n(t,v[1],r))},m(c,l,g,h)):x.error("Unknown transition %o",a)):b(c,l,h)},b=function(e,t,n){return e.hide(),up.layout.revealOrRestoreScroll(t,n)},v=function(t,n){var r,o,u,i,a,s,l,c,p;for(i=x.measure(t,{relative:!0,inner:!0}),u=t.clone(),u.find("script").remove(),u.css({position:"static"===t.css("position")?"static":"relative",top:"",right:"",bottom:"",left:"",width:"100%",height:"100%"}),u.addClass("up-ghost"),r=e('<div class="up-bounds"></div>'),r.css({position:"absolute"}),r.css(i),p=i.top,c=function(e){return 0!==e?(p+=e,r.css({top:p})):void 0},u.appendTo(r),r.insertBefore(t),c(t.offset().top-u.offset().top),o=up.layout.fixedChildren(u),s=0,l=o.length;l>s;s++)a=o[s],x.fixedToAbsolute(a,n);return{$ghost:u,$bounds:r,moveTop:c}},k=function(e,t){return S[e]=t},o=function(e,t){return u[e]=t},w=function(){return s=x.copy(u),l=x.copy(S)},y=x.resolvableWhen,h=x.resolvedDeferred,o("none",h),o("fade-in",function(e,t){return e.css({opacity:0}),n(e,{opacity:1},t)}),o("fade-out",function(e,t){return e.css({opacity:1}),n(e,{opacity:0},t)}),o("move-to-top",function(e,t){var r,o;return r=x.measure(e),o=r.top+r.height,e.css({"margin-top":"0px"}),n(e,{"margin-top":"-"+o+"px"},t)}),o("move-from-top",function(e,t){var r,o;return r=x.measure(e),o=r.top+r.height,e.css({"margin-top":"-"+o+"px"}),n(e,{"margin-top":"0px"},t)}),o("move-to-bottom",function(e,t){var r,o;return r=x.measure(e),o=x.clientSize().height-r.top,e.css({"margin-top":"0px"}),n(e,{"margin-top":o+"px"},t)}),o("move-from-bottom",function(e,t){var r,o;return r=x.measure(e),o=x.clientSize().height-r.top,e.css({"margin-top":o+"px"}),n(e,{"margin-top":"0px"},t)}),o("move-to-left",function(e,t){var r,o;return r=x.measure(e),o=r.left+r.width,e.css({"margin-left":"0px"}),n(e,{"margin-left":"-"+o+"px"},t)}),o("move-from-left",function(e,t){var r,o;return r=x.measure(e),o=r.left+r.width,e.css({"margin-left":"-"+o+"px"}),n(e,{"margin-left":"0px"},t)}),o("move-to-right",function(e,t){var r,o;return r=x.measure(e),o=x.clientSize().width-r.left,e.css({"margin-left":"0px"}),n(e,{"margin-left":o+"px"},t)}),o("move-from-right",function(e,t){var r,o;return r=x.measure(e),o=x.clientSize().width-r.left,e.css({"margin-left":o+"px"}),n(e,{"margin-left":"0px"},t)}),o("roll-down",function(e,t){var r,o;return r=e.height(),o=x.temporaryCss(e,{height:"0px",overflow:"hidden"}),n(e,{height:r+"px"},t).then(o)}),k("none",h),k("move-left",function(e,t,r){return y(n(e,"move-to-left",r),n(t,"move-from-right",r))}),k("move-right",function(e,t,r){return y(n(e,"move-to-right",r),n(t,"move-from-left",r))}),k("move-up",function(e,t,r){return y(n(e,"move-to-top",r),n(t,"move-from-bottom",r))}),k("move-down",function(e,t,r){return y(n(e,"move-to-bottom",r),n(t,"move-from-top",r))}),k("cross-fade",function(e,t,r){return y(n(e,"fade-out",r),n(t,"fade-in",r))}),up.on("up:framework:boot",w),up.on("up:framework:reset",g),{morph:m,animate:n,animateOptions:r,finish:p,transition:k,animation:o,config:a,isEnabled:d,defaults:function(){return x.error("up.motion.defaults(...) no longer exists. Set values on he up.motion.config property instead.")},none:h,when:y,prependCopy:v}}(jQuery),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){var e=[].slice;up.proxy=function(t){var n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,S,x,T,$,C,E,A,P,D,U,O,F;return F=up.util,n=void 0,C=void 0,i=void 0,x=void 0,a=void 0,A=[],m=F.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5,maxRequests:4,wrapMethods:["PATCH","PUT","DELETE"],wrapMethodParam:"_method",safeMethods:["GET","OPTIONS","HEAD"]}),l=function(e){return S(e),[e.url,e.method,e.data,e.target].join("|")},s=F.cache({size:function(){return m.cacheSize},expiry:function(){return m.cacheExpiry},key:l,log:"up.proxy"}),h=function(e){var t,n,r,o,u,i,a;for(e=S(e),n=[e],"html"!==e.target&&(i=F.merge(e,{target:"html"}),n.push(i),"body"!==e.target&&(u=F.merge(e,{target:"body"}),n.push(u))),r=0,o=n.length;o>r;r++)if(t=n[r],a=s.get(t))return a},U=s.set,P=s.remove,d=s.clear,p=function(){return clearTimeout(C),C=null},c=function(){return clearTimeout(i),i=null},D=function(){return n=null,p(),c(),x=0,m.reset(),a=!1,s.clear(),A=[]},D(),o=s.alias,S=function(e){return e._normalized||(e.method=F.normalizeMethod(e.method),e.url&&(e.url=F.normalizeUrl(e.url)),e.target||(e.target="body"),e._normalized=!0),e},r=function(e){var t,n,r,o,u;return t=e.cache===!0,n=e.cache===!1,u=F.only(e,"url","method","data","target","headers","_normalized"),r=!0,g(u)||t?(o=h(u))&&!n?r="pending"===o.state():(o=w(u),U(u,o),o.fail(function(){return P(u)})):(d(),o=w(u)),r&&!e.preload&&(k(),o.always(b)),o},v=function(){return 0===x},u=function(){return x>0},k=function(){var e,t;return t=v(),x+=1,t?(e=function(){return u()?(up.emit("up:proxy:busy"),a=!0):void 0},m.busyDelay>0?i=setTimeout(e,m.busyDelay):e()):void 0},b=function(){return x-=1,v()&&a?(up.emit("up:proxy:idle"),a=!1):void 0},w=function(e){return x<m.maxRequests?y(e):E(e)},E=function(e){var n,r;return F.debug("Queuing URL %o",e.url),n=t.Deferred(),r={deferred:n,request:e},A.push(r),n.promise()},y=function(e){var n;return F.debug("Fetching %o via %o",e.url,e.method),up.emit("up:proxy:load",e),e=F.copy(e),e.headers||(e.headers={}),e.headers["X-Up-Target"]=e.target,e.data=F.requestDataAsArray(e.data),F.contains(m.wrapMethods,e.method)&&(e.data.push({name:m.wrapMethodParam,value:e.method}),e.method="POST"),n=t.ajax(e),n.always(function(){return up.emit("up:proxy:received",e),T()}),n},T=function(){var t,n;return(t=A.shift())?(n=y(t.request),n.done(function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],(r=t.deferred).resolve.apply(r,n)}),n.fail(function(){var n,r;return n=1<=arguments.length?e.call(arguments,0):[],(r=t.deferred).reject.apply(r,n)})):void 0},g=function(e){return S(e),F.contains(m.safeMethods,e.method)},f=function(e){var t,r;return r=parseInt(F.presentAttr(e,"up-delay"))||m.preloadDelay,e.is(n)?void 0:(n=e,p(),t=function(){return $(e),n=null},O(t,r))},O=function(e,t){return C=setTimeout(e,t)},$=function(e,n){var r,o;return r=t(e),n=F.options(n),o=up.link.followMethod(r,n),g({method:o})?(F.debug("Preloading %o",r),n.preload=!0,up.follow(r,n)):(F.debug("Won't preload %o due to unsafe method %o",r,o),F.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(e,t){return up.link.childClicked(e,t)?void 0:f(t)}),up.on("up:framework:reset",D),{preload:$,ajax:r,get:h,alias:o,clear:d,remove:P,idle:v,busy:u,config:m,defaults:function(){return F.error("up.proxy.defaults(...) no longer exists. Set values on he up.proxy.config property instead.")}}}(jQuery)}.call(this),function(){up.link=function($){var allowDefault,childClicked,follow,followMethod,followVariantSelectors,isFollowable,makeFollowable,onAction,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(e,t){var n;return t=u.options(t),n=u.option(t.target,"body"),up.replace(n,e,t)},follow=function(e,t){var n,r,o;return n=$(e),t=u.options(t),o=u.option(n.attr("up-href"),n.attr("href")),r=u.option(t.target,n.attr("up-target"),"body"),t.failTarget=u.option(t.failTarget,n.attr("up-fail-target"),"body"),t.transition=u.option(t.transition,u.castedAttr(n,"up-transition"),"none"),t.failTransition=u.option(t.failTransition,u.castedAttr(n,"up-fail-transition"),"none"),t.history=u.option(t.history,u.castedAttr(n,"up-history")),t.reveal=u.option(t.reveal,u.castedAttr(n,"up-reveal"),!0),t.cache=u.option(t.cache,u.castedAttr(n,"up-cache")),t.restoreScroll=u.option(t.restoreScroll,u.castedAttr(n,"up-restore-scroll")),t.method=followMethod(n,t),t.origin=u.option(t.origin,n),t.confirm=u.option(t.confirm,n.attr("up-confirm")),t=u.merge(t,up.motion.animateOptions(t,n)),up.browser.confirm(t.confirm).then(function(){return up.replace(r,o,t)})},followMethod=function(e,t){var n;return n=$(e),t=u.options(t),u.option(t.method,n.attr("up-method"),n.attr("data-method"),"get").toUpperCase()},childClicked=function(e,t){var n,r;return n=$(e.target),r=n.closest("a, [up-href]"),r.length&&t.find(r).length},shouldProcessLinkEvent=function(e,t){return u.isUnmodifiedMouseEvent(e)&&!childClicked(e,t)},followVariantSelectors=[],allowDefault=function(){},onAction=function(e,t){return followVariantSelectors.push(e),up.on("click","a"+e+", [up-href]"+e,function(e,n){return shouldProcessLinkEvent(e,n)?n.is("[up-instant]")?e.preventDefault():(e.preventDefault(),t(n)):allowDefault(e)}),up.on("mousedown","a"+e+"[up-instant], [up-href]"+e+"[up-instant]",function(e,n){return shouldProcessLinkEvent(e,n)?(e.preventDefault(),t(n)):void 0})},isFollowable=function(e){return u.any(followVariantSelectors,function(t){return e.is(t)})},makeFollowable=function(e){var t;return t=$(e),isFollowable(t)?void 0:t.attr("up-follow","")},onAction("[up-target]",function(e){return follow(e)}),onAction("[up-follow]",function(e){return follow(e)}),up.compiler("[up-expand]",function(e){var t,n,r,o,i,a,s,l,c,p;if(t=e.find("a, [up-href]"),(c=e.attr("up-expand"))&&(t=t.filter(c)),i=t.get(0)){for(p=/^up-/,s={},s["up-href"]=$(i).attr("href"),l=i.attributes,r=0,o=l.length;o>r;r++)n=l[r],a=n.name,a.match(p)&&(s[a]=n.value);return u.setMissingAttrs(e,s),e.removeAttr("up-expand"),makeFollowable(e)}}),up.compiler("[up-dash]",function(e){var t,n;return n=u.castedAttr(e,"up-dash"),t={"up-preload":"true","up-instant":"true"},n===!0?t["up-follow"]="":t["up-target"]=n,u.setMissingAttrs(e,t),e.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,makeFollowable:makeFollowable,shouldProcessLinkEvent:shouldProcessLinkEvent,childClicked:childClicked,followMethod:followMethod,onAction:onAction}}(jQuery),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){var slice=[].slice;up.form=function($){var autosubmit,config,currentValuesForToggle,observe,observeForm,reset,resolveValidateTarget,submit,toggleTargets,u,validate;return u=up.util,config=u.config({validateTargets:["[up-fieldset]:has(&)","fieldset:has(&)","label:has(&)","form:has(&)"],fields:[":input"],observeDelay:0}),reset=function(){return config.reset()},submit=function(e,t){var n,r,o,i,a;return n=$(e).closest("form"),t=u.options(t),i=u.option(t.target,n.attr("up-target"),"body"),a=u.option(t.url,n.attr("action"),up.browser.url()),t.failTarget=u.option(t.failTarget,n.attr("up-fail-target"))||u.selectorForElement(n),t.history=u.option(t.history,u.castedAttr(n,"up-history"),!0),t.transition=u.option(t.transition,u.castedAttr(n,"up-transition"),"none"),t.failTransition=u.option(t.failTransition,u.castedAttr(n,"up-fail-transition"),"none"),t.method=u.option(t.method,n.attr("up-method"),n.attr("data-method"),n.attr("method"),"post").toUpperCase(),t.headers=u.option(t.headers,{}),t.reveal=u.option(t.reveal,u.castedAttr(n,"up-reveal"),!0),t.cache=u.option(t.cache,u.castedAttr(n,"up-cache")),t.restoreScroll=u.option(t.restoreScroll,u.castedAttr(n,"up-restore-scroll")),t.origin=u.option(t.origin,n),t.data=n.serializeArray(),t=u.merge(t,up.motion.animateOptions(t,n)),r=n.find("input[type=file]").length,t.validate&&(t.headers||(t.headers={}),t.headers["X-Up-Validate"]=t.validate,r)?u.unresolvablePromise():(n.addClass("up-active"),r||!up.browser.canPushState()&&t.history!==!1?(n.get(0).submit(),u.unresolvablePromise()):(o=up.replace(i,a,t),o.always(function(){return n.removeClass("up-active")}),o))},observe=function(){var $element,args,callback,callbackArg,callbackPromise,callbackTimer,changeEvents,check,clearTimer,delay,knownValue,nextCallback,options,rawCallback,runNextCallback,selectorOrElement;return selectorOrElement=arguments[0],args=2<=arguments.length?slice.call(arguments,1):[],options={},callbackArg=void 0,1===args.length&&(callbackArg=args[0]),args.length>1&&(options=u.options(args[0]),callbackArg=args[1]),$element=$(selectorOrElement),options=u.options(options),delay=u.option($element.attr("up-delay"),options.delay,config.observeDelay),delay=parseInt(delay),callback=null,u.isGiven(options.change)&&up.error("up.observe now takes the change callback as the last argument"),rawCallback=u.option(u.presentAttr($element,"op-observe"),callbackArg),callback=u.isString(rawCallback)?function(value,$field){return eval(rawCallback)}:rawCallback||u.error("up.observe: No change callback given"),$element.is("form")?observeForm($element,options,callback):(knownValue=null,callbackTimer=null,callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var e;return nextCallback?(e=nextCallback(),nextCallback=null,e):void 0},check=function(){var e,t,n;return n=$element.val(),t=u.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($element.get(0),[n,$element])},e=function(){return callbackPromise.then(function(){var e;return e=runNextCallback(),callbackPromise=u.isPromise(e)?e:u.resolvedPromise()})},0===delay?e():setTimeout(e,delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$element.on(changeEvents,check),check(),function(){return $element.off(changeEvents,check),clearTimer()})},observeForm=function(e,t,n){var r,o;return r=u.multiSelector(config.fields).find(e),o=u.map(r,function(e){return observe(e,n)}),function(){var e,t,n,r;for(r=[],t=0,n=o.length;n>t;t++)e=o[t],r.push(e());return r}},autosubmit=function(e,t){return observe(e,t,function(e,t){var n;return n=t.closest("form"),t.addClass("up-active"),submit(n).always(function(){return t.removeClass("up-active")})})},resolveValidateTarget=function(e,t){var n;return n=u.option(t.target,e.attr("up-validate")),u.isBlank(n)&&(n||(n=u.detect(config.validateTargets,function(n){var r;return r=up.flow.resolveSelector(n,t.origin),e.closest(r).length}))),u.isBlank(n)&&error("Could not find default validation target for %o (tried ancestors %o)",e,config.validateTargets),u.isString(n)||(n=u.selectorForElement(n)),n},validate=function(e,t){var n,r,o;return n=$(e),t=u.options(t),t.origin=n,t.target=resolveValidateTarget(n,t),t.failTarget=t.target,t.history=!1,t.headers=u.option(t.headers,{}),t.validate=n.attr("name")||"__none__",t=u.merge(t,up.motion.animateOptions(t,n)),r=n.closest("form"),o=up.submit(r,t)},currentValuesForToggle=function(e){var t,n,r;return r=void 0,e.is("input[type=checkbox]")?r=e.is(":checked")?[":checked",":present",e.val()]:[":unchecked",":blank"]:e.is("input[type=radio]")?(console.log("-- it is a radio button --"),t=e.closest("form, body").find("input[type='radio'][name='"+e.attr("name")+"']:checked"),console.log("checked button is %o",t),console.log("checked button val is %o",t.val()),r=t.length?[":checked",":present",t.val()]:[":unchecked",":blank"]):(console.log("-- else -- for %o",e),n=e.val(),r=u.isPresent(n)?[":present",n]:[":blank"]),r},currentValuesForToggle=function(e){var t,n,r,o;return e.is("input[type=checkbox]")?e.is(":checked")?(r=e.val(),n=":checked"):n=":unchecked":e.is("input[type=radio]")?(t=e.closest("form, body").find("input[type='radio'][name='"+e.attr("name")+"']:checked"),t.length?(n=":checked",r=t.val()):n=":unchecked"):r=e.val(),o=[],u.isPresent(r)?(o.push(r),o.push(":present")):o.push(":blank"),u.isPresent(n)&&o.push(n),o},toggleTargets=function(e,t){var n,r,o;return n=$(e),t=u.options(t),o=u.option(t.target,n.attr("up-toggle")),u.isPresent(o)||u.error("No toggle target given for %o",n),r=currentValuesForToggle(n),$(o).each(function(){var e,t,n,o;return e=$(this),(t=e.attr("up-hide-for"))?(t=t.split(" "),n=0===u.intersect(r,t).length):(o=(o=e.attr("up-show-for"))?o.split(" "):[":present",":checked"],n=u.intersect(r,o).length>0),e.toggle(n)})},up.on("submit","form[up-target]",function(e,t){return e.preventDefault(),submit(t)}),up.on("change","[up-validate]",function(e,t){return validate(t)}),up.on("change","[up-toggle]",function(e,t){return console.log("CHANGE EVENT"),toggleTargets(t)}),up.compiler("[up-toggle]",function(e){return toggleTargets(e)}),up.compiler("[up-observe]",function(e){return observe(e)}),up.compiler("[up-autosubmit]",function(e){return autosubmit(e)}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),config:config,submit:submit,observe:observe,validate:validate,toggleTargets:toggleTargets}}(jQuery),up.submit=up.form.submit,up.observe=up.form.observe,up.autosubmit=up.form.autosubmit,up.validate=up.form.validate}.call(this),function(){up.popup=function($){var attach,autoclose,close,config,contains,coveredUrl,createFrame,currentUrl,discardHistory,ensureInViewport,isOpen,reset,setPosition,u;return u=up.util,currentUrl=void 0,coveredUrl=function(){return $(".up-popup").attr("up-covered-url")},config=u.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right",history:!1}),reset=function(){return close({animation:!1}),config.reset()},setPosition=function(e,t){var n,r,o;return o=u.measure(e,{full:!0}),r=function(){switch(t){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.top+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return u.error("Unknown position %o",t)}}(),n=$(".up-popup"),n.attr("up-position",t),n.css(r),ensureInViewport(n)},ensureInViewport=function(e){var t,n,r,o,i,a,s;if(n=u.measure(e,{full:!0}),r=null,o=null,n.right<0&&(r=-n.right),n.bottom<0&&(o=-n.bottom),n.left<0&&(r=n.left),n.top<0&&(o=n.top),r&&((i=parseInt(e.css("left")))?e.css("left",i-r):(a=parseInt(e.css("right")))&&e.css("right",a+r)),o){if(s=parseInt(e.css("top")))return e.css("top",s-o);if(t=parseInt(e.css("bottom")))return e.css("bottom",t+o)}},discardHistory=function(){var e;return e=$(".up-popup"),e.removeAttr("up-covered-url"),e.removeAttr("up-covered-title")},createFrame=function(e,t){var n,r;return r=u.$createElementFromSelector(".up-popup"),t.sticky&&r.attr("up-sticky",""),r.attr("up-covered-url",up.browser.url()),r.attr("up-covered-title",document.title),n=u.$createElementFromSelector(e),n.appendTo(r),r.appendTo(document.body),r},isOpen=function(){return $(".up-popup").length>0},attach=function(e,t){var n,r,o,i;return n=$(e),n.length||u.error("Cannot attach popup to non-existing element %o",e),t=u.options(t),i=u.option(t.url,n.attr("href")),o=u.option(t.target,n.attr("up-popup"),"body"),t.position=u.option(t.position,n.attr("up-position"),config.position),t.animation=u.option(t.animation,n.attr("up-animation"),config.openAnimation),t.sticky=u.option(t.sticky,u.castedAttr(n,"up-sticky")),t.history=up.browser.canPushState()?u.option(t.history,u.castedAttr(n,"up-history"),config.history):!1,t.confirm=u.option(t.confirm,n.attr("up-confirm")),r=up.motion.animateOptions(t,n),up.browser.confirm(t.confirm).then(function(){var e,a;return up.bus.nobodyPrevents("up:popup:open",{url:i})?(a=isOpen(),a&&close({animation:!1}),t.beforeSwap=function(){return createFrame(o,t)},e=up.replace(o,i,u.merge(t,{animation:!1})),e=e.then(function(){return setPosition(n,t.position)}),a||(e=e.then(function(){return up.animate($(".up-popup"),t.animation,r)})),e=e.then(function(){return up.emit("up:popup:opened")})):u.unresolvableDeferred()})},close=function(e){var t,n;return t=$(".up-popup"),t.length?up.bus.nobodyPrevents("up:popup:close",{$element:t})?(e=u.options(e,{animation:config.closeAnimation,url:t.attr("up-covered-url"),title:t.attr("up-covered-title")}),currentUrl=void 0,n=up.destroy(t,e),n.then(function(){return up.emit("up:popup:closed")}),n):u.unresolvableDeferred():u.resolvedDeferred()},autoclose=function(){return $(".up-popup").is("[up-sticky]")?void 0:(discardHistory(),close())},contains=function(e){var t;return t=$(e),t.closest(".up-popup").length>0},up.link.onAction("[up-popup]",function(e){return e.is(".up-current")?close():attach(e)}),up.on("click","body",function(e){var t;return t=$(e.target),t.closest(".up-popup").length||t.closest("[up-popup]").length?void 0:close()}),up.on("up:fragment:inserted",function(e,t){var n;if(contains(t)){if(n=t.attr("up-source"))return currentUrl=n}else if(contains(e.origin))return autoclose()}),up.bus.onEscape(function(){return close()}),up.on("click","[up-close]",function(e,t){return t.closest(".up-popup").length?(close(),e.preventDefault()):void 0}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),attach:attach,close:close,url:function(){return currentUrl},coveredUrl:coveredUrl,config:config,defaults:function(){return u.error("up.popup.defaults(...) no longer exists. Set values on he up.popup.config property instead.")},contains:contains,open:function(){return up.error("up.popup.open no longer exists. Please use up.popup.attach instead.")},source:function(){return up.error("up.popup.source no longer exists. Please use up.popup.url instead.")},isOpen:isOpen}}(jQuery)}.call(this),function(){up.modal=function($){var autoclose,close,config,contains,coveredUrl,createFrame,currentUrl,discardHistory,follow,isOpen,open,reset,shiftElements,templateHtml,u,unshiftElements,unshifters,visit;return u=up.util,config=u.config({maxWidth:null,minWidth:null,width:null,height:null,history:!0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",template:function(e){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+e.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}}),currentUrl=void 0,coveredUrl=function(){return $(".up-modal").attr("up-covered-url")},reset=function(){return close({animation:!1}),currentUrl=void 0,config.reset()},templateHtml=function(){var e;return e=config.template,u.isFunction(e)?e(config):e},discardHistory=function(){var e;return e=$(".up-modal"),e.removeAttr("up-covered-url"),e.removeAttr("up-covered-title")},createFrame=function(e,t){var n,r,o,i;return shiftElements(),o=$(templateHtml()),t.sticky&&o.attr("up-sticky",""),o.attr("up-covered-url",up.browser.url()),o.attr("up-covered-title",document.title),r=o.find(".up-modal-dialog"),u.isPresent(t.width)&&r.css("width",t.width),u.isPresent(t.maxWidth)&&r.css("max-width",t.maxWidth),u.isPresent(t.height)&&r.css("height",t.height),n=o.find(".up-modal-content"),i=u.$createElementFromSelector(e),i.appendTo(n),o.appendTo(document.body),o},unshifters=[],shiftElements=function(){var e,t,n,r;return n=u.scrollbarWidth(),e=parseInt($("body").css("padding-right")),t=n+e,r=u.temporaryCss($("body"),{"padding-right":t+"px","overflow-y":"hidden"}),unshifters.push(r),up.layout.anchoredRight().each(function(){var e,t,r,o;return e=$(this),t=parseInt(e.css("right")),r=n+t,o=u.temporaryCss(e,{right:r}),unshifters.push(o)})},unshiftElements=function(){var e,t;for(e=[];t=unshifters.pop();)e.push(t());return e},isOpen=function(){return $(".up-modal").length>0},follow=function(e,t){return t=u.options(t),t.$link=$(e),open(t)},visit=function(e,t){return t=u.options(t),t.url=e,open(t)},open=function(e){var t,n,r,o;return e=u.options(e),t=u.option(e.$link,u.nullJQuery()),o=u.option(e.url,t.attr("up-href"),t.attr("href")),r=u.option(e.target,t.attr("up-modal"),"body"),e.width=u.option(e.width,t.attr("up-width"),config.width),e.maxWidth=u.option(e.maxWidth,t.attr("up-max-width"),config.maxWidth),e.height=u.option(e.height,t.attr("up-height"),config.height),e.animation=u.option(e.animation,t.attr("up-animation"),config.openAnimation),e.sticky=u.option(e.sticky,u.castedAttr(t,"up-sticky")),e.history=up.browser.canPushState()?u.option(e.history,u.castedAttr(t,"up-history"),config.history):!1,e.confirm=u.option(e.confirm,t.attr("up-confirm")),n=up.motion.animateOptions(e,t),up.browser.confirm(e.confirm).then(function(){var t,i;return up.bus.nobodyPrevents("up:modal:open",{url:o})?(i=isOpen(),i&&close({animation:!1}),e.beforeSwap=function(){return createFrame(r,e)},t=up.replace(r,o,u.merge(e,{animation:!1})),i||(t=t.then(function(){return up.animate($(".up-modal"),e.animation,n)})),t=t.then(function(){return up.emit("up:modal:opened")})):u.unresolvablePromise()})},close=function(e){var t,n;return t=$(".up-modal"),t.length?up.bus.nobodyPrevents("up:modal:close",{$element:t})?(e=u.options(e,{animation:config.closeAnimation,url:t.attr("up-covered-url"),title:t.attr("up-covered-title")}),currentUrl=void 0,n=up.destroy(t,e),n=n.then(function(){return unshiftElements(),up.emit("up:modal:closed")})):u.unresolvableDeferred():u.resolvedDeferred()},autoclose=function(){return $(".up-modal").is("[up-sticky]")?void 0:(discardHistory(),close())},contains=function(e){var t;return t=$(e),t.closest(".up-modal").length>0},up.link.onAction("[up-modal]",function(e){return follow(e)}),up.on("click","body",function(e){var t;return t=$(e.target),t.closest(".up-modal-dialog").length||t.closest("[up-modal]").length?void 0:close()}),up.on("up:fragment:inserted",function(e,t){var n;if(contains(t)){if(n=t.attr("up-source"))return currentUrl=n}else if(!up.popup.contains(t)&&contains(e.origin))return autoclose()}),up.bus.onEscape(function(){return close()}),up.on("click","[up-close]",function(e,t){return t.closest(".up-modal").length?(close(),e.preventDefault()):void 0}),up.on("up:framework:reset",reset),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,open:function(){return up.error("up.modal.open no longer exists. Please use either up.modal.follow or up.modal.visit.")},close:close,url:function(){return currentUrl},coveredUrl:coveredUrl,config:config,defaults:function(){return u.error("up.modal.defaults(...) no longer exists. Set values on he up.modal.config property instead.")},contains:contains,source:function(){return up.error("up.modal.source no longer exists. Please use up.popup.url instead.")},isOpen:isOpen}}(jQuery)}.call(this),function(){up.tooltip=function(e){var t,n,r,o,u,i,a;return a=up.util,r=a.config({position:"top",openAnimation:"fade-in",closeAnimation:"fade-out"}),u=function(){return r.reset()},i=function(e,t,n){var r,o,u;return o=a.measure(e),u=a.measure(t),r=function(){switch(n){case"top":return{left:o.left+.5*(o.width-u.width),top:o.top-u.height};case"bottom":return{left:o.left+.5*(o.width-u.width),top:o.top+o.height};default:return a.error("Unknown position %o",n)}}(),t.attr("up-position",n),t.css(r)},o=function(e){var t;return t=a.$createElementFromSelector(".up-tooltip"),a.isGiven(e.text)?t.text(e.text):t.html(e.html),t.appendTo(document.body),t},t=function(t,u){var s,l,c,p,f,d,m;return null==u&&(u={}),s=e(t),f=a.option(u.html,s.attr("up-tooltip-html")),m=a.option(u.text,s.attr("up-tooltip")),d=a.option(u.position,s.attr("up-position"),r.position),p=a.option(u.animation,a.castedAttr(s,"up-animation"),r.openAnimation),c=up.motion.animateOptions(u,s),n(),l=o({text:m,html:f}),i(s,l,d),up.animate(l,p,c)},n=function(t){var n;return n=e(".up-tooltip"),n.length?(t=a.options(t,{animation:r.closeAnimation}),t=a.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[up-tooltip], [up-tooltip-html]",function(e){return e.on("mouseover",function(){return t(e)}),e.on("mouseout",function(){return n()})}),up.on("click","body",function(){return n()}),up.on("up:framework:reset",n),up.bus.onEscape(function(){return n()}),up.on("up:framework:reset",u),{attach:t,close:n,open:function(){return a.error("up.tooltip.open no longer exists. Use up.tooltip.attach instead.")}}}(jQuery)}.call(this),function(){up.navigation=function(e){var t,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return h=up.util,i=h.config({currentClasses:["up-current"]}),p=function(){return i.reset()},a=function(){var e;return e=i.currentClasses,e=e.concat(["up-current"]),e=h.uniq(e),e.join(" ")},t="up-active",n=["a","[up-href]","[up-alias]"],o=n.join(", "),u=function(){var e,t,r;for(r=[],e=0,t=n.length;t>e;e++)m=n[e],r.push(m+"[up-instant]");return r}().join(", "),r="."+t,c=function(e){return h.isPresent(e)?h.normalizeUrl(e,{search:!1,stripTrailingSlash:!0}):void 0},d=function(e){var t,n,r,o,u,i,a,s,l,p;for(s=[],i=["href","up-href","up-alias"],n=0,o=i.length;o>n;n++)if(t=i[n],l=h.presentAttr(e,t))for(p="up-alias"===t?l.split(" "):[l],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=c(a),s.push(a));return s},g=function(e){var t,n,r,o;return e=h.compact(e),r=function(e){return"*"===e.substr(-1)?n(e.slice(0,-1)):t(e)},t=function(t){return h.contains(e,t)},n=function(t){return h.detect(e,function(e){return 0===e.indexOf(t)})},o=function(e){return h.detect(e,r)},{matchesAny:o}},l=function(){var t,n;return t=g([c(up.browser.url()),c(up.modal.url()),c(up.modal.coveredUrl()),c(up.popup.url()),c(up.popup.coveredUrl())]),n=a(),h.each(e(o),function(r){var o,u;return o=e(r),u=d(o),t.matchesAny(u)?o.addClass(n):o.hasClass(n)&&0===o.closest(".up-destroying").length?o.removeClass(n):void 0})},f=function(e){return v(),e=s(e),e.addClass(t)},s=function(e){return h.presence(e.parents(o))||e},v=function(){return e(r).removeClass(t)},up.on("click",o,function(e,t){return h.isUnmodifiedMouseEvent(e)&&!t.is("[up-instant]")?f(t):void 0}),up.on("mousedown",u,function(e,t){return h.isUnmodifiedMouseEvent(e)?f(t):void 0}),up.on("up:fragment:inserted",function(){return v(),l()}),up.on("up:fragment:destroyed",function(e,t){return t.is(".up-modal, .up-popup")?l():void 0}),up.on("up:framework:reset",p),{config:i,defaults:function(){return h.error("up.navigation.defaults(...) no longer exists. Set values on he up.navigation.config property instead.")}}}(jQuery)}.call(this),function(){up.rails=function(e){var t,n,r,o;return r=up.util,o=function(e){return e.is("[up-follow], [up-target], [up-modal], [up-popup]")},n=function(){return r.isGiven(e.rails)},r.each(["method","confirm"],function(e){var t,u;return t="data-"+e,u="up-"+e,up.compiler("["+t+"]",function(e){var i;return n()&&o(e)?(i={},i[u]=e.attr(t),r.setMissingAttrs(e,i),e.removeAttr(t)):void 0})}),t=function(){return n()?{name:e.rails.csrfParam(),value:e.rails.csrfToken()}:void 0},{csrfField:t,isRails:n}}(jQuery)}.call(this),function(){up.boot()}.call(this);
@@ -11,24 +11,29 @@ up.browser = (($) ->
11
11
 
12
12
  u = up.util
13
13
 
14
+ ###*
15
+ @method up.browser.loadPage
16
+ @param {String} url
17
+ @param {String} [options.method='get']
18
+ @param {Object|Array} [options.data]
19
+ @internal
20
+ ###
14
21
  loadPage = (url, options = {}) ->
15
22
  method = u.option(options.method, 'get').toLowerCase()
16
23
  if method == 'get'
17
- location.href = url
18
- else if $.rails
19
- target = options.target
20
- csrfToken = $.rails.csrfToken()
21
- csrfParam = $.rails.csrfParam()
24
+ location.href = url + u.requestDataAsQueryString(options.data)
25
+ else
22
26
  $form = $("<form method='post' action='#{url}'></form>")
23
- metadataInput = "<input name='_method' value='#{method}' type='hidden' />"
24
- if u.isDefined(csrfParam) && u.isDefined(csrfToken)
25
- metadataInput += "<input name='#{csrfParam}' value='#{csrfToken}' type='hidden' />"
26
- if target
27
- $form.attr('target', target)
28
- $form.hide().append(metadataInput).appendTo('body')
27
+ addField = (field) ->
28
+ $field = $('<input type="hidden">')
29
+ $field.attr(field.name, field.value)
30
+ $field.appendTo($form)
31
+ addField(name: up.proxy.config.wrapMethodParam, value: method)
32
+ if csrfField = up.rails.csrfField()
33
+ addField(csrfField)
34
+ u.each u.requestDataAsArray(options.data), addField
35
+ $form.hide().appendTo('body')
29
36
  $form.submit()
30
- else
31
- error("Can't fake a #{method.toUpperCase()} request without Rails UJS")
32
37
 
33
38
  ###*
34
39
  A cross-browser way to interact with `console.log`, `console.error`, etc.
@@ -131,7 +136,7 @@ up.browser = (($) ->
131
136
  console.log("Hello %o!", "Judy");
132
137
 
133
138
  @function up.browser.canLogSubstitution
134
- @return boolean
139
+ @return {Boolean}
135
140
  @internal
136
141
  ###
137
142
  canLogSubstitution = u.memoize ->
@@ -152,6 +157,17 @@ up.browser = (($) ->
152
157
  document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/'
153
158
  value
154
159
 
160
+ ###*
161
+ @function up,browser.confirm
162
+ @return {Promise}
163
+ @internal
164
+ ###
165
+ confirm = (message) ->
166
+ if u.isBlank(message) || confirm(message)
167
+ u.resolvedPromise()
168
+ else
169
+ u.unresolvablePromise()
170
+
155
171
  # Server-side companion libraries like upjs-rails set this cookie so we
156
172
  # have a way to detect the request method of the initial page load.
157
173
  # There is no Javascript API for this.
@@ -179,6 +195,7 @@ up.browser = (($) ->
179
195
 
180
196
  url: url
181
197
  loadPage: loadPage
198
+ confirm: confirm
182
199
  canPushState: canPushState
183
200
  canCssTransition: canCssTransition
184
201
  canInputEvent: canInputEvent
@@ -42,18 +42,45 @@ up.bus = (($) ->
42
42
 
43
43
  u = up.util
44
44
 
45
- liveDescriptions = []
46
- defaultLiveDescriptions = null
45
+ # We remember which argument lists have been passed to `up.on`
46
+ # so we can clean out the listener registry between tests.
47
+ liveUpDescriptions = {}
48
+ nextUpDescriptionNumber = 0
47
49
 
48
50
  ###*
49
- # Convert an Up.js style listener (second argument is the event target
50
- # as a jQuery collection) to a vanilla jQuery listener
51
+ Convert an Up.js style listener (second argument is the event target
52
+ as a jQuery collection) to a vanilla jQuery listener
53
+
54
+ @function upListenerToJqueryListener
55
+ @internal
51
56
  ###
52
57
  upListenerToJqueryListener = (upListener) ->
53
58
  (event) ->
54
59
  $me = event.$element || $(this)
55
60
  upListener.apply($me.get(0), [event, $me, up.syntax.data($me)])
56
61
 
62
+ ###*
63
+ Converts an argument list for `up.on` to an argument list for `jQuery.on`.
64
+ This involves rewriting the listener signature in the last argument slot.
65
+
66
+ @function upDescriptionToJqueryDescription
67
+ @internal
68
+ ###
69
+ upDescriptionToJqueryDescription = (upDescription, isNew) ->
70
+ jqueryDescription = u.copy(upDescription)
71
+ upListener = jqueryDescription.pop()
72
+ jqueryListener = undefined
73
+ if isNew
74
+ jqueryListener = upListenerToJqueryListener(upListener)
75
+ upListener._asJqueryListener = jqueryListener
76
+ upListener._descriptionNumber = ++nextUpDescriptionNumber
77
+ else
78
+ jqueryListener = upListener._asJqueryListener
79
+ jqueryListener or u.error('up.off: The event listener %o was never registered through up.on')
80
+ jqueryDescription.push(jqueryListener)
81
+ jqueryDescription
82
+
83
+
57
84
  ###*
58
85
  Listens to an event on `document`.
59
86
 
@@ -73,7 +100,6 @@ up.bus = (($) ->
73
100
  Other than jQuery, Up.js will silently discard event listeners
74
101
  on [unsupported browsers](/up.browser.isSupported).
75
102
 
76
-
77
103
  \#\#\#\# Attaching structured data
78
104
 
79
105
  In case you want to attach structured data to the event you're observing,
@@ -88,7 +114,6 @@ up.bus = (($) ->
88
114
  console.log("This is %o who is %o years old", data.name, data.age);
89
115
  });
90
116
 
91
-
92
117
  \#\#\#\# Migrating jQuery event handlers to `up.on`
93
118
 
94
119
  Within the event handler, Up.js will bind `this` to the
@@ -107,6 +132,12 @@ up.bus = (($) ->
107
132
  $(this).something();
108
133
  });
109
134
 
135
+ \#\#\#\# Stopping to listen
136
+
137
+ `up.on` returns a function that unbinds the event listeners when called.
138
+
139
+ There is also a function [`up.off`](/up.off) which you can use for the same purpose.
140
+
110
141
  @function up.on
111
142
  @param {String} events
112
143
  A space-separated list of event names to bind.
@@ -123,26 +154,58 @@ up.bus = (($) ->
123
154
  A function that unbinds the event listeners when called.
124
155
  @stable
125
156
  ###
126
- live = (args...) ->
157
+ live = (upDescription...) ->
127
158
  # Silently discard any event handlers that are registered on unsupported
128
159
  # browsers and return a no-op destructor
129
160
  return (->) unless up.browser.isSupported()
130
161
 
131
- description = u.copy(args)
132
- lastIndex = description.length - 1
133
- behavior = description[lastIndex]
134
- description[lastIndex] = upListenerToJqueryListener(behavior)
162
+ # Convert the args for up.on to an argument list as expected by jQuery.on.
163
+ jqueryDescription = upDescriptionToJqueryDescription(upDescription, true)
135
164
 
136
165
  # Remember the descriptions we registered, so we can
137
- # clean up after ourselves during a reset
138
- liveDescriptions.push(description)
166
+ # clean up after ourselves during a `reset`
167
+ rememberUpDescription(upDescription)
139
168
 
140
- $document = $(document)
141
- $document.on(description...)
169
+ $(document).on(jqueryDescription...)
142
170
 
143
171
  # Return destructor
144
- -> $document.off(description...)
172
+ -> unbind(upDescription...)
173
+
174
+ ###*
175
+ Unregisters an event listener previously bound with [`up.on`](/up.on).
176
+
177
+ \#\#\#\# Example
178
+
179
+ Let's say you are listing to clicks on `.button` elements:
180
+
181
+ var listener = function() { };
182
+ up.on('click', '.button', listener);
183
+
184
+ You can stop listening to these events like this:
185
+
186
+ up.off('click', '.button', listener);
187
+
188
+ Note that you need to pass `up.off` a reference to the same listener function
189
+ that was passed to `up.on` earlier.
190
+
191
+ @function up.off
192
+ @stable
193
+ ###
194
+ unbind = (upDescription...) ->
195
+ jqueryDescription = upDescriptionToJqueryDescription(upDescription, false)
196
+ forgetUpDescription(upDescription)
197
+ $(document).off(jqueryDescription...)
198
+
199
+ rememberUpDescription = (upDescription) ->
200
+ number = upDescriptionNumber(upDescription)
201
+ liveUpDescriptions[number] = upDescription
202
+
203
+ forgetUpDescription = (upDescription) ->
204
+ number = upDescriptionNumber(upDescription)
205
+ delete liveUpDescriptions[number]
145
206
 
207
+ upDescriptionNumber = (upDescription) ->
208
+ u.last(upDescription)._descriptionNumber
146
209
 
147
210
  ###*
148
211
  Emits a event with the given name and properties.
@@ -170,7 +233,7 @@ up.bus = (($) ->
170
233
  will by default include properties like `preventDefault()`
171
234
  or `stopPropagation()`.
172
235
  @param {jQuery} [eventProps.$element=$(document)]
173
- The element on which the event is trigered.
236
+ The element on which the event is triggered.
174
237
  @experimental
175
238
  ###
176
239
  emit = (eventName, eventProps = {}) ->
@@ -217,7 +280,8 @@ up.bus = (($) ->
217
280
  @internal
218
281
  ###
219
282
  snapshot = ->
220
- defaultLiveDescriptions = u.copy(liveDescriptions)
283
+ for description in liveUpDescriptions
284
+ description._isDefault = true
221
285
 
222
286
  ###*
223
287
  Resets the list of registered event listeners to the
@@ -226,10 +290,8 @@ up.bus = (($) ->
226
290
  @internal
227
291
  ###
228
292
  restoreSnapshot = ->
229
- for description in liveDescriptions
230
- unless u.contains(defaultLiveDescriptions, description)
231
- $(document).off(description...)
232
- liveDescriptions = u.copy(defaultLiveDescriptions)
293
+ doomedDescriptions = u.reject(liveUpDescriptions, (description) -> description._isDefault)
294
+ unbind(description...) for description in doomedDescriptions
233
295
 
234
296
  ###*
235
297
  Resets Up.js to the state when it was booted.
@@ -279,7 +341,9 @@ up.bus = (($) ->
279
341
  live 'up:framework:boot', snapshot
280
342
  live 'up:framework:reset', restoreSnapshot
281
343
 
344
+ knife: eval(Knife?.point)
282
345
  on: live # can't name symbols `on` in Coffeescript
346
+ off: unbind # can't name symbols `off` in Coffeescript
283
347
  emit: emit
284
348
  nobodyPrevents: nobodyPrevents
285
349
  onEscape: onEscape
@@ -289,6 +353,7 @@ up.bus = (($) ->
289
353
  )(jQuery)
290
354
 
291
355
  up.on = up.bus.on
356
+ up.off = up.bus.off
292
357
  up.emit = up.bus.emit
293
358
  up.reset = up.bus.emitReset
294
359
  up.boot = up.bus.boot
@@ -19,19 +19,33 @@ up.flow = (($) ->
19
19
  sourceUrl = u.normalizeUrl(sourceUrl) if u.isPresent(sourceUrl)
20
20
  $element.attr("up-source", sourceUrl)
21
21
 
22
+ ###*
23
+ Returns the URL the given element was retrieved from.
24
+
25
+ @method up.flow.source
26
+ @param {String|Element|jQuery} selectorOrElement
27
+ @experimental
28
+ ###
22
29
  source = (selectorOrElement) ->
23
30
  $element = $(selectorOrElement).closest('[up-source]')
24
31
  u.presence($element.attr("up-source")) || up.browser.url()
25
32
 
26
33
  ###*
34
+ Resolves the given selector (which might contain `&` references)
35
+ to an absolute selector.
36
+
27
37
  @function up.flow.resolveSelector
38
+ @param {String|Element|jQuery} selectorOrElement
39
+ @param {String|Element|jQuery} origin
40
+ The element that this selector resolution is relative to.
41
+ That element's selector will be substituted for `&`.
28
42
  @internal
29
43
  ###
30
- resolveSelector = (selectorOrElement, options) ->
44
+ resolveSelector = (selectorOrElement, origin) ->
31
45
  if u.isString(selectorOrElement)
32
46
  selector = selectorOrElement
33
47
  if u.contains(selector, '&')
34
- if origin = u.presence(options.origin)
48
+ if origin
35
49
  originSelector = u.selectorForElement(origin)
36
50
  selector = selector.replace(/\&/, originSelector)
37
51
  else
@@ -103,7 +117,7 @@ up.flow = (($) ->
103
117
  \#\#\#\# Optimizing response rendering
104
118
 
105
119
  The server is free to optimize Up.js requests by only rendering the HTML fragment
106
- that is being updated. The request's `X-Up-Selector` header will contain
120
+ that is being updated. The request's `X-Up-Target` header will contain
107
121
  the CSS selector for the updating fragment.
108
122
 
109
123
  If you are using the `upjs-rails` gem you can also access the selector via
@@ -121,8 +135,17 @@ up.flow = (($) ->
121
135
  here, in which case a selector will be inferred from the element's class and ID.
122
136
  @param {String} url
123
137
  The URL to fetch from the server.
124
- @param {String} [options.method='get']
138
+ @param {String} [options.failTarget='body']
139
+ The CSS selector to update if the server sends a non-200 status code.
125
140
  @param {String} [options.title]
141
+ @param {String} [options.method='get']
142
+ @param {Object|Array} [options.data]
143
+ Parameters that should be sent as the request's payload.
144
+
145
+ Parameters can either be passed as an object (where the property names become
146
+ the param names and the property values become the param values) or as
147
+ an array of `{ name: 'param-name', value: 'param-value' }` objects
148
+ (compare to jQuery's [`serializeArray`](https://api.jquery.com/serializeArray/)).
126
149
  @param {String} [options.transition='none']
127
150
  @param {String|Boolean} [options.history=true]
128
151
  If a `String` is given, it is used as the URL the browser's location bar and history.
@@ -154,48 +177,83 @@ up.flow = (($) ->
154
177
  @stable
155
178
  ###
156
179
  replace = (selectorOrElement, url, options) ->
157
-
158
180
  u.debug("Replace %o with %o (options %o)", selectorOrElement, url, options)
159
181
 
160
182
  options = u.options(options)
161
-
162
- selector = resolveSelector(selectorOrElement, options)
163
-
183
+ target = resolveSelector(selectorOrElement, options.origin)
184
+ failTarget = u.option(options.failTarget, 'body')
185
+ failTarget = resolveSelector(failTarget, options.origin)
186
+
164
187
  if !up.browser.canPushState() && options.history != false
165
- up.browser.loadPage(url, u.only(options, 'method')) unless options.preload
188
+ unless options.preload
189
+ up.browser.loadPage(url, u.only(options, 'method', 'data'))
166
190
  return u.unresolvablePromise()
167
191
 
168
192
  request =
169
193
  url: url
170
194
  method: options.method
171
- selector: selector
195
+ data: options.data
196
+ target: target
197
+ failTarget: failTarget
172
198
  cache: options.cache
173
199
  preload: options.preload
174
200
  headers: options.headers
175
201
 
176
202
  promise = up.proxy.ajax(request)
177
-
203
+
178
204
  promise.done (html, textStatus, xhr) ->
179
- # The server can send us the current path using a header value.
180
- # This way we know the actual URL if the server has redirected.
181
- if currentLocation = u.locationFromXhr(xhr)
182
- u.debug('Location from server: %o', currentLocation)
205
+ processResponse(true, target, url, request, xhr, options)
206
+
207
+ promise.fail (xhr, textStatus, errorThrown) ->
208
+ processResponse(false, failTarget, url, request, xhr, options)
209
+
210
+ promise
211
+
212
+ ###*
213
+ @internal
214
+ ###
215
+ processResponse = (isSuccess, selector, url, request, xhr, options) ->
216
+
217
+ options.method = u.normalizeMethod(u.option(u.methodFromXhr(xhr), options.method))
218
+ options.title = u.option(u.titleFromXhr(xhr), options.title)
219
+ isReloadable = (options.method == 'GET')
220
+
221
+ # The server can send us the current path using a header value.
222
+ # This way we know the actual URL if the server has redirected.
223
+ if urlFromServer = u.locationFromXhr(xhr)
224
+ url = urlFromServer
225
+ if isSuccess
183
226
  newRequest =
184
- url: currentLocation
227
+ url: url
185
228
  method: u.methodFromXhr(xhr)
186
- selector: selector
229
+ target: selector
187
230
  up.proxy.alias(request, newRequest)
188
- url = currentLocation
189
- unless options.history is false
190
- options.history = url
191
- unless options.source is false
192
- options.source = url
193
- options.title ||= u.titleFromXhr(xhr)
194
- implant(selector, html, options) unless options.preload
195
-
196
- promise.fail(u.error)
197
-
198
- promise
231
+ else if isReloadable
232
+ url = url + u.requestDataAsQueryString(options.data)
233
+
234
+ if isSuccess
235
+ if isReloadable # e.g. GET returns 200 OK
236
+ options.history = url unless options.history is false || u.isString(options.history)
237
+ options.source = url unless options.source is false || u.isString(options.source)
238
+ else # e.g. POST returns 200 OK
239
+ options.history = false unless u.isString(options.history)
240
+ options.source = 'keep' unless u.isString(options.source)
241
+ else
242
+ options.transition = options.failTransition
243
+ options.failTransition = undefined
244
+ if isReloadable # e.g. GET returns 500 Internal Server Error
245
+ options.history = url unless options.history is false
246
+ options.source = url unless options.source is false
247
+ else # e.g. POST returns 500 Internal Server Error
248
+ options.source = 'keep'
249
+ options.history = false
250
+
251
+ if options.preload
252
+ u.resolvedPromise()
253
+ else
254
+ implant(selector, xhr.responseText, options)
255
+
256
+
199
257
 
200
258
  ###*
201
259
  Updates a selector on the current page with the
@@ -230,25 +288,34 @@ up.flow = (($) ->
230
288
  @param {String} html
231
289
  @param {Object} [options]
232
290
  See options for [`up.replace`](/up.replace).
291
+ @return {Promise}
292
+ A promise that will be resolved then the selector was updated
293
+ and all animation has finished.
233
294
  @experimental
234
295
  ###
235
296
  implant = (selectorOrElement, html, options) ->
236
- selector = resolveSelector(selectorOrElement, options)
237
297
  options = u.options(options,
238
298
  historyMethod: 'push',
239
299
  requireMatch: true
240
300
  )
241
- options.source = u.option(options.source, options.history)
301
+ selector = resolveSelector(selectorOrElement, options.origin)
242
302
  response = parseResponse(html, options)
243
303
  options.title ||= response.title()
244
304
 
245
305
  up.layout.saveScroll() unless options.saveScroll == false
246
306
 
307
+ options.beforeSwap?($old, $new)
308
+ deferreds = []
309
+
247
310
  for step in parseImplantSteps(selector, options)
248
311
  $old = findOldFragment(step.selector, options)
249
312
  $new = response.find(step.selector)?.first()
250
313
  if $old && $new
251
- swapElements($old, $new, step.pseudoClass, step.transition, options)
314
+ deferred = swapElements($old, $new, step.pseudoClass, step.transition, options)
315
+ deferreds.push(deferred)
316
+
317
+ options.afterSwap?($old, $new)
318
+ return up.motion.when(deferreds...)
252
319
 
253
320
  findOldFragment = (selector, options) ->
254
321
  # Prefer to replace fragments in an open popup or modal
@@ -295,6 +362,9 @@ up.flow = (($) ->
295
362
  swapElements = ($old, $new, pseudoClass, transition, options) ->
296
363
  transition ||= 'none'
297
364
 
365
+ if options.source == 'keep'
366
+ options = u.merge(options, source: source($old))
367
+
298
368
  # Ensure that all transitions and animations have completed.
299
369
  up.motion.finish($old)
300
370
 
@@ -314,18 +384,17 @@ up.flow = (($) ->
314
384
  elementsInserted($wrapper.children(), options)
315
385
 
316
386
  # Reveal element that was being prepended/appended.
317
- up.layout.revealOrRestoreScroll($wrapper, options)
318
- .then ->
319
- # Since we're adding content instead of replacing, we'll only
320
- # animate $new instead of morphing between $old and $new
321
- return up.animate($wrapper, transition, options)
322
- .then ->
323
- u.unwrapElement($wrapper)
324
- return
387
+ promise = up.layout.revealOrRestoreScroll($wrapper, options)
388
+ promise = promise.then ->
389
+ # Since we're adding content instead of replacing, we'll only
390
+ # animate $new instead of morphing between $old and $new
391
+ up.animate($wrapper, transition, options)
392
+ promise = promise.then ->
393
+ u.unwrapElement($wrapper)
394
+ promise
395
+
325
396
  else
326
- # Wrap the replacement as a destroy animation, so $old will
327
- # get marked as .up-destroying right away.
328
- destroy $old, animation: ->
397
+ replacement = ->
329
398
  # Don't insert the new element after the old element.
330
399
  # For some reason this will make the browser scroll to the
331
400
  # bottom of the new element.
@@ -336,6 +405,10 @@ up.flow = (($) ->
336
405
  # Morphing will also process options.reveal
337
406
  up.morph($old, $new, transition, options)
338
407
 
408
+ # Wrap the replacement as a destroy animation, so $old will
409
+ # get marked as .up-destroying right away.
410
+ destroy $old, animation: replacement
411
+
339
412
  parseImplantSteps = (selector, options) ->
340
413
  transitionString = options.transition || options.animation || 'none'
341
414
  comma = /\ *,\ */
@@ -344,6 +417,7 @@ up.flow = (($) ->
344
417
  for selectorAtom, i in disjunction
345
418
  # Splitting the atom
346
419
  selectorParts = selectorAtom.match(/^(.+?)(?:\:(before|after))?$/)
420
+ selectorParts or u.error('Could not parse selector atom %o', selectorAtom)
347
421
  selector = selectorParts[1]
348
422
  if selector == 'html'
349
423
  # If someone really asked us to replace the <html> root, the best
@@ -428,7 +502,7 @@ up.flow = (($) ->
428
502
  destroy = (selectorOrElement, options) ->
429
503
  $element = $(selectorOrElement)
430
504
  if up.bus.nobodyPrevents('up:fragment:destroy', $element: $element)
431
- options = u.options(options, animation: 'none')
505
+ options = u.options(options, animation: false)
432
506
  animateOptions = up.motion.animateOptions(options)
433
507
  $element.addClass('up-destroying')
434
508
  # If e.g. a modal or popup asks us to restore a URL, do this
@@ -507,11 +581,13 @@ up.flow = (($) ->
507
581
  setSource(document.body, up.browser.url())
508
582
  )
509
583
 
584
+ knife: eval(Knife?.point)
510
585
  replace: replace
511
586
  reload: reload
512
587
  destroy: destroy
513
588
  implant: implant
514
589
  first: first
590
+ source: source
515
591
  resolveSelector: resolveSelector
516
592
 
517
593
  )(jQuery)