upjs-rails 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/dist/up.css +16 -1
- data/dist/up.js +499 -88
- data/dist/up.min.css +1 -1
- data/dist/up.min.js +2 -1
- data/lib/assets/javascripts/up/browser.js.coffee +17 -1
- data/lib/assets/javascripts/up/bus.js.coffee +6 -4
- data/lib/assets/javascripts/up/flow.js.coffee +25 -16
- data/lib/assets/javascripts/up/form.js.coffee +11 -3
- data/lib/assets/javascripts/up/history.js.coffee +3 -4
- data/lib/assets/javascripts/up/link.js.coffee +47 -17
- data/lib/assets/javascripts/up/magic.js.coffee +36 -8
- data/lib/assets/javascripts/up/modal.js.coffee +6 -8
- data/lib/assets/javascripts/up/motion.js.coffee +9 -7
- data/lib/assets/javascripts/up/navigation.js.coffee +17 -7
- data/lib/assets/javascripts/up/popup.js.coffee +2 -4
- data/lib/assets/javascripts/up/proxy.js.coffee +179 -0
- data/lib/assets/javascripts/up/tooltip.js.coffee +6 -2
- data/lib/assets/javascripts/up/util.js.coffee +92 -6
- data/lib/assets/javascripts/up.js.coffee +4 -1
- data/lib/assets/stylesheets/up/error.css.sass +15 -0
- data/lib/assets/stylesheets/up/tooltip.css.sass +1 -0
- data/lib/upjs/rails/current_location.rb +2 -1
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +38 -9
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +2 -2
- data/spec_app/spec/javascripts/up/magic_spec.js.coffee +25 -1
- data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +2 -2
- metadata +4 -2
data/dist/up.min.css
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[up-close]{cursor:pointer}[up-follow]{cursor:pointer}.up-modal{position:fixed;top:0;left:0;bottom:0;right:0;z-index:10000;background-color:rgba(90,90,90,0.4)}.up-modal-dialog{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);-webkit-transform:translate(-50%, -50%);max-width:100%;max-height:100%;background-color:#fff;box-shadow:0 0 10px 1px rgba(0,0,0,0.3);box-sizing:border-box}.up-modal-close{position:absolute;right:0;top:0;width:36px;text-align:center;line-height:24px;height:24px;background-color:#999;color:#fff;font-weight:bold;text-transform:uppercase;cursor:pointer;transform:translateY(-100%);-ms-transform:translateY(-100%);-webkit-transform:translateY(-100%)}.up-modal-content{overflow-x:hidden;overflow-y:auto;width:100%;height:100%;padding:20px;box-sizing:border-box}.up-popup{z-index:10000;position:fixed;background-color:#fff;padding:15px;box-shadow:0 0 4px rgba(0,0,0,0.3)}.up-modal .up-popup{z-index:15000}.up-tooltip{z-index:30000;position:fixed;background-color:#666;color:white;padding:6px 9px}.up-tooltip[up-origin=top]{margin-top:-6px}.up-tooltip[up-origin=top]:after{content:"";position:absolute;border-style:solid;border-width:8px 8px 0;border-color:#666 transparent;display:block;width:0;z-index:1;bottom:-8px;left:50%;margin-left:-8px}.up-tooltip[up-origin=bottom]{margin-top:6px}.up-tooltip[up-origin=bottom]:after{content:"";position:absolute;border-style:solid;border-width:0 8px 8px;border-color:#666 transparent;display:block;width:0;z-index:1;top:-8px;left:50%;margin-left:-8px}
|
1
|
+
[up-close]{cursor:pointer}.up-error{background-color:#e10;color:white;padding:5px;font-family:arial, helvetica, sans-serif;font-weight:bold;font-size:14px;line-height:18px;position:fixed;left:0;top:0;max-width:100%;box-sizing:border-box;z-index:99999999}[up-follow]{cursor:pointer}.up-modal{position:fixed;top:0;left:0;bottom:0;right:0;z-index:10000;background-color:rgba(90,90,90,0.4)}.up-modal-dialog{position:absolute;top:50%;left:50%;transform:translate(-50%, -50%);-ms-transform:translate(-50%, -50%);-webkit-transform:translate(-50%, -50%);max-width:100%;max-height:100%;background-color:#fff;box-shadow:0 0 10px 1px rgba(0,0,0,0.3);box-sizing:border-box}.up-modal-close{position:absolute;right:0;top:0;width:36px;text-align:center;line-height:24px;height:24px;background-color:#999;color:#fff;font-weight:bold;text-transform:uppercase;cursor:pointer;transform:translateY(-100%);-ms-transform:translateY(-100%);-webkit-transform:translateY(-100%)}.up-modal-content{overflow-x:hidden;overflow-y:auto;width:100%;height:100%;padding:20px;box-sizing:border-box}.up-popup{z-index:10000;position:fixed;background-color:#fff;padding:15px;box-shadow:0 0 4px rgba(0,0,0,0.3)}.up-modal .up-popup{z-index:15000}.up-tooltip{z-index:30000;position:fixed;background-color:#666;color:white;padding:6px 9px;white-space:nowrap}.up-tooltip[up-origin=top]{margin-top:-6px}.up-tooltip[up-origin=top]:after{content:"";position:absolute;border-style:solid;border-width:8px 8px 0;border-color:#666 transparent;display:block;width:0;z-index:1;bottom:-8px;left:50%;margin-left:-8px}.up-tooltip[up-origin=bottom]{margin-top:6px}.up-tooltip[up-origin=bottom]:after{content:"";position:absolute;border-style:solid;border-width:0 8px 8px;border-color:#666 transparent;display:block;width:0;z-index:1;top:-8px;left:50%;margin-left:-8px}
|
data/dist/up.min.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
(function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w,k,C,S,x,T,E,P,A,F,D,U,O,j,z,H,I,N,W,L,M,G,X,V,R,q,B,J,Z,_,Q,K,Y,tn,nn,en,rn,on,un,an;return C=function(t,n){return n=n||{},n.url=t,r(n)},r=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},N=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},B=function(t,n){var e,r,o;return e=W(t)?$("<a>").attr({href:t}).get(0):an(t),r=e.protocol+"//"+e.hostname,N(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},n=function(t){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v;for(p=t.split(/[ >]/),r=null,l=d=0,h=p.length;h>d;l=++d){for(i=p[l],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,m=0,v=u.length;v>m;m++)switch(a=u[m],a[0]){case".":o.push(a.substr(1));break;case"#":c=a.substr(1);break;default:f=a}s="<"+f,o.length&&(s+=' class="'+o.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===l&&(r=n),e=n}return r},l=function(t,n){var e;return e=document.createElement(t),H(n)&&(e.innerHTML=n),e},v=function(){var n,e;throw n=1<=arguments.length?t.call(arguments,0):[],console.log.apply(console,["[UP] Error"].concat(t.call(n))),e=1===n.length&&up.util.isString(n[0])?n[0]:JSON.stringify(n),alert(e),e},f=function(t){var n,e,r,o,u,i,a;for(console.log("Creating selector from element",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),u=t.prop("tagName").toLowerCase(),r&&(u+="#"+r),i=0,a=e.length;a>i;i++)o=e[i],u+="."+o;return u},p=function(t){var n,e,r,o,u,i,a,s,c,p,f,d;return c=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(c("head")+n+c("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(c("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=l("body",r[1]),s.appendChild(e),(f=t.match(d))&&(a=l("head"),s.appendChild(a),p=l("title",f[1]),a.appendChild(p)),s):l("div",t)},y=$.extend,un=$.trim,M=Object.keys||function(t){var n,e,r,o;for(e=[],r=0,o=t.length;o>r;r++)n=t[r],t.hasOwnProperty(n)&&e.push(n);return e},h=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},j=function(t){return null===t},L=function(t){return void 0===t},P=function(t){return!L(t)},O=function(t){return L(t)||j(t)},F=function(t){return!O(t)},T=function(t){return O(t)||z(t)&&0===M(t).length||0===t.length},K=function(t,n){return null==n&&(n=H),n(t)?t:null},H=function(t){return!T(t)},A=function(t){return"function"==typeof t},W=function(t){return"string"==typeof t},D=function(t){return"object"==typeof t&&!!t},z=function(t){return D(t)||"function"==typeof t},U=function(t){return t instanceof jQuery},I=function(t){return z(t)&&A(t.then)},E=function(t){return I(t)&&A(t.resolve)},S=function(t){return F(t)?t:void 0},x=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},s=function(t){return x(t)?t.slice():y({},t)},an=function(t){return U(t)?t.get(0):t},R=function(t,n){return y(s(t),n)},_=function(t,n){var e,r,o,u;if(o=t?s(t):{},n)for(r in n)e=n[r],u=o[r],F(u)?z(e)&&z(u)&&(o[r]=_(u,e)):o[r]=e;return o},Z=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],r=null,u=0,i=e.length;i>u;u++)if(n=e[u],o=n,A(o)&&(o=o()),H(o)){r=o;break}return r},m=function(t,n){var e,r,o,u;for(r=null,o=0,u=t.length;u>o;o++)if(e=t[o],n(e)){r=e;break}return r},rn=function(t,n){var e;return e=[],h(t,function(t){return n(t)?e.push(t):void 0}),e},Y=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),m(o,H)},q=function(t){return setTimeout(t,0)},G=function(t){return t[t.length-1]},i=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},on=function(t,n,e){var r,o;return o=t.css(M(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},k=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),T(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},d=function(t,n,r){var o,u,i,a,s,c;return o=$(t),up.browser.canCssAnimation()?(r=_(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":M(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=k(o),c=on(o,a),o.css(n),u.then(s),u.then(c),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),en())},e="up-animation-promise",w=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},V=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=i(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},c=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},Q=function(t){var n,e;return e=V(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},b=function(t,n){return t.find(n).addBack(n)},g=function(t){return 27===t.keyCode},a=function(t,n){return t.indexOf(n)>=0},u=function(t){return"true"===String(t)},o=function(t){return"false"===String(t)},X=function(t){return t.getResponseHeader("X-Up-Current-Location")},J=function(){var n,e,r,o,u,i;for(o=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],n={},u=0,i=r.length;i>u;u++)e=r[u],o.hasOwnProperty(e)&&(n[e]=o[e]);return n},nn=function(){var t;return t=$.Deferred(),t.resolve(),t},en=function(){return nn().promise()},tn=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return h(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},{presentAttr:Y,createElement:l,normalizeUrl:B,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:f,get:C,ajax:r,extend:y,copy:s,merge:R,options:_,option:Z,error:v,each:h,detect:m,select:rn,last:G,isNull:j,isDefined:P,isUndefined:L,isGiven:F,isMissing:O,isPresent:H,isBlank:T,presence:K,isObject:z,isFunction:A,isString:W,isJQuery:U,isPromise:I,isDeferred:E,isHash:D,ifGiven:S,unwrap:an,nextFrame:q,measure:V,temporaryCss:on,cssAnimate:d,finishCssAnimate:w,forceCompositing:k,prependGhost:Q,escapePressed:g,copyAttributes:c,findWithSelf:b,contains:a,isArray:x,castsToTrue:u,castsToFalse:o,locationFromXhr:X,clientSize:i,only:J,trim:un,keys:M,resolvedPromise:en,resolvedDeferred:nn,resolvableWhen:tn}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,c;return s=up.util,i=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=s.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",s.isDefined(r)&&s.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},c=function(){return location.href},o=function(){var t;return window.console||(window.console={}),(t=window.console).log||(t.log=function(){})},a=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=a(function(){return s.isDefined(history.pushState)}),n=a(function(){return"transition"in document.documentElement.style}),e=a(function(){return"oninput"in document.createElement("input")}),u=a(function(){return s.isDefined(document.addEventListener)}),{url:c,ensureConsoleExists:o,loadPage:i,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a;return n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=up.util.copy(t));return o},i=function(){return n=up.util.copy(r)},u=function(t,n){return e(t).push(n)},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],console.log("bus emitting",o,n),r=e(o),up.util.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,c,l,p;return p=up.util,s=function(t,n){var e;return e=$(t),p.isPresent(n)&&(n=p.normalizeUrl(n)),e.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),p.presence(n.attr("up-source"))||up.browser.url()},i=function(t,n,e){var o;return e=p.options(e),o=p.presence(t)?t:p.createSelectorFromElement($(t)),up.browser.canPushState()||p.castsToFalse(e.history)?p.ajax({url:n,selector:o},p.only(e,"method")).done(function(t,u,i){var a;return(a=p.locationFromXhr(i))&&(n=a),(p.isMissing(e.history)||p.castsToTrue(e.history))&&(e.history=n),(p.isMissing(e.source)||p.castsToTrue(e.source))&&(e.source=n),r(o,t,e)}).fail(p.error):void up.browser.loadPage(n,p.only(e,"method"))},r=function(t,n,e){var r,u,i,a,s,c,f,d,m,h;for(e=p.options(e,{historyMethod:"push"}),"false"===e.history&&(e.history=null),e.source=p.option(e.source,e.history),a=p.createElementFromHtml(n),e.title||(e.title=null!=(d=a.querySelector("title"))?d.textContent:void 0),m=o(t,e),h=[],c=0,f=m.length;f>c;c++)s=m[c],up.motion.finish(s.selector),u=p.presence($(".up-popup "+s.selector))||p.presence($(".up-modal "+s.selector))||p.presence($(s.selector))||p.error("Could not find selector ("+s.selector+") in current body HTML"),(i=a.querySelector(s.selector))?(r=$(i),h.push(l(u,r,s.pseudoClass,s.transition,e))):h.push(p.error("Could not find selector ("+s.selector+") in response ("+n+")"));return h},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),s(n,e.source),t(n),up.ready(n)},l=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),p.copyAttributes(r,t),e(a,i),up.animate(r,u)):n(t,{animation:function(){return r.insertAfter(t),e(r,i),t.is("body")&&"none"!==u&&p.error("Cannot apply transitions to body-elements",u),up.morph(t,r,u)}})},o=function(t,n){var e,r,o,u,i,a,s,c,l,f,d;for(s=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),p.isPresent(s)&&(c=s.split(e)),d=[],o=l=0,f=r.length;f>l;o=++l)u=r[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||p.last(c),d.push({selector:i[1],pseudoClass:i[2],transition:a});return d},t=function(t){var n,e;return e="[autofocus]:last",n=p.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var e,r;return e=$(t),n=p.options(n,{animation:"none"}),e.addClass("up-destroying"),p.isPresent(n.url)&&up.history.push(n.url),p.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),r=p.presence(n.animation,p.isPromise)||up.motion.animate(e,n.animation),r.then(function(){return e.remove()})},u=function(t){var n;return n=c(t),i(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:i,reload:u,destroy:n,implant:r,reset:a}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v;return v=up.util,n="up-destroyable",e="up-destroyer",p=[],s=null,l=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this)])}],p.push(r),(o=$(document)).on.apply(o,r)},u=[],a=null,o=function(){var n,e,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(e=n.pop(),r=v.options(n[0],{batch:!1}),u.push({selector:o,callback:e,batch:r.batch})):void 0},r=function(t,r,o){var u;return u=t.callback.apply(o,[r]),v.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},i=function(t){var n,e,o,i,a;for(console.log("Compiling fragment",t),a=[],o=0,i=u.length;i>o;o++)e=u[o],n=v.findWithSelf(t,e.selector),a.push(n.length?e.batch?r(e,n,n.get()):n.each(function(){return r(e,$(this),this)}):void 0);return a},c=function(t){return v.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},h=function(){return s=v.copy(p),a=v.copy(u)},m=function(){var t,n,e,r;for(n=0,e=p.length;e>n;n++)t=p[n],v.contains(s,t)||(r=$(document)).off.apply(r,t);return p=v.copy(s),u=v.copy(a)},d=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},f=function(t){return l("keydown","body",function(n){return v.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return d(document.body)}),up.bus.on("fragment:ready",i),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",h),up.bus.on("framework:reset",m),{awaken:o,on:l,ready:d,onEscape:f}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,console.log("popping state",n),console.log("current href",up.browser.url()),(null!=n?n.fromUp:void 0)?up.visit(up.browser.url(),{historyMethod:"replace"}):console.log("strange state",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w;return b=up.util,u={duration:300,delay:0,easing:"ease"},r={},i={},y={},a={},s=function(t){return b.extend(u,t)},n=function(t,e,r){var i;return i=$(t),l(i),r=b.options(r,u),b.isFunction(e)?o(e(i,r),e):b.isString(e)?n(i,c(e),r):b.isHash(e)?b.cssAnimate(i,e,r):b.error("Unknown animation type",e)},c=function(t){return r[t]||b.error("Unknown animation",e)},t="up-ghosting-promise",w=function(n,e,r){var o,u,i,a;return u=null,o=null,b.temporaryCss(e,{display:"none"},function(){return u=b.prependGhost(n).addClass("up-destroying")}),b.temporaryCss(n,{display:"none"},function(){return o=b.prependGhost(e)}),n.css({visibility:"hidden"}),i=b.temporaryCss(e,{display:"none"}),a=r(u,o),n.data(t,a),e.data(t,a),a.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),i()}),a},l=function(t){return $(t).each(function(){var t;return t=$(this),b.finishCssAnimate(t),p(t)})},p=function(n){var e;return(e=n.data(t))?(console.log("EXISTING",e),"function"==typeof e.resolve?e.resolve():void 0):void 0},o=function(t,n){return b.isDeferred(t)?t:b.error("Did not return a promise with .then and .resolve methods: ",n)},f=function(t,e,i,a){var s,c,p,d,m;return up.browser.canCssAnimation()?(a=b.options(u),c=$(t),s=$(e),l(c),l(s),m=b.presence(i,b.isFunction)||y[i],m?w(c,s,function(t,n){return o(m(t,n,a),i)}):(p=r[i])?(c.hide(),n(s,p,a)):b.isString(i)&&i.indexOf("/")>=0?(d=i.split("/"),m=function(t,e,r){return h(n(t,d[0],r),n(e,d[1],r))},f(c,s,m,a)):b.error("Unknown transition: "+i)):b.resolvedDeferred()},g=function(t,n){return y[t]=n},e=function(t,n){return r[t]=n},v=function(){return i=b.copy(r),a=b.copy(y)},m=function(){return r=b.copy(i),y=b.copy(a)},h=b.resolvableWhen,d=b.resolvedDeferred,e("none",d),e("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),e("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),e("move-to-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),e("move-from-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),e("move-from-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),e("move-from-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),e("move-to-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),e("move-from-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),e("roll-down",function(t,e){var r,o;return r=t.height(),o=b.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),g("none",d),g("move-left",function(t,e,r){return h(n(t,"move-to-left",r),n(e,"move-from-right",r))}),g("move-right",function(t,e,r){return h(n(t,"move-to-right",r),n(e,"move-from-left",r))}),g("move-up",function(t,e,r){return h(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),g("move-down",function(t,e,r){return h(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),g("cross-fade",function(t,e,r){return h(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",v),up.bus.on("framework:reset",m),{morph:f,animate:n,finish:l,transition:g,animation:e,defaults:s,none:d,when:h}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.link=function(){var t,n,e,r,o;return r=up.util,o=function(t,n){return console.log("up.visit",t),up.replace("body",t,n)},t=function(t,n){var e,o,u;return e=$(t),n=r.options(n),u=r.option(e.attr("href"),e.attr("up-follow")),o=r.option(n.target,e.attr("up-target"),"body"),n.transition=r.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=r.option(n.history,e.attr("up-history")),up.replace(o,u,n)},n=function(t){var n;return n=$(t),n.is("a")||r.presentAttr(n,"up-follow")?n:n.find("a:first")},e=function(t){var e;return(e=n(t))?r.option(e.attr("href"),e.attr("up-follow")):void 0},up.on("click","a[up-target]",function(n,e){return n.preventDefault(),t(e)}),up.on("click","[up-follow]",function(e,r){var o;return o=function(){var t,n;return t=$(e.target),n=t.closest("a, [up-follow]"),n.length&&r.find(n).length},o()?void 0:(e.preventDefault(),t(n(r)))}),{visit:o,follow:t,resolve:n,resolveUrl:e}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,c,l,p,f;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),r=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),i=u.option(n.history,e.attr("up-history"),!0),l=u.option(n.transition,e.attr("up-transition")),o=u.option(n.failTransition,e.attr("up-fail-transition")),a=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),f=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(i)?(s={url:f,type:a,data:e.serialize(),selector:c},p=function(t){var n;return f=i?"false"===i?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){return up.flow.implant(c,t,{history:p(e),transition:l})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(r,n,{transition:o})})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input":"keypress paste cut change click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,c,l;return c=up.util,e={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(e,t)},a=function(t,n,e){var r,o;return o=c.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return c.error("Unknown origin",e)}}(),n.attr("up-origin",e),n.css(r),u(n)},u=function(t){var n,e,r,o,u,i,a;if(e=c.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},r=function(t,n,e){var r,o;return o=c.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),r=c.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),o.hide(),o},l=function(t,n,e,r){return n.show(),a(t,n,e),up.animate(n,r)},i=function(t,o){var u,i,a,s,p,f,d,m;return u=$(t),o=c.options(o),m=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),p=c.option(o.origin,u.attr("up-origin"),e.origin),a=c.option(o.animation,u.attr("up-animation"),e.openAnimation),d=c.option(o.sticky,u.is("[up-sticky]")),s=up.browser.canPushState()?c.option(o.history,u.attr("up-history"),!1):!1,n(),i=r(u,f,d),up.replace(f,m,{history:s,insert:function(){return l(u,i,p,a)}})},s=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=c.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():i(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,e,r,o,u,i,a,s,c;return s=up.util,e={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return s.extend(e,t)},a=function(){var t;return t=e.template,s.isFunction(t)?t(e):t},r=function(t,n,e,r){var o,u,i,c;return i=$(a()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),s.isPresent(n)&&u.css("width",n),s.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),i.appendTo(document.body),i.hide(),i},c=function(t,n){return t.show(),up.animate(t,n)},u=function(t,o){var u,i,a,l,p,f,d,m,h;return u=$(t),o=s.options(o),m=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),e.width),l=s.option(o.height,u.attr("up-height"),e.height),a=s.option(o.animation,u.attr("up-animation"),e.openAnimation),d=s.option(o.sticky,u.is("[up-sticky]")),p=up.browser.canPushState()?s.option(o.history,u.attr("up-history"),!0):!1,n(),i=r(f,h,l,d),up.replace(f,m,{history:p,insert:function(){return c(i,a)}})},i=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-modal"),n.length?(t=s.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:n()},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():u(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:(console.log("fragment inserted",n,n.closest(".up-modal")),t())}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:i,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown origin",e)}}(),n.attr("up-origin",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,c,l;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip")),l=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),r(i,a,l),up.animate(a,s,u)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,c;return s=up.util,t="up-active",n="up-current",r="a[href], a[up-target], [up-follow], [up-modal], [up-popup]",e="."+t,i=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},u=function(){var t,e,o;return o=i(up.browser.url()),t=i(up.modal.source()),e=i(up.popup.source()),s.each($(r),function(r){var u,a;return u=$(r),a=up.link.resolveUrl(u),a=i(a),a===o||a===t||a===e?u.addClass(n):u.removeClass(n)})},a=function(n){return c(),n=o(n),n.addClass(t)},o=function(t){return s.presence(t.parents(r))||t},c=function(){return $(e).removeClass(t)},up.on("click",r,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return c(),u()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?u():void 0})}()}.call(this),function(){up.marker=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
|
1
|
+
(function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w,k,C,x,S,T,E,P,A,D,F,U,j,z,O,H,M,q,I,N,W,G,L,X,R,V,_,J,B,Q,Z,K,Y,tn,nn,en,rn,on,un,an,sn,cn,ln,pn,fn,dn,mn;return S=function(t,n){return n=n||{},n.url=t,o(n)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},N=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},Z=function(t,n){var e,r,o;return e=W(t)?$("<a>").attr({href:t}).get(0):mn(t),r=e.protocol+"//"+e.hostname,N(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},Q=function(t){return t?t.toUpperCase():"GET"},n=function(t){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v;for(p=t.split(/[ >]/),r=null,l=d=0,h=p.length;h>d;l=++d){for(i=p[l],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,m=0,v=u.length;v>m;m++)switch(a=u[m],a[0]){case".":o.push(a.substr(1));break;case"#":c=a.substr(1);break;default:f=a}s="<"+f,o.length&&(s+=' class="'+o.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===l&&(r=n),e=n}return r},p=function(t,n){var e;return e=document.createElement(t),q(n)&&(e.innerHTML=n),e},h=function(){var n,e,o,u,i,a;if(n=1<=arguments.length?t.call(arguments,0):[],n=fn(n),o=n.shift(),o="[UP] "+o,u=(null!=(a=o.match(r))?a.length:void 0)||0,F(X(n))&&u<n.length&&(e=n.pop()),i=console.debug.apply(console,[o].concat(t.call(n))),e){console.groupCollapsed();try{i=e()}finally{console.groupEnd()}}return i},y=function(){var n,e,r;throw e=1<=arguments.length?t.call(arguments,0):[],e[0]="[UP] "+e[0],console.error.apply(console,e),r=ln(e),n=en($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),r},r=/\%[odisf]/g,ln=function(t){var n,e,o;return o=t[0],n=0,e=30,o.replace(r,function(){var r,o;return n+=1,r=t[n],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>e&&(r=r.substr(0,e)+"\u2026"),'"'+r+'"'):"number"===o?r.toString():"("+o+")"})},d=function(t){var n,e,r,o,u,i,a;for(h("Creating selector from element %o",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),u=t.prop("tagName").toLowerCase(),r&&(u+="#"+r),i=0,a=e.length;a>i;i++)o=e[i],u+="."+o;return u},f=function(t){var n,e,r,o,u,i,a,s,c,l,f,d;return c=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(c("head")+n+c("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(c("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=p("body",r[1]),s.appendChild(e),(f=t.match(d))&&(a=p("head"),s.appendChild(a),l=p("title",f[1]),a.appendChild(l)),s):p("div",t)},w=$.extend,dn=$.trim,L=Object.keys||function(t){var n,e,r,o;for(e=[],r=0,o=t.length;o>r;r++)n=t[r],t.hasOwnProperty(n)&&e.push(n);return e},g=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},H=function(t){return null===t},G=function(t){return void 0===t},D=function(t){return!G(t)},O=function(t){return G(t)||H(t)},U=function(t){return!O(t)},P=function(t){return O(t)||M(t)&&0===L(t).length||0===t.length},en=function(t,n){return null==n&&(n=q),n(t)?t:null},q=function(t){return!P(t)},F=function(t){return"function"==typeof t},W=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},M=function(t){return j(t)||"function"==typeof t},z=function(t){return t instanceof jQuery},I=function(t){return M(t)&&F(t.then)},A=function(t){return I(t)&&F(t.resolve)},T=function(t){return U(t)?t:void 0},E=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},fn=function(t){return Array.prototype.slice.call(t)},c=function(t){return E(t)?t.slice():w({},t)},mn=function(t){return z(t)?t.get(0):t},_=function(t,n){return w(c(t),n)},tn=function(t,n){var e,r,o,u;if(o=t?c(t):{},n)for(r in n)e=n[r],u=o[r],U(u)?M(e)&&M(u)&&(o[r]=tn(u,e)):o[r]=e;return o},Y=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],r=null,u=0,i=e.length;i>u;u++)if(n=e[u],o=n,F(o)&&(o=o()),q(o)){r=o;break}return r},v=function(t,n){var e,r,o,u;for(r=null,o=0,u=t.length;u>o;o++)if(e=t[o],n(e)){r=e;break}return r},sn=function(t,n){var e;return e=[],g(t,function(t){return n(t)?e.push(t):void 0}),e},rn=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),v(o,q)},B=function(t){return setTimeout(t,0)},X=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},pn=function(t,n,e){var r,o;return o=t.css(L(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},x=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),P(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},m=function(t,n,r){var o,u,i,a,s,c;return o=$(t),up.browser.canCssAnimation()?(r=tn(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":L(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=x(o),c=pn(o,a),o.css(n),u.then(s),u.then(c),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),an())},e="up-animation-promise",C=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},V=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=a(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},l=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},nn=function(t){var n,e;return e=V(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},k=function(t,n){return t.find(n).addBack(n)},b=function(t){return 27===t.keyCode},s=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},R=function(t){return t.getResponseHeader("X-Up-Location")},J=function(t){return t.getResponseHeader("X-Up-Method")},K=function(){var n,e,r,o,u,i;for(o=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],n={},u=0,i=r.length;i>u;u++)e=r[u],o.hasOwnProperty(e)&&(n[e]=o[e]);return n},un=function(){var t;return t=$.Deferred(),t.resolve(),t},an=function(){return un().promise()},on=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return g(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},cn=function(t){var n,e,r,o,u,i,a,s;for(u={},n=function(t){return u[r(t)]},e=function(t){return v(t,n)},o=function(t){return u[r(t)]=!0},r=function(t){return"_"+t},a=0,s=t.length;s>a;a++)i=t[a],o(i);return{put:o,includes:n,includesAny:e}},{presentAttr:rn,createElement:p,normalizeUrl:Z,normalizeMethod:Q,createElementFromHtml:f,$createElementFromSelector:n,createSelectorFromElement:d,get:S,ajax:o,extend:w,copy:c,merge:_,options:tn,option:Y,error:y,debug:h,each:g,detect:v,select:sn,last:X,isNull:H,isDefined:D,isUndefined:G,isGiven:U,isMissing:O,isPresent:q,isBlank:P,presence:en,isObject:M,isFunction:F,isString:W,isJQuery:z,isPromise:I,isDeferred:A,isHash:j,ifGiven:T,unwrap:mn,nextFrame:B,measure:V,temporaryCss:pn,cssAnimate:m,finishCssAnimate:C,forceCompositing:x,prependGhost:nn,escapePressed:b,copyAttributes:l,findWithSelf:k,contains:s,isArray:E,toArray:fn,castsToTrue:i,castsToFalse:u,locationFromXhr:R,methodFromXhr:J,clientSize:a,only:K,trim:dn,keys:L,resolvedPromise:an,resolvedDeferred:un,resolvableWhen:on,stringSet:cn}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,c,l;return c=up.util,a=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=c.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",c.isDefined(r)&&c.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},l=function(){return location.href},o=function(){var t,n,e,r,o,u,i,a;return window.console||(window.console={}),t=function(){},(n=window.console).log||(n.log=t),(e=window.console).info||(e.info=t),(r=window.console).error||(r.error=t),(o=window.console).debug||(o.debug=t),(u=window.console).group||(u.group=t),(i=window.console).groupCollapsed||(i.groupCollapsed=t),(a=window.console).groupEnd||(a.groupEnd=t)},s=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=s(function(){return c.isDefined(history.pushState)}),n=s(function(){return"transition"in document.documentElement.style}),e=s(function(){return"oninput"in document.createElement("input")}),u=function(){var t,n,e,r,o;return o=$.fn.jquery,r=o.split("."),n=parseInt(r[0]),e=parseInt(r[1]),t=n>=2||1===n&&e>=9,t||c.error("jQuery %o found, but Up.js requires 1.9+",o)},i=s(function(){return c.isDefined(document.addEventListener)}),{url:l,ensureConsoleExists:o,loadPage:a,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:i,ensureRecentJquery:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s;return s=up.util,n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=s.copy(t));return o},i=function(){return n=s.copy(r)},u=function(t,n){return e(t).push(n)},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],s.debug("Emitting event %o with args %o",o,n),r=e(o),s.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,c,l,p;return p=up.util,s=function(t,n){var e;return e=$(t),p.isPresent(n)&&(n=p.normalizeUrl(n)),e.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),p.presence(n.attr("up-source"))||up.browser.url()},i=function(t,n,e){var o,u,i;return e=p.options(e),i=p.presence(t)?t:p.createSelectorFromElement($(t)),up.browser.canPushState()||p.castsToFalse(e.history)?(u={url:n,method:e.method,selector:i},o=up.proxy.ajax(u),o.done(function(t,o,a){var s,c;return(s=p.locationFromXhr(a))&&(p.debug("Location from server: %o",s),c={url:s,method:p.methodFromXhr(a),selector:i},up.proxy.alias(u,c),n=s),(p.isMissing(e.history)||p.castsToTrue(e.history))&&(e.history=n),(p.isMissing(e.source)||p.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:r(i,t,e)}),o.fail(p.error),o):void(e.preload||up.browser.loadPage(n,p.only(e,"method")))},r=function(t,n,e){var r,u,i,a,s,c,f,d,m,h;for(e=p.options(e,{historyMethod:"push"}),"false"===e.history&&(e.history=null),e.source=p.option(e.source,e.history),a=p.createElementFromHtml(n),e.title||(e.title=null!=(d=a.querySelector("title"))?d.textContent:void 0),m=o(t,e),h=[],c=0,f=m.length;f>c;c++)s=m[c],up.motion.finish(s.selector),u=p.presence($(".up-popup "+s.selector))||p.presence($(".up-modal "+s.selector))||p.presence($(s.selector))||p.error("Could not find selector %o in current body HTML",s.selector),(i=a.querySelector(s.selector))?(r=$(i),h.push(l(u,r,s.pseudoClass,s.transition,e))):h.push(p.error("Could not find selector %o in response %o",s.selector,n));return h},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),s(n,e.source),t(n),up.ready(n)},l=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),p.copyAttributes(r,t),e(a,i),up.animate(r,u)):n(t,{animation:function(){return r.insertAfter(t),e(r,i),t.is("body")&&"none"!==u&&p.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u)}})},o=function(t,n){var e,r,o,u,i,a,s,c,l,f,d;for(s=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),p.isPresent(s)&&(c=s.split(e)),d=[],o=l=0,f=r.length;f>l;o=++l)u=r[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||p.last(c),d.push({selector:i[1],pseudoClass:i[2],transition:a});return d},t=function(t){var n,e;return e="[autofocus]:last",n=p.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var e,r;return e=$(t),n=p.options(n,{animation:"none"}),e.addClass("up-destroying"),p.isPresent(n.url)&&up.history.push(n.url),p.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),r=p.presence(n.animation,p.isPromise)||up.motion.animate(e,n.animation),r.then(function(){return e.remove()})},u=function(t){var n;return n=c(t),i(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:i,reload:u,destroy:n,implant:r,reset:a}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g;return g=up.util,n="up-destroyable",e="up-destroyer",f=[],c=null,p=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},u=[],s=null,o=function(){var n,e,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(e=n.pop(),r=g.options(n[0],{batch:!1}),u.push({selector:o,callback:e,batch:r.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying awakener %o on %o",t.selector,o),u=t.callback.apply(o,[r,a(r)]),g.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},i=function(t){var n,e,o,i,a;for(g.debug("Compiling fragment %o",t),a=[],o=0,i=u.length;i>o;o++)e=u[o],n=g.findWithSelf(t,e.selector),a.push(n.length?e.batch?r(e,n,n.get()):n.each(function(){return r(e,$(this),this)}):void 0);return a},l=function(t){return g.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},a=function(t){var n,e;return n=$(t),e=n.attr("up-data"),g.isString(e)&&""!==g.trim(e)?JSON.parse(e):{}},v=function(){return c=g.copy(f),s=g.copy(u)},h=function(){var t,n,e,r;for(n=0,e=f.length;e>n;n++)t=f[n],g.contains(c,t)||(r=$(document)).off.apply(r,t);return f=g.copy(c),u=g.copy(s)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},d=function(t){return p("keydown","body",function(n){return g.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",i),up.bus.on("fragment:destroy",l),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{awaken:o,on:p,ready:m,onEscape:d,data:a}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,(null!=n?n.fromUp:void 0)?(u.debug("Restoring state %o (now on "+up.browser.url()+")",n),up.visit(up.browser.url(),{historyMethod:"replace"})):u.debug("Discarding unknown state %o",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w;return b=up.util,u={duration:300,delay:0,easing:"ease"},r={},i={},y={},a={},s=function(t){return b.extend(u,t)},n=function(t,e,r){var i;return i=$(t),l(i),r=b.options(r,u),b.isFunction(e)?o(e(i,r),e):b.isString(e)?n(i,c(e),r):b.isHash(e)?b.cssAnimate(i,e,r):b.error("Unknown animation type %o",e)},c=function(t){return r[t]||b.error("Unknown animation %o",e)},t="up-ghosting-promise",w=function(n,e,r){var o,u,i,a;return u=null,o=null,b.temporaryCss(e,{display:"none"},function(){return u=b.prependGhost(n).addClass("up-destroying")}),b.temporaryCss(n,{display:"none"},function(){return o=b.prependGhost(e)}),n.css({visibility:"hidden"}),i=b.temporaryCss(e,{display:"none"}),a=r(u,o),n.data(t,a),e.data(t,a),a.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),i()}),a},l=function(t){return $(t).each(function(){var t;return t=$(this),b.finishCssAnimate(t),p(t)})},p=function(n){var e;return(e=n.data(t))?(b.debug("Canceling existing ghosting on %o",n),"function"==typeof e.resolve?e.resolve():void 0):void 0},o=function(t,n){return b.isDeferred(t)?t:b.error("Did not return a promise with .then and .resolve methods: %o",n)},f=function(t,e,i,a){var s,c,p,m,v;return up.browser.canCssAnimation()?(a=b.options(u),c=$(t),s=$(e),l(c),l(s),"none"===i?d():(v=b.presence(i,b.isFunction)||y[i])?w(c,s,function(t,n){return o(v(t,n,a),i)}):(p=r[i])?(c.hide(),n(s,p,a)):b.isString(i)&&i.indexOf("/")>=0?(m=i.split("/"),v=function(t,e,r){return h(n(t,m[0],r),n(e,m[1],r))},f(c,s,v,a)):b.error("Unknown transition %o",i)):b.resolvedDeferred()},g=function(t,n){return y[t]=n},e=function(t,n){return r[t]=n},v=function(){return i=b.copy(r),a=b.copy(y)},m=function(){return r=b.copy(i),y=b.copy(a)},h=b.resolvableWhen,d=b.resolvedDeferred,e("none",d),e("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),e("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),e("move-to-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),e("move-from-top",function(t,e){var r,o;return r=b.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),e("move-from-bottom",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),e("move-to-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),e("move-from-left",function(t,e){var r,o;return r=b.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),e("move-to-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),e("move-from-right",function(t,e){var r,o;return r=b.measure(t),o=b.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),e("roll-down",function(t,e){var r,o;return r=t.height(),o=b.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),g("none",d),g("move-left",function(t,e,r){return h(n(t,"move-to-left",r),n(e,"move-from-right",r))}),g("move-right",function(t,e,r){return h(n(t,"move-to-right",r),n(e,"move-from-left",r))}),g("move-up",function(t,e,r){return h(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),g("move-down",function(t,e,r){return h(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),g("cross-fade",function(t,e,r){return h(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",v),up.bus.on("framework:reset",m),{morph:f,animate:n,finish:l,transition:g,animation:e,defaults:s,none:d,when:h}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.proxy=function(){var t,n,e,r,o,u,i,a,s,c,l,p,f,d,m,h,v,g,y,b,w,k,$,C,x;return s={preloadDelay:50,cacheSize:70,cacheExpiry:3e5},c=function(t){return x.extend(s,t)},r={},x=up.util,t=null,l=null,o=function(t){return h(t),[t.url,t.method,t.selector].join("|")},C=function(){var t,n,e;return t=x.keys(r),t.length>s.cacheSize&&(n=null,e=null,x.each(t,function(t){var o,u;return o=r[t],u=o.timestamp,!e||e>u?(n=t,e=u):void 0}),n)?delete r[n]:void 0},k=function(){return(new Date).valueOf()},h=function(t){return!x.isHash(t),t._requestNormalized||(t.method=x.normalizeMethod(t.method),t.url&&(t.url=x.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._requestNormalized=!0),t},e=function(t,n){var e;return x.debug("Aliasing %o to %o",t,n),(e=f(t))?b(n,e):void 0},n=function(t){var n;return m(t)?(n=f(t))?$(n):(n=x.ajax(t),b(t,n)):(a(),n=x.ajax(t)),n},m=function(t){return h(t),"GET"===t.method},p=function(t){return m(t)||x.error("Won't preload non-GET request %o",t)},d=function(t){var n;return n=k()-t.timestamp,n<s.cacheExpiry},$=function(t){return t.timestamp=k()},f=function(t){var n,e;return n=o(t),(e=r[n])?d(e)?(x.debug("Cache hit for %o (%o)",t.url,t),e):(x.debug("Discarding stale cache entry for %o (%o)",t.url,t),void g(t)):void x.debug("Cache miss for %o (%o)",t.url,t)},b=function(t,n){var e;return C(),e=o(t),r[e]=n,$(n),n},g=function(t){var n;return n=o(t),delete r[n]},a=function(){return r={}},i=function(n){var e,r;return r=parseInt(x.presentAttr(n,"up-delay"))||s.preloadDelay,n.is(t)?void 0:(t=n,u(),e=function(){return v(n)},w(e,r))},w=function(t,n){return l=setTimeout(t,n)},u=function(){return clearTimeout(l),l=null},v=function(t,n){return n=x.options(),p(n),x.debug("Preloading %o",t),n.preload=!0,up.link.follow(t,n)},y=function(){return u(),r={}},up.bus.on("framework:reset",y),up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:i(up.link.resolve(n))}),{preload:v,ajax:n,get:f,set:b,alias:e,clear:a,defaults:c}}()}.call(this),function(){up.link=function(){var t,n,e,r,o;return r=up.util,o=function(t,n){return r.debug("Visiting "+t),up.replace("body",t,n)},n=function(t,n){var e,o,u;return e=$(t),n=r.options(n),u=r.option(e.attr("href"),e.attr("up-follow")),o=r.option(n.target,e.attr("up-target"),"body"),n.transition=r.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=r.option(n.history,e.attr("up-history")),up.replace(o,u,n)},e=function(t){var n,e;return n=$(t),e=n.attr("up-follow"),n.is("a")||r.isPresent(e)&&!r.castsToTrue(e)?n:n.find("a:first")},up.on("click","a[up-target]",function(t,e){return t.preventDefault(),e.is("[up-instant]")?void 0:n(e)}),up.on("mousedown","a[up-target][up-instant]",function(t,e){return 1===t.which?(t.preventDefault(),n(e)):void 0}),t=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-follow]"),r.length&&n.find(r).length},up.on("click","[up-follow]",function(r,o){return t(r,o)||(r.preventDefault(),o.is("[up-instant]"))?void 0:n(e(o))}),up.on("mousedown","[up-follow][up-instant]",function(r,o){return t(r,o)||1!==r.which?void 0:(r.preventDefault(),n(e(o)))}),{visit:o,follow:n,resolve:e,childClicked:t}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,c,l,p,f;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),r=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),i=u.option(n.history,e.attr("up-history"),!0),l=u.option(n.transition,e.attr("up-transition")),o=u.option(n.failTransition,e.attr("up-fail-transition")),a=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),f=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(i)?(s={url:f,type:a,data:e.serialize(),selector:c},p=function(t){var n;return f=i?"false"===i?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){return up.flow.implant(c,t,{history:p(e),transition:l})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(r,n,{transition:o})})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("up.observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,c,l;return c=up.util,e={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(e,t)},a=function(t,n,e){var r,o;return o=c.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return c.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r),u(n)},u=function(t){var n,e,r,o,u,i,a;if(e=c.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},r=function(t,n,e){var r,o;return o=c.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),r=c.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),o.hide(),o},l=function(t,n,e,r){return n.show(),a(t,n,e),up.animate(n,r)},i=function(t,o){var u,i,a,s,p,f,d,m;return u=$(t),o=c.options(o),m=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),p=c.option(o.origin,u.attr("up-origin"),e.origin),a=c.option(o.animation,u.attr("up-animation"),e.openAnimation),d=c.option(o.sticky,u.is("[up-sticky]")),s=up.browser.canPushState()?c.option(o.history,u.attr("up-history"),!1):!1,n(),i=r(u,f,d),up.replace(f,m,{history:s,insert:function(){return l(u,i,p,a)}})},s=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=c.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():i(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,e,r,o,u,i,a,s,c;return s=up.util,e={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return s.extend(e,t)},a=function(){var t;return t=e.template,s.isFunction(t)?t(e):t},r=function(t,n,e,r){var o,u,i,c;return i=$(a()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),s.isPresent(n)&&u.css("width",n),s.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),i.appendTo(document.body),i.hide(),i},c=function(t,n){return t.show(),up.animate(t,n)},u=function(t,o){var u,i,a,l,p,f,d,m,h;return u=$(t),o=s.options(o),m=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),e.width),l=s.option(o.height,u.attr("up-height"),e.height),a=s.option(o.animation,u.attr("up-animation"),e.openAnimation),d=s.option(o.sticky,u.is("[up-sticky]")),p=up.browser.canPushState()?s.option(o.history,u.attr("up-history"),!0):!1,n(),i=r(f,h,l,d),up.replace(f,m,{history:p,insert:function(){return c(i,a)}})},i=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-modal"),n.length?(t=s.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:n()},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():u(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:i,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown origin %o",e)}}(),n.attr("up-origin",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,c,l;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),l=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),r(i,a,l),up.animate(a,s,u)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,c,l;return c=up.util,t="up-active",n="up-current",r="a[href], a[up-target], [up-follow], [up-modal], [up-popup], [up-source]",e="."+t,i=function(t){return c.isPresent(t)?c.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},s=function(t){var n,e,r,o,u,a,s;if(o=[],n=up.link.resolve(t))for(s=["href","up-follow","up-source"],u=0,a=s.length;a>u;u++)e=s[u],(r=c.presentAttr(n,e))&&(r=i(r),o.push(r));
|
2
|
+
return o},u=function(){var t;return t=c.stringSet([i(up.browser.url()),i(up.modal.source()),i(up.popup.source())]),c.each($(r),function(e){var r,o;return r=$(e),o=s(r),t.includesAny(o)?r.addClass(n):r.removeClass(n)})},a=function(n){return l(),n=o(n),n.addClass(t)},o=function(t){return c.presence(t.parents(r))||t},l=function(){return $(e).removeClass(t)},up.on("click",r,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return l(),u()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?u():void 0})}()}.call(this),function(){up.marker=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.ensureRecentJquery(),up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
|
@@ -49,7 +49,14 @@ up.browser = (->
|
|
49
49
|
|
50
50
|
ensureConsoleExists = ->
|
51
51
|
window.console ||= {}
|
52
|
-
|
52
|
+
noop = () ->
|
53
|
+
window.console.log ||= noop
|
54
|
+
window.console.info ||= noop
|
55
|
+
window.console.error ||= noop
|
56
|
+
window.console.debug ||= noop
|
57
|
+
window.console.group ||= noop
|
58
|
+
window.console.groupCollapsed ||= noop
|
59
|
+
window.console.groupEnd ||= noop
|
53
60
|
|
54
61
|
memoize = (func) ->
|
55
62
|
cache = undefined
|
@@ -70,6 +77,14 @@ up.browser = (->
|
|
70
77
|
canInputEvent = memoize ->
|
71
78
|
'oninput' of document.createElement('input')
|
72
79
|
|
80
|
+
ensureRecentJquery = ->
|
81
|
+
version = $.fn.jquery
|
82
|
+
parts = version.split('.')
|
83
|
+
major = parseInt(parts[0])
|
84
|
+
minor = parseInt(parts[1])
|
85
|
+
compatible = major >= 2 || (major == 1 && minor >= 9)
|
86
|
+
compatible or u.error("jQuery %o found, but Up.js requires 1.9+", version)
|
87
|
+
|
73
88
|
isSupported = memoize ->
|
74
89
|
# This is the most concise way to exclude IE8 and lower
|
75
90
|
# while keeping all relevant desktop and mobile browsers.
|
@@ -82,6 +97,7 @@ up.browser = (->
|
|
82
97
|
canCssAnimation: canCssAnimation
|
83
98
|
canInputEvent: canInputEvent
|
84
99
|
isSupported: isSupported
|
100
|
+
ensureRecentJquery: ensureRecentJquery
|
85
101
|
|
86
102
|
)()
|
87
103
|
|
@@ -24,6 +24,8 @@ We need to work on this page:
|
|
24
24
|
@class up.bus
|
25
25
|
###
|
26
26
|
up.bus = (->
|
27
|
+
|
28
|
+
u = up.util
|
27
29
|
|
28
30
|
callbacksByEvent = {}
|
29
31
|
defaultCallbacksByEvent = {}
|
@@ -41,7 +43,7 @@ up.bus = (->
|
|
41
43
|
snapshot = ->
|
42
44
|
defaultCallbacksByEvent = {}
|
43
45
|
for event, callbacks of callbacksByEvent
|
44
|
-
defaultCallbacksByEvent[event] =
|
46
|
+
defaultCallbacksByEvent[event] = u.copy(callbacks)
|
45
47
|
|
46
48
|
###*
|
47
49
|
Resets the list of registered event listeners to the
|
@@ -51,7 +53,7 @@ up.bus = (->
|
|
51
53
|
@method up.bus.reset
|
52
54
|
###
|
53
55
|
reset = ->
|
54
|
-
callbacksByEvent =
|
56
|
+
callbacksByEvent = u.copy(defaultCallbacksByEvent)
|
55
57
|
|
56
58
|
###*
|
57
59
|
Registers an event handler to be called when the given
|
@@ -78,9 +80,9 @@ up.bus = (->
|
|
78
80
|
The arguments that describe the event.
|
79
81
|
###
|
80
82
|
emit = (eventName, args...) ->
|
81
|
-
|
83
|
+
u.debug("Emitting event %o with args %o", eventName, args)
|
82
84
|
callbacks = callbacksFor(eventName)
|
83
|
-
|
85
|
+
u.each(callbacks, (callback) ->
|
84
86
|
callback(args...)
|
85
87
|
)
|
86
88
|
|
@@ -60,28 +60,37 @@ up.flow = (->
|
|
60
60
|
u.createSelectorFromElement($(selectorOrElement))
|
61
61
|
|
62
62
|
if !up.browser.canPushState() && !u.castsToFalse(options.history)
|
63
|
-
|
63
|
+
if !options.preload
|
64
|
+
up.browser.loadPage(url, u.only(options, 'method'))
|
64
65
|
return
|
66
|
+
|
67
|
+
request =
|
68
|
+
url: url
|
69
|
+
method: options.method
|
70
|
+
selector: selector
|
65
71
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
u.only(options, 'method')
|
70
|
-
)
|
71
|
-
.done (html, textStatus, xhr) ->
|
72
|
+
promise = up.proxy.ajax(request)
|
73
|
+
|
74
|
+
promise.done (html, textStatus, xhr) ->
|
72
75
|
# The server can send us the current path using a header value.
|
73
76
|
# This way we know the actual URL if the server has redirected.
|
74
77
|
if currentLocation = u.locationFromXhr(xhr)
|
78
|
+
u.debug('Location from server: %o', currentLocation)
|
79
|
+
newRequest =
|
80
|
+
url: currentLocation
|
81
|
+
method: u.methodFromXhr(xhr)
|
82
|
+
selector: selector
|
83
|
+
up.proxy.alias(request, newRequest)
|
75
84
|
url = currentLocation
|
76
|
-
|
77
85
|
if u.isMissing(options.history) || u.castsToTrue(options.history)
|
78
86
|
options.history = url
|
79
|
-
|
80
87
|
if u.isMissing(options.source) || u.castsToTrue(options.source)
|
81
88
|
options.source = url
|
82
|
-
|
83
|
-
|
84
|
-
.fail(u.error)
|
89
|
+
implant(selector, html, options) unless options.preload
|
90
|
+
|
91
|
+
promise.fail(u.error)
|
92
|
+
|
93
|
+
promise
|
85
94
|
|
86
95
|
###*
|
87
96
|
Replaces the given selector with the same CSS selector from the given HTML string.
|
@@ -112,7 +121,7 @@ up.flow = (->
|
|
112
121
|
htmlElement = u.createElementFromHtml(html)
|
113
122
|
|
114
123
|
# TODO: extract title from HTTP header
|
115
|
-
options.title ||= htmlElement.querySelector("title")?.textContent
|
124
|
+
options.title ||= htmlElement.querySelector("title")?.textContent
|
116
125
|
|
117
126
|
for step in implantSteps(selector, options)
|
118
127
|
|
@@ -127,12 +136,12 @@ up.flow = (->
|
|
127
136
|
u.presence($(".up-popup " + step.selector)) ||
|
128
137
|
u.presence($(".up-modal " + step.selector)) ||
|
129
138
|
u.presence($(step.selector)) ||
|
130
|
-
u.error(
|
139
|
+
u.error('Could not find selector %o in current body HTML', step.selector)
|
131
140
|
if fragment = htmlElement.querySelector(step.selector)
|
132
141
|
$new = $(fragment)
|
133
142
|
swapElements $old, $new, step.pseudoClass, step.transition, options
|
134
143
|
else
|
135
|
-
u.error("Could not find selector
|
144
|
+
u.error("Could not find selector %o in response %o", step.selector, html)
|
136
145
|
|
137
146
|
elementsInserted = ($new, options) ->
|
138
147
|
options.insert?($new)
|
@@ -171,7 +180,7 @@ up.flow = (->
|
|
171
180
|
$new.insertAfter($old)
|
172
181
|
elementsInserted($new, options)
|
173
182
|
if $old.is('body') && transition != 'none'
|
174
|
-
u.error('Cannot apply transitions to body-elements', transition)
|
183
|
+
u.error('Cannot apply transitions to body-elements (%o)', transition)
|
175
184
|
up.morph($old, $new, transition)
|
176
185
|
|
177
186
|
implantSteps = (selector, options) ->
|
@@ -13,7 +13,7 @@ We need to work on this page:
|
|
13
13
|
- Explain how to display form errors
|
14
14
|
- Explain that the server needs to send 2xx or 5xx status codes so
|
15
15
|
Up.js can decide whether the form submission was successful
|
16
|
-
- Explain that the server needs to send
|
16
|
+
- Explain that the server needs to send `X-Up-Location` and `X-Up-Method` headers
|
17
17
|
if an successful form submission resulted in a redirect
|
18
18
|
- Examples
|
19
19
|
|
@@ -146,7 +146,7 @@ up.form = (->
|
|
146
146
|
else if options.change
|
147
147
|
callback = options.change
|
148
148
|
else
|
149
|
-
u.error('observe: No change callback given')
|
149
|
+
u.error('up.observe: No change callback given')
|
150
150
|
|
151
151
|
callbackPromise = u.resolvedPromise()
|
152
152
|
|
@@ -189,7 +189,15 @@ up.form = (->
|
|
189
189
|
clearTimer = ->
|
190
190
|
clearTimeout(callbackTimer)
|
191
191
|
|
192
|
-
changeEvents = if up.browser.canInputEvent()
|
192
|
+
changeEvents = if up.browser.canInputEvent()
|
193
|
+
# Actually we only need `input`, but we want to notice
|
194
|
+
# if another script manually triggers `change` on the element.
|
195
|
+
'input change'
|
196
|
+
else
|
197
|
+
# Actually we won't ever get `input` from the user in this browser,
|
198
|
+
# but we want to notice if another script manually triggers `input`
|
199
|
+
# on the element.
|
200
|
+
'input change keypress paste cut click propertychange'
|
193
201
|
$field.on changeEvents, check
|
194
202
|
|
195
203
|
check()
|
@@ -43,16 +43,15 @@ up.history = (->
|
|
43
43
|
method += "State" # resulting in either pushState or replaceState
|
44
44
|
window.history[method]({ fromUp: true }, '', url)
|
45
45
|
else
|
46
|
-
u.error
|
46
|
+
u.error "This browser doesn't support history.pushState"
|
47
47
|
|
48
48
|
pop = (event) ->
|
49
49
|
state = event.originalEvent.state
|
50
|
-
console.log "popping state", state
|
51
|
-
console.log "current href", up.browser.url()
|
52
50
|
if state?.fromUp
|
51
|
+
u.debug "Restoring state %o (now on #{up.browser.url()})", state
|
53
52
|
up.visit up.browser.url(), historyMethod: 'replace'
|
54
53
|
else
|
55
|
-
|
54
|
+
u.debug 'Discarding unknown state %o', state
|
56
55
|
|
57
56
|
# Defeat an unnecessary popstate that some browsers trigger on pageload (Chrome?).
|
58
57
|
# We should check in 2016 if we can remove this.
|
@@ -91,7 +91,7 @@ up.link = (->
|
|
91
91
|
up.visit('/users')
|
92
92
|
###
|
93
93
|
visit = (url, options) ->
|
94
|
-
|
94
|
+
u.debug "Visiting #{url}"
|
95
95
|
# options = util.options(options, )
|
96
96
|
up.replace('body', url, options)
|
97
97
|
|
@@ -123,30 +123,56 @@ up.link = (->
|
|
123
123
|
|
124
124
|
resolve = (element) ->
|
125
125
|
$element = $(element)
|
126
|
-
|
126
|
+
followAttr = $element.attr('up-follow')
|
127
|
+
if $element.is('a') || (u.isPresent(followAttr) && !u.castsToTrue(followAttr))
|
127
128
|
$element
|
128
129
|
else
|
129
130
|
$element.find('a:first')
|
130
|
-
|
131
|
-
resolveUrl = (element) ->
|
132
|
-
if $link = resolve(element)
|
133
|
-
u.option($link.attr('href'), $link.attr('up-follow'))
|
134
131
|
|
135
132
|
###*
|
136
133
|
Follows this link via AJAX and replaces a CSS selector in the current page
|
137
|
-
with corresponding elements from a new page fetched from the server
|
134
|
+
with corresponding elements from a new page fetched from the server:
|
138
135
|
|
139
136
|
<a href="/users" up-target=".main">User list</a>
|
137
|
+
|
138
|
+
By also adding an `up-instant` attribute, the page will be fetched
|
139
|
+
on `mousedown` instead of `click`, making the interaction even faster:
|
140
|
+
|
141
|
+
<a href="/users" up-target=".main" up-instant>User list</a>
|
142
|
+
|
143
|
+
Note that using `[up-instant]` will prevent a user from canceling a link
|
144
|
+
click by moving the mouse away from the interaction area. However, for
|
145
|
+
navigation actions this isn't needed. E.g. popular operation
|
146
|
+
systems switch tabs on `mousedown`.
|
140
147
|
|
141
148
|
@method a[up-target]
|
142
149
|
@ujs
|
143
150
|
@param {String} up-target
|
144
151
|
The CSS selector to replace
|
152
|
+
@param up-instant
|
153
|
+
If set, fetches the element on `mousedown` instead of `click`.
|
154
|
+
This makes the interaction faster.
|
145
155
|
###
|
146
156
|
up.on 'click', 'a[up-target]', (event, $link) ->
|
147
157
|
event.preventDefault()
|
148
|
-
|
158
|
+
# Check if the event was already triggered by `mousedown`
|
159
|
+
unless $link.is('[up-instant]')
|
160
|
+
follow($link)
|
161
|
+
|
162
|
+
up.on 'mousedown', 'a[up-target][up-instant]', (event, $link) ->
|
163
|
+
if event.which is 1
|
164
|
+
event.preventDefault()
|
165
|
+
follow($link)
|
149
166
|
|
167
|
+
###
|
168
|
+
@method up.link.childClicked
|
169
|
+
@private
|
170
|
+
###
|
171
|
+
childClicked = (event, $link) ->
|
172
|
+
$target = $(event.target)
|
173
|
+
$targetLink = $target.closest('a, [up-follow]')
|
174
|
+
$targetLink.length && $link.find($targetLink).length
|
175
|
+
|
150
176
|
###*
|
151
177
|
If applied on a link, Follows this link via AJAX and replaces the
|
152
178
|
current `<body>` element with the response's `<body>` element
|
@@ -167,22 +193,26 @@ up.link = (->
|
|
167
193
|
@method [up-follow]
|
168
194
|
@ujs
|
169
195
|
@param {String} [up-follow]
|
196
|
+
@param up-instant
|
197
|
+
If set, fetches the element on `mousedown` instead of `click`.
|
198
|
+
This makes the interaction faster.
|
170
199
|
###
|
171
200
|
up.on 'click', '[up-follow]', (event, $element) ->
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
201
|
+
unless childClicked(event, $element)
|
202
|
+
event.preventDefault()
|
203
|
+
# Check if the event was already triggered by `mousedown`
|
204
|
+
unless $element.is('[up-instant]')
|
205
|
+
follow(resolve($element))
|
206
|
+
|
207
|
+
up.on 'mousedown', '[up-follow][up-instant]', (event, $element) ->
|
208
|
+
if !childClicked(event, $element) && event.which == 1
|
179
209
|
event.preventDefault()
|
180
210
|
follow(resolve($element))
|
181
|
-
|
211
|
+
|
182
212
|
visit: visit
|
183
213
|
follow: follow
|
184
214
|
resolve: resolve
|
185
|
-
|
215
|
+
childClicked: childClicked
|
186
216
|
|
187
217
|
)()
|
188
218
|
|
@@ -35,8 +35,11 @@ up.magic = (->
|
|
35
35
|
A space-separated list of event names to bind.
|
36
36
|
@param {String} selector
|
37
37
|
The selector an on which the event must be triggered.
|
38
|
-
@param {Function(event, $element)} behavior
|
38
|
+
@param {Function(event, $element, data)} behavior
|
39
39
|
The handler that should be called.
|
40
|
+
The function takes the affected element as the first argument (as a jQuery object).
|
41
|
+
If the element has an `up-data` attribute, its value is parsed as JSON
|
42
|
+
and passed as a second argument.
|
40
43
|
###
|
41
44
|
liveDescriptions = []
|
42
45
|
defaultLiveDescriptions = null
|
@@ -47,7 +50,8 @@ up.magic = (->
|
|
47
50
|
description = [
|
48
51
|
events,
|
49
52
|
selector,
|
50
|
-
(event) ->
|
53
|
+
(event) ->
|
54
|
+
behavior.apply(this, [event, $(this), data(this)])
|
51
55
|
]
|
52
56
|
liveDescriptions.push(description)
|
53
57
|
$(document).on(description...)
|
@@ -63,9 +67,11 @@ up.magic = (->
|
|
63
67
|
If set to `true` and a fragment insertion contains multiple
|
64
68
|
elements matching the selector, `awakener` is only called once
|
65
69
|
with a jQuery collection containing all matching elements.
|
66
|
-
@param {Function($element)} awakener
|
70
|
+
@param {Function($element, data)} awakener
|
67
71
|
The function to call when a matching element is inserted.
|
68
72
|
The function takes the new element as the first argument (as a jQuery object).
|
73
|
+
If the element has an `up-data` attribute, its value is parsed as JSON
|
74
|
+
and passed as a second argument.
|
69
75
|
|
70
76
|
The function may return another function that destroys the awakened
|
71
77
|
object when it is removed from the DOM, by clearing global state such as
|
@@ -85,15 +91,15 @@ up.magic = (->
|
|
85
91
|
batch: options.batch
|
86
92
|
|
87
93
|
applyAwakener = (awakener, $jqueryElement, nativeElement) ->
|
88
|
-
|
94
|
+
u.debug "Applying awakener %o on %o", awakener.selector, nativeElement
|
95
|
+
destroyer = awakener.callback.apply(nativeElement, [$jqueryElement, data($jqueryElement)])
|
89
96
|
if u.isFunction(destroyer)
|
90
97
|
$jqueryElement.addClass(DESTROYABLE_CLASS)
|
91
|
-
$jqueryElement.data(DESTROYER_KEY, destroyer)
|
98
|
+
$jqueryElement.data(DESTROYER_KEY, destroyer)
|
92
99
|
|
93
100
|
compile = ($fragment) ->
|
94
|
-
|
101
|
+
u.debug "Compiling fragment %o", $fragment
|
95
102
|
for awakener in awakeners
|
96
|
-
# console.log("running", awakener.selector, "on", $fragment)
|
97
103
|
$matches = u.findWithSelf($fragment, awakener.selector)
|
98
104
|
if $matches.length
|
99
105
|
if awakener.batch
|
@@ -106,7 +112,28 @@ up.magic = (->
|
|
106
112
|
$element = $(this)
|
107
113
|
destroyer = $element.data(DESTROYER_KEY)
|
108
114
|
destroyer()
|
109
|
-
|
115
|
+
|
116
|
+
###
|
117
|
+
Checks if the given element has an `up-data` attribute.
|
118
|
+
If yes, parses the attribute value as JSON and returns the parsed object.
|
119
|
+
|
120
|
+
Returns an empty object if the element has no `up-data` attribute.
|
121
|
+
|
122
|
+
The API of this method is likely to change in the future, so
|
123
|
+
we can support getting or setting individual keys.
|
124
|
+
|
125
|
+
@protected
|
126
|
+
@method up.magic.data
|
127
|
+
@param {String|Element|jQuery} elementOrSelector
|
128
|
+
###
|
129
|
+
data = (elementOrSelector) ->
|
130
|
+
$element = $(elementOrSelector)
|
131
|
+
json = $element.attr('up-data')
|
132
|
+
if u.isString(json) && u.trim(json) != ''
|
133
|
+
JSON.parse(json)
|
134
|
+
else
|
135
|
+
{}
|
136
|
+
|
110
137
|
###*
|
111
138
|
Makes a snapshot of the currently registered event listeners,
|
112
139
|
to later be restored through [`up.bus.reset`](/up.bus#up.bus.reset).
|
@@ -165,6 +192,7 @@ up.magic = (->
|
|
165
192
|
on: live
|
166
193
|
ready: ready
|
167
194
|
onEscape: onEscape
|
195
|
+
data: data
|
168
196
|
|
169
197
|
)()
|
170
198
|
|
@@ -39,12 +39,12 @@ up.modal = (->
|
|
39
39
|
|
40
40
|
###*
|
41
41
|
@method up.modal.defaults
|
42
|
-
@param {Number} options.width
|
43
|
-
@param {Number} options.height
|
44
|
-
@param {String|Function(config)} options.template
|
45
|
-
@param {String} options.closeLabel
|
46
|
-
@param {String} options.openAnimation
|
47
|
-
@param {String} options.closeAnimation
|
42
|
+
@param {Number} [options.width]
|
43
|
+
@param {Number} [options.height]
|
44
|
+
@param {String|Function(config)} [options.template]
|
45
|
+
@param {String} [options.closeLabel]
|
46
|
+
@param {String} [options.openAnimation]
|
47
|
+
@param {String} [options.closeAnimation]
|
48
48
|
###
|
49
49
|
defaults = (options) ->
|
50
50
|
u.extend(config, options)
|
@@ -177,8 +177,6 @@ up.modal = (->
|
|
177
177
|
|
178
178
|
up.bus.on('fragment:ready', ($fragment) ->
|
179
179
|
unless $fragment.closest('.up-modal').length
|
180
|
-
console.log('fragment inserted', $fragment, $fragment.closest('.up-modal'))
|
181
|
-
# alert("autoclosing due to inserted fragment")
|
182
180
|
autoclose()
|
183
181
|
)
|
184
182
|
|