upjs-rails 0.7.8 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e0810b525ab5ef3d7e10bcfaf2a33445a164fc6f
4
- data.tar.gz: 75201c1899721e795c5be00a2e3c3da8d6f2fcad
3
+ metadata.gz: 72b273956002a422a8bad50da6af92fcb218590a
4
+ data.tar.gz: 22e16af9e0e7bc146ad50760233948b0d5a6bed2
5
5
  SHA512:
6
- metadata.gz: 388d933e084613fd41f4784931ec31b08e526315589ad85f6ea0115df48753f16b521f74b36b354e742b70e313be4a683d753a38c3b6ba5c43ca85a2009c5bf6
7
- data.tar.gz: 44a50b5e52c3dd0053aa3eb601225244bb3c3c3df5c4ec9e8027dc1d6ff4c57c0b6f7d1463943a3033da80616e79ff300b04242eff54ba357747d07d9912efae
6
+ metadata.gz: a96eb49d26da0fc7fdcdd91f13ea4c7ba84ef6cb0881457ec741c3162bd4596045bef046ffb876b43a8495ad9616de0abab307c8a6dcdf373674c91703f6b3e7
7
+ data.tar.gz: e0aacbd0455d1f1095b4b2f6ffbb2fd6449257a368f182ad26d9347af7ec28879f61b399f03efade3fb259223c5581fea5ec8f5a54590839d3fec2edc88c2b19
data/dist/up.js CHANGED
@@ -25,7 +25,7 @@ If you use them in your own code, you will get hurt.
25
25
  var slice = [].slice;
26
26
 
27
27
  up.util = (function() {
28
- var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, castsToFalse, castsToTrue, clientSize, compact, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, measure, merge, methodFromXhr, nextFrame, normalizeMethod, normalizeUrl, nullJquery, only, option, options, prependGhost, presence, presentAttr, resolvableWhen, resolvedDeferred, resolvedPromise, select, setMissingAttrs, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unwrap, warn;
28
+ var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, castsToFalse, castsToTrue, clientSize, compact, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, measure, merge, methodFromXhr, nextFrame, normalizeMethod, normalizeUrl, nullJquery, only, option, options, prependGhost, presence, presentAttr, remove, resolvableWhen, resolvedDeferred, resolvedPromise, select, setMissingAttrs, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unwrap, warn;
29
29
  get = function(url, options) {
30
30
  options = options || {};
31
31
  options.url = url;
@@ -709,6 +709,14 @@ If you use them in your own code, you will get hurt.
709
709
  }
710
710
  return results;
711
711
  };
712
+ remove = function(array, element) {
713
+ var index;
714
+ index = array.indexOf(element);
715
+ if (index >= 0) {
716
+ array.splice(index, 1);
717
+ return element;
718
+ }
719
+ };
712
720
  return {
713
721
  presentAttr: presentAttr,
714
722
  createElement: createElement,
@@ -778,7 +786,8 @@ If you use them in your own code, you will get hurt.
778
786
  resolvedPromise: resolvedPromise,
779
787
  resolvedDeferred: resolvedDeferred,
780
788
  resolvableWhen: resolvableWhen,
781
- setMissingAttrs: setMissingAttrs
789
+ setMissingAttrs: setMissingAttrs,
790
+ remove: remove
782
791
  };
783
792
  })();
784
793
 
@@ -932,8 +941,8 @@ We need to work on this page:
932
941
 
933
942
  - Decide whether to refactor this into document events
934
943
  - Decide whether `fragment:enter` and `fragment:leave` would be better names
944
+ - Decide if we wouldn't rather document events in the respective module (e.g. proxy).
935
945
 
936
-
937
946
  @class up.bus
938
947
  */
939
948
 
@@ -941,7 +950,7 @@ We need to work on this page:
941
950
  var slice = [].slice;
942
951
 
