upjs-rails 0.2.1 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +3 -45
- data/Rakefile +3 -0
- data/bower.json +6 -1
- data/dist/up.css +27 -4
- data/dist/up.js +197 -60
- data/dist/up.min.css +1 -1
- data/dist/up.min.js +1 -1
- data/lib/assets/javascripts/up/bus.js.coffee +16 -6
- data/lib/assets/javascripts/up/flow.js.coffee +30 -13
- data/lib/assets/javascripts/up/form.js.coffee +40 -10
- data/lib/assets/javascripts/up/history.js.coffee +8 -1
- data/lib/assets/javascripts/up/magic.js.coffee +17 -5
- data/lib/assets/javascripts/up/modal.js.coffee +16 -2
- data/lib/assets/javascripts/up/motion.js.coffee +14 -1
- data/lib/assets/javascripts/up/navigation.js.coffee +15 -6
- data/lib/assets/javascripts/up/popup.js.coffee +21 -3
- data/lib/assets/javascripts/up/tooltip.js.coffee +15 -1
- data/lib/assets/javascripts/up/util.js.coffee +24 -8
- data/lib/assets/stylesheets/up/tooltip.css.sass +30 -5
- data/lib/upjs/rails/current_location.rb +19 -0
- data/lib/upjs/rails/version.rb +1 -1
- data/lib/upjs-rails.rb +1 -4
- data/spec_app/Gemfile.lock +11 -11
- data/spec_app/app/assets/stylesheets/application.css +2 -0
- data/spec_app/app/assets/stylesheets/jasmine_specs.css +5 -0
- data/spec_app/app/views/pages/home.html.haml +8 -1
- data/spec_app/spec/javascripts/support/jasmine.yml +1 -0
- data/spec_app/spec/javascripts/up/bus_spec.js.coffee +12 -0
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +92 -68
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +100 -0
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +12 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +47 -0
- data/spec_app/spec/javascripts/up/magic_spec.js.coffee +49 -0
- data/spec_app/spec/javascripts/up/marker_spec.js.coffee +14 -12
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +30 -0
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +25 -0
- data/spec_app/spec/javascripts/up/navigation_spec.js.coffee +60 -24
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +30 -0
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +46 -0
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +27 -25
- metadata +13 -3
- data/lib/upjs/rails/redirection.rb +0 -26
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,u,i,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,T,C,S,E,A,U,F,P,x,O,j,z,D,H,M,W,G,I,L,N,V,q,X,B,J,Q,R;return b=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)},z=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},L=function(t,n){var r,e;return r=D(t)?$("<a>").attr({href:t}).get(0):R(t),e=r.protocol+"//"+r.hostname,z(r.protocol,r.port)||(e+=":"+r.port),e+=r.pathname,(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,u,i,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(i=l[p],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=u.length;v>d;d++)switch(a=u[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,u,i,a;for(console.log("Creating selector from element",t),r=(n=t.attr("class"))?n.split(" "):[],e=t.attr("id"),u=t.prop("tagName").toLowerCase(),e&&(u+="#"+e),i=0,a=r.length;a>i;i++)o=r[i],u+="."+o;return u},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,u,i;for(i=[],r=o=0,u=t.length;u>o;r=++o)e=t[r],i.push(n(e,r));return i},P=function(t){return null===t},H=function(t){return void 0===t},C=function(t){return!H(t)},F=function(t){return H(t)||P(t)},E=function(t){return!F(t)},T=function(t){return F(t)||0===t.length},X=function(t,n){return null==n&&(n=O),n(t)?t:null},O=function(t){return!T(t)},S=function(t){return"function"==typeof t},D=function(t){return"string"==typeof t},A=function(t){return"object"==typeof t&&!!t},x=function(t){return A(t)||"function"==typeof t},U=function(t){return t instanceof jQuery},j=function(t){return S(t.then)},w=function(t){return E(t)?t:void 0},k=Array.isArray,a=function(t){return k(t)?t.slice():g({},t)},R=function(t){return U(t)?t.get(0):t},G=function(t,n){return g(a(t),n)},V=function(t,n){var r,e,o,u;if(o=t?a(t):{},n)for(e in n)r=n[e],u=o[e],E(u)?x(r)&&x(u)&&(o[e]=V(u,r)):o[e]=r;return o},N=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],m(n,function(t){var n;return n=t,S(n)&&(n=n()),O(n)})},m=function(t,n){var r;return r=null,t.every(function(t){return n(t)?(r=t,!1):!0}),r},J=function(t,n){var r;return r=[],d(t,function(t){return n(t)?r.push(t):void 0}),r},B=function(){var n,r,e,o;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=e.length;o>t;t++)r=e[t],u.push(n.attr(r));return u}(),m(o,O)},I=function(t){return setTimeout(t,0)},M=function(t){return t[t.length-1]},u=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},Q=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},f=function(t,n,r){var e,o,u,i;return r=V(r,{duration:300,delay:0,easing:"ease"}),e=$(t),o=$.Deferred(),u={"transition-property":Object.keys(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},i=Q(e,u),e.css(n),o.then(i),setTimeout(function(){return o.resolve()},r.duration+r.delay),o.promise()},W=function(t,n){var r,e,o;return e=t.offset(),r={left:e.left,top:e.top,width:t.outerWidth(),height:t.outerHeight()},(null!=n?n.full:void 0)&&(o=u(),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,u,i;for(u=t.get(0).attributes,i=[],e=0,o=u.length;o>e;e++)r=u[e],i.push(r.specified?n.attr(r.name,r.value):void 0);return i},q=function(t){var n,r;return r=W(t),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",margin:0,position:"absolute"}),n.css(r),n.addClass("up-ghost"),n.prependTo(document.body)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},i=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},e=function(t){return"false"===String(t)},{presentAttr:B,createElement:c,normalizeUrl:L,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:b,ajax:r,extend:g,copy:a,merge:G,options:V,option:N,error:h,each:d,detect:m,select:J,last:M,isNull:P,isDefined:C,isUndefined:H,isGiven:E,isMissing:F,isPresent:O,isBlank:T,presence:X,isObject:x,isFunction:S,isString:D,isJQuery:U,isPromise:j,isHash:A,ifGiven:w,unwrap:R,nextFrame:I,measure:W,temporaryCss:Q,cssAnimate:f,prependGhost:q,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:i,isArray:k,castsToTrue:o,castsToFalse:e}}()}.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,u,i,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},i=function(){return n=up.util.copy(e)},u=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)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,r,e,o,u,i,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()},i=function(t,n,r){var o;return r=l.options(r),o=l.presence(t)?t:l.createSelectorFromElement($(t)),(l.isMissing(r.history)||l.castsToTrue(r.history))&&(r.history=n),(l.isMissing(r.source)||l.castsToTrue(r.source))&&(r.source=n),l.get(n,{selector:o}).done(function(t){return e(o,t,r)}).fail(l.error)},e=function(t,n,r){var e,u,i,a,s,c,f,m,d,h;for(r=l.options(r,{historyMethod:"push"}),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],u=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector)),(i=a.querySelector(s.selector))?(e=$(i),h.push(p(u,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 n.each(function(){var n;return n=$(this),"function"==typeof r.insert&&r.insert(n),r.history&&(r.title&&(document.title=r.title),up.history[r.historyMethod](r.history)),s(n,l.presence(r.source)||r.history),t(n),up.ready(n)})},p=function(t,e,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=e.children(),t[s](e.contents()),l.copyAttributes(e,t),r(a,i),up.animate(e,u)):n(t,{animation:function(){return e.insertAfter(t),r(e,i),t.is("body")&&"none"!==u&&l.error("Cannot apply transitions to body-elements",u),up.morph(t,e,u)}})},o=function(t,n){var r,e,o,u,i,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)u=e[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:i[1],pseudoClass:i[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()})},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: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(){up.magic=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d;return d=up.util,t="up-destroyable",n="up-destroyer",c=[],i=null,s=function(t,n,r){var e,o;return e=[t,n,function(t){return r.apply(this,[t,$(this)])}],c.push(e),(o=$(document)).on.apply(o,e)},e=[],u=null,r=function(t,n){return e.push({selector:t,callback:n})},o=function(r){var o,u,i,a;for(console.log("Compiling fragment",r,"with",e),a=[],u=0,i=e.length;i>u;u++)o=e[u],console.log("running",o.selector,"on",r),a.push(d.findWithSelf(r,o.selector).each(function(){var r,e;return r=$(this),e=o.callback.apply(this,[r]),console.log("got destroyer",e),d.isFunction(e)?(r.addClass(t),r.data(n,e)):void 0}));return a},a=function(r){return d.findWithSelf(r,"."+t).each(function(){var t,r;return t=$(this),(r=t.data(n))()})},m=function(){return i=d.copy(c),u=d.copy(e)},f=function(){var t,n,r,o;for(n=0,r=c.length;r>n;n++)t=c[n],d.contains(i,t)||(o=$(document)).off.apply(o,t);return c=d.copy(i),e=d.copy(u)},l=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},p=function(t){return s("keydown","body",function(n){return d.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return l(document.body)}),up.bus.on("fragment:ready",o),up.bus.on("fragment:destroy",a),up.bus.on("framework:ready",m),up.bus.on("framework:reset",f),{awaken:r,on:s,ready:l,onEscape:p}}(),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,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(r){return t(r)?void 0:n("replace",r)},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("null state")},setTimeout(function(){return $(window).on("popstate",r),o(up.browser.url())},200),{push:e,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d,h;return d=up.util,u={duration:300,delay:0,easing:"ease"},r={},o={},m={},i={},t=function(n,r,o){var i;return i=$(n),o=d.options(o,u),d.isFunction(r)?e(r(i,o),["Animation did not return a Promise",r]):d.isString(r)?t(i,a(r),o):d.isHash(r)?d.cssAnimate(i,r,o):d.error("Unknown animation type",r)},a=function(t){return r[t]||d.error("Unknown animation",n)},h=function(t,n,r){var e,o,u,i;return o=null,e=null,d.temporaryCss(n,{display:"none"},function(){return o=d.prependGhost(t).addClass("up-destroying")}),d.temporaryCss(t,{display:"none"},function(){return e=d.prependGhost(n)}),t.css({visibility:"hidden"}),u=d.temporaryCss(n,{display:"none"}),i=r(o,e),i.then(function(){return o.remove(),e.remove(),t.css({display:"none"}),u()})},e=function(t,n){return d.isPromise(t)||d.error.apply(d,n),t},s=function(n,o,i,a){var c,p,l,f,v;return a=d.options(u),p=$(n),c=$(o),v=d.presence(i,d.isFunction)||m[i],v?h(p,c,function(t,n){return e(v(t,n,a),["Transition did not return a promise",i])}):(l=r[i])?(p.hide(),t(c,l,a)):d.isString(i)&&i.indexOf("/")>=0?(f=i.split("/"),v=function(n,r,e){return $.when(t(n,f[0],e),t(r,f[1],e))},s(p,c,v,a)):d.error("Unknown transition: "+i)},f=function(t,n){return m[t]=n},n=function(t,n){return r[t]=n},l=function(){return o=d.copy(r),i=d.copy(m)},p=function(){return r=d.copy(o),m=d.copy(i)},c=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},n("none",c),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){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"-100%"},r)}),n("move-from-top",function(n,r){return n.css({"margin-top":"-100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-bottom",function(n,r){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"100%"},r)}),n("move-from-bottom",function(n,r){return n.css({"margin-top":"100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-left",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"-100%"},r)}),n("move-from-left",function(n,r){return n.css({"margin-left":"-100%"}),t(n,{"margin-left":"0%"},r)}),n("move-to-right",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"100%"},r)}),n("move-from-right",function(n,r){return n.css({"margin-left":"100%"}),t(n,{"margin-left":"0%"},r)}),n("roll-down",function(n,r){var e,o;return e=n.height(),o=d.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:e+"px"},r).then(o)}),f("none",c),f("move-left",function(n,r,e){return $.when(t(n,"move-to-left",e),t(r,"move-from-right",e))}),f("move-right",function(n,r,e){return $.when(t(n,"move-to-right",e),t(r,"move-from-left",e))}),f("move-up",function(n,r,e){return $.when(t(n,"move-to-top",e),t(r,"move-from-bottom",e))}),f("move-down",function(n,r,e){return $.when(t(n,"move-to-bottom",e),t(r,"move-from-top",e))}),f("cross-fade",function(n,r,e){return $.when(t(n,"fade-out",e),t(r,"fade-in",e))}),up.bus.on("framework:ready",l),up.bus.on("framework:reset",p),{morph:s,animate:t,transition:f,animation:n,none:c}}(),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,u;return r=$(t),n=e.options(n),u=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,u,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;return r=$(t).closest("form"),n=u.options(n),s=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),c=u.option(n.transition,r.attr("up-transition")),o=u.option(n.failTransition,r.attr("up-fail-transition")),r.addClass("up-active"),a={url:r.attr("action")||up.browser.url(),type:(null!=(l=r.attr("method"))?l.toUpperCase():void 0)||"POST",data:r.serialize(),selector:s},p=function(t){var n,r;return r=i?u.isString(i)?i:(n=t.getResponseHeader("X-Up-Previous-Redirect-Location"))?n:"GET"===a.type?a.url+"?"+a.data:void 0:void 0,u.option(r,!1)},u.ajax(a).always(function(){return r.removeClass("up-active")}).done(function(t,n,r){return up.flow.implant(s,t,{history:p(r),transition:c})}).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,u,i,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),u(n)},u=function(t){var n,r,e,o,u,i,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&&((u=parseInt(t.css("left")))?t.css("left",u-e):(i=parseInt(t.css("right")))&&t.css("right",i+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)},i=function(t,o){var u,i,a,s,l,f,m,d;return u=$(t),o=c.options(o),d=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),l=c.option(o.origin,u.attr("up-origin"),r.origin),a=c.option(o.animation,u.attr("up-animation"),r.openAnimation),m=c.option(o.sticky,u.is("[up-sticky]")),s=c.option(o.history,u.attr("up-history"),!1),n(),i=e(u,f,m),up.replace(f,d,{history:s,insert:function(){return p(u,i,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():i(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}),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,r,e,o,u,i,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,u,i,c;return i=$(a()),e&&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(r)&&u.css("height",r),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,p,l,f,m,d,h;return u=$(t),o=s.options(o),d=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),r.width),p=s.option(o.height,u.attr("up-height"),r.height),a=s.option(o.animation,u.attr("up-animation"),r.openAnimation),m=s.option(o.sticky,u.is("[up-sticky]")),l=s.option(o.history,u.attr("up-history"),!0),n(),i=e(f,h,p,m),up.replace(f,d,{history:l,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: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():u(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-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:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,r){return r.closest(".up-modal")?n():void 0}),{open:u,close:n,source:i,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,u,i;return u=o.measure(t),i=o.measure(n),e=function(){switch(r){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",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,u){var i,a,s,c,p;return null==u&&(u={}),i=$(r),c=o.option(u.html,i.attr("up-tooltip")),p=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),e(i,a,p),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 r(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.magic.onEscape(function(){return t()}),{open:r,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,r,e,o,u,i,a;return t="up-active",n="up-current",e="a[href], a[up-target], [up-follow], [up-modal], [up-popup]",r="."+t,u=function(){var t,r,o;return o=up.util.normalizeUrl(up.browser.url(),{search:!1}),t=up.modal.source(),r=up.popup.source(),up.util.each($(e),function(e){var u,i;return u=$(e),i=up.link.resolveUrl(u),i=up.util.normalizeUrl(i,{search:!1}),i===o||i===t||i===r?u.addClass(n):u.removeClass(n)})},i=function(n){return a(),n=o(n),n.addClass(t)},o=function(t){return up.util.presence(t.parents(e))||t},a=function(){return $(r).removeClass(t)},up.on("click",e,function(t,n){return i(n)}),up.bus.on("fragment:ready",function(){return a(),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;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,r,e,o,u,i,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,T,S,C,E,A,F,U,x,P,j,O,D,H,z,M,W,G,I,X,L,N,V,q,B,J,Q,_,R;return b=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},L=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,u,i,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(i=l[p],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=u.length;v>d;d++)switch(a=u[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,u,i,a;for(console.log("Creating selector from element",t),r=(n=t.attr("class"))?n.split(" "):[],e=t.attr("id"),u=t.prop("tagName").toLowerCase(),e&&(u+="#"+e),i=0,a=r.length;a>i;i++)o=r[i],u+="."+o;return u},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,u,i;for(i=[],r=o=0,u=t.length;u>o;r=++o)e=t[r],i.push(n(e,r));return i},x=function(t){return null===t},z=function(t){return void 0===t},S=function(t){return!z(t)},U=function(t){return z(t)||x(t)},E=function(t){return!U(t)},T=function(t){return U(t)||0===t.length},B=function(t,n){return null==n&&(n=j),n(t)?t:null},j=function(t){return!T(t)},C=function(t){return"function"==typeof t},H=function(t){return"string"==typeof t},A=function(t){return"object"==typeof t&&!!t},P=function(t){return A(t)||"function"==typeof t},F=function(t){return t instanceof jQuery},O=function(t){return C(t.then)},w=function(t){return E(t)?t:void 0},k=Array.isArray,a=function(t){return k(t)?t.slice():g({},t)},R=function(t){return F(t)?t.get(0):t},I=function(t,n){return g(a(t),n)},V=function(t,n){var r,e,o,u;if(o=t?a(t):{},n)for(e in n)r=n[e],u=o[e],E(u)?P(r)&&P(u)&&(o[e]=V(u,r)):o[e]=r;return o},N=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()),j(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,u;for(u=[],t=0,o=e.length;o>t;t++)r=e[t],u.push(n.attr(r));return u}(),m(o,j)},X=function(t){return setTimeout(t,0)},M=function(t){return t[t.length-1]},u=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},f=function(t,n,r){var e,o,u,i;return r=V(r,{duration:300,delay:0,easing:"ease"}),e=$(t),o=$.Deferred(),u={"transition-property":Object.keys(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},i=_(e,u),e.css(n),o.then(i),setTimeout(function(){return o.resolve()},r.duration+r.delay),o.promise()},G=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,width:t.outerWidth(),height:t.outerHeight()},(null!=n?n.full:void 0)&&(o=u(),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,u,i;for(u=t.get(0).attributes,i=[],e=0,o=u.length;o>e;e++)r=u[e],i.push(r.specified?n.attr(r.name,r.value):void 0);return i},q=function(t){var n,r;return r=G(t),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",margin:0,position:"absolute"}),n.css(r),n.addClass("up-ghost"),n.prependTo(document.body)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},i=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},e=function(t){return"false"===String(t)},W=function(t){return t.getResponseHeader("X-Up-Current-Location")},{presentAttr:J,createElement:c,normalizeUrl:L,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:b,ajax:r,extend:g,copy:a,merge:I,options:V,option:N,error:h,each:d,detect:m,select:Q,last:M,isNull:x,isDefined:S,isUndefined:z,isGiven:E,isMissing:U,isPresent:j,isBlank:T,presence:B,isObject:P,isFunction:C,isString:H,isJQuery:F,isPromise:O,isHash:A,ifGiven:w,unwrap:R,nextFrame:X,measure:G,temporaryCss:_,cssAnimate:f,prependGhost:q,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:i,isArray:k,castsToTrue:o,castsToFalse:e,locationFromXhr:W}}()}.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,u,i,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},i=function(){return n=up.util.copy(e)},u=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)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,r,e,o,u,i,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()},i=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,u,i){var a;return(a=l.locationFromXhr(i))&&(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,u,i,a,s,c,f,m,d,h;for(r=l.options(r,{historyMethod:"push"}),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],u=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector)),(i=a.querySelector(s.selector))?(e=$(i),h.push(p(u,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 n.each(function(){var n;return n=$(this),"function"==typeof r.insert&&r.insert(n),r.history&&(r.title&&(document.title=r.title),up.history[r.historyMethod](r.history)),s(n,l.presence(r.source)||r.history),t(n),up.ready(n)})},p=function(t,e,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=e.children(),t[s](e.contents()),l.copyAttributes(e,t),r(a,i),up.animate(e,u)):n(t,{animation:function(){return e.insertAfter(t),r(e,i),t.is("body")&&"none"!==u&&l.error("Cannot apply transitions to body-elements",u),up.morph(t,e,u)}})},o=function(t,n){var r,e,o,u,i,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)u=e[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:i[1],pseudoClass:i[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()})},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: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(){up.magic=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d;return d=up.util,t="up-destroyable",n="up-destroyer",c=[],i=null,s=function(t,n,r){var e,o;return e=[t,n,function(t){return r.apply(this,[t,$(this)])}],c.push(e),(o=$(document)).on.apply(o,e)},e=[],u=null,r=function(t,n){return e.push({selector:t,callback:n})},o=function(r){var o,u,i,a;for(a=[],u=0,i=e.length;i>u;u++)o=e[u],a.push(d.findWithSelf(r,o.selector).each(function(){var r,e;return r=$(this),e=o.callback.apply(this,[r]),d.isFunction(e)?(r.addClass(t),r.data(n,e)):void 0}));return a},a=function(r){return d.findWithSelf(r,"."+t).each(function(){var t,r;return t=$(this),(r=t.data(n))()})},m=function(){return i=d.copy(c),u=d.copy(e)},f=function(){var t,n,r,o;for(n=0,r=c.length;r>n;n++)t=c[n],d.contains(i,t)||(o=$(document)).off.apply(o,t);return c=d.copy(i),e=d.copy(u)},l=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},p=function(t){return s("keydown","body",function(n){return d.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return l(document.body)}),up.bus.on("fragment:ready",o),up.bus.on("fragment:destroy",a),up.bus.on("framework:ready",m),up.bus.on("framework:reset",f),{awaken:r,on:s,ready:l,onEscape:p}}(),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,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(r){return t(r)?void 0:n("replace",r)},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("null state")},setTimeout(function(){return $(window).on("popstate",r),o(up.browser.url())},200),{push:e,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d,h;return d=up.util,u={duration:300,delay:0,easing:"ease"},r={},o={},m={},i={},t=function(n,r,o){var i;return i=$(n),o=d.options(o,u),d.isFunction(r)?e(r(i,o),["Animation did not return a Promise",r]):d.isString(r)?t(i,a(r),o):d.isHash(r)?d.cssAnimate(i,r,o):d.error("Unknown animation type",r)},a=function(t){return r[t]||d.error("Unknown animation",n)},h=function(t,n,r){var e,o,u,i;return o=null,e=null,d.temporaryCss(n,{display:"none"},function(){return o=d.prependGhost(t).addClass("up-destroying")}),d.temporaryCss(t,{display:"none"},function(){return e=d.prependGhost(n)}),t.css({visibility:"hidden"}),u=d.temporaryCss(n,{display:"none"}),i=r(o,e),i.then(function(){return o.remove(),e.remove(),t.css({display:"none"}),u()})},e=function(t,n){return d.isPromise(t)||d.error.apply(d,n),t},s=function(n,o,i,a){var c,p,l,f,v;return a=d.options(u),p=$(n),c=$(o),v=d.presence(i,d.isFunction)||m[i],v?h(p,c,function(t,n){return e(v(t,n,a),["Transition did not return a promise",i])}):(l=r[i])?(p.hide(),t(c,l,a)):d.isString(i)&&i.indexOf("/")>=0?(f=i.split("/"),v=function(n,r,e){return $.when(t(n,f[0],e),t(r,f[1],e))},s(p,c,v,a)):d.error("Unknown transition: "+i)},f=function(t,n){return m[t]=n},n=function(t,n){return r[t]=n},l=function(){return o=d.copy(r),i=d.copy(m)},p=function(){return r=d.copy(o),m=d.copy(i)},c=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},n("none",c),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){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"-100%"},r)}),n("move-from-top",function(n,r){return n.css({"margin-top":"-100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-bottom",function(n,r){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"100%"},r)}),n("move-from-bottom",function(n,r){return n.css({"margin-top":"100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-left",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"-100%"},r)}),n("move-from-left",function(n,r){return n.css({"margin-left":"-100%"}),t(n,{"margin-left":"0%"},r)}),n("move-to-right",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"100%"},r)}),n("move-from-right",function(n,r){return n.css({"margin-left":"100%"}),t(n,{"margin-left":"0%"},r)}),n("roll-down",function(n,r){var e,o;return e=n.height(),o=d.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:e+"px"},r).then(o)}),f("none",c),f("move-left",function(n,r,e){return $.when(t(n,"move-to-left",e),t(r,"move-from-right",e))}),f("move-right",function(n,r,e){return $.when(t(n,"move-to-right",e),t(r,"move-from-left",e))}),f("move-up",function(n,r,e){return $.when(t(n,"move-to-top",e),t(r,"move-from-bottom",e))}),f("move-down",function(n,r,e){return $.when(t(n,"move-to-bottom",e),t(r,"move-from-top",e))}),f("cross-fade",function(n,r,e){return $.when(t(n,"fade-out",e),t(r,"fade-in",e))}),up.bus.on("framework:ready",l),up.bus.on("framework:reset",p),{morph:s,animate:t,transition:f,animation:n,none:c}}(),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,u;return r=$(t),n=e.options(n),u=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,u,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,u,i,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),u(n)},u=function(t){var n,r,e,o,u,i,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&&((u=parseInt(t.css("left")))?t.css("left",u-e):(i=parseInt(t.css("right")))&&t.css("right",i+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)},i=function(t,o){var u,i,a,s,l,f,m,d;return u=$(t),o=c.options(o),d=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),l=c.option(o.origin,u.attr("up-origin"),r.origin),a=c.option(o.animation,u.attr("up-animation"),r.openAnimation),m=c.option(o.sticky,u.is("[up-sticky]")),s=c.option(o.history,u.attr("up-history"),!1),n(),i=e(u,f,m),up.replace(f,d,{history:s,insert:function(){return p(u,i,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():i(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:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,r,e,o,u,i,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,u,i,c;return i=$(a()),e&&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(r)&&u.css("height",r),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,p,l,f,m,d,h;return u=$(t),o=s.options(o),d=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),r.width),p=s.option(o.height,u.attr("up-height"),r.height),a=s.option(o.animation,u.attr("up-animation"),r.openAnimation),m=s.option(o.sticky,u.is("[up-sticky]")),l=s.option(o.history,u.attr("up-history"),!0),n(),i=e(f,h,p,m),up.replace(f,d,{history:l,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: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():u(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-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: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:u,close:n,source:i,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,u,i;return u=o.measure(t),i=o.measure(n),e=function(){switch(r){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",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,u){var i,a,s,c,p;return null==u&&(u={}),i=$(r),c=o.option(u.html,i.attr("up-tooltip")),p=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),e(i,a,p),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 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,u,i,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,i=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},u=function(){var t,r,o;return o=i(up.browser.url()),t=i(up.modal.source()),r=i(up.popup.source()),s.each($(e),function(e){var u,a;return u=$(e),a=up.link.resolveUrl(u),a=i(a),a===o||a===t||a===r?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(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(),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;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);
|
@@ -2,15 +2,25 @@
|
|
2
2
|
Framework events
|
3
3
|
================
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
This class is kind-of internal and in constant flux.
|
6
|
+
|
7
|
+
The framework event bus might eventually be rolled
|
8
|
+
into regular document events.
|
9
9
|
|
10
|
+
\#\#\# Available events
|
11
|
+
|
10
12
|
- `app:ready`
|
11
13
|
- `fragment:ready` with arguments `($fragment)`
|
12
14
|
- `fragment:destroy` with arguments `($fragment)`
|
13
15
|
|
16
|
+
\#\#\# Incomplete documentation!
|
17
|
+
|
18
|
+
We need to work on this page:
|
19
|
+
|
20
|
+
- Decide whether to refactor this into document events
|
21
|
+
- Document events
|
22
|
+
|
23
|
+
|
14
24
|
@class up.bus
|
15
25
|
###
|
16
26
|
up.bus = (->
|
@@ -47,7 +57,7 @@ up.bus = (->
|
|
47
57
|
Registers an event handler to be called when the given
|
48
58
|
event is triggered.
|
49
59
|
|
50
|
-
@method up.bus.
|
60
|
+
@method up.bus.on
|
51
61
|
@param {String} eventName
|
52
62
|
The event name to match.
|
53
63
|
@param {Function} handler
|
@@ -64,7 +74,7 @@ up.bus = (->
|
|
64
74
|
@method up.bus.emit
|
65
75
|
@param {String} eventName
|
66
76
|
The name of the event.
|
67
|
-
@param
|
77
|
+
@param args...
|
68
78
|
The arguments that describe the event.
|
69
79
|
###
|
70
80
|
emit = (eventName, args...) ->
|
@@ -1,10 +1,18 @@
|
|
1
1
|
###*
|
2
2
|
Changing page fragments programmatically
|
3
3
|
========================================
|
4
|
+
|
5
|
+
This module contains Up's core functions to insert, change
|
6
|
+
or destroy page fragments.
|
4
7
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
+
\#\#\# Incomplete documentation!
|
9
|
+
|
10
|
+
We need to work on this page:
|
11
|
+
|
12
|
+
- Explain the UJS approach vs. pragmatic approach
|
13
|
+
- Examples
|
14
|
+
|
15
|
+
|
8
16
|
@class up.flow
|
9
17
|
###
|
10
18
|
up.flow = (->
|
@@ -49,19 +57,28 @@ up.flow = (->
|
|
49
57
|
selectorOrElement
|
50
58
|
else
|
51
59
|
u.createSelectorFromElement($(selectorOrElement))
|
52
|
-
|
53
|
-
if u.isMissing(options.history) || u.castsToTrue(options.history)
|
54
|
-
options.history = url
|
55
|
-
|
56
|
-
if u.isMissing(options.source) || u.castsToTrue(options.source)
|
57
|
-
options.source = url
|
58
60
|
|
59
|
-
u.
|
60
|
-
|
61
|
-
|
61
|
+
u.ajax(
|
62
|
+
url: url,
|
63
|
+
selector: selector
|
64
|
+
)
|
65
|
+
.done (html, textStatus, xhr) ->
|
66
|
+
# The server can send us the current path using a header value.
|
67
|
+
# This way we know the actual URL if the server has redirected.
|
68
|
+
if currentLocation = u.locationFromXhr(xhr)
|
69
|
+
url = currentLocation
|
70
|
+
|
71
|
+
if u.isMissing(options.history) || u.castsToTrue(options.history)
|
72
|
+
options.history = url
|
73
|
+
|
74
|
+
if u.isMissing(options.source) || u.castsToTrue(options.source)
|
75
|
+
options.source = url
|
76
|
+
|
77
|
+
implant(selector, html, options)
|
78
|
+
.fail(u.error)
|
62
79
|
|
63
80
|
###*
|
64
|
-
Replaces the given selector with the same selector from the given HTML string.
|
81
|
+
Replaces the given selector with the same CSS selector from the given HTML string.
|
65
82
|
|
66
83
|
@method up.flow.implant
|
67
84
|
@protected
|
@@ -2,7 +2,22 @@
|
|
2
2
|
Forms and controls
|
3
3
|
==================
|
4
4
|
|
5
|
-
|
5
|
+
Up.js comes with functionality to submit forms without
|
6
|
+
leaving the current page. This means you can replace page fragments,
|
7
|
+
open dialogs with sub-forms, etc. all without losing form state.
|
8
|
+
|
9
|
+
\#\#\# Incomplete documentation!
|
10
|
+
|
11
|
+
We need to work on this page:
|
12
|
+
|
13
|
+
- Explain how to display form errors
|
14
|
+
- Explain that the server needs to send 2xx or 5xx status codes so
|
15
|
+
Up.js can decide whether the form submission was successful
|
16
|
+
- Explain that the server needs to send an `X-Up-Current-Location` header
|
17
|
+
if an successful form submission resulted in a redirect
|
18
|
+
- Examples
|
19
|
+
|
20
|
+
|
6
21
|
|
7
22
|
@class up.form
|
8
23
|
###
|
@@ -12,14 +27,20 @@ up.form = (->
|
|
12
27
|
|
13
28
|
###*
|
14
29
|
Submits a form using the Up.js flow:
|
15
|
-
|
30
|
+
|
16
31
|
up.submit('form.new_user')
|
17
|
-
|
32
|
+
|
33
|
+
Instead of loading a new page, the form is submitted via AJAX.
|
34
|
+
The response is parsed for a CSS selector and the matching elements will
|
35
|
+
replace corresponding elements on the current page.
|
36
|
+
|
18
37
|
@method up.submit
|
19
38
|
@param {Element|jQuery|String} formOrSelector
|
20
39
|
A reference or selector for the form to submit.
|
21
40
|
If the argument points to an element that is not a form,
|
22
41
|
Up.js will search its ancestors for the closest form.
|
42
|
+
@param {String} [options.url]
|
43
|
+
@param {String} [options.method]
|
23
44
|
@param {String} [options.target]
|
24
45
|
@param {String} [options.failTarget]
|
25
46
|
@param {Boolean|String} [options.history=true]
|
@@ -43,22 +64,26 @@ up.form = (->
|
|
43
64
|
historyOption = u.option(options.history, $form.attr('up-history'), true)
|
44
65
|
successTransition = u.option(options.transition, $form.attr('up-transition'))
|
45
66
|
failureTransition = u.option(options.failTransition, $form.attr('up-fail-transition'))
|
67
|
+
httpMethod = u.option(options.method, $form.attr('up-method'), $form.attr('data-method'), $form.attr('method'), 'post').toUpperCase()
|
68
|
+
url = u.option(options.url, $form.attr('action'), up.browser.url())
|
46
69
|
|
47
70
|
$form.addClass('up-active')
|
48
71
|
|
49
72
|
request = {
|
50
|
-
url:
|
51
|
-
type:
|
73
|
+
url: url
|
74
|
+
type: httpMethod
|
52
75
|
data: $form.serialize(),
|
53
76
|
selector: successSelector
|
54
77
|
}
|
55
78
|
|
56
79
|
successUrl = (xhr) ->
|
57
80
|
url = if historyOption
|
58
|
-
if
|
81
|
+
if historyOption == 'false'
|
82
|
+
false
|
83
|
+
else if u.isString(historyOption)
|
59
84
|
historyOption
|
60
|
-
else if
|
61
|
-
|
85
|
+
else if currentLocation = u.locationFromXhr(xhr)
|
86
|
+
currentLocation
|
62
87
|
else if request.type == 'GET'
|
63
88
|
request.url + '?' + request.data
|
64
89
|
u.option(url, false)
|
@@ -145,7 +170,7 @@ up.form = (->
|
|
145
170
|
Submits the form through AJAX, searches the response for the selector
|
146
171
|
given in `up-target` and replaces the selector content in the current page:
|
147
172
|
|
148
|
-
<form method="
|
173
|
+
<form method="post" action="/users" up-target=".main">
|
149
174
|
...
|
150
175
|
</form>
|
151
176
|
|
@@ -153,9 +178,14 @@ up.form = (->
|
|
153
178
|
@ujs
|
154
179
|
@param {String} up-target
|
155
180
|
@param {String} [up-fail-target]
|
156
|
-
@param {String} [up-history]
|
157
181
|
@param {String} [up-transition]
|
158
182
|
@param {String} [up-fail-transition]
|
183
|
+
@param {String} [up-history]
|
184
|
+
@param {String} [up-method]
|
185
|
+
The HTTP method to be used to submit the form
|
186
|
+
(`get`, `post`, `put`, `delete`, `patch`).
|
187
|
+
Alternately you can use an attribute `data-method` (Rails UJS)
|
188
|
+
or `method` (vanilla HTML) for the same purpose.
|
159
189
|
###
|
160
190
|
up.on 'submit', 'form[up-target]', (event, $form) ->
|
161
191
|
event.preventDefault()
|
@@ -2,8 +2,15 @@
|
|
2
2
|
Manipulating the browser history
|
3
3
|
=======
|
4
4
|
|
5
|
-
|
5
|
+
\#\#\# Incomplete documentation!
|
6
6
|
|
7
|
+
We need to work on this page:
|
8
|
+
|
9
|
+
- Explain how the other modules manipulate history
|
10
|
+
- Decide whether we want to expose these methods as public API
|
11
|
+
- Document methods and parameters
|
12
|
+
|
13
|
+
|
7
14
|
@class up.history
|
8
15
|
###
|
9
16
|
up.history = (->
|
@@ -2,7 +2,19 @@
|
|
2
2
|
Registering behavior and custom elements
|
3
3
|
========================================
|
4
4
|
|
5
|
-
|
5
|
+
Up.js keeps a persistent Javascript environment during page transitions.
|
6
|
+
To prevent memory leaks it is important to cleanly set up and tear down
|
7
|
+
event handlers and custom elements.
|
8
|
+
|
9
|
+
\#\#\# Incomplete documentation!
|
10
|
+
|
11
|
+
We need to work on this page:
|
12
|
+
|
13
|
+
- Explain when to use `up.on` and when to use `up.awaken`
|
14
|
+
- Example for integrating an external JS lib that is not aware of Up.js
|
15
|
+
- Example for defining a custom element
|
16
|
+
- Tell more about memory leaks and why they don't matter
|
17
|
+
so much when you have full page loads.
|
6
18
|
|
7
19
|
@class up.magic
|
8
20
|
###
|
@@ -23,7 +35,7 @@ up.magic = (->
|
|
23
35
|
A space-separated list of event names to bind.
|
24
36
|
@param {String} selector
|
25
37
|
The selector an on which the event must be triggered.
|
26
|
-
@param {Function} behavior
|
38
|
+
@param {Function(event, $element)} behavior
|
27
39
|
The handler that should be called.
|
28
40
|
###
|
29
41
|
liveDescriptions = []
|
@@ -62,13 +74,13 @@ up.magic = (->
|
|
62
74
|
callback: awakener
|
63
75
|
|
64
76
|
compile = ($fragment) ->
|
65
|
-
console.log("Compiling fragment", $fragment, "with", awakeners)
|
77
|
+
# console.log("Compiling fragment", $fragment, "with", awakeners)
|
66
78
|
for awakener in awakeners
|
67
|
-
console.log("running", awakener.selector, "on", $fragment)
|
79
|
+
# console.log("running", awakener.selector, "on", $fragment)
|
68
80
|
util.findWithSelf($fragment, awakener.selector).each ->
|
69
81
|
$element = $(this)
|
70
82
|
destroyer = awakener.callback.apply(this, [$element])
|
71
|
-
console.log("got destroyer", destroyer)
|
83
|
+
# console.log("got destroyer", destroyer)
|
72
84
|
if util.isFunction(destroyer)
|
73
85
|
$element.addClass(DESTROYABLE_CLASS)
|
74
86
|
$element.data(DESTROYER_KEY, destroyer)
|
@@ -2,7 +2,18 @@
|
|
2
2
|
Modal dialogs
|
3
3
|
=============
|
4
4
|
|
5
|
-
|
5
|
+
Instead of linking to another page fragment, you can also choose
|
6
|
+
to open any target CSS selector in a modal dialog.
|
7
|
+
|
8
|
+
For popup overlays see [up.popup](/up.popup) instead.
|
9
|
+
|
10
|
+
\#\#\# Incomplete documentation!
|
11
|
+
|
12
|
+
We need to work on this page:
|
13
|
+
|
14
|
+
- Show the HTML structure of the dialog elements, and how to style them via CSS
|
15
|
+
- Explain how dialogs auto-close themselves when a fragment changes behind the modal layer
|
16
|
+
- Document method parameters
|
6
17
|
|
7
18
|
@class up.modal
|
8
19
|
###
|
@@ -146,7 +157,6 @@ up.modal = (->
|
|
146
157
|
|
147
158
|
@method a[up-modal]
|
148
159
|
@ujs
|
149
|
-
@param up-target
|
150
160
|
@param [up-sticky]
|
151
161
|
###
|
152
162
|
up.on('click', 'a[up-modal]', (event, $link) ->
|
@@ -184,6 +194,10 @@ up.modal = (->
|
|
184
194
|
close()
|
185
195
|
)
|
186
196
|
|
197
|
+
# The framework is reset between tests, so also close
|
198
|
+
# a currently open modal dialog.
|
199
|
+
up.bus.on 'framework:reset', close
|
200
|
+
|
187
201
|
open: open
|
188
202
|
close: close
|
189
203
|
source: source
|
@@ -2,7 +2,20 @@
|
|
2
2
|
Animation and transitions
|
3
3
|
=========================
|
4
4
|
|
5
|
-
|
5
|
+
Any fragment change in Up.js can be animated.
|
6
|
+
Up.js ships with a number of predefined animations and transitions,
|
7
|
+
and you can easily define your own using Javascript or CSS.
|
8
|
+
|
9
|
+
|
10
|
+
\#\#\# Incomplete documentation!
|
11
|
+
|
12
|
+
We need to work on this page:
|
13
|
+
|
14
|
+
- Explain the difference between transitions and animations
|
15
|
+
- Demo the built-in animations and transitions
|
16
|
+
- Examples for defining your own animations and transitions
|
17
|
+
- Explain ghosting
|
18
|
+
|
6
19
|
|
7
20
|
@class up.motion
|
8
21
|
###
|
@@ -25,22 +25,31 @@ From Up's point of view the "current" location is either:
|
|
25
25
|
###
|
26
26
|
up.navigation = (->
|
27
27
|
|
28
|
+
u = up.util
|
29
|
+
|
28
30
|
CLASS_ACTIVE = 'up-active'
|
29
31
|
CLASS_CURRENT = 'up-current'
|
30
32
|
SELECTOR_SECTION = 'a[href], a[up-target], [up-follow], [up-modal], [up-popup]'
|
31
33
|
SELECTOR_ACTIVE = ".#{CLASS_ACTIVE}"
|
34
|
+
|
35
|
+
normalizeUrl = (url) ->
|
36
|
+
if u.isPresent(url)
|
37
|
+
u.normalizeUrl(url,
|
38
|
+
search: false
|
39
|
+
stripTrailingSlash: true
|
40
|
+
)
|
32
41
|
|
33
42
|
locationChanged = ->
|
34
|
-
windowLocation =
|
35
|
-
modalLocation = up.modal.source()
|
36
|
-
popupLocation = up.popup.source()
|
43
|
+
windowLocation = normalizeUrl(up.browser.url())
|
44
|
+
modalLocation = normalizeUrl(up.modal.source())
|
45
|
+
popupLocation = normalizeUrl(up.popup.source())
|
37
46
|
|
38
|
-
|
47
|
+
u.each $(SELECTOR_SECTION), (section) ->
|
39
48
|
$section = $(section)
|
40
49
|
# if $section is marked up with up-follow,
|
41
50
|
# the actual link might be a child element.
|
42
51
|
url = up.link.resolveUrl($section)
|
43
|
-
url =
|
52
|
+
url = normalizeUrl(url)
|
44
53
|
if url == windowLocation || url == modalLocation || url == popupLocation
|
45
54
|
$section.addClass(CLASS_CURRENT)
|
46
55
|
else
|
@@ -52,7 +61,7 @@ up.navigation = (->
|
|
52
61
|
$section.addClass(CLASS_ACTIVE)
|
53
62
|
|
54
63
|
enlargeClickArea = ($section) ->
|
55
|
-
|
64
|
+
u.presence($section.parents(SELECTOR_SECTION)) || $section
|
56
65
|
|
57
66
|
unmarkActive = ->
|
58
67
|
$(SELECTOR_ACTIVE).removeClass(CLASS_ACTIVE)
|
@@ -1,8 +1,23 @@
|
|
1
1
|
###*
|
2
2
|
Pop-up overlays
|
3
3
|
===============
|
4
|
+
|
5
|
+
Instead of linking to another page fragment, you can also choose
|
6
|
+
to "roll up" any target CSS selector in a popup overlay.
|
7
|
+
Popup overlays close themselves if the user clicks somewhere outside the
|
8
|
+
popup area.
|
9
|
+
|
10
|
+
For modal dialogs see [up.modal](/up.modal) instead.
|
11
|
+
|
12
|
+
\#\#\# Incomplete documentation!
|
13
|
+
|
14
|
+
We need to work on this page:
|
15
|
+
|
16
|
+
- Show the HTML structure of the popup elements, and how to style them via CSS
|
17
|
+
- Explain how to position popup using `up-origin`
|
18
|
+
- Explain how dialogs auto-close themselves when a fragment changes behind the popup layer
|
19
|
+
- Document method parameters
|
4
20
|
|
5
|
-
For modal dialogs see [up.modal](/up.modal).
|
6
21
|
|
7
22
|
@class up.popup
|
8
23
|
###
|
@@ -170,7 +185,6 @@ up.popup = (->
|
|
170
185
|
|
171
186
|
@method a[up-popup]
|
172
187
|
@ujs
|
173
|
-
@param up-target
|
174
188
|
@param [up-sticky]
|
175
189
|
@param [up-origin]
|
176
190
|
###
|
@@ -209,7 +223,11 @@ up.popup = (->
|
|
209
223
|
if $element.closest('.up-popup')
|
210
224
|
close()
|
211
225
|
)
|
212
|
-
|
226
|
+
|
227
|
+
# The framework is reset between tests, so also close
|
228
|
+
# a currently open popup.
|
229
|
+
up.bus.on 'framework:reset', close
|
230
|
+
|
213
231
|
open: open
|
214
232
|
close: close
|
215
233
|
source: source
|
@@ -2,7 +2,17 @@
|
|
2
2
|
Tooltips
|
3
3
|
========
|
4
4
|
|
5
|
-
|
5
|
+
Elements that have an `up-tooltip` attribute will show the attribute
|
6
|
+
value in a tooltip when a user hovers over the element.
|
7
|
+
|
8
|
+
\#\#\# Incomplete documentation!
|
9
|
+
|
10
|
+
We need to work on this page:
|
11
|
+
|
12
|
+
- Show the tooltip's HTML structure and how to style the elements
|
13
|
+
- Explain how to position tooltips using `up-origin`
|
14
|
+
- We should have a position about tooltips that contain HTML.
|
15
|
+
|
6
16
|
|
7
17
|
@class up.tooltip
|
8
18
|
###
|
@@ -84,6 +94,10 @@ up.tooltip = (->
|
|
84
94
|
close()
|
85
95
|
)
|
86
96
|
|
97
|
+
# The framework is reset between tests, so also close
|
98
|
+
# a currently open tooltip.
|
99
|
+
up.bus.on 'framework:reset', close
|
100
|
+
|
87
101
|
# Close the tooltip when the user presses ESC.
|
88
102
|
up.magic.onEscape(-> close())
|
89
103
|
|
@@ -49,8 +49,10 @@ up.util = (->
|
|
49
49
|
else
|
50
50
|
unwrap(urlOrAnchor)
|
51
51
|
normalized = anchor.protocol + "//" + anchor.hostname
|
52
|
-
normalized += ":#{anchor.port}" unless isStandardPort(anchor.protocol, anchor.port)
|
53
|
-
|
52
|
+
normalized += ":#{anchor.port}" unless isStandardPort(anchor.protocol, anchor.port)
|
53
|
+
pathname = anchor.pathname
|
54
|
+
pathname = pathname.replace(/\/$/, '') if options?.stripTrailingSlash == true
|
55
|
+
normalized += pathname
|
54
56
|
normalized += anchor.hash if options?.hash == true
|
55
57
|
normalized += anchor.search unless options?.search == false
|
56
58
|
normalized
|
@@ -207,11 +209,17 @@ up.util = (->
|
|
207
209
|
@param {Array} args...
|
208
210
|
###
|
209
211
|
option = (args...) ->
|
210
|
-
|
212
|
+
# This behavior is subtly different from detect!
|
213
|
+
match = null
|
214
|
+
args.every (arg) ->
|
211
215
|
value = arg
|
212
216
|
value = value() if isFunction(value)
|
213
|
-
isPresent(value)
|
214
|
-
|
217
|
+
if isPresent(value)
|
218
|
+
match = value
|
219
|
+
false
|
220
|
+
else
|
221
|
+
true
|
222
|
+
match
|
215
223
|
|
216
224
|
detect = (array, tester) ->
|
217
225
|
match = null
|
@@ -299,10 +307,14 @@ up.util = (->
|
|
299
307
|
deferred.promise()
|
300
308
|
|
301
309
|
measure = ($element, options) ->
|
302
|
-
|
310
|
+
coordinates = if options?.relative
|
311
|
+
$element.position()
|
312
|
+
else
|
313
|
+
$element.offset()
|
314
|
+
|
303
315
|
box =
|
304
|
-
left:
|
305
|
-
top:
|
316
|
+
left: coordinates.left
|
317
|
+
top: coordinates.top
|
306
318
|
width: $element.outerWidth()
|
307
319
|
height: $element.outerHeight()
|
308
320
|
if options?.full
|
@@ -343,6 +355,9 @@ up.util = (->
|
|
343
355
|
|
344
356
|
castsToFalse = (object) ->
|
345
357
|
String(object) == "false"
|
358
|
+
|
359
|
+
locationFromXhr = (xhr) ->
|
360
|
+
xhr.getResponseHeader('X-Up-Current-Location')
|
346
361
|
|
347
362
|
# memoArray = ->
|
348
363
|
# array = []
|
@@ -406,6 +421,7 @@ up.util = (->
|
|
406
421
|
isArray: isArray
|
407
422
|
castsToTrue: castsToTrue
|
408
423
|
castsToFalse: castsToFalse
|
424
|
+
locationFromXhr: locationFromXhr
|
409
425
|
# memoArray: memoArray
|
410
426
|
# replaceInPlace: replaceInPlace
|
411
427
|
|