upjs-rails 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/dist/up.min.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%);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%)}.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-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}
data/dist/up.min.js CHANGED
@@ -1 +1 @@
1
- (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,T,S,x,C,E,A,F,U,P,j,z,O,D,H,M,W,G,I,X,L,N,V,q,B,Z,J,Q,_,R;return w=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)},D=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},N=function(t,n){var r,e,o;return r=H(t)?$("<a>").attr({href:t}).get(0):R(t),e=r.protocol+"//"+r.hostname,D(r.protocol,r.port)||(e+=":"+r.port),o=r.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),e+=o,(null!=n?n.hash:void 0)===!0&&(e+=r.hash),(null!=n?n.search:void 0)!==!1&&(e+=r.search),e},n=function(t){var n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;for(l=t.split(/[ >]/),e=null,p=m=0,h=l.length;h>m;p=++m){for(u=l[p],i=u.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=i.length;v>d;d++)switch(a=i[d],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),r&&n.appendTo(r),0===p&&(e=n),r=n}return e},c=function(t,n){var r;return r=document.createElement(t),r.innerHTML=n,r},h=function(){var n,r;throw n=1<=arguments.length?t.call(arguments,0):[],r=1===n.length&&up.util.isString(n[0])?n[0]:JSON.stringify(n),console.log.apply(console,["[UP] Error: "+r].concat(t.call(n))),alert(r),r},l=function(t){var n,r,e,o,i,u,a;for(console.log("Creating selector from element",t),r=(n=t.attr("class"))?n.split(" "):[],e=t.attr("id"),i=t.prop("tagName").toLowerCase(),e&&(i+="#"+e),u=0,a=r.length;a>u;u++)o=r[u],i+="."+o;return i},p=function(t){var n,r,e;return n=/<html>((?:.|\n)*)<\/html>/i,r=void 0,r=(e=t.match(n))?e[1]:"<html><body>"+t+"</body></html>",c("html",r)},g=$.extend,d=function(t,n){var r,e,o,i,u;for(u=[],r=o=0,i=t.length;i>o;r=++o)e=t[r],u.push(n(e,r));return u},P=function(t){return null===t},M=function(t){return void 0===t},x=function(t){return!M(t)},U=function(t){return M(t)||P(t)},E=function(t){return!U(t)},S=function(t){return U(t)||j(t)&&0===Object.keys(t).length||0===t.length},Z=function(t,n){return null==n&&(n=z),n(t)?t:null},z=function(t){return!S(t)},C=function(t){return"function"==typeof t},H=function(t){return"string"==typeof t},A=function(t){return"object"==typeof t&&!!t},j=function(t){return A(t)||"function"==typeof t},F=function(t){return t instanceof jQuery},O=function(t){return C(t.then)},k=function(t){return E(t)?t:void 0},T=Array.isArray,a=function(t){return T(t)?t.slice():g({},t)},R=function(t){return F(t)?t.get(0):t},X=function(t,n){return g(a(t),n)},q=function(t,n){var r,e,o,i;if(o=t?a(t):{},n)for(e in n)r=n[e],i=o[e],E(i)?j(r)&&j(i)&&(o[e]=q(i,r)):o[e]=r;return o},V=function(){var n,r;return n=1<=arguments.length?t.call(arguments,0):[],r=null,n.every(function(t){var n;return n=t,C(n)&&(n=n()),z(n)?(r=n,!1):!0}),r},m=function(t,n){var r;return r=null,t.every(function(t){return n(t)?(r=t,!1):!0}),r},Q=function(t,n){var r;return r=[],d(t,function(t){return n(t)?r.push(t):void 0}),r},J=function(){var n,r,e,o;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,i;for(i=[],t=0,o=e.length;o>t;t++)r=e[t],i.push(n.attr(r));return i}(),m(o,z)},L=function(t){return setTimeout(t,0)},W=function(t){return t[t.length-1]},i=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},_=function(t,n,r){var e,o;return o=t.css(Object.keys(n)),t.css(n),e=function(){return t.css(o)},r?(r(),e()):e},b=function(t){var n,r;return r=t.css(["transform","-webkit-transform"]),S(r)?(n=function(){return t.css(r)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},f=function(t,n,r){var e,o,i,u,a;return r=q(r,{duration:300,delay:0,easing:"ease"}),e=$(t),o=$.Deferred(),i={"transition-property":Object.keys(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},u=b(e),a=_(e,i),e.css(n),o.then(u),o.then(a),setTimeout(function(){return o.resolve()},r.duration+r.delay),o.promise()},I=function(t,n){var r,e,o;return e=(null!=n?n.relative:void 0)?t.position():t.offset(),r={left:e.left,top:e.top},(null!=n?n.inner:void 0)?(r.width=t.width(),r.height=t.height()):(r.width=t.outerWidth(),r.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=i(),r.right=o.width-(r.left+r.width),r.bottom=o.height-(r.top+r.height)),r},s=function(t,n){var r,e,o,i,u;for(i=t.get(0).attributes,u=[],e=0,o=i.length;o>e;e++)r=i[e],u.push(r.specified?n.attr(r.name,r.value):void 0);return u},B=function(t){var n,r;return r=I(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(r),n.addClass("up-ghost"),n.insertBefore(t)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},u=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},e=function(t){return"false"===String(t)},G=function(t){return t.getResponseHeader("X-Up-Current-Location")},{presentAttr:J,createElement:c,normalizeUrl:N,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:w,ajax:r,extend:g,copy:a,merge:X,options:q,option:V,error:h,each:d,detect:m,select:Q,last:W,isNull:P,isDefined:x,isUndefined:M,isGiven:E,isMissing:U,isPresent:z,isBlank:S,presence:Z,isObject:j,isFunction:C,isString:H,isJQuery:F,isPromise:O,isHash:A,ifGiven:k,unwrap:R,nextFrame:L,measure:I,temporaryCss:_,cssAnimate:f,forceCompositing:b,prependGhost:B,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:u,isArray:T,castsToTrue:o,castsToFalse:e,locationFromXhr:G,clientSize:i}}()}.call(this),function(){up.browser=function(){var t;return t=function(){return location.href},{url:t}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,r,e,o,i,u,a;return n={},e={},r=function(t){return n[t]||(n[t]=[])},a=function(){var t,r,o;e={},o=[];for(r in n)t=n[r],o.push(e[r]=up.util.copy(t));return o},u=function(){return n=up.util.copy(e)},i=function(t,n){return r(t).push(n)},o=function(){var n,e,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],console.log("bus emitting",o,n),e=r(o),up.util.each(e,function(t){return t.apply(null,n)})},i("framework:ready",a),i("framework:reset",u),{on:i,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,r,e,o,i,u,a,s,c,p,l;return l=up.util,s=function(t,n){var r;return r=$(t),l.isPresent(n)&&(n=l.normalizeUrl(n)),r.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),l.presence(n.attr("up-source"))||up.browser.url()},u=function(t,n,r){var o;return r=l.options(r),o=l.presence(t)?t:l.createSelectorFromElement($(t)),l.ajax({url:n,selector:o}).done(function(t,i,u){var a;return(a=l.locationFromXhr(u))&&(n=a),(l.isMissing(r.history)||l.castsToTrue(r.history))&&(r.history=n),(l.isMissing(r.source)||l.castsToTrue(r.source))&&(r.source=n),e(o,t,r)}).fail(l.error)},e=function(t,n,r){var e,i,u,a,s,c,f,m,d,h;for(r=l.options(r,{historyMethod:"push"}),"false"===r.history&&(r.history=null),r.source=l.option(r.source,r.history),a=l.createElementFromHtml(n),r.title||(r.title=null!=(m=a.querySelector("title"))?m.textContent:void 0),d=o(t,r),h=[],c=0,f=d.length;f>c;c++)s=d[c],i=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector)),(u=a.querySelector(s.selector))?(e=$(u),h.push(p(i,e,s.pseudoClass,s.transition,r))):h.push(l.error("Could not find selector ("+s.selector+") in response ("+n+")"));return h},r=function(n,r){return"function"==typeof r.insert&&r.insert(n),r.history&&(r.title&&(document.title=r.title),up.history[r.historyMethod](r.history)),s(n,r.source),t(n),up.ready(n)},p=function(t,e,o,i,u){var a,s;return i||(i="none"),o?(s="before"===o?"prepend":"append",a=e.children(),t[s](e.contents()),l.copyAttributes(e,t),r(a,u),up.animate(e,i)):n(t,{animation:function(){return e.insertAfter(t),r(e,u),t.is("body")&&"none"!==i&&l.error("Cannot apply transitions to body-elements",i),up.morph(t,e,i)}})},o=function(t,n){var r,e,o,i,u,a,s,c,p,f,m;for(s=n.transition||n.animation||"none",r=/\ *,\ */,e=t.split(r),l.isPresent(s)&&(c=s.split(r)),m=[],o=p=0,f=e.length;f>p;o=++p)i=e[o],u=i.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:u[1],pseudoClass:u[2],transition:a});return m},t=function(t){var n,r;return r="[autofocus]:last",n=l.findWithSelf(t,r),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var r,e;return r=$(t),n=l.options(n,{animation:"none"}),r.addClass("up-destroying"),l.isPresent(n.url)&&up.history.push(n.url),l.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",r),e=l.presence(n.animation,l.isPromise)||up.motion.animate(r,n.animation),e.then(function(){return r.remove()})},i=function(t){var n;return n=c(t),u(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:u,reload:i,destroy:n,implant:e,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,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;return v=up.util,n="up-destroyable",r="up-destroyer",l=[],s=null,p=function(t,n,r){var e,o;return e=[t,n,function(t){return r.apply(this,[t,$(this)])}],l.push(e),(o=$(document)).on.apply(o,e)},i=[],a=null,o=function(){var n,r,e,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],r=n.pop(),e=v.options(n[0],{batch:!1}),i.push({selector:o,callback:r,batch:e.batch})},e=function(t,e,o){var i;return i=t.callback.apply(o,[e]),v.isFunction(i)?(e.addClass(n),e.data(r,i)):void 0},u=function(t){var n,r,o,u,a;for(console.log("Compiling fragment",t),a=[],o=0,u=i.length;u>o;o++)r=i[o],n=v.findWithSelf(t,r.selector),a.push(n.length?r.batch?e(r,n,n.get()):n.each(function(){return e(r,$(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(r))()})},h=function(){return s=v.copy(l),a=v.copy(i)},d=function(){var t,n,r,e;for(n=0,r=l.length;r>n;n++)t=l[n],v.contains(s,t)||(e=$(document)).off.apply(e,t);return l=v.copy(s),i=v.copy(a)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},f=function(t){return p("keydown","body",function(n){return v.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",u),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",h),up.bus.on("framework:reset",d),{awaken:o,on:p,ready:m,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,r,e,o,i;return i=up.util,t=function(t){return i.normalizeUrl(t,{hash:!0})===i.normalizeUrl(up.browser.url(),{hash:!0})},o=function(r,e){return e=i.options(e,{force:!1}),e.force||!t(r)?n("replace",r):void 0},e=function(r){return t(r)?void 0:n("push",r)},n=function(t,n){return t+="State",window.history[t]({fromUp:!0},"",n)},r=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)},setTimeout(function(){return $(window).on("popstate",r),o(up.browser.url(),{force:!0})},200),{push:e,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;return h=up.util,o={duration:300,delay:0,easing:"ease"},r={},i={},d={},u={},a=function(t){return h.extend(o,t)},t=function(n,r,i){var u;return u=$(n),i=h.options(i,o),h.isFunction(r)?e(r(u,i),["Animation did not return a Promise",r]):h.isString(r)?t(u,s(r),i):h.isHash(r)?h.cssAnimate(u,r,i):h.error("Unknown animation type",r)},s=function(t){return r[t]||h.error("Unknown animation",n)},v=function(t,n,r){var e,o,i,u;return o=null,e=null,h.temporaryCss(n,{display:"none"},function(){return o=h.prependGhost(t).addClass("up-destroying")}),h.temporaryCss(t,{display:"none"},function(){return e=h.prependGhost(n)}),t.css({visibility:"hidden"}),i=h.temporaryCss(n,{display:"none"}),u=r(o,e),u.then(function(){return o.remove(),e.remove(),t.css({display:"none"}),i()})},e=function(t,n){return h.isPromise(t)||h.error.apply(h,n),t},c=function(n,i,u,a){var s,p,l,f,m;return a=h.options(o),p=$(n),s=$(i),m=h.presence(u,h.isFunction)||d[u],m?v(p,s,function(t,n){return e(m(t,n,a),["Transition did not return a promise",u])}):(l=r[u])?(p.hide(),t(s,l,a)):h.isString(u)&&u.indexOf("/")>=0?(f=u.split("/"),m=function(n,r,e){return $.when(t(n,f[0],e),t(r,f[1],e))},c(p,s,m,a)):h.error("Unknown transition: "+u)},m=function(t,n){return d[t]=n},n=function(t,n){return r[t]=n},f=function(){return i=h.copy(r),u=h.copy(d)},l=function(){return r=h.copy(i),d=h.copy(u)},p=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},n("none",p),n("fade-in",function(n,r){return n.css({opacity:0}),t(n,{opacity:1},r)}),n("fade-out",function(n,r){return n.css({opacity:1}),t(n,{opacity:0},r)}),n("move-to-top",function(n,r){var e,o;return e=h.measure(n),o=e.top+e.height,n.css({"margin-top":"0px"}),t(n,{"margin-top":"-"+o+"px"},r)}),n("move-from-top",function(n,r){var e,o;return e=h.measure(n),o=e.top+e.height,n.css({"margin-top":"-"+o+"px"}),t(n,{"margin-top":"0px"},r)}),n("move-to-bottom",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().height-e.top,n.css({"margin-top":"0px"}),t(n,{"margin-top":o+"px"},r)}),n("move-from-bottom",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().height-e.top,n.css({"margin-top":o+"px"}),t(n,{"margin-top":"0px"},r)}),n("move-to-left",function(n,r){var e,o;return e=h.measure(n),o=e.left+e.width,n.css({"margin-left":"0px"}),t(n,{"margin-left":"-"+o+"px"},r)}),n("move-from-left",function(n,r){var e,o;return e=h.measure(n),o=e.left+e.width,n.css({"margin-left":"-"+o+"px"}),t(n,{"margin-left":"0px"},r)}),n("move-to-right",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().width-e.left,n.css({"margin-left":"0px"}),t(n,{"margin-left":o+"px"},r)}),n("move-from-right",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().width-e.left,n.css({"margin-left":o+"px"}),t(n,{"margin-left":"0px"},r)}),n("roll-down",function(n,r){var e,o;return e=n.height(),o=h.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:e+"px"},r).then(o)}),m("none",p),m("move-left",function(n,r,e){return $.when(t(n,"move-to-left",e),t(r,"move-from-right",e))}),m("move-right",function(n,r,e){return $.when(t(n,"move-to-right",e),t(r,"move-from-left",e))}),m("move-up",function(n,r,e){return $.when(t(n,"move-to-top",e),t(r,"move-from-bottom",e))}),m("move-down",function(n,r,e){return $.when(t(n,"move-to-bottom",e),t(r,"move-from-top",e))}),m("cross-fade",function(n,r,e){return $.when(t(n,"fade-out",e),t(r,"fade-in",e))}),up.bus.on("framework:ready",f),up.bus.on("framework:reset",l),{morph:c,animate:t,transition:m,animation:n,defaults:a,none:p}}(),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,r,e,o;return e=up.util,o=function(t,n){return console.log("up.visit",t),up.replace("body",t,n)},t=function(t,n){var r,o,i;return r=$(t),n=e.options(n),i=e.option(r.attr("href"),r.attr("up-follow")),o=e.option(n.target,r.attr("up-target"),"body"),n.transition=e.option(n.transition,r.attr("up-transition"),r.attr("up-animation")),n.history=e.option(n.history,r.attr("up-history")),up.replace(o,i,n)},n=function(t){var n;return n=$(t),n.is("a")||e.presentAttr(n,"up-follow")?n:n.find("a:first")},r=function(t){var r;return(r=n(t))?e.option(r.attr("href"),r.attr("up-follow")):void 0},up.on("click","a[up-target]",function(n,r){return n.preventDefault(),t(r)}),up.on("click","[up-follow]",function(r,e){var o;return o=function(){var t,n;return t=$(r.target),n=t.closest("a, [up-follow]"),n.length&&e.find(n).length},o()?void 0:(r.preventDefault(),t(n(e)))}),{visit:o,follow:t,resolve:n,resolveUrl:r}}(),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 r,e,o,i,a,s,c,p,l,f;return r=$(t).closest("form"),n=u.options(n),c=u.option(n.target,r.attr("up-target"),"body"),e=u.option(n.failTarget,r.attr("up-fail-target"),function(){return u.createSelectorFromElement(r)}),i=u.option(n.history,r.attr("up-history"),!0),p=u.option(n.transition,r.attr("up-transition")),o=u.option(n.failTransition,r.attr("up-fail-transition")),a=u.option(n.method,r.attr("up-method"),r.attr("data-method"),r.attr("method"),"post").toUpperCase(),f=u.option(n.url,r.attr("action"),up.browser.url()),r.addClass("up-active"),s={url:f,type:a,data:r.serialize(),selector:c},l=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 r.removeClass("up-active")}).done(function(t,n,r){return up.flow.implant(c,t,{history:l(r),transition:p})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(e,n,{transition:o})})},observe=function(fieldOrSelector,options){var $field,callback,check,clearTimer,codeOnChange,knownValue,resetTimer,startTimer,timer;return $field=$(fieldOrSelector),options=u.options(options,{frequency:500}),knownValue=null,timer=null,callback=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"),check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:callback.apply($field.get(0),[n,$field])},resetTimer=function(){return timer?(clearTimer(),startTimer()):void 0},clearTimer=function(){return clearInterval(timer),timer=null},startTimer=function(){return timer=setInterval(check,options.frequency)},$field.bind("keyup click mousemove",resetTimer),check(),startTimer(),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,r,e,o,i,u,a,s,c,p;return c=up.util,r={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(r,t)},a=function(t,n,r){var e,o;return o=c.measure(t,{full:!0}),e=function(){switch(r){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",r)}}(),n.attr("up-origin",r),n.css(e),i(n)},i=function(t){var n,r,e,o,i,u,a;if(r=c.measure(t,{full:!0}),e=null,o=null,r.right<0&&(e=-r.right),r.bottom<0&&(o=-r.bottom),r.left<0&&(e=r.left),r.top<0&&(o=r.top),e&&((i=parseInt(t.css("left")))?t.css("left",i-e):(u=parseInt(t.css("right")))&&t.css("right",u+e)),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)}},e=function(t,n,r){var e,o;return o=c.$createElementFromSelector(".up-popup"),r&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),e=c.$createElementFromSelector(n),e.appendTo(o),o.appendTo(document.body),o.hide(),o},p=function(t,n,r,e){return n.show(),a(t,n,r),up.animate(n,e)},u=function(t,o){var i,u,a,s,l,f,m,d;return i=$(t),o=c.options(o),d=c.option(i.attr("href")),f=c.option(o.target,i.attr("up-popup"),"body"),l=c.option(o.origin,i.attr("up-origin"),r.origin),a=c.option(o.animation,i.attr("up-animation"),r.openAnimation),m=c.option(o.sticky,i.is("[up-sticky]")),s=c.option(o.history,i.attr("up-history"),!1),n(),u=e(i,f,m),up.replace(f,d,{history:s,insert:function(){return p(i,u,l,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:r.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,r){return t.preventDefault(),r.is(".up-current")?n():u(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-popup").length||r.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,r){return r.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,r,e,o,i,u,a,s,c;return s=up.util,r={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(r,t)},a=function(){var t;return t=r.template,s.isFunction(t)?t(r):t},e=function(t,n,r,e){var o,i,u,c;return u=$(a()),e&&u.attr("up-sticky",""),u.attr("up-previous-url",up.browser.url()),u.attr("up-previous-title",document.title),i=u.find(".up-modal-dialog"),s.isPresent(n)&&i.css("width",n),s.isPresent(r)&&i.css("height",r),o=i.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),u.appendTo(document.body),u.hide(),u},c=function(t,n){return t.show(),up.animate(t,n)},i=function(t,o){var i,u,a,p,l,f,m,d,h;return i=$(t),o=s.options(o),d=s.option(i.attr("href")),f=s.option(o.target,i.attr("up-modal"),"body"),h=s.option(o.width,i.attr("up-width"),r.width),p=s.option(o.height,i.attr("up-height"),r.height),a=s.option(o.animation,i.attr("up-animation"),r.openAnimation),m=s.option(o.sticky,i.is("[up-sticky]")),l=s.option(o.history,i.attr("up-history"),!0),n(),u=e(f,h,p,m),up.replace(f,d,{history:l,insert:function(){return c(u,a)}})},u=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:r.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,r){return t.preventDefault(),r.is(".up-current")?n():i(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-modal-dialog").length||r.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,r){return r.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:u,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,r,e,o;return o=up.util,e=function(t,n,r){var e,i,u;return i=o.measure(t),u=o.measure(n),e=function(){switch(r){case"top":return{left:i.left+.5*(i.width-u.width),top:i.top-u.height};case"bottom":return{left:i.left+.5*(i.width-u.width),top:i.top+i.height};default:return o.error("Unknown origin",r)}}(),n.attr("up-origin",r),n.css(e)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},r=function(r,i){var u,a,s,c,p;return null==i&&(i={}),u=$(r),c=o.option(i.html,u.attr("up-tooltip")),p=o.option(i.origin,u.attr("up-origin"),"top"),s=o.option(i.animation,u.attr("up-animation"),"fade-in"),t(),a=n(c),e(u,a,p),up.animate(a,s,i)},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 r(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:r,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,r,e,o,i,u,a,s,c;return s=up.util,t="up-active",n="up-current",e="a[href], a[up-target], [up-follow], [up-modal], [up-popup]",r="."+t,u=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},i=function(){var t,r,o;return o=u(up.browser.url()),t=u(up.modal.source()),r=u(up.popup.source()),s.each($(e),function(e){var i,a;return i=$(e),a=up.link.resolveUrl(i),a=u(a),a===o||a===t||a===r?i.addClass(n):i.removeClass(n)})},a=function(n){return c(),n=o(n),n.addClass(t)},o=function(t){return s.presence(t.parents(e))||t},c=function(){return $(r).removeClass(t)},up.on("click",e,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return c(),i()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?i():void 0})}()}.call(this),function(){up.marker=function(){var t,n;return n=function(t){return""!==t.html().trim()},t=function(t){return up.util.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.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,i,u,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,S,C,T,x,P,E,A,F,U,O,j,z,D,H,L,M,W,G,I,X,q,N,V,R,B,J,Z,_,Q,K,Y,tn,nn;return w=function(t,n){return n=n||{},n.url=t,e(n)},e=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},D=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},N=function(t,n){var e,r,o;return e=H(t)?$("<a>").attr({href:t}).get(0):nn(t),r=e.protocol+"//"+e.hostname,D(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,i,u,a,s,c,p,l,f,m,d,h,v;for(l=t.split(/[ >]/),r=null,p=m=0,h=l.length;h>m;p=++m){for(u=l[p],i=u.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=i.length;v>d;d++)switch(a=i[d],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===p&&(r=n),e=n}return r},c=function(t,n){var e;return e=document.createElement(t),j(n)&&(e.innerHTML=n),e},h=function(){var n,e;throw n=1<=arguments.length?t.call(arguments,0):[],e=1===n.length&&up.util.isString(n[0])?n[0]:JSON.stringify(n),console.log.apply(console,["[UP] Error: "+e].concat(t.call(n))),alert(e),e},l=function(t){var n,e,r,o,i,u,a;for(console.log("Creating selector from element",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),i=t.prop("tagName").toLowerCase(),r&&(i+="#"+r),u=0,a=e.length;a>u;u++)o=e[u],i+="."+o;return i},p=function(t){var n,e,r,o,i,u,a,s,p,l,f,m;return p=function(t){return"<"+t+"(?: [^>]*)?>"},u=function(t){return"</"+t+">"},n="(?:.|\\n)*?",i=function(t){return"("+t+")"},m=new RegExp(p("head")+n+p("title")+i(n)+u("title")+n+u("body"),"i"),o=new RegExp(p("body")+i(n)+u("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=c("body",r[1]),s.appendChild(e),(f=t.match(m))&&(a=c("head"),s.appendChild(a),l=c("title",f[1]),a.appendChild(l)),s):c("div",t)},g=$.extend,tn=$.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},d=function(t,n){var e,r,o,i,u;for(u=[],e=o=0,i=t.length;i>o;e=++o)r=t[e],u.push(n(r,e));return u},U=function(t){return null===t},L=function(t){return void 0===t},T=function(t){return!L(t)},F=function(t){return L(t)||U(t)},P=function(t){return!F(t)},C=function(t){return F(t)||O(t)&&0===M(t).length||0===t.length},Z=function(t,n){return null==n&&(n=j),n(t)?t:null},j=function(t){return!C(t)},x=function(t){return"function"==typeof t},H=function(t){return"string"==typeof t},E=function(t){return"object"==typeof t&&!!t},O=function(t){return E(t)||"function"==typeof t},A=function(t){return t instanceof jQuery},z=function(t){return x(t.then)},k=function(t){return P(t)?t:void 0},S=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},a=function(t){return S(t)?t.slice():g({},t)},nn=function(t){return A(t)?t.get(0):t},X=function(t,n){return g(a(t),n)},B=function(t,n){var e,r,o,i;if(o=t?a(t):{},n)for(r in n)e=n[r],i=o[r],P(i)?O(e)&&O(i)&&(o[r]=B(i,e)):o[r]=e;return o},R=function(){var n,e,r,o,i,u;for(e=1<=arguments.length?t.call(arguments,0):[],r=null,i=0,u=e.length;u>i;i++)if(n=e[i],o=n,x(o)&&(o=o()),j(o)){r=o;break}return r},m=function(t,n){var e,r,o,i;for(r=null,o=0,i=t.length;i>o;o++)if(e=t[o],n(e)){r=e;break}return r},K=function(t,n){var e;return e=[],d(t,function(t){return n(t)?e.push(t):void 0}),e},_=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,i;for(i=[],t=0,o=r.length;o>t;t++)e=r[t],i.push(n.attr(e));return i}(),m(o,j)},q=function(t){return setTimeout(t,0)},W=function(t){return t[t.length-1]},i=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},Y=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},b=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),C(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},f=function(t,n,e){var r,o,i,u,a;return r=$(t),up.browser.canCssAnimation()?(e=B(e,{duration:300,delay:0,easing:"ease"}),o=$.Deferred(),i={"transition-property":M(n).join(", "),"transition-duration":e.duration+"ms","transition-delay":e.delay+"ms","transition-timing-function":e.easing},u=b(r),a=Y(r,i),r.css(n),o.then(u),o.then(a),setTimeout(function(){return o.resolve()},e.duration+e.delay),o.promise()):(r.css(n),Q())},I=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},s=function(t,n){var e,r,o,i,u;for(i=t.get(0).attributes,u=[],r=0,o=i.length;o>r;r++)e=i[r],u.push(e.specified?n.attr(e.name,e.value):void 0);return u},J=function(t){var n,e;return e=I(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)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},u=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},r=function(t){return"false"===String(t)},G=function(t){return t.getResponseHeader("X-Up-Current-Location")},V=function(){var n,e,r,o,i,u;for(o=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],n={},i=0,u=r.length;u>i;i++)e=r[i],o.hasOwnProperty(e)&&(n[e]=o[e]);return n},Q=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},{presentAttr:_,createElement:c,normalizeUrl:N,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:w,ajax:e,extend:g,copy:a,merge:X,options:B,option:R,error:h,each:d,detect:m,select:K,last:W,isNull:U,isDefined:T,isUndefined:L,isGiven:P,isMissing:F,isPresent:j,isBlank:C,presence:Z,isObject:O,isFunction:x,isString:H,isJQuery:A,isPromise:z,isHash:E,ifGiven:k,unwrap:nn,nextFrame:q,measure:I,temporaryCss:Y,cssAnimate:f,forceCompositing:b,prependGhost:J,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:u,isArray:S,castsToTrue:o,castsToFalse:r,locationFromXhr:G,clientSize:i,only:V,trim:tn,keys:M,resolvedPromise:Q}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,i,u,a,s;return a=up.util,i=function(t,n){var e,r,o,i,u,s;return null==n&&(n={}),u=a.option(n.method,"get").toLowerCase(),"get"===u?location.href=t:$.rails?(s=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),i="<input name='_method' value='"+u+"' type='hidden' />",a.isDefined(r)&&a.isDefined(o)&&(i+="<input name='"+r+"' value='"+o+"' type='hidden' />"),s&&e.attr("target",s),e.hide().append(i).appendTo("body"),e.submit()):error("Can't fake a "+u.toUpperCase()+" request without Rails UJS")},s=function(){return location.href},r=function(){var t;return window.console||(window.console={}),(t=window.console).log||(t.log=function(){})},u=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},e=u(function(){return a.isDefined(history.pushState)}),n=u(function(){return"transition"in document.documentElement.style}),o=u(function(){return a.isDefined(document.addEventListener)}),{url:s,ensureConsoleExists:r,loadPage:i,canPushState:e,canCssAnimation:n,isSupported:o}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,i,u,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},u=function(){return n=up.util.copy(r)},i=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)})},i("framework:ready",a),i("framework:reset",u),{on:i,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,e,r,o,i,u,a,s,c,p,l;return l=up.util,s=function(t,n){var e;return e=$(t),l.isPresent(n)&&(n=l.normalizeUrl(n)),e.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),l.presence(n.attr("up-source"))||up.browser.url()},u=function(t,n,e){var o;return e=l.options(e),o=l.presence(t)?t:l.createSelectorFromElement($(t)),up.browser.canPushState()||l.castsToFalse(e.history)?l.ajax({url:n,selector:o},l.only(e,"method")).done(function(t,i,u){var a;return(a=l.locationFromXhr(u))&&(n=a),(l.isMissing(e.history)||l.castsToTrue(e.history))&&(e.history=n),(l.isMissing(e.source)||l.castsToTrue(e.source))&&(e.source=n),r(o,t,e)}).fail(l.error):void up.browser.loadPage(n,l.only(e,"method"))},r=function(t,n,e){var r,i,u,a,s,c,f,m,d,h;for(e=l.options(e,{historyMethod:"push"}),"false"===e.history&&(e.history=null),e.source=l.option(e.source,e.history),a=l.createElementFromHtml(n),e.title||(e.title=null!=(m=a.querySelector("title"))?m.textContent:void 0),d=o(t,e),h=[],c=0,f=d.length;f>c;c++)s=d[c],i=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector))||l.error("Could not find selector ("+s.selector+") in current body HTML"),(u=a.querySelector(s.selector))?(r=$(u),h.push(p(i,r,s.pseudoClass,s.transition,e))):h.push(l.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)},p=function(t,r,o,i,u){var a,s;return i||(i="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),l.copyAttributes(r,t),e(a,u),up.animate(r,i)):n(t,{animation:function(){return r.insertAfter(t),e(r,u),t.is("body")&&"none"!==i&&l.error("Cannot apply transitions to body-elements",i),up.morph(t,r,i)}})},o=function(t,n){var e,r,o,i,u,a,s,c,p,f,m;for(s=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),l.isPresent(s)&&(c=s.split(e)),m=[],o=p=0,f=r.length;f>p;o=++p)i=r[o],u=i.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:u[1],pseudoClass:u[2],transition:a});return m},t=function(t){var n,e;return e="[autofocus]:last",n=l.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=l.options(n,{animation:"none"}),e.addClass("up-destroying"),l.isPresent(n.url)&&up.history.push(n.url),l.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),r=l.presence(n.animation,l.isPromise)||up.motion.animate(e,n.animation),r.then(function(){return e.remove()})},i=function(t){var n;return n=c(t),u(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:u,reload:i,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,i,u,a,s,c,p,l,f,m,d,h,v;return v=up.util,n="up-destroyable",e="up-destroyer",l=[],s=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)])}],l.push(r),(o=$(document)).on.apply(o,r)},i=[],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}),i.push({selector:o,callback:e,batch:r.batch})):void 0},r=function(t,r,o){var i;return i=t.callback.apply(o,[r]),v.isFunction(i)?(r.addClass(n),r.data(e,i)):void 0},u=function(t){var n,e,o,u,a;for(console.log("Compiling fragment",t),a=[],o=0,u=i.length;u>o;o++)e=i[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(l),a=v.copy(i)},d=function(){var t,n,e,r;for(n=0,e=l.length;e>n;n++)t=l[n],v.contains(s,t)||(r=$(document)).off.apply(r,t);return l=v.copy(s),i=v.copy(a)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},f=function(t){return p("keydown","body",function(n){return v.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",u),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",h),up.bus.on("framework:reset",d),{awaken:o,on:p,ready:m,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,i;return i=up.util,t=function(t){return i.normalizeUrl(t,{hash:!0})===i.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=i.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)):i.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,i,u,a,s,c,p,l,f,m,d,h,v;return h=up.util,o={duration:300,delay:0,easing:"ease"},e={},i={},d={},u={},a=function(t){return h.extend(o,t)},t=function(n,e,i){var u;return u=$(n),i=h.options(i,o),h.isFunction(e)?r(e(u,i),["Animation did not return a Promise",e]):h.isString(e)?t(u,s(e),i):h.isHash(e)?h.cssAnimate(u,e,i):h.error("Unknown animation type",e)},s=function(t){return e[t]||h.error("Unknown animation",n)},v=function(t,n,e){var r,o,i,u;return o=null,r=null,h.temporaryCss(n,{display:"none"},function(){return o=h.prependGhost(t).addClass("up-destroying")}),h.temporaryCss(t,{display:"none"},function(){return r=h.prependGhost(n)}),t.css({visibility:"hidden"}),i=h.temporaryCss(n,{display:"none"}),u=e(o,r),u.then(function(){return o.remove(),r.remove(),t.css({display:"none"}),i()})},r=function(t,n){return h.isPromise(t)||h.error.apply(h,n),t},c=function(n,i,u,a){var s,p,l,f,m;return up.browser.canCssAnimation()?(a=h.options(o),p=$(n),s=$(i),m=h.presence(u,h.isFunction)||d[u],m?v(p,s,function(t,n){return r(m(t,n,a),["Transition did not return a promise",u])}):(l=e[u])?(p.hide(),t(s,l,a)):h.isString(u)&&u.indexOf("/")>=0?(f=u.split("/"),m=function(n,e,r){return $.when(t(n,f[0],r),t(e,f[1],r))},c(p,s,m,a)):h.error("Unknown transition: "+u)):h.resolvedPromise()},m=function(t,n){return d[t]=n},n=function(t,n){return e[t]=n},f=function(){return i=h.copy(e),u=h.copy(d)},l=function(){return e=h.copy(i),d=h.copy(u)},p=h.resolvedPromise,n("none",p),n("fade-in",function(n,e){return n.css({opacity:0}),t(n,{opacity:1},e)}),n("fade-out",function(n,e){return n.css({opacity:1}),t(n,{opacity:0},e)}),n("move-to-top",function(n,e){var r,o;return r=h.measure(n),o=r.top+r.height,n.css({"margin-top":"0px"}),t(n,{"margin-top":"-"+o+"px"},e)}),n("move-from-top",function(n,e){var r,o;return r=h.measure(n),o=r.top+r.height,n.css({"margin-top":"-"+o+"px"}),t(n,{"margin-top":"0px"},e)}),n("move-to-bottom",function(n,e){var r,o;return r=h.measure(n),o=h.clientSize().height-r.top,n.css({"margin-top":"0px"}),t(n,{"margin-top":o+"px"},e)}),n("move-from-bottom",function(n,e){var r,o;return r=h.measure(n),o=h.clientSize().height-r.top,n.css({"margin-top":o+"px"}),t(n,{"margin-top":"0px"},e)}),n("move-to-left",function(n,e){var r,o;return r=h.measure(n),o=r.left+r.width,n.css({"margin-left":"0px"}),t(n,{"margin-left":"-"+o+"px"},e)}),n("move-from-left",function(n,e){var r,o;return r=h.measure(n),o=r.left+r.width,n.css({"margin-left":"-"+o+"px"}),t(n,{"margin-left":"0px"},e)}),n("move-to-right",function(n,e){var r,o;return r=h.measure(n),o=h.clientSize().width-r.left,n.css({"margin-left":"0px"}),t(n,{"margin-left":o+"px"},e)}),n("move-from-right",function(n,e){var r,o;return r=h.measure(n),o=h.clientSize().width-r.left,n.css({"margin-left":o+"px"}),t(n,{"margin-left":"0px"},e)}),n("roll-down",function(n,e){var r,o;return r=n.height(),o=h.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:r+"px"},e).then(o)}),m("none",p),m("move-left",function(n,e,r){return $.when(t(n,"move-to-left",r),t(e,"move-from-right",r))}),m("move-right",function(n,e,r){return $.when(t(n,"move-to-right",r),t(e,"move-from-left",r))}),m("move-up",function(n,e,r){return $.when(t(n,"move-to-top",r),t(e,"move-from-bottom",r))}),m("move-down",function(n,e,r){return $.when(t(n,"move-to-bottom",r),t(e,"move-from-top",r))}),m("cross-fade",function(n,e,r){return $.when(t(n,"fade-out",r),t(e,"fade-in",r))}),up.bus.on("framework:ready",f),up.bus.on("framework:reset",l),{morph:c,animate:t,transition:m,animation:n,defaults:a,none:p}}(),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,i;return e=$(t),n=r.options(n),i=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,i,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,p,l,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),p=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},l=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:l(e),transition:p})}).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,check,clearTimer,codeOnChange,knownValue,resetTimer,startTimer,timer;return $field=$(fieldOrSelector),options=u.options(options,{frequency:500}),knownValue=null,timer=null,callback=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"),check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:callback.apply($field.get(0),[n,$field])},resetTimer=function(){return timer?(clearTimer(),startTimer()):void 0},clearTimer=function(){return clearInterval(timer),timer=null},startTimer=function(){return timer=setInterval(check,options.frequency)},$field.bind("keyup click mousemove",resetTimer),check(),startTimer(),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,i,u,a,s,c,p;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),i(n)},i=function(t){var n,e,r,o,i,u,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&&((i=parseInt(t.css("left")))?t.css("left",i-r):(u=parseInt(t.css("right")))&&t.css("right",u+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},p=function(t,n,e,r){return n.show(),a(t,n,e),up.animate(n,r)},u=function(t,o){var i,u,a,s,l,f,m,d;return i=$(t),o=c.options(o),d=c.option(i.attr("href")),f=c.option(o.target,i.attr("up-popup"),"body"),l=c.option(o.origin,i.attr("up-origin"),e.origin),a=c.option(o.animation,i.attr("up-animation"),e.openAnimation),m=c.option(o.sticky,i.is("[up-sticky]")),s=up.browser.canPushState()?c.option(o.history,i.attr("up-history"),!1):!1,n(),u=r(i,f,m),up.replace(f,d,{history:s,insert:function(){return p(i,u,l,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():u(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:u,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,e,r,o,i,u,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,i,u,c;return u=$(a()),r&&u.attr("up-sticky",""),u.attr("up-previous-url",up.browser.url()),u.attr("up-previous-title",document.title),i=u.find(".up-modal-dialog"),s.isPresent(n)&&i.css("width",n),s.isPresent(e)&&i.css("height",e),o=i.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),u.appendTo(document.body),u.hide(),u},c=function(t,n){return t.show(),up.animate(t,n)},i=function(t,o){var i,u,a,p,l,f,m,d,h;return i=$(t),o=s.options(o),d=s.option(i.attr("href")),f=s.option(o.target,i.attr("up-modal"),"body"),h=s.option(o.width,i.attr("up-width"),e.width),p=s.option(o.height,i.attr("up-height"),e.height),a=s.option(o.animation,i.attr("up-animation"),e.openAnimation),m=s.option(o.sticky,i.is("[up-sticky]")),l=up.browser.canPushState()?s.option(o.history,i.attr("up-history"),!0):!1,n(),u=r(f,h,p,m),up.replace(f,d,{history:l,insert:function(){return c(u,a)}})},u=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():i(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:(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:i,close:n,source:u,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,i,u;return i=o.measure(t),u=o.measure(n),r=function(){switch(e){case"top":return{left:i.left+.5*(i.width-u.width),top:i.top-u.height};case"bottom":return{left:i.left+.5*(i.width-u.width),top:i.top+i.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,i){var u,a,s,c,p;return null==i&&(i={}),u=$(e),c=o.option(i.html,u.attr("up-tooltip")),p=o.option(i.origin,u.attr("up-origin"),"top"),s=o.option(i.animation,u.attr("up-animation"),"fade-in"),t(),a=n(c),r(u,a,p),up.animate(a,s,i)},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,i,u,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,u=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},i=function(){var t,e,o;return o=u(up.browser.url()),t=u(up.modal.source()),e=u(up.popup.source()),s.each($(r),function(r){var i,a;return i=$(r),a=up.link.resolveUrl(i),a=u(a),a===o||a===t||a===e?i.addClass(n):i.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(),i()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?i():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);
@@ -15,5 +15,9 @@
15
15
  #= require up/marker
16
16
  #= require_self
17
17
 
18
- up.bus.emit('framework:ready')
19
- $(document).on 'ready', -> up.bus.emit('app:ready')
18
+ if up.browser.isSupported()
19
+
20
+ up.browser.ensureConsoleExists()
21
+
22
+ up.bus.emit('framework:ready')
23
+ $(document).on 'ready', -> up.bus.emit('app:ready')
@@ -6,6 +6,8 @@ Browser interface
6
6
  ###
7
7
  up.browser = (->
8
8
 
9
+ u = up.util
10
+
9
11
  # safari = false
10
12
  #
11
13
  # detect = ->
@@ -23,9 +25,59 @@ up.browser = (->
23
25
  #
24
26
  # transitionEndEvent: transitionEndEvent
25
27
 
28
+ loadPage = (url, options = {}) ->
29
+ method = u.option(options.method, 'get').toLowerCase()
30
+ if method == 'get'
31
+ location.href = url
32
+ else if $.rails
33
+ target = options.target
34
+ csrfToken = $.rails.csrfToken()
35
+ csrfParam = $.rails.csrfParam()
36
+ $form = $("<form method='post' action='#{url}'></form>")
37
+ metadataInput = "<input name='_method' value='#{method}' type='hidden' />"
38
+ if u.isDefined(csrfParam) && u.isDefined(csrfToken)
39
+ metadataInput += "<input name='#{csrfParam}' value='#{csrfToken}' type='hidden' />"
40
+ if target
41
+ $form.attr('target', target)
42
+ $form.hide().append(metadataInput).appendTo('body')
43
+ $form.submit()
44
+ else
45
+ error("Can't fake a #{method.toUpperCase()} request without Rails UJS")
46
+
26
47
  url = ->
27
48
  location.href
28
49
 
50
+ ensureConsoleExists = ->
51
+ window.console ||= {}
52
+ window.console.log ||= () ->
53
+
54
+ memoize = (func) ->
55
+ cache = undefined
56
+ cached = false
57
+ (args...) ->
58
+ if cached
59
+ cache
60
+ else
61
+ cached = true
62
+ cache = func(args...)
63
+
64
+ canPushState = memoize ->
65
+ u.isDefined(history.pushState)
66
+
67
+ canCssAnimation = memoize ->
68
+ 'transition' of document.documentElement.style
69
+
70
+ isSupported = memoize ->
71
+ # This is the most concise way to exclude IE8 and lower
72
+ # while keeping all relevant desktop and mobile browsers.
73
+ u.isDefined(document.addEventListener)
74
+
29
75
  url: url
76
+ ensureConsoleExists: ensureConsoleExists
77
+ loadPage: loadPage
78
+ canPushState: canPushState
79
+ canCssAnimation: canCssAnimation
80
+ isSupported: isSupported
30
81
 
31
82
  )()
83
+
@@ -41,6 +41,7 @@ up.flow = (->
41
41
  @param {String} url
42
42
  The URL to fetch from the server.
43
43
  @param {String} [options.title]
44
+ @param {String} [options.method='get']
44
45
  @param {String|Boolean} [options.history=true]
45
46
  If a `String` is given, it is used as the URL the browser's location bar and history.
46
47
  If omitted or true, the `url` argument will be used.
@@ -58,9 +59,14 @@ up.flow = (->
58
59
  else
59
60
  u.createSelectorFromElement($(selectorOrElement))
60
61
 
62
+ if !up.browser.canPushState() && !u.castsToFalse(options.history)
63
+ up.browser.loadPage(url, u.only(options, 'method'))
64
+ return
65
+
61
66
  u.ajax(
62
67
  url: url,
63
- selector: selector
68
+ selector: selector,
69
+ u.only(options, 'method')
64
70
  )
65
71
  .done (html, textStatus, xhr) ->
66
72
  # The server can send us the current path using a header value.
@@ -113,7 +119,8 @@ up.flow = (->
113
119
  # always prefer to replace content in popups or modals
114
120
  u.presence($(".up-popup " + step.selector)) ||
115
121
  u.presence($(".up-modal " + step.selector)) ||
116
- u.presence($(step.selector))
122
+ u.presence($(step.selector)) ||
123
+ u.error("Could not find selector (#{step.selector}) in current body HTML")
117
124
  if fragment = htmlElement.querySelector(step.selector)
118
125
  $new = $(fragment)
119
126
  swapElements $old, $new, step.pseudoClass, step.transition, options
@@ -68,6 +68,10 @@ up.form = (->
68
68
  url = u.option(options.url, $form.attr('action'), up.browser.url())
69
69
 
70
70
  $form.addClass('up-active')
71
+
72
+ if !up.browser.canPushState() && !u.castsToFalse(historyOption)
73
+ $form.get(0).submit()
74
+ return
71
75
 
72
76
  request = {
73
77
  url: url
@@ -39,8 +39,11 @@ up.history = (->
39
39
  manipulate("push", url) unless isCurrentUrl(url)
40
40
 
41
41
  manipulate = (method, url) ->
42
- method += "State" # resulting in either pushState or replaceState
43
- window.history[method]({ fromUp: true }, '', url)
42
+ if up.browser.canPushState()
43
+ method += "State" # resulting in either pushState or replaceState
44
+ window.history[method]({ fromUp: true }, '', url)
45
+ else
46
+ u.error("This browser doesn't support history.pushState")
44
47
 
45
48
  pop = (event) ->
46
49
  state = event.originalEvent.state
@@ -53,10 +56,11 @@ up.history = (->
53
56
 
54
57
  # Defeat an unnecessary popstate that some browsers trigger on pageload (Chrome?).
55
58
  # We should check in 2016 if we can remove this.
56
- setTimeout (->
57
- $(window).on "popstate", pop
58
- replace(up.browser.url(), force: true)
59
- ), 200
59
+ if up.browser.canPushState()
60
+ setTimeout (->
61
+ $(window).on "popstate", pop
62
+ replace(up.browser.url(), force: true)
63
+ ), 200
60
64
 
61
65
  push: push
62
66
  replace: replace
@@ -42,6 +42,8 @@ up.magic = (->
42
42
  defaultLiveDescriptions = null
43
43
 
44
44
  live = (events, selector, behavior) ->
45
+ # Silently discard any awakeners that are registered on unsupported browsers
46
+ return unless up.browser.isSupported()
45
47
  description = [
46
48
  events,
47
49
  selector,
@@ -73,6 +75,8 @@ up.magic = (->
73
75
  defaultAwakeners = null
74
76
 
75
77
  awaken = (selector, args...) ->
78
+ # Silently discard any awakeners that are registered on unsupported browsers
79
+ return unless up.browser.isSupported()
76
80
  awakener = args.pop()
77
81
  options = u.options(args[0], batch: false)
78
82
  awakeners.push
@@ -8,11 +8,13 @@ TODO: Write some documentation
8
8
  ###
9
9
  up.marker = (->
10
10
 
11
+ u = up.util
12
+
11
13
  hasContent = ($marker) ->
12
- $marker.html().trim() != ''
14
+ u.trim($marker.html()) != ''
13
15
 
14
16
  check = ($element) ->
15
- up.util.findWithSelf($element, '[up-marker]').each ->
17
+ u.findWithSelf($element, '[up-marker]').each ->
16
18
  $marker = $(this)
17
19
  unless hasContent($marker)
18
20
  $marker.hide()
@@ -99,7 +99,7 @@ up.modal = (->
99
99
  height = u.option(options.height, $link.attr('up-height'), config.height)
100
100
  animation = u.option(options.animation, $link.attr('up-animation'), config.openAnimation)
101
101
  sticky = u.option(options.sticky, $link.is('[up-sticky]'))
102
- history = u.option(options.history, $link.attr('up-history'), true)
102
+ history = if up.browser.canPushState() then u.option(options.history, $link.attr('up-history'), true) else false
103
103
 
104
104
  close()
105
105
  $modal = createHiddenModal(selector, width, height, sticky)
@@ -140,29 +140,34 @@ up.motion = (->
140
140
  A promise for the transition's end.
141
141
  ###
142
142
  morph = (source, target, transitionOrName, options) ->
143
- options = u.options(config)
144
- $old = $(source)
145
- $new = $(target)
146
- transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName]
147
- if transition
148
- withGhosts $old, $new, ($oldGhost, $newGhost) ->
149
- assertIsPromise(
150
- transition($oldGhost, $newGhost, options),
151
- ["Transition did not return a promise", transitionOrName]
152
- )
153
- else if animation = animations[transitionOrName]
154
- $old.hide()
155
- animate($new, animation, options)
156
- else if u.isString(transitionOrName) && transitionOrName.indexOf('/') >= 0
157
- parts = transitionOrName.split('/')
158
- transition = ($old, $new, options) ->
159
- $.when(
160
- animate($old, parts[0], options),
161
- animate($new, parts[1], options)
162
- )
163
- morph($old, $new, transition, options)
143
+ if up.browser.canCssAnimation()
144
+ options = u.options(config)
145
+ $old = $(source)
146
+ $new = $(target)
147
+ transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName]
148
+ if transition
149
+ withGhosts $old, $new, ($oldGhost, $newGhost) ->
150
+ assertIsPromise(
151
+ transition($oldGhost, $newGhost, options),
152
+ ["Transition did not return a promise", transitionOrName]
153
+ )
154
+ else if animation = animations[transitionOrName]
155
+ $old.hide()
156
+ animate($new, animation, options)
157
+ else if u.isString(transitionOrName) && transitionOrName.indexOf('/') >= 0
158
+ parts = transitionOrName.split('/')
159
+ transition = ($old, $new, options) ->
160
+ $.when(
161
+ animate($old, parts[0], options),
162
+ animate($new, parts[1], options)
163
+ )
164
+ morph($old, $new, transition, options)
165
+ else
166
+ u.error("Unknown transition: #{transitionOrName}")
164
167
  else
165
- u.error("Unknown transition: #{transitionOrName}")
168
+ # Skip ghosting and all the other stuff that can go wrong
169
+ # in ancient browsers
170
+ u.resolvedPromise()
166
171
 
167
172
  ###*
168
173
  Defines a named transition.
@@ -200,10 +205,7 @@ up.motion = (->
200
205
  @return {Promise}
201
206
  A resolved promise
202
207
  ###
203
- none = ->
204
- deferred = $.Deferred()
205
- deferred.resolve()
206
- deferred.promise()
208
+ none = u.resolvedPromise
207
209
 
208
210
  animation('none', none)
209
211
 
@@ -123,7 +123,7 @@ up.popup = (->
123
123
  origin = u.option(options.origin, $link.attr('up-origin'), config.origin)
124
124
  animation = u.option(options.animation, $link.attr('up-animation'), config.openAnimation)
125
125
  sticky = u.option(options.sticky, $link.is('[up-sticky]'))
126
- history = u.option(options.history, $link.attr('up-history'), false)
126
+ history = if up.browser.canPushState() then u.option(options.history, $link.attr('up-history'), false) else false
127
127
 
128
128
  close()
129
129
  $popup = createHiddenPopup($link, selector, sticky)
@@ -85,7 +85,7 @@ up.util = (->
85
85
 
86
86
  createElement = (tagName, html) ->
87
87
  element = document.createElement(tagName)
88
- element.innerHTML = html
88
+ element.innerHTML = html if isPresent(html)
89
89
  element
90
90
 
91
91
  error = (args...) ->
@@ -106,16 +106,59 @@ up.util = (->
106
106
 
107
107
  # jQuery's implementation of $(...) cannot create elements that have
108
108
  # an <html> or <body> tag. So we're using native elements.
109
+ # Also IE9 cannot set innerHTML on a <html> or <head> element.
109
110
  createElementFromHtml = (html) ->
110
- htmlElementPattern = /<html>((?:.|\n)*)<\/html>/i
111
- innerHtml = undefined
112
- if match = html.match(htmlElementPattern)
113
- innerHtml = match[1]
111
+
112
+ openTag = (tag) -> "<#{tag}(?: [^>]*)?>"
113
+ closeTag = (tag) -> "</#{tag}>"
114
+ anything = '(?:.|\\n)*?'
115
+ capture = (pattern) -> "(#{pattern})"
116
+
117
+ titlePattern = new RegExp(
118
+ openTag('head') +
119
+ anything +
120
+ openTag('title') +
121
+ capture(anything) +
122
+ closeTag('title') +
123
+ anything +
124
+ closeTag('body'),
125
+ 'i')
126
+
127
+ bodyPattern = new RegExp(
128
+ openTag('body') +
129
+ capture(anything) +
130
+ closeTag('body'),
131
+ 'i')
132
+
133
+ if bodyMatch = html.match(bodyPattern)
134
+
135
+ htmlElement = document.createElement('html')
136
+ bodyElement = createElement('body', bodyMatch[1])
137
+ htmlElement.appendChild(bodyElement)
138
+
139
+ if titleMatch = html.match(titlePattern)
140
+ headElement = createElement('head')
141
+ htmlElement.appendChild(headElement)
142
+ titleElement = createElement('title', titleMatch[1])
143
+ headElement.appendChild(titleElement)
144
+
145
+ htmlElement
146
+
114
147
  else
115
- innerHtml = "<html><body>#{html}</body></html>"
116
- createElement('html', innerHtml)
148
+
149
+ # we possibly received a layout-less fragment
150
+ createElement('div', html)
117
151
 
118
152
  extend = $.extend
153
+
154
+ trim = $.trim
155
+
156
+ keys = Object.keys || (object) ->
157
+ result = []
158
+ for key in object
159
+ if object.hasOwnProperty(key)
160
+ result.push(key)
161
+ result
119
162
 
120
163
  each = (collection, block) ->
121
164
  block(item, index) for item, index in collection
@@ -137,7 +180,7 @@ up.util = (->
137
180
 
138
181
  isBlank = (object) ->
139
182
  isMissing(object) || # null or undefined
140
- (isObject(object) && Object.keys(object).length == 0) ||
183
+ (isObject(object) && keys(object).length == 0) ||
141
184
  (object.length == 0) # String, Array, jQuery
142
185
 
143
186
  presence = (object, checker = isPresent) ->
@@ -168,7 +211,8 @@ up.util = (->
168
211
  object if isGiven(object)
169
212
 
170
213
  # https://developer.mozilla.org/de/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
171
- isArray = Array.isArray
214
+ isArray = Array.isArray ||
215
+ (object) -> Object.prototype.toString.call(object) == '[object Array]'
172
216
 
173
217
  copy = (object) ->
174
218
  if isArray(object)
@@ -211,24 +255,20 @@ up.util = (->
211
255
  option = (args...) ->
212
256
  # This behavior is subtly different from detect!
213
257
  match = null
214
- args.every (arg) ->
258
+ for arg in args
215
259
  value = arg
216
260
  value = value() if isFunction(value)
217
261
  if isPresent(value)
218
262
  match = value
219
- false
220
- else
221
- true
263
+ break
222
264
  match
223
265
 
224
266
  detect = (array, tester) ->
225
267
  match = null
226
- array.every (element) ->
268
+ for element in array
227
269
  if tester(element)
228
270
  match = element
229
- false
230
- else
231
- true
271
+ break
232
272
  match
233
273
 
234
274
  select = (array, tester) ->
@@ -254,7 +294,7 @@ up.util = (->
254
294
  height: element.clientHeight
255
295
 
256
296
  temporaryCss = ($element, css, block) ->
257
- oldCss = $element.css(Object.keys(css))
297
+ oldCss = $element.css(keys(css))
258
298
  $element.css(css)
259
299
  memo = -> $element.css(oldCss)
260
300
  if block
@@ -296,25 +336,29 @@ up.util = (->
296
336
 
297
337
  ###
298
338
  cssAnimate = (elementOrSelector, lastFrame, opts) ->
299
- opts = options(opts,
300
- duration: 300,
301
- delay: 0,
302
- easing: 'ease'
303
- )
304
339
  $element = $(elementOrSelector)
305
- deferred = $.Deferred()
306
- transition =
307
- 'transition-property': Object.keys(lastFrame).join(', ')
308
- 'transition-duration': "#{opts.duration}ms"
309
- 'transition-delay': "#{opts.delay}ms"
310
- 'transition-timing-function': opts.easing
311
- withoutCompositing = forceCompositing($element)
312
- withoutTransition = temporaryCss($element, transition)
313
- $element.css(lastFrame)
314
- deferred.then(withoutCompositing)
315
- deferred.then(withoutTransition)
316
- setTimeout((-> deferred.resolve()), opts.duration + opts.delay)
317
- deferred.promise()
340
+ if up.browser.canCssAnimation()
341
+ opts = options(opts,
342
+ duration: 300,
343
+ delay: 0,
344
+ easing: 'ease'
345
+ )
346
+ deferred = $.Deferred()
347
+ transition =
348
+ 'transition-property': keys(lastFrame).join(', ')
349
+ 'transition-duration': "#{opts.duration}ms"
350
+ 'transition-delay': "#{opts.delay}ms"
351
+ 'transition-timing-function': opts.easing
352
+ withoutCompositing = forceCompositing($element)
353
+ withoutTransition = temporaryCss($element, transition)
354
+ $element.css(lastFrame)
355
+ deferred.then(withoutCompositing)
356
+ deferred.then(withoutTransition)
357
+ setTimeout((-> deferred.resolve()), opts.duration + opts.delay)
358
+ deferred.promise()
359
+ else
360
+ $element.css(lastFrame)
361
+ resolvedPromise()
318
362
 
319
363
  measure = ($element, options) ->
320
364
  coordinates = if options?.relative
@@ -375,6 +419,21 @@ up.util = (->
375
419
 
376
420
  locationFromXhr = (xhr) ->
377
421
  xhr.getResponseHeader('X-Up-Current-Location')
422
+
423
+ # willChangeHistory = (historyOption) ->
424
+ # isPresent(historyOption) && !castsToFalse(historyOption)
425
+
426
+ only = (object, keys...) ->
427
+ filtered = {}
428
+ for key in keys
429
+ if object.hasOwnProperty(key)
430
+ filtered[key] = object[key]
431
+ filtered
432
+
433
+ resolvedPromise = ->
434
+ deferred = $.Deferred()
435
+ deferred.resolve()
436
+ deferred.promise()
378
437
 
379
438
  # memoArray = ->
380
439
  # array = []
@@ -441,7 +500,9 @@ up.util = (->
441
500
  castsToFalse: castsToFalse
442
501
  locationFromXhr: locationFromXhr
443
502
  clientSize: clientSize
444
- # memoArray: memoArray
445
- # replaceInPlace: replaceInPlace
503
+ only: only
504
+ trim: trim
505
+ keys: keys
506
+ resolvedPromise: resolvedPromise
446
507
 
447
508
  )()