943
952
  up.bus = (function() {
944
- var callbacksByEvent, callbacksFor, defaultCallbacksByEvent, emit, listen, reset, snapshot, u;
953
+ var callbacksByEvent, callbacksFor, defaultCallbacksByEvent, emit, listen, reset, snapshot, stopListen, u;
945
954
  u = up.util;
946
955
  callbacksByEvent = {};
947
956
  defaultCallbacksByEvent = {};
@@ -983,13 +992,43 @@ We need to work on this page:
983
992
  event is triggered.
984
993
 
985
994
  @method up.bus.on
986
- @param {String} eventName
987
- The event name to match.
995
+ @param {String} eventNames
996
+ A space-separated list of event names to match.
988
997
  @param {Function} handler
989
998
  The event handler to be called with the event arguments.
999
+ @return {Function}
1000
+ A function that unregisters the given handlers
1001
+ */
1002
+ listen = function(eventNames, handler) {
1003
+ var eventName, i, len, ref;
1004
+ ref = eventNames.split(' ');
1005
+ for (i = 0, len = ref.length; i < len; i++) {
1006
+ eventName = ref[i];
1007
+ callbacksFor(eventName).push(handler);
1008
+ }
1009
+ return function() {
1010
+ return stopListen(eventNames, handler);
1011
+ };
1012
+ };
1013
+
1014
+ /**
1015
+ Unregisters the given handler from the given events.
1016
+
1017
+ @method up.bus.off
1018
+ @param {String} eventNames
1019
+ A space-separated list of event names .
1020
+ @param {Function} handler
1021
+ The event handler that should stop listening.
990
1022
  */
991
- listen = function(eventName, handler) {
992
- return callbacksFor(eventName).push(handler);
1023
+ stopListen = function(eventNames, handler) {
1024
+ var eventName, i, len, ref, results;
1025
+ ref = eventNames.split(' ');
1026
+ results = [];
1027
+ for (i = 0, len = ref.length; i < len; i++) {
1028
+ eventName = ref[i];
1029
+ results.push(u.remove(callbacksFor(eventName), handler));
1030
+ }
1031
+ return results;
993
1032
  };
994
1033
 
995
1034
  /**
@@ -1028,6 +1067,7 @@ We need to work on this page:
1028
1067
  listen('framework:reset', reset);
1029
1068
  return {
1030
1069
  on: listen,
1070
+ off: stopListen,
1031
1071
  emit: emit
1032
1072
  };
1033
1073
  })();
@@ -1244,7 +1284,8 @@ We need to work on this page:
1244
1284
  url: url,
1245
1285
  method: options.method,
1246
1286
  selector: selector,
1247
- cache: options.cache
1287
+ cache: options.cache,
1288
+ preload: options.preload
1248
1289
  };
1249
1290
  promise = up.proxy.ajax(request);
1250
1291
  promise.done(function(html, textStatus, xhr) {
@@ -2621,7 +2662,7 @@ Caching and preloading
2621
2662
 
2622
2663
  All HTTP requests go through the Up.js proxy.
2623
2664
  It caches a [limited](/up.proxy#up.proxy.defaults) number of server responses
2624
- for a [limited](/up.proxy#up.proxy.defaults) amount of time,
2665
+ for a [limited](/up.proxy#up.proxy.defaults) amount of time,
2625
2666
  making requests to these URLs return insantly.
2626
2667
 
2627
2668
  The cache is cleared whenever the user makes a non-`GET` request
@@ -2630,19 +2671,78 @@ The cache is cleared whenever the user makes a non-`GET` request
2630
2671
  The proxy can also used to speed up reaction times by preloading
2631
2672
  links when the user hovers over the click area (or puts the mouse/finger
2632
2673
  down before releasing). This way the
2633
- response will already be cached when the user performs the click.
2674
+ response will already be cached when the user performs the click.
2675
+
2676
+ Spinners
2677
+ ---------
2678
+
2679
+ You can listen to [framework events](/up.bus) to implement a spinner
2680
+ (progress indicator) that appears during a long-running request,
2681
+ and disappears once the response has been received:
2682
+
2683
+ <div class="spinner">Please wait!</div>
2684
+
2685
+ Here is the Javascript to make it alive:
2686
+
2687
+ up.compiler('.spinner', function($element) {
2688
+
2689
+ show = function() { $element.show() };
2690
+ hide = function() { $element.hide() };
2691
+
2692
+ up.bus.on('proxy:busy', show);
2693
+ up.bus.on('proxy:idle', hide);
2694
+
2695
+ return function() {
2696
+ up.bus.off('proxy:busy', show);
2697
+ up.bus.off('proxy:idle', hide);
2698
+ };
2699
+
2700
+ });
2701
+
2702
+ The `proxy:busy` event will be emitted after a delay of 300 ms
2703
+ to prevent the spinner from flickering on and off.
2704
+ You can change (or remove) this delay like this:
2705
+
2706
+ up.proxy.defaults({ busyDelay: 150 });
2634
2707
 
2635
2708
  @class up.proxy
2636
2709
  */
2637
2710
 
2638
2711
  (function() {
2639
2712
  up.proxy = (function() {
2640
- var $waitingLink, SAFE_HTTP_METHODS, ajax, alias, cache, cacheKey, cancelDelay, checkPreload, clear, config, defaults, delayTimer, get, isFresh, isIdempotent, normalizeRequest, preload, remove, reset, set, startDelay, timestamp, trim, u;
2641
- config = {
2713
+ var $waitingLink, FACTORY_CONFIG, SAFE_HTTP_METHODS, ajax, alias, busy, busyDelayTimer, busyEventEmitted, cache, cacheKey, cancelBusyDelay, cancelPreloadDelay, checkPreload, clear, config, defaults, get, idle, isFresh, isIdempotent, load, loadEnded, loadStarted, normalizeRequest, pendingCount, preload, preloadDelayTimer, remove, reset, set, startPreloadDelay, timestamp, trim, u;
2714
+ u = up.util;
2715
+ cache = void 0;
2716
+ $waitingLink = void 0;
2717
+ preloadDelayTimer = void 0;
2718
+ busyDelayTimer = void 0;
2719
+ pendingCount = void 0;
2720
+ config = void 0;
2721
+ busyEventEmitted = void 0;
2722
+ FACTORY_CONFIG = {
2723
+ busyDelay: 300,
2642
2724
  preloadDelay: 75,
2643
2725
  cacheSize: 70,
2644
2726
  cacheExpiry: 1000 * 60 * 5
2645
2727
  };
2728
+ cancelPreloadDelay = function() {
2729
+ clearTimeout(preloadDelayTimer);
2730
+ return preloadDelayTimer = null;
2731
+ };
2732
+ cancelBusyDelay = function() {
2733
+ clearTimeout(busyDelayTimer);
2734
+ return busyDelayTimer = null;
2735
+ };
2736
+ reset = function() {
2737
+ cache = {};
2738
+ $waitingLink = null;
2739
+ cancelPreloadDelay();
2740
+ cancelBusyDelay();
2741
+ pendingCount = 0;
2742
+ config = u.copy(FACTORY_CONFIG);
2743
+ return busyEventEmitted = false;
2744
+ };
2745
+ reset();
2646
2746
 
2647
2747
  /**
2648
2748
  @method up.proxy.defaults
@@ -2655,14 +2755,13 @@ response will already be cached when the user performs the click.
2655
2755
  @param {Number} [options.cacheExpiry=300000]
2656
2756
  The number of milliseconds until a cache entry expires.
2657
2757
  Defaults to 5 minutes.
2758
+ @param {Number} [options.busyDelay=300]
2759
+ How long the proxy waits until emitting the `proxy:busy` [event](/up.bus).
2760
+ Use this to prevent flickering of spinners.
2658
2761
  */
2659
2762
  defaults = function(options) {
2660
2763
  return u.extend(config, options);
2661
2764
  };
2662
- cache = {};
2663
- u = up.util;
2664
- $waitingLink = null;
2665
- delayTimer = null;
2666
2765
  cacheKey = function(request) {
2667
2766
  normalizeRequest(request);
2668
2767
  return [request.url, request.method, request.data, request.selector].join('|');
@@ -2718,6 +2817,11 @@ response will already be cached when the user performs the click.
2718
2817
  Only requests with a method of `GET`, `OPTIONS` and `HEAD`
2719
2818
  are considered to be read-only.
2720
2819
 
2820
+ If a network connection is attempted, the proxy will emit
2821
+ a `proxy:load` event with the `request` as its argument.
2822
+ Once the response is received, a `proxy:receive` event will
2823
+ be emitted.
2824
+
2721
2825
  @method up.proxy.ajax
2722
2826
  @param {String} request.url
2723
2827
  @param {String} [request.method='GET']
@@ -2727,22 +2831,89 @@ response will already be cached when the user performs the click.
2727
2831
  If set to `false` a network connection will always be attempted.
2728
2832
  */
2729
2833
  ajax = function(options) {
2730
- var forceCache, ignoreCache, promise, request;
2834
+ var forceCache, ignoreCache, pending, promise, request;
2731
2835
  forceCache = u.castsToTrue(options.cache);
2732
2836
  ignoreCache = u.castsToFalse(options.cache);
2733
2837
  request = u.only(options, 'url', 'method', 'data', 'selector', '_normalized');
2838
+ pending = true;
2734
2839
  if (!isIdempotent(request) && !forceCache) {
2735
2840
  clear();
2736
- promise = u.ajax(request);
2841
+ promise = load(request);
2737
2842
  } else if ((promise = get(request)) && !ignoreCache) {
2738
- promise;
2843
+ pending = promise.state() === 'pending';
2739
2844
  } else {
2740
- promise = u.ajax(request);
2845
+ promise = load(request);
2741
2846
  set(request, promise);
2742
2847
  }
2848
+ if (pending && !options.preload) {
2849
+ loadStarted();
2850
+ promise.then(loadEnded);
2851
+ }
2743
2852
  return promise;
2744
2853
  };
2745
2854
  SAFE_HTTP_METHODS = ['GET', 'OPTIONS', 'HEAD'];
2855
+
2856
+ /**
2857
+ Returns `true` if the proxy is not currently waiting
2858
+ for a request to finish. Returns `false` otherwise.
2859
+
2860
+ The proxy will also emit an `proxy:idle` [event](/up.bus) if it
2861
+ used to busy, but is now idle.
2862
+
2863
+ @method up.proxy.idle
2864
+ @return {Boolean} Whether the proxy is idle
2865
+ */
2866
+ idle = function() {
2867
+ return pendingCount === 0;
2868
+ };
2869
+
2870
+ /**
2871
+ Returns `true` if the proxy is currently waiting
2872
+ for a request to finish. Returns `false` otherwise.
2873
+
2874
+ The proxy will also emit an `proxy:busy` [event](/up.bus) if it
2875
+ used to idle, but is now busy.
2876
+
2877
+ @method up.proxy.busy
2878
+ @return {Boolean} Whether the proxy is busy
2879
+ */
2880
+ busy = function() {
2881
+ return pendingCount > 0;
2882
+ };
2883
+ loadStarted = function() {
2884
+ var emission, wasIdle;
2885
+ wasIdle = idle();
2886
+ pendingCount += 1;
2887
+ if (wasIdle) {
2888
+ emission = function() {
2889
+ if (busy()) {
2890
+ up.bus.emit('proxy:busy');
2891
+ return busyEventEmitted = true;
2892
+ }
2893
+ };
2894
+ if (config.busyDelay > 0) {
2895
+ return busyDelayTimer = setTimeout(emission, config.busyDelay);
2896
+ } else {
2897
+ return emission();
2898
+ }
2899
+ }
2900
+ };
2901
+ loadEnded = function() {
2902
+ pendingCount -= 1;
2903
+ if (idle() && busyEventEmitted) {
2904
+ up.bus.emit('proxy:idle');
2905
+ return busyEventEmitted = false;
2906
+ }
2907
+ };
2908
+ load = function(request) {
2909
+ var promise;
2910
+ up.bus.emit('proxy:load', request);
2911
+ promise = u.ajax(request);
2912
+ promise.then(function() {
2913
+ return up.bus.emit('proxy:receive', request);
2914
+ });
2915
+ return promise;
2916
+ };
2746
2917
  isIdempotent = function(request) {
2747
2918
  normalizeRequest(request);
2748
2919
  return u.contains(SAFE_HTTP_METHODS, request.method);
@@ -2810,19 +2981,15 @@ response will already be cached when the user performs the click.
2810
2981
  delay = parseInt(u.presentAttr($link, 'up-delay')) || config.preloadDelay;
2811
2982
  if (!$link.is($waitingLink)) {
2812
2983
  $waitingLink = $link;
2813
- cancelDelay();
2984
+ cancelPreloadDelay();
2814
2985
  curriedPreload = function() {
2815
2986
  return preload($link);
2816
2987
  };
2817
- return startDelay(curriedPreload, delay);
2988
+ return startPreloadDelay(curriedPreload, delay);
2818
2989
  }
2819
2990
  };
2820
- startDelay = function(block, delay) {
2821
- return delayTimer = setTimeout(block, delay);
2822
- };
2823
- cancelDelay = function() {
2824
- clearTimeout(delayTimer);
2825
- return delayTimer = null;
2991
+ startPreloadDelay = function(block, delay) {
2992
+ return preloadDelayTimer = setTimeout(block, delay);
2826
2993
  };
2827
2994
 
2828
2995
  /**
@@ -2847,10 +3014,6 @@ response will already be cached when the user performs the click.
2847
3014
  return u.resolvedPromise();
2848
3015
  }
2849
3016
  };
2850
- reset = function() {
2851
- cancelDelay();
2852
- return cache = {};
2853
- };
2854
3017
  up.bus.on('framework:reset', reset);
2855
3018
 
2856
3019
  /**
@@ -2880,6 +3043,8 @@ response will already be cached when the user performs the click.
2880
3043
  alias: alias,
2881
3044
  clear: clear,
2882
3045
  remove: remove,
3046
+ idle: idle,
3047
+ busy: busy,
2883
3048
  defaults: defaults
2884
3049
  };
2885
3050
  })();
data/dist/up.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,C,x,T,E,S,P,A,D,U,F,M,O,j,z,L,I,N,H,W,q,G,X,J,R,K,V,B,_,Q,Z,Y,tn,nn,en,rn,on,un,an,sn,ln,cn,pn,fn,dn,mn,hn,vn,gn,yn,bn,wn,kn;return E=function(t,n){return n=n||{},n.url=t,o(n)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},q=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},nn=function(t,n){var e,r,o;return e=null,G(t)?(e=$("<a>").attr({href:t}).get(0),A(e.hostname)&&(e.href=e.href)):e=wn(t),r=e.protocol+"//"+e.hostname,q(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,"/"!==o[0]&&(o="/"+o),(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},tn=function(t){return t?t.toUpperCase():"GET"},n=function(t){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v;for(h=t.split(/[ >]/),r=null,c=p=0,d=h.length;d>p;c=++p){for(i=h[c],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),v="div",o=[],l=null,f=0,m=u.length;m>f;f++)switch(a=u[f],a[0]){case".":o.push(a.substr(1));break;case"#":l=a.substr(1);break;default:v=a}s="<"+v,o.length&&(s+=' class="'+o.join(" ")+'"'),l&&(s+=' id="'+l+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===c&&(r=n),e=n}return r},f=function(t,n){var e;return e=document.createElement(t),H(n)&&(e.innerHTML=n),e},v=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.debug.apply(console,[e].concat(t.call(n)))},kn=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.warn.apply(console,[e].concat(t.call(n)))},b=function(){var n,e,r;throw e=1<=arguments.length?t.call(arguments,0):[],e[0]="[UP] "+e[0],console.error.apply(console,e),r=hn(e),n=sn($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),new Error(r)},r=/\%[odisf]/g,hn=function(t){var n,e,o;return o=t[0],n=0,e=30,o.replace(r,function(){var r,o;return n+=1,r=t[n],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>e&&(r=r.substr(0,e)+"\u2026"),'"'+r+'"'):"number"===o?r.toString():"("+o+")"})},m=function(t){var n,e,r,o,u,i,a;for(v("Creating selector from element %o",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),a=t.prop("tagName").toLowerCase(),r&&(a+="#"+r),o=0,i=e.length;i>o;o++)u=e[o],a+="."+u;return a},d=function(t){var n,e,r,o,u,i,a,s,l,c,p,d;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(l("head")+n+l("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(l("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=f("body",r[1]),s.appendChild(e),(p=t.match(d))&&(a=f("head"),s.appendChild(a),c=f("title",p[1]),a.appendChild(c)),s):f("div",t)},k=$.extend,bn=$.trim,K=Object.keys||function(t){var n,e,r,o;for(o=[],n=0,r=t.length;r>n;n++)e=t[n],t.hasOwnProperty(e)&&o.push(e);return o},y=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},gn=function(t,n){var e,r,o,u;for(u=[],e=r=0,o=t-1;o>=0?o>=r:r>=o;e=o>=0?++r:--r)u.push(n(e));return u},I=function(t){return null===t},X=function(t){return void 0===t},U=function(t){return!X(t)},L=function(t){return X(t)||I(t)},O=function(t){return!L(t)},A=function(t){return L(t)||N(t)&&0===K(t).length||0===t.length},sn=function(t,n){return null==n&&(n=H),n(t)?t:null},H=function(t){return!A(t)},M=function(t){return"function"==typeof t},G=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},N=function(t){return j(t)||"function"==typeof t},F=function(t){return!(!t||1!==t.nodeType)},z=function(t){return t instanceof jQuery},W=function(t){return N(t)&&M(t.then)},D=function(t){return W(t)&&M(t.resolve)},S=function(t){return O(t)?t:void 0},P=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},yn=function(t){return Array.prototype.slice.call(t)},c=function(t){return P(t)?t.slice():k({},t)},wn=function(t){return z(t)?t.get(0):t},Q=function(t,n){return k(c(t),n)},un=function(t,n){var e,r,o,u;if(o=t?c(t):{},n)for(r in n)e=n[r],u=o[r],O(u)?N(e)&&N(u)&&(o[r]=un(u,e)):o[r]=e;return o},on=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],u=null,r=0,o=e.length;o>r;r++)if(n=e[r],i=n,M(i)&&(i=i()),O(i)){u=i;break}return u},g=function(t,n){var e,r,o,u;for(u=null,r=0,o=t.length;o>r;r++)if(e=t[r],n(e)){u=e;break}return u},s=function(t){return dn(t,O)},dn=function(t,n){var e;return e=[],y(t,function(t){return n(t)?e.push(t):void 0}),e},ln=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),g(o,H)},Y=function(t){return setTimeout(t,0)},V=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},vn=function(t,n,e){var r,o;return o=t.css(K(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},T=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),A(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},h=function(t,n,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=un(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":K(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=T(o),l=vn(o,a),o.css(n),u.then(s),u.then(l),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),fn())},e="up-animation-promise",x=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},_=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=a(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},p=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},an=function(t){var n,e;return e=_(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},C=function(t,n){return t.find(n).addBack(n)},w=function(t){return 27===t.keyCode},l=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},B=function(t){return t.getResponseHeader("X-Up-Location")},Z=function(t){return t.getResponseHeader("X-Up-Method")},rn=function(){var n,e,r,o,u,i;for(i=arguments[0],o=2<=arguments.length?t.call(arguments,1):[],n={},e=0,u=o.length;u>e;e++)r=o[e],i.hasOwnProperty(r)&&(n[r]=i[r]);return n},J=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},R=function(t){var n;return n=X(t.button)||0===t.button,n&&J(t)},pn=function(){var t;return t=$.Deferred(),t.resolve(),t},fn=function(){return pn().promise()},en=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},cn=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return y(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},mn=function(t,n){var e,r,o;r=[];for(e in n)o=n[e],r.push(L(t.attr(e))?t.attr(e,o):void 0);return r},{presentAttr:ln,createElement:f,normalizeUrl:nn,normalizeMethod:tn,createElementFromHtml:d,$createElementFromSelector:n,createSelectorFromElement:m,get:E,ajax:o,extend:k,copy:c,merge:Q,options:un,option:on,error:b,debug:v,warn:kn,each:y,times:gn,detect:g,select:dn,compact:s,last:V,isNull:I,isDefined:U,isUndefined:X,isGiven:O,isMissing:L,isPresent:H,isBlank:A,presence:sn,isObject:N,isFunction:M,isString:G,isElement:F,isJQuery:z,isPromise:W,isDeferred:D,isHash:j,ifGiven:S,isUnmodifiedKeyEvent:J,isUnmodifiedMouseEvent:R,nullJquery:en,unwrap:wn,nextFrame:Y,measure:_,temporaryCss:vn,cssAnimate:h,finishCssAnimate:x,forceCompositing:T,prependGhost:an,escapePressed:w,copyAttributes:p,findWithSelf:C,contains:l,isArray:P,toArray:yn,castsToTrue:i,castsToFalse:u,locationFromXhr:B,methodFromXhr:Z,clientSize:a,only:rn,trim:bn,keys:K,resolvedPromise:fn,resolvedDeferred:pn,resolvableWhen:cn,setMissingAttrs:mn}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,l,c;return l=up.util,a=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=l.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",l.isDefined(r)&&l.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},c=function(){return location.href},o=function(){var t,n,e,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(n=window.console).info||(n.info=s),(e=window.console).error||(e.error=s),(r=window.console).debug||(r.debug=s),(o=window.console).warn||(o.warn=s),(u=window.console).group||(u.group=s),(i=window.console).groupCollapsed||(i.groupCollapsed=s),(a=window.console).groupEnd||(a.groupEnd=s)},s=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=s(function(){return l.isDefined(history.pushState)}),n=s(function(){return"transition"in document.documentElement.style}),e=s(function(){return"oninput"in document.createElement("input")}),u=function(){var t,n,e,r,o;return o=$.fn.jquery,r=o.split("."),n=parseInt(r[0]),e=parseInt(r[1]),t=n>=2||1===n&&e>=9,t||l.error("jQuery %o found, but Up.js requires 1.9+",o)},i=s(function(){return l.isDefined(document.addEventListener)}),{url:c,ensureConsoleExists:o,loadPage:a,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:i,ensureRecentJquery:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s;return s=up.util,n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=s.copy(t));return o},i=function(){return n=s.copy(r)},u=function(t,n){return e(t).push(n)},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],s.debug("Emitting event %o with args %o",o,n),r=e(o),s.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.viewport=function(){var t,n,e,r,o,u,i;return i=up.util,n={duration:0,view:"body",easing:"swing"},e=function(t){return i.extend(n,t)},t="up-scroll-promise",u=function(e,o,u){var a,s,l,c,p;return a=$(e),u=i.options(u),l=i.option(u.duration,n.duration),c=i.option(u.easing,n.easing),r(a),l>0?(s=$.Deferred(),a.data(t,s),s.then(function(){return a.removeData(t),a.finish()}),p={scrollTop:o},a.animate(p,{duration:l,easing:c,complete:function(){return s.resolve()}}),s):(a.scrollTop(o),i.resolvedDeferred())},r=function(n){return $(n).each(function(){var n;return(n=$(this).data(t))?n.resolve():void 0})},o=function(t,e){var r,o,a,s,l,c,p,f,d,m,h;return e=i.options(e),m=i.option(e.view,n.view),f=i.option(e.padding,n.padding),r=$(t),o=$(m),h=o.height(),d=o.scrollTop(),c=d,p=d+h,l=r.position().top,a=c>l-f,s=l>p-f,a||s?(d=l-f,d=Math.max(d,0),d=Math.min(d,h-1),u(o,d,e)):i.resolvedDeferred()},{reveal:o,scroll:u,finishScrolling:r,defaults:e}}(),up.scroll=up.viewport.scroll,up.reveal=up.viewport.reveal}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y;return y=up.util,h=function(t,n){var e;return e=$(t),y.isPresent(n)&&(n=y.normalizeUrl(n)),e.attr("up-source",n)},v=function(t){var n;return n=$(t).closest("[up-source]"),y.presence(n.attr("up-source"))||up.browser.url()},f=function(t,n,e){var r,o,u;return e=y.options(e),u=y.presence(t)?t:y.createSelectorFromElement($(t)),up.browser.canPushState()||y.castsToFalse(e.history)?(o={url:n,method:e.method,selector:u,cache:e.cache},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=y.locationFromXhr(a))&&(y.debug("Location from server: %o",s),l={url:s,method:y.methodFromXhr(a),selector:u},up.proxy.alias(o,l),n=s),(y.isMissing(e.history)||y.castsToTrue(e.history))&&(e.history=n),(y.isMissing(e.source)||y.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:i(u,t,e)}),r.fail(y.error),r):(e.preload||up.browser.loadPage(n,y.only(e,"method")),y.resolvedPromise())},i=function(t,n,e){var o,u,i,a,p,f,d,m;for(e=y.options(e,{historyMethod:"push"}),y.castsToFalse(e.history)&&(e.history=null),y.castsToFalse(e.scroll)&&(e.scroll=null),e.source=y.option(e.source,e.history),f=l(n),e.title||(e.title=f.title()),p=s(t,e),d=[],i=0,a=p.length;a>i;i++)m=p[i],u=r(m.selector),o=f.find(m.selector),d.push(c(u,e).then(function(){return g(u,o,m.pseudoClass,m.transition,e)}));return d},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var n;return n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),y.error(n,t)},l=function(t){var n;return n=y.createElementFromHtml(t),{title:function(){var t;return null!=(t=n.querySelector("title"))?t.textContent:void 0},find:function(e){var r;return(r=n.querySelector(e))?$(r):y.error("Could not find selector %o in response %o",e,t)}}},c=function(t,n){return up.motion.finish(t),m(t,n.scroll)},m=function(t,n){return n?up.reveal(t,{view:n}):y.resolvedDeferred()},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),h(n,e.source),t(n),up.ready(n)},g=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),y.copyAttributes(r,t),e(a,i),up.animate(r,u,i)):n(t,{animation:function(){return r.insertBefore(t),e(r,i),t.is("body")&&"none"!==u&&y.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})},s=function(t,n){var e,r,o,u,i,a,s,l,c,p,f;for(p=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),y.isPresent(p)&&(f=p.split(e)),a=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],l=s.match(/^(.+?)(?:\:(before|after))?$/),c=f[o]||y.last(f),a.push({selector:l[1],pseudoClass:l[2],transition:c});return a},t=function(t){var n,e;return e="[autofocus]:last",n=y.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},a=function(t){var n;return n=".up-ghost, .up-destroying",0===t.closest(n).length},o=function(t){var n,e,r,o,u,i;for(o=$(t).get(),e=null,u=0,i=o.length;i>u;u++)if(r=o[u],n=$(r),a(n)){e=n;break}return e},n=function(t,n){var e,r,o;return e=$(t),n=y.options(n,{animation:"none"}),r=up.motion.animateOptions(n),e.addClass("up-destroying"),y.isPresent(n.url)&&up.history.push(n.url),y.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),o=y.presence(n.animation,y.isPromise)||up.motion.animate(e,n.animation,r),o.then(function(){return e.remove()})},p=function(t,n){var e;return n=y.options(n,{cache:!1}),e=n.url||v(t),f(t,e,n)},d=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return h(document.body,up.browser.url())}),{replace:f,reload:p,destroy:n,implant:i,reset:d,first:o}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset,up.first=up.flow.first}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,n="up-destroyable",e="up-destroyer",f=[],l=null,p=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},i=[],s=null,u=function(){var n,e,r;return r=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=n.pop(),e=g.options(n[0],{batch:!1}),i.push({selector:r,callback:u,batch:e.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying compiler %o on %o",t.selector,o),u=t.callback.apply(o,[r,a(r)]),g.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},o=function(t){var n,e,o,a;for(g.debug("Compiling fragment %o",t),a=[],e=0,o=i.length;o>e;e++)u=i[e],n=g.findWithSelf(t,u.selector),a.push(n.length?u.batch?r(u,n,n.get()):n.each(function(){return r(u,$(this),this)}):void 0);return a},c=function(t){return g.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},a=function(t){var n,e;return n=$(t),e=n.attr("up-data"),g.isString(e)&&""!==g.trim(e)?JSON.parse(e):{}},v=function(){return l=g.copy(f),s=g.copy(i)},h=function(){var t,n,e,r;for(n=0,e=f.length;e>n;n++)t=f[n],g.contains(l,t)||(r=$(document)).off.apply(r,t);return f=g.copy(l),i=g.copy(s)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},d=function(t){return p("keydown","body",function(n){return g.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",o),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{compiler:u,on:p,ready:m,onEscape:d,data:a}}(),up.compiler=up.magic.compiler,up.on=up.magic.on,up.ready=up.magic.ready,up.awaken=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],up.util.warn("up.awaken has been renamed to up.compiler and will be removed in a future version"),up.compiler.apply(up,n)}}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,(null!=n?n.fromUp:void 0)?(u.debug("Restoring state %o (now on "+up.browser.url()+")",n),up.visit(up.browser.url(),{historyMethod:"replace"})):u.debug("Discarding unknown state %o",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k;return w=up.util,o={},a={},b={},s={},i={duration:300,delay:0,easing:"ease"},l=function(t){return w.extend(i,t)},n=function(t,r,o){var i;return i=$(t),p(i),o=e(o),w.isFunction(r)?u(r(i,o),r):w.isString(r)?n(i,c(r),o):w.isHash(r)?w.cssAnimate(i,r,o):w.error("Unknown animation type %o",r)},e=function(t,n){var e;return null==n&&(n=null),t=w.options(t),e={},e.easing=w.option(t.easing,null!=n?n.attr("up-easing"):void 0,i.easing),e.duration=Number(w.option(t.duration,null!=n?n.attr("up-duration"):void 0,i.duration)),e.delay=Number(w.option(t.delay,null!=n?n.attr("up-delay"):void 0,i.delay)),e},c=function(t){return o[t]||w.error("Unknown animation %o",r)},t="up-ghosting-promise",k=function(n,e,r){var o,u,i,a;return u=null,o=null,w.temporaryCss(e,{display:"none"},function(){return u=w.prependGhost(n).addClass("up-destroying")}),w.temporaryCss(n,{display:"none"},function(){return o=w.prependGhost(e)}),n.css({visibility:"hidden"}),a=w.temporaryCss(e,{display:"none"}),i=r(u,o),n.data(t,i),e.data(t,i),i.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),a()}),i},p=function(t){return $(t).each(function(){var t;return t=$(this),w.finishCssAnimate(t),f(t)})},f=function(n){var e;return(e=n.data(t))?(w.debug("Canceling existing ghosting on %o",n),"function"==typeof e.resolve?e.resolve():void 0):void 0},u=function(t,n){return w.isDeferred(t)?t:w.error("Did not return a promise with .then and .resolve methods: %o",n)},d=function(t,r,i,a){var s,l,c,f,h;return up.browser.canCssAnimation()?(a=e(a),l=$(t),s=$(r),p(l),p(s),"none"===i?m():(h=w.presence(i,w.isFunction)||b[i])?k(l,s,function(t,n){return u(h(t,n,a),i)}):(c=o[i])?(l.hide(),n(s,c,a)):w.isString(i)&&i.indexOf("/")>=0?(f=i.split("/"),h=function(t,e,r){return v(n(t,f[0],r),n(e,f[1],r))},d(l,s,h,a)):w.error("Unknown transition %o",i)):w.resolvedDeferred()},y=function(t,n){return b[t]=n},r=function(t,n){return o[t]=n},g=function(){return a=w.copy(o),s=w.copy(b)},h=function(){return o=w.copy(a),b=w.copy(s)},v=w.resolvableWhen,m=w.resolvedDeferred,r("none",m),r("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),r("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),r("move-to-top",function(t,e){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),r("move-from-top",function(t,e){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),r("move-to-bottom",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),r("move-from-bottom",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),r("move-to-left",function(t,e){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),r("move-from-left",function(t,e){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),r("move-to-right",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),r("move-from-right",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),r("roll-down",function(t,e){var r,o;return r=t.height(),o=w.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),y("none",m),y("move-left",function(t,e,r){return v(n(t,"move-to-left",r),n(e,"move-from-right",r))}),y("move-right",function(t,e,r){return v(n(t,"move-to-right",r),n(e,"move-from-left",r))}),y("move-up",function(t,e,r){return v(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),y("move-down",function(t,e,r){return v(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),y("cross-fade",function(t,e,r){return v(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",g),up.bus.on("framework:reset",h),{morph:d,animate:n,animateOptions:e,finish:p,transition:y,animation:r,defaults:l,none:m,when:v}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.proxy=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,C,x;return l={preloadDelay:75,cacheSize:70,cacheExpiry:3e5},c=function(t){return x.extend(l,t)},o={},x=up.util,t=null,p=null,u=function(t){return h(t),[t.url,t.method,t.data,t.selector].join("|")},C=function(){var t,n,e;return t=x.keys(o),t.length>l.cacheSize&&(n=null,e=null,x.each(t,function(t){var r,u;return r=o[t],u=r.timestamp,!e||e>u?(n=t,e=u):void 0}),n)?delete o[n]:void 0},k=function(){return(new Date).valueOf()},h=function(t){return t._normalized||(t.method=x.normalizeMethod(t.method),t.url&&(t.url=x.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},r=function(t,n){var e;return x.debug("Aliasing %o to %o",t,n),(e=f(t))?b(n,e):void 0},e=function(t){var n,e,r,o;return n=x.castsToTrue(t.cache),e=x.castsToFalse(t.cache),o=x.only(t,"url","method","data","selector","_normalized"),m(o)||n?(r=f(o))&&!e||(r=x.ajax(o),b(o,r)):(s(),r=x.ajax(o)),r},n=["GET","OPTIONS","HEAD"],m=function(t){return h(t),x.contains(n,t.method)},d=function(t){var n;return n=k()-t.timestamp,n<l.cacheExpiry},f=function(t){var n,e;return n=u(t),(e=o[n])?d(e)?(x.debug("Cache hit for %o (%o)",t.url,t),e):(x.debug("Discarding stale cache entry for %o (%o)",t.url,t),void g(t)):void x.debug("Cache miss for %o (%o)",t.url,t)},b=function(t,n){var e;return C(),e=u(t),n.timestamp=k(),o[e]=n,n},g=function(t){var n;return n=u(t),delete o[n]},s=function(){return o={}},a=function(n){var e,r;return r=parseInt(x.presentAttr(n,"up-delay"))||l.preloadDelay,n.is(t)?void 0:(t=n,i(),e=function(){return v(n)},w(e,r))},w=function(t,n){return p=setTimeout(t,n)},i=function(){return clearTimeout(p),p=null},v=function(t,n){var e,r;return e=$(t),n=x.options(n),r=up.link.followMethod(e,n),m({method:r})?(x.debug("Preloading %o",e),n.preload=!0,up.link.follow(e,n)):(x.debug("Won't preload %o due to unsafe method %o",e,r),x.resolvedPromise())},y=function(){return i(),o={}},up.bus.on("framework:reset",y),up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:a(n)}),{preload:v,ajax:e,get:f,set:b,alias:r,clear:s,remove:g,defaults:c}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,n){return u.debug("Visiting "+t),up.replace("body",t,n)},follow=function(t,n){var e,r,o;return e=$(t),n=u.options(n),o=u.option(e.attr("up-href"),e.attr("href")),r=u.option(n.target,e.attr("up-target"),"body"),n.transition=u.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=u.option(n.history,e.attr("up-history")),n.scroll=u.option(n.scroll,e.attr("up-scroll"),"body"),n.cache=u.option(n.cache,e.attr("up-cache")),n.method=followMethod(e,n),n=u.merge(n,up.motion.animateOptions(n,e)),up.replace(r,o,n)},followMethod=function(t,n){return n=u.options(n),u.option(n.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,n){return shouldProcessLinkEvent(t,n)?(t.preventDefault(),follow(n)):void 0}),childClicked=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-href]"),r.length&&n.find(r).length},shouldProcessLinkEvent=function(t,n){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,n)},up.on("click","a[up-follow], [up-href][up-follow]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.compiler("[up-expand]",function(t){var n,e,r,o,i,a,s,l;for(o=t.find("a, [up-href]").get(0),o||u.error("No link to expand within %o",t),l=/^up-/,a={},a["up-href"]=$(o).attr("href"),s=o.attributes,e=0,r=s.length;r>e;e++)n=s[e],i=n.name,i.match(l)&&(a[i]=n.value);return u.isGiven(a["up-target"])||(a["up-follow"]=""),u.setMissingAttrs(t,a),t.removeAttr("up-expand")}),up.compiler("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},u.isBlank(e)||u.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,u.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,childClicked:childClicked,followMethod:followMethod}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,l,c,p,f,d,m;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),o=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),a=u.option(n.history,e.attr("up-history"),!0),p=u.option(n.transition,e.attr("up-transition")),i=u.option(n.failTransition,e.attr("up-fail-transition"),p),s=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),r=up.motion.animateOptions(n,e),m=u.option(n.cache,e.attr("up-cache")),d=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(a)?(l={url:d,method:s,data:e.serialize(),selector:c,cache:m},f=function(t){var n;return d=a?u.castsToFalse(a)?!1:u.isString(a)?a:(n=u.locationFromXhr(t))?n:"GET"===l.type?l.url+"?"+l.data:void 0:void 0,u.option(d,!1)},up.proxy.ajax(l).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){var o;return o=u.merge(r,{history:f(e),transition:p}),up.flow.implant(c,t,o)}).fail(function(t){var n,e;return e=t.responseText,n=u.merge(r,{transition:i}),up.flow.implant(o,e,n)})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("up.observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=u.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.compiler("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,u=void 0,e={openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"},i=function(t){return d.extend(e,t)},p=function(t,n,e){var r,o;return o=d.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return d.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r),s(n)},s=function(t){var n,e,r,o,u,i,a;if(e=d.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},c=function(){var t;return t=$(".up-popup"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,n,e){var r,o;return o=d.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),r=d.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),c(),o.hide(),o},m=function(t,n,e,r,o){return n.show(),p(t,n,e),up.animate(n,r,o)},l=function(t,r){var u,i,a,s,l,c,p,f,h;return u=$(t),r=d.options(r),h=d.option(r.url,u.attr("href")),p=d.option(r.target,u.attr("up-popup"),"body"),c=d.option(r.position,u.attr("up-position"),e.position),s=d.option(r.animation,u.attr("up-animation"),e.openAnimation),f=d.option(r.sticky,u.is("[up-sticky]")),l=up.browser.canPushState()?d.option(r.history,u.attr("up-history"),!1):!1,a=up.motion.animateOptions(r,u),n(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},n=function(t){var n;return n=$(".up-popup"),n.length?(t=d.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),u=void 0,up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(a(),n())},r=function(t){var n;return n=$(t),n.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():l(e)
2
- }),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){var e;return r(n)?(e=n.attr("up-source"))?u=e:void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:l,close:n,source:f,defaults:i,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,i=void 0,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>'}},a=function(t){return d.extend(r,t)},f=function(){var t;return t=r.template,d.isFunction(t)?t(r):t},c=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},s=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t,n,e,r){var o,u,i,a;return i=$(f()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),d.isPresent(n)&&u.css("width",n),d.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),a=d.$createElementFromSelector(t),a.appendTo(o),i.appendTo(document.body),c(),i.hide(),i},m=function(t,n,e){return t.show(),up.animate(t,n,e)},l=function(){var n,o,i,a,s,l,c,p,f,h,v,g;return s=1<=arguments.length?t.call(arguments,0):[],!d.isObject(s[0])||d.isElement(s[0])||d.isJQuery(s[0])?(n=$(s[0]),p=s[1]):(n=d.nullJquery(),p=s[0]),p=d.options(p),v=d.option(p.url,n.attr("up-href"),n.attr("href")),f=d.option(p.target,n.attr("up-modal"),"body"),g=d.option(p.width,n.attr("up-width"),r.width),l=d.option(p.height,n.attr("up-height"),r.height),a=d.option(p.animation,n.attr("up-animation"),r.openAnimation),h=d.option(p.sticky,n.is("[up-sticky]")),c=up.browser.canPushState()?d.option(p.history,n.attr("up-history"),!0):!1,i=up.motion.animateOptions(p,n),e(),o=u(f,g,l,h),up.replace(f,v,{history:c,insert:function(){return m(o,a,i)}})},p=function(){return i},e=function(t){var n;return n=$(".up-modal"),n.length?(t=d.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),i=void 0,up.destroy(n,t)):void 0},n=function(){return $(".up-modal").is("[up-sticky]")?void 0:(s(),e())},o=function(t){var n;return n=$(t),n.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():l(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-modal-dialog").length||n.closest("[up-modal]").length?void 0:e()}),up.bus.on("fragment:ready",function(t){var e;if(o(t)){if(e=t.attr("up-source"))return i=e}else if(!up.popup.contains(t))return n()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-modal")?e():void 0}),up.bus.on("framework:reset",e),{open:l,close:e,source:p,defaults:a,contains:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,l,c,p;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),p=o.option(u.position,i.attr("up-position"),"top"),l=o.option(u.animation,i.attr("up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=n(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m;return f=up.util,t="up-active",n="up-current",e=["a","[up-href]","[up-alias]"],o=e.join(", "),u=function(){var t,n,r;for(r=[],t=0,n=e.length;n>t;t++)p=e[t],r.push(p+"[up-instant]");return r}().join(", "),r="."+t,s=function(t){return f.isPresent(t)?f.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},c=function(t){var n,e,r,o,u,i,a,l;for(i=[],u=["href","up-href"],r=0,o=u.length;o>r;r++)e=u[r],(a=f.presentAttr(t,e))&&i.push(a);return(n=f.presentAttr(t,"up-alias"))&&(l=n.split(" "),i=i.concat(l)),i.map(s)},m=function(t){var n,e,r,o;return t=f.compact(t),r=function(t){return"*"===t.substr(-1)?e(t.slice(0,-1)):n(t)},n=function(n){return f.contains(t,n)},e=function(n){return f.detect(t,function(t){return 0===t.indexOf(n)})},o=function(t){return f.detect(t,r)},{matchesAny:o}},a=function(){var t;return t=m([s(up.browser.url()),s(up.modal.source()),s(up.popup.source())]),f.each($(o),function(e){var r,o;return r=$(e),o=c(r),t.matchesAny(o)?r.addClass(n):r.removeClass(n)})},l=function(n){return d(),n=i(n),n.addClass(t)},i=function(t){return f.presence(t.parents(o))||t},d=function(){return $(r).removeClass(t)},up.on("click",o,function(t,n){return f.isUnmodifiedMouseEvent(t)&&!n.is("[up-instant]")?l(n):void 0}),up.on("mousedown",u,function(t,n){return f.isUnmodifiedMouseEvent(t)?l(n):void 0}),up.bus.on("fragment:ready",function(){return d(),a()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?a():void 0})}()}.call(this),function(){up.slot=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-slot]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.ensureRecentJquery(),up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
1
+ (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,C,T,E,S,P,A,D,U,F,O,M,j,z,L,I,N,H,W,q,G,X,J,R,K,V,B,_,Q,Z,Y,tn,nn,en,rn,on,un,an,sn,ln,cn,pn,fn,dn,mn,hn,vn,gn,yn,bn,wn,kn,$n;return E=function(t,n){return n=n||{},n.url=t,o(n)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},q=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},nn=function(t,n){var e,r,o;return e=null,G(t)?(e=$("<a>").attr({href:t}).get(0),A(e.hostname)&&(e.href=e.href)):e=kn(t),r=e.protocol+"//"+e.hostname,q(e.protocol,e.port)||(r+=":"+e.port),o=e.pathname,"/"!==o[0]&&(o="/"+o),(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=n?n.hash:void 0)===!0&&(r+=e.hash),(null!=n?n.search:void 0)!==!1&&(r+=e.search),r},tn=function(t){return t?t.toUpperCase():"GET"},n=function(t){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v;for(h=t.split(/[ >]/),r=null,c=p=0,d=h.length;d>p;c=++p){for(i=h[c],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),v="div",o=[],l=null,f=0,m=u.length;m>f;f++)switch(a=u[f],a[0]){case".":o.push(a.substr(1));break;case"#":l=a.substr(1);break;default:v=a}s="<"+v,o.length&&(s+=' class="'+o.join(" ")+'"'),l&&(s+=' id="'+l+'"'),s+=">",n=$(s),e&&n.appendTo(e),0===c&&(r=n),e=n}return r},f=function(t,n){var e;return e=document.createElement(t),H(n)&&(e.innerHTML=n),e},v=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.debug.apply(console,[e].concat(t.call(n)))},$n=function(){var n,e;return e=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],e="[UP] "+e,console.warn.apply(console,[e].concat(t.call(n)))},b=function(){var n,e,r;throw e=1<=arguments.length?t.call(arguments,0):[],e[0]="[UP] "+e[0],console.error.apply(console,e),r=vn(e),n=sn($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),n.addClass("up-error"),n.text(r),new Error(r)},r=/\%[odisf]/g,vn=function(t){var n,e,o;return o=t[0],n=0,e=30,o.replace(r,function(){var r,o;return n+=1,r=t[n],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>e&&(r=r.substr(0,e)+"\u2026"),'"'+r+'"'):"number"===o?r.toString():"("+o+")"})},m=function(t){var n,e,r,o,u,i,a;for(v("Creating selector from element %o",t),e=(n=t.attr("class"))?n.split(" "):[],r=t.attr("id"),a=t.prop("tagName").toLowerCase(),r&&(a+="#"+r),o=0,i=e.length;i>o;o++)u=e[o],a+="."+u;return a},d=function(t){var n,e,r,o,u,i,a,s,l,c,p,d;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},n="(?:.|\\n)*?",u=function(t){return"("+t+")"},d=new RegExp(l("head")+n+l("title")+u(n)+i("title")+n+i("body"),"i"),o=new RegExp(l("body")+u(n)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),e=f("body",r[1]),s.appendChild(e),(p=t.match(d))&&(a=f("head"),s.appendChild(a),c=f("title",p[1]),a.appendChild(c)),s):f("div",t)},k=$.extend,wn=$.trim,K=Object.keys||function(t){var n,e,r,o;for(o=[],n=0,r=t.length;r>n;n++)e=t[n],t.hasOwnProperty(e)&&o.push(e);return o},y=function(t,n){var e,r,o,u,i;for(i=[],e=o=0,u=t.length;u>o;e=++o)r=t[e],i.push(n(r,e));return i},yn=function(t,n){var e,r,o,u;for(u=[],e=r=0,o=t-1;o>=0?o>=r:r>=o;e=o>=0?++r:--r)u.push(n(e));return u},I=function(t){return null===t},X=function(t){return void 0===t},U=function(t){return!X(t)},L=function(t){return X(t)||I(t)},M=function(t){return!L(t)},A=function(t){return L(t)||N(t)&&0===K(t).length||0===t.length},sn=function(t,n){return null==n&&(n=H),n(t)?t:null},H=function(t){return!A(t)},O=function(t){return"function"==typeof t},G=function(t){return"string"==typeof t},j=function(t){return"object"==typeof t&&!!t},N=function(t){return j(t)||"function"==typeof t},F=function(t){return!(!t||1!==t.nodeType)},z=function(t){return t instanceof jQuery},W=function(t){return N(t)&&O(t.then)},D=function(t){return W(t)&&O(t.resolve)},S=function(t){return M(t)?t:void 0},P=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},bn=function(t){return Array.prototype.slice.call(t)},c=function(t){return P(t)?t.slice():k({},t)},kn=function(t){return z(t)?t.get(0):t},Q=function(t,n){return k(c(t),n)},un=function(t,n){var e,r,o,u;if(o=t?c(t):{},n)for(r in n)e=n[r],u=o[r],M(u)?N(e)&&N(u)&&(o[r]=un(u,e)):o[r]=e;return o},on=function(){var n,e,r,o,u,i;for(e=1<=arguments.length?t.call(arguments,0):[],u=null,r=0,o=e.length;o>r;r++)if(n=e[r],i=n,O(i)&&(i=i()),M(i)){u=i;break}return u},g=function(t,n){var e,r,o,u;for(u=null,r=0,o=t.length;o>r;r++)if(e=t[r],n(e)){u=e;break}return u},s=function(t){return mn(t,M)},mn=function(t,n){var e;return e=[],y(t,function(t){return n(t)?e.push(t):void 0}),e},ln=function(){var n,e,r,o;return n=arguments[0],r=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=r.length;o>t;t++)e=r[t],u.push(n.attr(e));return u}(),g(o,H)},Y=function(t){return setTimeout(t,0)},V=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},gn=function(t,n,e){var r,o;return o=t.css(K(n)),t.css(n),r=function(){return t.css(o)},e?(e(),r()):r},T=function(t){var n,e;return e=t.css(["transform","-webkit-transform"]),A(e)?(n=function(){return t.css(e)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},h=function(t,n,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=un(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":K(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=T(o),l=gn(o,a),o.css(n),u.then(s),u.then(l),o.data(e,u),u.then(function(){return o.removeData(e)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(n),dn())},e="up-animation-promise",C=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},_=function(t,n){var e,r,o;return r=(null!=n?n.relative:void 0)?t.position():t.offset(),e={left:r.left,top:r.top},(null!=n?n.inner:void 0)?(e.width=t.width(),e.height=t.height()):(e.width=t.outerWidth(),e.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=a(),e.right=o.width-(e.left+e.width),e.bottom=o.height-(e.top+e.height)),e},p=function(t,n){var e,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)e=u[r],i.push(e.specified?n.attr(e.name,e.value):void 0);return i},an=function(t){var n,e;return e=_(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(e),n.addClass("up-ghost"),n.insertBefore(t)},x=function(t,n){return t.find(n).addBack(n)},w=function(t){return 27===t.keyCode},l=function(t,n){return t.indexOf(n)>=0},i=function(t){return"true"===String(t)},u=function(t){return"false"===String(t)},B=function(t){return t.getResponseHeader("X-Up-Location")},Z=function(t){return t.getResponseHeader("X-Up-Method")},rn=function(){var n,e,r,o,u,i;for(i=arguments[0],o=2<=arguments.length?t.call(arguments,1):[],n={},e=0,u=o.length;u>e;e++)r=o[e],i.hasOwnProperty(r)&&(n[r]=i[r]);return n},J=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},R=function(t){var n;return n=X(t.button)||0===t.button,n&&J(t)},fn=function(){var t;return t=$.Deferred(),t.resolve(),t},dn=function(){return fn().promise()},en=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},pn=function(){var n,e;return n=1<=arguments.length?t.call(arguments,0):[],e=$.when.apply($,n),e.resolve=function(){return y(n,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},e},hn=function(t,n){var e,r,o;r=[];for(e in n)o=n[e],r.push(L(t.attr(e))?t.attr(e,o):void 0);return r},cn=function(t,n){var e;return e=t.indexOf(n),e>=0?(t.splice(e,1),n):void 0},{presentAttr:ln,createElement:f,normalizeUrl:nn,normalizeMethod:tn,createElementFromHtml:d,$createElementFromSelector:n,createSelectorFromElement:m,get:E,ajax:o,extend:k,copy:c,merge:Q,options:un,option:on,error:b,debug:v,warn:$n,each:y,times:yn,detect:g,select:mn,compact:s,last:V,isNull:I,isDefined:U,isUndefined:X,isGiven:M,isMissing:L,isPresent:H,isBlank:A,presence:sn,isObject:N,isFunction:O,isString:G,isElement:F,isJQuery:z,isPromise:W,isDeferred:D,isHash:j,ifGiven:S,isUnmodifiedKeyEvent:J,isUnmodifiedMouseEvent:R,nullJquery:en,unwrap:kn,nextFrame:Y,measure:_,temporaryCss:gn,cssAnimate:h,finishCssAnimate:C,forceCompositing:T,prependGhost:an,escapePressed:w,copyAttributes:p,findWithSelf:x,contains:l,isArray:P,toArray:bn,castsToTrue:i,castsToFalse:u,locationFromXhr:B,methodFromXhr:Z,clientSize:a,only:rn,trim:wn,keys:K,resolvedPromise:dn,resolvedDeferred:fn,resolvableWhen:pn,setMissingAttrs:hn,remove:cn}}()}.call(this),function(){var t=[].slice;up.browser=function(){var n,e,r,o,u,i,a,s,l,c;return l=up.util,a=function(t,n){var e,r,o,u,i,a;return null==n&&(n={}),i=l.option(n.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(a=n.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),e=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",l.isDefined(r)&&l.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),a&&e.attr("target",a),e.hide().append(u).appendTo("body"),e.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},c=function(){return location.href},o=function(){var t,n,e,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(n=window.console).info||(n.info=s),(e=window.console).error||(e.error=s),(r=window.console).debug||(r.debug=s),(o=window.console).warn||(o.warn=s),(u=window.console).group||(u.group=s),(i=window.console).groupCollapsed||(i.groupCollapsed=s),(a=window.console).groupEnd||(a.groupEnd=s)},s=function(n){var e,r;return e=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?e:(r=!0,e=n.apply(null,o))}},r=s(function(){return l.isDefined(history.pushState)}),n=s(function(){return"transition"in document.documentElement.style}),e=s(function(){return"oninput"in document.createElement("input")}),u=function(){var t,n,e,r,o;return o=$.fn.jquery,r=o.split("."),n=parseInt(r[0]),e=parseInt(r[1]),t=n>=2||1===n&&e>=9,t||l.error("jQuery %o found, but Up.js requires 1.9+",o)},i=s(function(){return l.isDefined(document.addEventListener)}),{url:c,ensureConsoleExists:o,loadPage:a,canPushState:r,canCssAnimation:n,canInputEvent:e,isSupported:i,ensureRecentJquery:u}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,e,r,o,u,i,a,s,l;return l=up.util,n={},r={},e=function(t){return n[t]||(n[t]=[])},a=function(){var t,e,o;r={},o=[];for(e in n)t=n[e],o.push(r[e]=l.copy(t));return o},i=function(){return n=l.copy(r)},u=function(t,n){var r,o,u,i;for(i=t.split(" "),o=0,u=i.length;u>o;o++)r=i[o],e(r).push(n);return function(){return s(t,n)}},s=function(t,n){var r,o,u,i,a;for(i=t.split(" "),a=[],o=0,u=i.length;u>o;o++)r=i[o],a.push(l.remove(e(r),n));return a},o=function(){var n,r,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],l.debug("Emitting event %o with args %o",o,n),r=e(o),l.each(r,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,off:s,emit:o}}()}.call(this),function(){up.viewport=function(){var t,n,e,r,o,u,i;return i=up.util,n={duration:0,view:"body",easing:"swing"},e=function(t){return i.extend(n,t)},t="up-scroll-promise",u=function(e,o,u){var a,s,l,c,p;return a=$(e),u=i.options(u),l=i.option(u.duration,n.duration),c=i.option(u.easing,n.easing),r(a),l>0?(s=$.Deferred(),a.data(t,s),s.then(function(){return a.removeData(t),a.finish()}),p={scrollTop:o},a.animate(p,{duration:l,easing:c,complete:function(){return s.resolve()}}),s):(a.scrollTop(o),i.resolvedDeferred())},r=function(n){return $(n).each(function(){var n;return(n=$(this).data(t))?n.resolve():void 0})},o=function(t,e){var r,o,a,s,l,c,p,f,d,m,h;return e=i.options(e),m=i.option(e.view,n.view),f=i.option(e.padding,n.padding),r=$(t),o=$(m),h=o.height(),d=o.scrollTop(),c=d,p=d+h,l=r.position().top,a=c>l-f,s=l>p-f,a||s?(d=l-f,d=Math.max(d,0),d=Math.min(d,h-1),u(o,d,e)):i.resolvedDeferred()},{reveal:o,scroll:u,finishScrolling:r,defaults:e}}(),up.scroll=up.viewport.scroll,up.reveal=up.viewport.reveal}.call(this),function(){up.flow=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y;return y=up.util,h=function(t,n){var e;return e=$(t),y.isPresent(n)&&(n=y.normalizeUrl(n)),e.attr("up-source",n)},v=function(t){var n;return n=$(t).closest("[up-source]"),y.presence(n.attr("up-source"))||up.browser.url()},f=function(t,n,e){var r,o,u;return e=y.options(e),u=y.presence(t)?t:y.createSelectorFromElement($(t)),up.browser.canPushState()||y.castsToFalse(e.history)?(o={url:n,method:e.method,selector:u,cache:e.cache,preload:e.preload},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=y.locationFromXhr(a))&&(y.debug("Location from server: %o",s),l={url:s,method:y.methodFromXhr(a),selector:u},up.proxy.alias(o,l),n=s),(y.isMissing(e.history)||y.castsToTrue(e.history))&&(e.history=n),(y.isMissing(e.source)||y.castsToTrue(e.source))&&(e.source=n),e.preload?void 0:i(u,t,e)}),r.fail(y.error),r):(e.preload||up.browser.loadPage(n,y.only(e,"method")),y.resolvedPromise())},i=function(t,n,e){var o,u,i,a,p,f,d,m;for(e=y.options(e,{historyMethod:"push"}),y.castsToFalse(e.history)&&(e.history=null),y.castsToFalse(e.scroll)&&(e.scroll=null),e.source=y.option(e.source,e.history),f=l(n),e.title||(e.title=f.title()),p=s(t,e),d=[],i=0,a=p.length;a>i;i++)m=p[i],u=r(m.selector),o=f.find(m.selector),d.push(c(u,e).then(function(){return g(u,o,m.pseudoClass,m.transition,e)}));return d},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var n;return n="Could not find selector %o in current body HTML","#"===n[0]&&(n+=" (avoid using IDs)"),y.error(n,t)},l=function(t){var n;return n=y.createElementFromHtml(t),{title:function(){var t;return null!=(t=n.querySelector("title"))?t.textContent:void 0},find:function(e){var r;return(r=n.querySelector(e))?$(r):y.error("Could not find selector %o in response %o",e,t)}}},c=function(t,n){return up.motion.finish(t),m(t,n.scroll)},m=function(t,n){return n?up.reveal(t,{view:n}):y.resolvedDeferred()},e=function(n,e){return"function"==typeof e.insert&&e.insert(n),e.history&&(e.title&&(document.title=e.title),up.history[e.historyMethod](e.history)),h(n,e.source),t(n),up.ready(n)},g=function(t,r,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=r.children(),t[s](r.contents()),y.copyAttributes(r,t),e(a,i),up.animate(r,u,i)):n(t,{animation:function(){return r.insertBefore(t),e(r,i),t.is("body")&&"none"!==u&&y.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})},s=function(t,n){var e,r,o,u,i,a,s,l,c,p,f;for(p=n.transition||n.animation||"none",e=/\ *,\ */,r=t.split(e),y.isPresent(p)&&(f=p.split(e)),a=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],l=s.match(/^(.+?)(?:\:(before|after))?$/),c=f[o]||y.last(f),a.push({selector:l[1],pseudoClass:l[2],transition:c});return a},t=function(t){var n,e;return e="[autofocus]:last",n=y.findWithSelf(t,e),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},a=function(t){var n;return n=".up-ghost, .up-destroying",0===t.closest(n).length},o=function(t){var n,e,r,o,u,i;for(o=$(t).get(),e=null,u=0,i=o.length;i>u;u++)if(r=o[u],n=$(r),a(n)){e=n;break}return e},n=function(t,n){var e,r,o;return e=$(t),n=y.options(n,{animation:"none"}),r=up.motion.animateOptions(n),e.addClass("up-destroying"),y.isPresent(n.url)&&up.history.push(n.url),y.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",e),o=y.presence(n.animation,y.isPromise)||up.motion.animate(e,n.animation,r),o.then(function(){return e.remove()})},p=function(t,n){var e;return n=y.options(n,{cache:!1}),e=n.url||v(t),f(t,e,n)},d=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return h(document.body,up.browser.url())}),{replace:f,reload:p,destroy:n,implant:i,reset:d,first:o}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset,up.first=up.flow.first}.call(this),function(){var t=[].slice;up.magic=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,n="up-destroyable",e="up-destroyer",f=[],l=null,p=function(t,n,e){var r,o;if(up.browser.isSupported())return r=[t,n,function(t){return e.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},i=[],s=null,u=function(){var n,e,r;return r=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=n.pop(),e=g.options(n[0],{batch:!1}),i.push({selector:r,callback:u,batch:e.batch})):void 0},r=function(t,r,o){var u;return g.debug("Applying compiler %o on %o",t.selector,o),u=t.callback.apply(o,[r,a(r)]),g.isFunction(u)?(r.addClass(n),r.data(e,u)):void 0},o=function(t){var n,e,o,a;for(g.debug("Compiling fragment %o",t),a=[],e=0,o=i.length;o>e;e++)u=i[e],n=g.findWithSelf(t,u.selector),a.push(n.length?u.batch?r(u,n,n.get()):n.each(function(){return r(u,$(this),this)}):void 0);return a},c=function(t){return g.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(e))()})},a=function(t){var n,e;return n=$(t),e=n.attr("up-data"),g.isString(e)&&""!==g.trim(e)?JSON.parse(e):{}},v=function(){return l=g.copy(f),s=g.copy(i)},h=function(){var t,n,e,r;for(n=0,e=f.length;e>n;n++)t=f[n],g.contains(l,t)||(r=$(document)).off.apply(r,t);return f=g.copy(l),i=g.copy(s)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},d=function(t){return p("keydown","body",function(n){return g.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",o),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",v),up.bus.on("framework:reset",h),{compiler:u,on:p,ready:m,onEscape:d,data:a}}(),up.compiler=up.magic.compiler,up.on=up.magic.on,up.ready=up.magic.ready,up.awaken=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],up.util.warn("up.awaken has been renamed to up.compiler and will be removed in a future version"),up.compiler.apply(up,n)}}.call(this),function(){up.history=function(){var t,n,e,r,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(e,r){return r=u.options(r,{force:!1}),r.force||!t(e)?n("replace",e):void 0},r=function(e){return t(e)?void 0:n("push",e)},n=function(t,n){return up.browser.canPushState()?(t+="State",window.history[t]({fromUp:!0},"",n)):u.error("This browser doesn't support history.pushState")},e=function(t){var n;return n=t.originalEvent.state,(null!=n?n.fromUp:void 0)?(u.debug("Restoring state %o (now on "+up.browser.url()+")",n),up.visit(up.browser.url(),{historyMethod:"replace"})):u.debug("Discarding unknown state %o",n)},up.browser.canPushState()&&setTimeout(function(){return $(window).on("popstate",e),o(up.browser.url(),{force:!0})},200),{push:r,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k;return w=up.util,o={},a={},b={},s={},i={duration:300,delay:0,easing:"ease"},l=function(t){return w.extend(i,t)},n=function(t,r,o){var i;return i=$(t),p(i),o=e(o),w.isFunction(r)?u(r(i,o),r):w.isString(r)?n(i,c(r),o):w.isHash(r)?w.cssAnimate(i,r,o):w.error("Unknown animation type %o",r)},e=function(t,n){var e;return null==n&&(n=null),t=w.options(t),e={},e.easing=w.option(t.easing,null!=n?n.attr("up-easing"):void 0,i.easing),e.duration=Number(w.option(t.duration,null!=n?n.attr("up-duration"):void 0,i.duration)),e.delay=Number(w.option(t.delay,null!=n?n.attr("up-delay"):void 0,i.delay)),e},c=function(t){return o[t]||w.error("Unknown animation %o",r)},t="up-ghosting-promise",k=function(n,e,r){var o,u,i,a;return u=null,o=null,w.temporaryCss(e,{display:"none"},function(){return u=w.prependGhost(n).addClass("up-destroying")}),w.temporaryCss(n,{display:"none"},function(){return o=w.prependGhost(e)}),n.css({visibility:"hidden"}),a=w.temporaryCss(e,{display:"none"}),i=r(u,o),n.data(t,i),e.data(t,i),i.then(function(){return n.removeData(t),e.removeData(t),u.remove(),o.remove(),n.css({display:"none"}),a()}),i},p=function(t){return $(t).each(function(){var t;return t=$(this),w.finishCssAnimate(t),f(t)})},f=function(n){var e;return(e=n.data(t))?(w.debug("Canceling existing ghosting on %o",n),"function"==typeof e.resolve?e.resolve():void 0):void 0},u=function(t,n){return w.isDeferred(t)?t:w.error("Did not return a promise with .then and .resolve methods: %o",n)},d=function(t,r,i,a){var s,l,c,f,h;return up.browser.canCssAnimation()?(a=e(a),l=$(t),s=$(r),p(l),p(s),"none"===i?m():(h=w.presence(i,w.isFunction)||b[i])?k(l,s,function(t,n){return u(h(t,n,a),i)}):(c=o[i])?(l.hide(),n(s,c,a)):w.isString(i)&&i.indexOf("/")>=0?(f=i.split("/"),h=function(t,e,r){return v(n(t,f[0],r),n(e,f[1],r))},d(l,s,h,a)):w.error("Unknown transition %o",i)):w.resolvedDeferred()},y=function(t,n){return b[t]=n},r=function(t,n){return o[t]=n},g=function(){return a=w.copy(o),s=w.copy(b)},h=function(){return o=w.copy(a),b=w.copy(s)},v=w.resolvableWhen,m=w.resolvedDeferred,r("none",m),r("fade-in",function(t,e){return t.css({opacity:0}),n(t,{opacity:1},e)}),r("fade-out",function(t,e){return t.css({opacity:1}),n(t,{opacity:0},e)}),r("move-to-top",function(t,e){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),n(t,{"margin-top":"-"+o+"px"},e)}),r("move-from-top",function(t,e){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),n(t,{"margin-top":"0px"},e)}),r("move-to-bottom",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":"0px"}),n(t,{"margin-top":o+"px"},e)}),r("move-from-bottom",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":o+"px"}),n(t,{"margin-top":"0px"},e)}),r("move-to-left",function(t,e){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),n(t,{"margin-left":"-"+o+"px"},e)}),r("move-from-left",function(t,e){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),n(t,{"margin-left":"0px"},e)}),r("move-to-right",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":"0px"}),n(t,{"margin-left":o+"px"},e)}),r("move-from-right",function(t,e){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":o+"px"}),n(t,{"margin-left":"0px"},e)}),r("roll-down",function(t,e){var r,o;return r=t.height(),o=w.temporaryCss(t,{height:"0px",overflow:"hidden"}),n(t,{height:r+"px"},e).then(o)}),y("none",m),y("move-left",function(t,e,r){return v(n(t,"move-to-left",r),n(e,"move-from-right",r))}),y("move-right",function(t,e,r){return v(n(t,"move-to-right",r),n(e,"move-from-left",r))}),y("move-up",function(t,e,r){return v(n(t,"move-to-top",r),n(e,"move-from-bottom",r))}),y("move-down",function(t,e,r){return v(n(t,"move-to-bottom",r),n(e,"move-from-top",r))}),y("cross-fade",function(t,e,r){return v(n(t,"fade-out",r),n(e,"fade-in",r))}),up.bus.on("framework:ready",g),up.bus.on("framework:reset",h),{morph:d,animate:n,animateOptions:e,finish:p,transition:y,animation:r,defaults:l,none:m,when:v}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.proxy=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,C,T,E,S,P,A,D,U,F,O,M;return M=up.util,s=void 0,t=void 0,S=void 0,i=void 0,T=void 0,m=void 0,a=void 0,n={busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5},p=function(){return clearTimeout(S),S=null},c=function(){return clearTimeout(i),i=null},A=function(){return s={},t=null,p(),c(),T=0,m=M.copy(n),a=!1},A(),h=function(t){return M.extend(m,t)},l=function(t){return C(t),[t.url,t.method,t.data,t.selector].join("|")},O=function(){var t,n,e;return t=M.keys(s),t.length>m.cacheSize&&(n=null,e=null,M.each(t,function(t){var r,o;return r=s[t],o=r.timestamp,!e||e>o?(n=t,e=o):void 0}),n)?delete s[n]:void 0},F=function(){return(new Date).valueOf()},C=function(t){return t._normalized||(t.method=M.normalizeMethod(t.method),t.url&&(t.url=M.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},o=function(t,n){var e;return M.debug("Aliasing %o to %o",t,n),(e=v(t))?D(n,e):void 0},r=function(t){var n,e,r,o,u;return n=M.castsToTrue(t.cache),e=M.castsToFalse(t.cache),u=M.only(t,"url","method","data","selector","_normalized"),r=!0,b(u)||n?(o=v(u))&&!e?r="pending"===o.state():(o=w(u),D(u,o)):(d(),o=w(u)),r&&!t.preload&&(x(),o.then(k)),o},e=["GET","OPTIONS","HEAD"],g=function(){return 0===T},u=function(){return T>0},x=function(){var t,n;return n=g(),T+=1,n?(t=function(){return u()?(up.bus.emit("proxy:busy"),a=!0):void 0},m.busyDelay>0?i=setTimeout(t,m.busyDelay):t()):void 0},k=function(){return T-=1,g()&&a?(up.bus.emit("proxy:idle"),a=!1):void 0},w=function(t){var n;return up.bus.emit("proxy:load",t),n=M.ajax(t),n.then(function(){return up.bus.emit("proxy:receive",t)}),n},b=function(t){return C(t),M.contains(e,t.method)},y=function(t){var n;return n=F()-t.timestamp,n<m.cacheExpiry},v=function(t){var n,e;return n=l(t),(e=s[n])?y(e)?(M.debug("Cache hit for %o (%o)",t.url,t),e):(M.debug("Discarding stale cache entry for %o (%o)",t.url,t),void P(t)):void M.debug("Cache miss for %o (%o)",t.url,t)},D=function(t,n){var e;return O(),e=l(t),n.timestamp=F(),s[e]=n,n},P=function(t){var n;return n=l(t),delete s[n]},d=function(){return s={}},f=function(n){var e,r;return r=parseInt(M.presentAttr(n,"up-delay"))||m.preloadDelay,n.is(t)?void 0:(t=n,p(),e=function(){return E(n)},U(e,r))},U=function(t,n){return S=setTimeout(t,n)},E=function(t,n){var e,r;return e=$(t),n=M.options(n),r=up.link.followMethod(e,n),b({method:r})?(M.debug("Preloading %o",e),n.preload=!0,up.link.follow(e,n)):(M.debug("Won't preload %o due to unsafe method %o",e,r),M.resolvedPromise())},up.bus.on("framework:reset",A),up.on("mouseover mousedown touchstart","[up-preload]",function(t,n){return up.link.childClicked(t,n)?void 0:f(n)}),{preload:E,ajax:r,get:v,set:D,alias:o,clear:d,remove:P,idle:g,busy:u,defaults:h}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,n){return u.debug("Visiting "+t),up.replace("body",t,n)},follow=function(t,n){var e,r,o;return e=$(t),n=u.options(n),o=u.option(e.attr("up-href"),e.attr("href")),r=u.option(n.target,e.attr("up-target"),"body"),n.transition=u.option(n.transition,e.attr("up-transition"),e.attr("up-animation")),n.history=u.option(n.history,e.attr("up-history")),n.scroll=u.option(n.scroll,e.attr("up-scroll"),"body"),n.cache=u.option(n.cache,e.attr("up-cache")),n.method=followMethod(e,n),n=u.merge(n,up.motion.animateOptions(n,e)),up.replace(r,o,n)},followMethod=function(t,n){return n=u.options(n),u.option(n.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,n){return shouldProcessLinkEvent(t,n)?(t.preventDefault(),follow(n)):void 0}),childClicked=function(t,n){var e,r;return e=$(t.target),r=e.closest("a, [up-href]"),r.length&&n.find(r).length},shouldProcessLinkEvent=function(t,n){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,n)},up.on("click","a[up-follow], [up-href][up-follow]",function(t,n){return shouldProcessLinkEvent(t,n)?n.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(n)):void 0}),up.compiler("[up-expand]",function(t){var n,e,r,o,i,a,s,l;for(o=t.find("a, [up-href]").get(0),o||u.error("No link to expand within %o",t),l=/^up-/,a={},a["up-href"]=$(o).attr("href"),s=o.attributes,e=0,r=s.length;r>e;e++)n=s[e],i=n.name,i.match(l)&&(a[i]=n.value);return u.isGiven(a["up-target"])||(a["up-follow"]=""),u.setMissingAttrs(t,a),t.removeAttr("up-expand")}),up.compiler("[up-dash]",function(t){var n,e;return e=t.attr("up-dash"),n={"up-preload":"true","up-instant":"true"},u.isBlank(e)||u.castsToTrue(e)?n["up-follow"]="":n["up-target"]=e,u.setMissingAttrs(t,n),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,childClicked:childClicked,followMethod:followMethod}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var e,r,o,i,a,s,l,c,p,f,d,m;return e=$(t).closest("form"),n=u.options(n),c=u.option(n.target,e.attr("up-target"),"body"),o=u.option(n.failTarget,e.attr("up-fail-target"),function(){return u.createSelectorFromElement(e)}),a=u.option(n.history,e.attr("up-history"),!0),p=u.option(n.transition,e.attr("up-transition")),i=u.option(n.failTransition,e.attr("up-fail-transition"),p),s=u.option(n.method,e.attr("up-method"),e.attr("data-method"),e.attr("method"),"post").toUpperCase(),r=up.motion.animateOptions(n,e),m=u.option(n.cache,e.attr("up-cache")),d=u.option(n.url,e.attr("action"),up.browser.url()),e.addClass("up-active"),up.browser.canPushState()||u.castsToFalse(a)?(l={url:d,method:s,data:e.serialize(),selector:c,cache:m},f=function(t){var n;return d=a?u.castsToFalse(a)?!1:u.isString(a)?a:(n=u.locationFromXhr(t))?n:"GET"===l.type?l.url+"?"+l.data:void 0:void 0,u.option(d,!1)},up.proxy.ajax(l).always(function(){return e.removeClass("up-active")}).done(function(t,n,e){var o;return o=u.merge(r,{history:f(e),transition:p}),up.flow.implant(c,t,o)}).fail(function(t){var n,e;return e=t.responseText,n=u.merge(r,{transition:i}),up.flow.implant(o,e,n)})):void e.get(0).submit()},observe=function(fieldOrSelector,options){var $field,callback,callbackPromise,callbackTimer,changeEvents,check,clearTimer,codeOnChange,delay,knownValue,nextCallback,runNextCallback;return $field=$(fieldOrSelector),options=u.options(options),delay=u.option($field.attr("up-delay"),options.delay,0),delay=parseInt(delay),knownValue=null,callback=null,callbackTimer=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("up.observe: No change callback given"),callbackPromise=u.resolvedPromise(),nextCallback=null,runNextCallback=function(){var t;return nextCallback?(t=nextCallback(),nextCallback=null,t):void 0},check=function(){var t,n;return n=$field.val(),t=u.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[n,$field])},callbackTimer=setTimeout(function(){return callbackPromise.then(function(){var t;return t=runNextCallback(),callbackPromise=u.isPromise(t)?t:u.resolvedPromise()})},delay))},clearTimer=function(){return clearTimeout(callbackTimer)},changeEvents=up.browser.canInputEvent()?"input change":"input change keypress paste cut click propertychange",$field.on(changeEvents,check),check(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.compiler("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,u=void 0,e={openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"},i=function(t){return d.extend(e,t)},p=function(t,n,e){var r,o;return o=d.measure(t,{full:!0}),r=function(){switch(e){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return d.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r),s(n)},s=function(t){var n,e,r,o,u,i,a;if(e=d.measure(t,{full:!0}),r=null,o=null,e.right<0&&(r=-e.right),e.bottom<0&&(o=-e.bottom),e.left<0&&(r=e.left),e.top<0&&(o=e.top),r&&((u=parseInt(t.css("left")))?t.css("left",u-r):(i=parseInt(t.css("right")))&&t.css("right",i+r)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},c=function(){var t;return t=$(".up-popup"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,n,e){var r,o;return o=d.$createElementFromSelector(".up-popup"),e&&o.attr("up-sticky",""),r=d.$createElementFromSelector(n),r.appendTo(o),o.appendTo(document.body),c(),o.hide(),o
2
+ },m=function(t,n,e,r,o){return n.show(),p(t,n,e),up.animate(n,r,o)},l=function(t,r){var u,i,a,s,l,c,p,f,h;return u=$(t),r=d.options(r),h=d.option(r.url,u.attr("href")),p=d.option(r.target,u.attr("up-popup"),"body"),c=d.option(r.position,u.attr("up-position"),e.position),s=d.option(r.animation,u.attr("up-animation"),e.openAnimation),f=d.option(r.sticky,u.is("[up-sticky]")),l=up.browser.canPushState()?d.option(r.history,u.attr("up-history"),!1):!1,a=up.motion.animateOptions(r,u),n(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},n=function(t){var n;return n=$(".up-popup"),n.length?(t=d.options(t,{animation:e.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),u=void 0,up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(a(),n())},r=function(t){var n;return n=$(t),n.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():l(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-popup").length||e.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){var e;return r(n)?(e=n.attr("up-source"))?u=e:void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:l,close:n,source:f,defaults:i,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var n,e,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,i=void 0,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>'}},a=function(t){return d.extend(r,t)},f=function(){var t;return t=r.template,d.isFunction(t)?t(r):t},c=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},s=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t,n,e,r){var o,u,i,a;return i=$(f()),r&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),d.isPresent(n)&&u.css("width",n),d.isPresent(e)&&u.css("height",e),o=u.find(".up-modal-content"),a=d.$createElementFromSelector(t),a.appendTo(o),i.appendTo(document.body),c(),i.hide(),i},m=function(t,n,e){return t.show(),up.animate(t,n,e)},l=function(){var n,o,i,a,s,l,c,p,f,h,v,g;return s=1<=arguments.length?t.call(arguments,0):[],!d.isObject(s[0])||d.isElement(s[0])||d.isJQuery(s[0])?(n=$(s[0]),p=s[1]):(n=d.nullJquery(),p=s[0]),p=d.options(p),v=d.option(p.url,n.attr("up-href"),n.attr("href")),f=d.option(p.target,n.attr("up-modal"),"body"),g=d.option(p.width,n.attr("up-width"),r.width),l=d.option(p.height,n.attr("up-height"),r.height),a=d.option(p.animation,n.attr("up-animation"),r.openAnimation),h=d.option(p.sticky,n.is("[up-sticky]")),c=up.browser.canPushState()?d.option(p.history,n.attr("up-history"),!0):!1,i=up.motion.animateOptions(p,n),e(),o=u(f,g,l,h),up.replace(f,v,{history:c,insert:function(){return m(o,a,i)}})},p=function(){return i},e=function(t){var n;return n=$(".up-modal"),n.length?(t=d.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),i=void 0,up.destroy(n,t)):void 0},n=function(){return $(".up-modal").is("[up-sticky]")?void 0:(s(),e())},o=function(t){var n;return n=$(t),n.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():l(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-modal-dialog").length||n.closest("[up-modal]").length?void 0:e()}),up.bus.on("fragment:ready",function(t){var e;if(o(t)){if(e=t.attr("up-source"))return i=e}else if(!up.popup.contains(t))return n()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-modal")?e():void 0}),up.bus.on("framework:reset",e),{open:l,close:e,source:p,defaults:a,contains:o}}()}.call(this),function(){up.tooltip=function(){var t,n,e,r,o;return o=up.util,r=function(t,n,e){var r,u,i;return u=o.measure(t),i=o.measure(n),r=function(){switch(e){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown position %o",e)}}(),n.attr("up-position",e),n.css(r)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},e=function(e,u){var i,a,s,l,c,p;return null==u&&(u={}),i=$(e),c=o.option(u.html,i.attr("up-tooltip"),i.attr("title")),p=o.option(u.position,i.attr("up-position"),"top"),l=o.option(u.animation,i.attr("up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=n(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(n,t)):void 0},up.compiler("[up-tooltip]",function(n){return n.on("mouseover",function(){return e(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:e,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,e,r,o,u,i,a,s,l,c,p,f,d,m;return f=up.util,t="up-active",n="up-current",e=["a","[up-href]","[up-alias]"],o=e.join(", "),u=function(){var t,n,r;for(r=[],t=0,n=e.length;n>t;t++)p=e[t],r.push(p+"[up-instant]");return r}().join(", "),r="."+t,s=function(t){return f.isPresent(t)?f.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},c=function(t){var n,e,r,o,u,i,a,l;for(i=[],u=["href","up-href"],r=0,o=u.length;o>r;r++)e=u[r],(a=f.presentAttr(t,e))&&i.push(a);return(n=f.presentAttr(t,"up-alias"))&&(l=n.split(" "),i=i.concat(l)),i.map(s)},m=function(t){var n,e,r,o;return t=f.compact(t),r=function(t){return"*"===t.substr(-1)?e(t.slice(0,-1)):n(t)},n=function(n){return f.contains(t,n)},e=function(n){return f.detect(t,function(t){return 0===t.indexOf(n)})},o=function(t){return f.detect(t,r)},{matchesAny:o}},a=function(){var t;return t=m([s(up.browser.url()),s(up.modal.source()),s(up.popup.source())]),f.each($(o),function(e){var r,o;return r=$(e),o=c(r),t.matchesAny(o)?r.addClass(n):r.removeClass(n)})},l=function(n){return d(),n=i(n),n.addClass(t)},i=function(t){return f.presence(t.parents(o))||t},d=function(){return $(r).removeClass(t)},up.on("click",o,function(t,n){return f.isUnmodifiedMouseEvent(t)&&!n.is("[up-instant]")?l(n):void 0}),up.on("mousedown",u,function(t,n){return f.isUnmodifiedMouseEvent(t)?l(n):void 0}),up.bus.on("fragment:ready",function(){return d(),a()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?a():void 0})}()}.call(this),function(){up.slot=function(){var t,n,e;return e=up.util,n=function(t){return""!==e.trim(t.html())},t=function(t){return e.findWithSelf(t,"[up-slot]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.browser.ensureRecentJquery(),up.browser.isSupported()&&(up.browser.ensureConsoleExists(),up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")}))}.call(this);
@@ -38,8 +38,8 @@ We need to work on this page:
38
38
 
39
39
  - Decide whether to refactor this into document events
40
40
  - Decide whether `fragment:enter` and `fragment:leave` would be better names
41
+ - Decide if we wouldn't rather document events in the respective module (e.g. proxy).
41
42
 
42
-
43
43
  @class up.bus
44
44
  ###
45
45
  up.bus = (->
@@ -79,15 +79,32 @@ up.bus = (->
79
79
  event is triggered.
80
80
 
81
81
  @method up.bus.on
82
- @param {String} eventName
83
- The event name to match.
82
+ @param {String} eventNames
83
+ A space-separated list of event names to match.
84
84
  @param {Function} handler
85
- The event handler to be called with the event arguments.
85
+ The event handler to be called with the event arguments.
86
+ @return {Function}
87
+ A function that unregisters the given handlers
86
88
  ###
87
89
  # We cannot call this function "on" because Coffeescript
88
90
  # https://makandracards.com/makandra/29733-english-words-that-you-cannot-use-in-coffeescript
89
- listen = (eventName, handler) ->
90
- callbacksFor(eventName).push(handler)
91
+ listen = (eventNames, handler) ->
92
+ for eventName in eventNames.split(' ')
93
+ callbacksFor(eventName).push(handler)
94
+ -> stopListen(eventNames, handler)
95
+
96
+ ###*
97
+ Unregisters the given handler from the given events.
98
+
99
+ @method up.bus.off
100
+ @param {String} eventNames
101
+ A space-separated list of event names .
102
+ @param {Function} handler
103
+ The event handler that should stop listening.
104
+ ###
105
+ stopListen = (eventNames, handler) ->
106
+ for eventName in eventNames.split(' ')
107
+ u.remove(callbacksFor(eventName), handler)
91
108
 
92
109
  ###*
93
110
  Triggers an event over the framework bus.
@@ -123,5 +140,6 @@ up.bus = (->
123
140
  listen 'framework:reset', reset
124
141
 
125
142
  on: listen
143
+ off: stopListen
126
144
  emit: emit
127
145
  )()
@@ -73,6 +73,7 @@ up.flow = (->
73
73
  method: options.method
74
74
  selector: selector
75
75
  cache: options.cache
76
+ preload: options.preload
76
77
 
77
78
  promise = up.proxy.ajax(request)
78
79
 
@@ -4,7 +4,7 @@ Caching and preloading
4
4
 
5
5
  All HTTP requests go through the Up.js proxy.
6
6
  It caches a [limited](/up.proxy#up.proxy.defaults) number of server responses
7
- for a [limited](/up.proxy#up.proxy.defaults) amount of time,
7
+ for a [limited](/up.proxy#up.proxy.defaults) amount of time,
8
8
  making requests to these URLs return insantly.
9
9
 
10
10
  The cache is cleared whenever the user makes a non-`GET` request
@@ -13,17 +13,78 @@ The cache is cleared whenever the user makes a non-`GET` request
13
13
  The proxy can also used to speed up reaction times by preloading
14
14
  links when the user hovers over the click area (or puts the mouse/finger
15
15
  down before releasing). This way the
16
- response will already be cached when the user performs the click.
16
+ response will already be cached when the user performs the click.
17
+
18
+ Spinners
19
+ ---------
20
+
21
+ You can listen to [framework events](/up.bus) to implement a spinner
22
+ (progress indicator) that appears during a long-running request,
23
+ and disappears once the response has been received:
24
+
25
+ <div class="spinner">Please wait!</div>
26
+
27
+ Here is the Javascript to make it alive:
28
+
29
+ up.compiler('.spinner', function($element) {
30
+
31
+ show = function() { $element.show() };
32
+ hide = function() { $element.hide() };
33
+
34
+ up.bus.on('proxy:busy', show);
35
+ up.bus.on('proxy:idle', hide);
36
+
37
+ return function() {
38
+ up.bus.off('proxy:busy', show);
39
+ up.bus.off('proxy:idle', hide);
40
+ };
41
+
42
+ });
43
+
44
+ The `proxy:busy` event will be emitted after a delay of 300 ms
45
+ to prevent the spinner from flickering on and off.
46
+ You can change (or remove) this delay like this:
47
+
48
+ up.proxy.defaults({ busyDelay: 150 });
17
49
 
18
50
  @class up.proxy
19
51
  ###
20
52
  up.proxy = (->
21
53
 
22
- config =
54
+ u = up.util
55
+
56
+ cache = undefined
57
+ $waitingLink = undefined
58
+ preloadDelayTimer = undefined
59
+ busyDelayTimer = undefined
60
+ pendingCount = undefined
61
+ config = undefined
62
+ busyEventEmitted = undefined
63
+ FACTORY_CONFIG =
64
+ busyDelay: 300
23
65
  preloadDelay: 75
24
66
  cacheSize: 70
25
67
  cacheExpiry: 1000 * 60 * 5
26
68
 
69
+ cancelPreloadDelay = ->
70
+ clearTimeout(preloadDelayTimer)
71
+ preloadDelayTimer = null
72
+
73
+ cancelBusyDelay = ->
74
+ clearTimeout(busyDelayTimer)
75
+ busyDelayTimer = null
76
+
77
+ reset = ->
78
+ cache = {}
79
+ $waitingLink = null
80
+ cancelPreloadDelay()
81
+ cancelBusyDelay()
82
+ pendingCount = 0
83
+ config = u.copy(FACTORY_CONFIG)
84
+ busyEventEmitted = false
85
+
86
+ reset()
87
+
27
88
  ###*
28
89
  @method up.proxy.defaults
29
90
  @param {Number} [options.preloadDelay=75]
@@ -35,17 +96,13 @@ up.proxy = (->
35
96
  @param {Number} [options.cacheExpiry=300000]
36
97
  The number of milliseconds until a cache entry expires.
37
98
  Defaults to 5 minutes.
99
+ @param {Number} [options.busyDelay=300]
100
+ How long the proxy waits until emitting the `proxy:busy` [event](/up.bus).
101
+ Use this to prevent flickering of spinners.
38
102
  ###
39
103
  defaults = (options) ->
40
104
  u.extend(config, options)
41
-
42
- cache = {}
43
-
44
- u = up.util
45
-
46
- $waitingLink = null
47
- delayTimer = null
48
-
105
+
49
106
  cacheKey = (request) ->
50
107
  normalizeRequest(request)
51
108
  [ request.url,
@@ -82,7 +139,7 @@ up.proxy = (->
82
139
  u.debug("Aliasing %o to %o", oldRequest, newRequest)
83
140
  if promise = get(oldRequest)
84
141
  set(newRequest, promise)
85
-
142
+
86
143
  ###*
87
144
  Makes a request to the given URL and caches the response.
88
145
  If the response was already cached, returns the HTML instantly.
@@ -91,6 +148,11 @@ up.proxy = (->
91
148
  not be cached and the entire cache will be cleared.
92
149
  Only requests with a method of `GET`, `OPTIONS` and `HEAD`
93
150
  are considered to be read-only.
151
+
152
+ If a network connection is attempted, the proxy will emit
153
+ a `proxy:load` event with the `request` as its argument.
154
+ Once the response is received, a `proxy:receive` event will
155
+ be emitted.
94
156
 
95
157
  @method up.proxy.ajax
96
158
  @param {String} request.url
@@ -106,23 +168,91 @@ up.proxy = (->
106
168
 
107
169
  request = u.only(options, 'url', 'method', 'data', 'selector', '_normalized')
108
170
 
171
+ pending = true
172
+
109
173
  # We don't cache non-GET responses unless `options.cache`
110
174
  # is explicitly set to `true`.
111
175
  if !isIdempotent(request) && !forceCache
112
176
  clear()
113
- promise = u.ajax(request)
177
+ promise = load(request)
114
178
  # If a cached response is available, we use it unless
115
179
  # `options.cache` is explicitly set to `false`.
116
180
  else if (promise = get(request)) && !ignoreCache
117
- promise
181
+ pending = (promise.state() == 'pending')
118
182
  else
119
- promise = u.ajax(request)
183
+ promise = load(request)
120
184
  set(request, promise)
121
185
 
186
+ if pending && !options.preload
187
+ # This will actually make `pendingCount` higher than the actual
188
+ # number of outstanding requests. However, we need to cover the
189
+ # following case:
190
+ #
191
+ # - User starts preloading a request.
192
+ # This triggers *no* `proxy:busy`.
193
+ # - User starts loading the request (without preloading).
194
+ # This triggers `proxy:busy`.
195
+ # - The request finishes.
196
+ # This triggers `proxy:idle`.
197
+ loadStarted()
198
+ promise.then(loadEnded)
199
+
122
200
  promise
123
201
 
124
202
  SAFE_HTTP_METHODS = ['GET', 'OPTIONS', 'HEAD']
125
-
203
+
204
+ ###*
205
+ Returns `true` if the proxy is not currently waiting
206
+ for a request to finish. Returns `false` otherwise.
207
+
208
+ The proxy will also emit an `proxy:idle` [event](/up.bus) if it
209
+ used to busy, but is now idle.
210
+
211
+ @method up.proxy.idle
212
+ @return {Boolean} Whether the proxy is idle
213
+ ###
214
+ idle = ->
215
+ pendingCount == 0
216
+
217
+ ###*
218
+ Returns `true` if the proxy is currently waiting
219
+ for a request to finish. Returns `false` otherwise.
220
+
221
+ The proxy will also emit an `proxy:busy` [event](/up.bus) if it
222
+ used to idle, but is now busy.
223
+
224
+ @method up.proxy.busy
225
+ @return {Boolean} Whether the proxy is busy
226
+ ###
227
+ busy = ->
228
+ pendingCount > 0
229
+
230
+ loadStarted = ->
231
+ wasIdle = idle()
232
+ pendingCount += 1
233
+ if wasIdle
234
+ emission = ->
235
+ if busy() # a fast response might have beaten the delay
236
+ up.bus.emit('proxy:busy')
237
+ busyEventEmitted = true
238
+ if config.busyDelay > 0
239
+ busyDelayTimer = setTimeout(emission, config.busyDelay)
240
+ else
241
+ emission()
242
+
243
+ loadEnded = ->
244
+ pendingCount -= 1
245
+ if idle() && busyEventEmitted
246
+ up.bus.emit('proxy:idle')
247
+ busyEventEmitted = false
248
+
249
+ load = (request) ->
250
+ up.bus.emit('proxy:load', request)
251
+ promise = u.ajax(request)
252
+ promise.then ->
253
+ up.bus.emit('proxy:receive', request)
254
+ promise
255
+
126
256
  isIdempotent = (request) ->
127
257
  normalizeRequest(request)
128
258
  u.contains(SAFE_HTTP_METHODS, request.method)
@@ -180,16 +310,12 @@ up.proxy = (->
180
310
  delay = parseInt(u.presentAttr($link, 'up-delay')) || config.preloadDelay
181
311
  unless $link.is($waitingLink)
182
312
  $waitingLink = $link
183
- cancelDelay()
313
+ cancelPreloadDelay()
184
314
  curriedPreload = -> preload($link)
185
- startDelay(curriedPreload, delay)
315
+ startPreloadDelay(curriedPreload, delay)
186
316
 
187
- startDelay = (block, delay) ->
188
- delayTimer = setTimeout(block, delay)
189
-
190
- cancelDelay = ->
191
- clearTimeout(delayTimer)
192
- delayTimer = null
317
+ startPreloadDelay = (block, delay) ->
318
+ preloadDelayTimer = setTimeout(block, delay)
193
319
 
194
320
  ###*
195
321
  @protected
@@ -209,10 +335,6 @@ up.proxy = (->
209
335
  else
210
336
  u.debug("Won't preload %o due to unsafe method %o", $link, method)
211
337
  u.resolvedPromise()
212
-
213
- reset = ->
214
- cancelDelay()
215
- cache = {}
216
338
 
217
339
  up.bus.on 'framework:reset', reset
218
340
 
@@ -244,6 +366,8 @@ up.proxy = (->
244
366
  alias: alias
245
367
  clear: clear
246
368
  remove: remove
369
+ idle: idle
370
+ busy: busy
247
371
  defaults: defaults
248
372
 
249
373
  )()
@@ -568,6 +568,12 @@ up.util = (->
568
568
  if isMissing($element.attr(key))
569
569
  $element.attr(key, value)
570
570
 
571
+ remove = (array, element) ->
572
+ index = array.indexOf(element)
573
+ if index >= 0
574
+ array.splice(index, 1)
575
+ element
576
+
571
577
  presentAttr: presentAttr
572
578
  createElement: createElement
573
579
  normalizeUrl: normalizeUrl
@@ -637,5 +643,6 @@ up.util = (->
637
643
  resolvedDeferred: resolvedDeferred
638
644
  resolvableWhen: resolvableWhen
639
645
  setMissingAttrs: setMissingAttrs
646
+ remove: remove
640
647
 
641
648
  )()
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.7.8'
3
+ VERSION = '0.8.0'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- upjs-rails (0.7.5)
4
+ upjs-rails (0.7.8)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -86,6 +86,146 @@ describe 'up.proxy', ->
86
86
  it "caches #{method} requests with cache: true option", ->
87
87
  u.times 2, -> up.proxy.ajax(url: '/foo', method: method, cache: true)
88
88
  expect(jasmine.Ajax.requests.count()).toEqual(1)
89
+
90
+ describe 'events', ->
91
+
92
+ beforeEach ->
93
+ up.proxy.defaults(busyDelay: 0)
94
+ @events = []
95
+ u.each ['proxy:load', 'proxy:receive', 'proxy:busy', 'proxy:idle'], (eventName) =>
96
+ up.bus.on eventName, =>
97
+ @events.push eventName
98
+
99
+ it 'emits an proxy:busy event once the proxy started loading, and proxy:idle if it is done loading', ->
100
+
101
+ up.proxy.ajax(url: '/foo')
102
+
103
+ expect(@events).toEqual([
104
+ 'proxy:load',
105
+ 'proxy:busy'
106
+ ])
107
+
108
+ up.proxy.ajax(url: '/bar')
109
+
110
+ expect(@events).toEqual([
111
+ 'proxy:load',
112
+ 'proxy:busy',
113
+ 'proxy:load'
114
+ ])
115
+
116
+ jasmine.Ajax.requests.at(0).respondWith
117
+ status: 200
118
+ contentType: 'text/html'
119
+ responseText: 'foo'
120
+
121
+ expect(@events).toEqual([
122
+ 'proxy:load',
123
+ 'proxy:busy',
124
+ 'proxy:load',
125
+ 'proxy:receive'
126
+ ])
127
+
128
+ jasmine.Ajax.requests.at(1).respondWith
129
+ status: 200
130
+ contentType: 'text/html'
131
+ responseText: 'bar'
132
+
133
+ expect(@events).toEqual([
134
+ 'proxy:load',
135
+ 'proxy:busy',
136
+ 'proxy:load',
137
+ 'proxy:receive',
138
+ 'proxy:receive',
139
+ 'proxy:idle'
140
+ ])
141
+
142
+ it 'does not emit an proxy:busy event if preloading', ->
143
+
144
+ # A request for preloading preloading purposes
145
+ # doesn't make us busy.
146
+ up.proxy.ajax(url: '/foo', preload: true)
147
+ expect(@events).toEqual([
148
+ 'proxy:load'
149
+ ])
150
+ expect(up.proxy.busy()).toBe(false)
151
+
152
+ # The same request with preloading does make us busy.
153
+ up.proxy.ajax(url: '/foo')
154
+ expect(@events).toEqual([
155
+ 'proxy:load',
156
+ 'proxy:busy'
157
+ ])
158
+ expect(up.proxy.busy()).toBe(true)
159
+
160
+ # The response resolves both promises and makes
161
+ # the proxy idle again.
162
+ jasmine.Ajax.requests.at(0).respondWith
163
+ status: 200
164
+ contentType: 'text/html'
165
+ responseText: 'foo'
166
+ expect(@events).toEqual([
167
+ 'proxy:load',
168
+ 'proxy:busy',
169
+ 'proxy:receive',
170
+ 'proxy:idle'
171
+ ])
172
+ expect(up.proxy.busy()).toBe(false)
173
+
174
+ it 'can delay the proxy:busy event to prevent flickering of spinners', ->
175
+ jasmine.clock().install()
176
+ up.proxy.defaults(busyDelay: 100)
177
+
178
+ up.proxy.ajax(url: '/foo')
179
+ expect(@events).toEqual([
180
+ 'proxy:load'
181
+ ])
182
+
183
+ jasmine.clock().tick(50)
184
+ expect(@events).toEqual([
185
+ 'proxy:load'
186
+ ])
187
+
188
+ jasmine.clock().tick(50)
189
+ expect(@events).toEqual([
190
+ 'proxy:load',
191
+ 'proxy:busy'
192
+ ])
193
+
194
+ jasmine.Ajax.requests.at(0).respondWith
195
+ status: 200
196
+ contentType: 'text/html'
197
+ responseText: 'foo'
198
+
199
+ expect(@events).toEqual([
200
+ 'proxy:load',
201
+ 'proxy:busy',
202
+ 'proxy:receive',
203
+ 'proxy:idle'
204
+ ])
205
+
206
+ it 'does not emit proxy:idle if a delayed proxy:busy was never emitted due to a fast response', ->
207
+ jasmine.clock().install()
208
+ up.proxy.defaults(busyDelay: 100)
209
+
210
+ up.proxy.ajax(url: '/foo')
211
+ expect(@events).toEqual([
212
+ 'proxy:load'
213
+ ])
214
+
215
+ jasmine.clock().tick(50)
216
+
217
+ jasmine.Ajax.requests.at(0).respondWith
218
+ status: 200
219
+ contentType: 'text/html'
220
+ responseText: 'foo'
221
+
222
+ jasmine.clock().tick(100)
223
+
224
+ expect(@events).toEqual([
225
+ 'proxy:load',
226
+ 'proxy:receive'
227
+ ])
228
+
89
229
 
90
230
  describe 'up.proxy.preload', ->
91
231
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: upjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.8
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-08-12 00:00:00.000000000 Z
11
+ date: 2015-08-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails