upjs-rails 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f3dab9011d6c5e3018025b0e43eec1986da6fb10
4
- data.tar.gz: d988ede1c45da41df73017621d2de43243366414
3
+ metadata.gz: b59ccc745c2214c54bf451b0faa9841822ab9e52
4
+ data.tar.gz: 72cc227d94c1c84edfe3ea5a3d3c01f4c1b49f78
5
5
  SHA512:
6
- metadata.gz: 1308ca2e5698d237e001d7ff586b2d8a65f7639853b11a83bbb23bffb4fb96d4f59ecbe2344429dbbd0544378f00d23282edbd08dceec30b8b390f35f3739798
7
- data.tar.gz: 9e9d6f5ffe0ad7a123b08977f5a582da89b9cf2714e269287d840dc9ba599637647a14fcf753b0248cdfc75ca062fae1f49bf14caa30e2ccd271b129de5d35ef
6
+ metadata.gz: 1814cd8904d97b36a09ec409c845376313686daab26c6c8e304279f2b319ac66e8357347344d2a0ba6fcf8e4da99fa6857b0032b312c2ec09d34fa2c1a560964
7
+ data.tar.gz: bafe6daa289650a1a44e7d7ac45a7480075ca1a8d3f1783fac0f375de1dab657c58e4fcb52ecb35aeff366d4e66c7cf2545a9435f3e1e354ea194d53b6e8c800
data/CHANGELOG.md CHANGED
@@ -24,7 +24,15 @@ This project mostly adheres to [Semantic Versioning](http://semver.org/).
24
24
  [`a[up-target]`](http://upjs.io/up.link#a-up-target).
25
25
 
26
26
 
27
- 0.10.1
27
+ 0.10.3
28
+ ------
29
+
30
+ ### Compatible changes
31
+
32
+ - The default viewport is now `document` instead of the `<body>` element.
33
+
34
+
35
+ 0.10.2
28
36
  ------
29
37
 
30
38
  ### Breaking changes
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, cache, castedAttr, clientSize, compact, config, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, endsWith, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, identity, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isNumber, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, map, measure, memoize, merge, methodFromXhr, nextFrame, normalizeMethod, normalizeUrl, nullJquery, once, only, option, options, presence, presentAttr, remove, resolvableWhen, resolvedDeferred, resolvedPromise, scrollbarWidth, select, setMissingAttrs, startsWith, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unJquery, uniq, unwrapElement, warn;
28
+ var $createElementFromSelector, ANIMATION_PROMISE_KEY, CONSOLE_PLACEHOLDERS, ajax, any, cache, castedAttr, clientSize, compact, config, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, debug, detect, each, emptyJQuery, endsWith, error, escapePressed, extend, findWithSelf, finishCssAnimate, forceCompositing, get, identity, ifGiven, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isNumber, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, keys, last, locationFromXhr, map, measure, memoize, merge, methodFromXhr, multiSelector, nextFrame, normalizeMethod, normalizeUrl, nullJquery, once, only, option, options, presence, presentAttr, remove, resolvableWhen, resolvedDeferred, resolvedPromise, scrollbarWidth, select, setMissingAttrs, startsWith, stringifyConsoleArgs, temporaryCss, times, toArray, trim, unJquery, uniq, unwrapElement, warn;
29
29
  memoize = function(func) {
30
30
  var cache, cached;
31
31
  cache = void 0;
@@ -415,7 +415,7 @@ If you use them in your own code, you will get hurt.
415
415
  option = function() {
416
416
  var arg, args, j, len, match, value;
417
417
  args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
418
- match = null;
418
+ match = void 0;
419
419
  for (j = 0, len = args.length; j < len; j++) {
420
420
  arg = args[j];
421
421
  value = arg;
@@ -431,7 +431,7 @@ If you use them in your own code, you will get hurt.
431
431
  };
432
432
  detect = function(array, tester) {
433
433
  var element, j, len, match;
434
- match = null;
434
+ match = void 0;
435
435
  for (j = 0, len = array.length; j < len; j++) {
436
436
  element = array[j];
437
437
  if (tester(element)) {
@@ -441,6 +441,11 @@ If you use them in your own code, you will get hurt.
441
441
  }
442
442
  return match;
443
443
  };
444
+ any = function(array, tester) {
445
+ var match;
446
+ match = detect(array, tester);
447
+ return isDefined(match);
448
+ };
444
449
  compact = function(array) {
445
450
  return select(array, isGiven);
446
451
  };
@@ -528,6 +533,18 @@ If you use them in your own code, you will get hurt.
528
533
  return result;
529
534
  };
530
535
  };
536
+
537
+ /**
538
+ * Temporarily sets the CSS for the given element.
539
+ #
540
+ * @method up.util.temporaryCss
541
+ * @param {jQuery} $element
542
+ * @param {Object} css
543
+ * @param {Function} [block]
544
+ * If given, the CSS is set, the block is called and
545
+ * the old CSS is restored.
546
+ * @private
547
+ */
531
548
  temporaryCss = function($element, css, block) {
532
549
  var memo, oldCss;
533
550
  oldCss = $element.css(keys(css));
@@ -786,6 +803,72 @@ If you use them in your own code, you will get hurt.
786
803
  return element;
787
804
  }
788
805
  };
806
+ emptyJQuery = function() {
807
+ return $([]);
808
+ };
809
+ multiSelector = function(parts) {
810
+ var combinedSelector, elements, j, len, obj, part, selectors;
811
+ obj = {};
812
+ selectors = [];
813
+ elements = [];
814
+ for (j = 0, len = parts.length; j < len; j++) {
815
+ part = parts[j];
816
+ if (isString(part)) {
817
+ selectors.push(part);
818
+ } else {
819
+ elements.push(part);
820
+ }
821
+ }
822
+ obj.parsed = elements;
823
+ if (selectors.length) {
824
+ combinedSelector = selectors.join(', ');
825
+ obj.parsed.push(combinedSelector);
826
+ }
827
+ obj.select = function() {
828
+ return obj.find(void 0);
829
+ };
830
+ obj.find = function($root) {
831
+ var $matches, $result, k, len1, ref, selector;
832
+ $result = emptyJQuery();
833
+ ref = obj.parsed;
834
+ for (k = 0, len1 = ref.length; k < len1; k++) {
835
+ selector = ref[k];
836
+ $matches = $root ? $root.find(selector) : $(selector);
837
+ $result = $result.add($matches);
838
+ }
839
+ return $result;
840
+ };
841
+ obj.findWithSelf = function($start) {
842
+ var $matches;
843
+ $matches = obj.find($start);
844
+ if (obj.doesMatch($start)) {
845
+ $matches = $matches.add($start);
846
+ }
847
+ return $matches;
848
+ };
849
+ obj.doesMatch = function(element) {
850
+ var $element;
851
+ $element = $(element);
852
+ return any(obj.parsed, function(selector) {
853
+ return $element.is(selector);
854
+ });
855
+ };
856
+ obj.seekUp = function(start) {
857
+ var $element, $result, $start;
858
+ $start = $(start);
859
+ $element = $start;
860
+ $result = void 0;
861
+ while ($element.length) {
862
+ if (obj.doesMatch($element)) {
863
+ $result = $element;
864
+ break;
865
+ }
866
+ $element = $element.parent();
867
+ }
868
+ return $result || emptyJQuery();
869
+ };
870
+ return obj;
871
+ };
789
872
 
790
873
  /**
791
874
  @method up.util.cache
@@ -1000,6 +1083,7 @@ If you use them in your own code, you will get hurt.
1000
1083
  map: map,
1001
1084
  identity: identity,
1002
1085
  times: times,
1086
+ any: any,
1003
1087
  detect: detect,
1004
1088
  select: select,
1005
1089
  compact: compact,
@@ -1056,7 +1140,9 @@ If you use them in your own code, you will get hurt.
1056
1140
  scrollbarWidth: scrollbarWidth,
1057
1141
  config: config,
1058
1142
  cache: cache,
1059
- unwrapElement: unwrapElement
1143
+ unwrapElement: unwrapElement,
1144
+ multiSelector: multiSelector,
1145
+ emptyJQuery: emptyJQuery
1060
1146
  };
1061
1147
  })();
1062
1148
 
@@ -1987,7 +2073,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
1987
2073
  */
1988
2074
  config = u.config({
1989
2075
  duration: 0,
1990
- viewports: ['body', '.up-modal', '[up-viewport]'],
2076
+ viewports: [document, '.up-modal', '[up-viewport]'],
1991
2077
  fixedTop: ['[up-fixed~=top]'],
1992
2078
  fixedBottom: ['[up-fixed~=bottom]'],
1993
2079
  snap: 50,
@@ -2152,26 +2238,26 @@ This modules contains functions to scroll the viewport and reveal contained elem
2152
2238
 
2153
2239
  @method up.reveal
2154
2240
  @param {String|Element|jQuery} element
2155
- @param {String|Element|jQuery} [options.viewport]
2156
2241
  @param {Number} [options.duration]
2157
2242
  @param {String} [options.easing]
2158
2243
  @param {String} [options.snap]
2244
+ @param {String|Element|jQuery} [options.viewport]
2159
2245
  @return {Deferred}
2160
2246
  A promise that will be resolved when the element is revealed.
2161
2247
  */
2162
2248
  reveal = function(elementOrSelector, options) {
2163
- var $element, $viewport, elementDims, firstElementRow, lastElementRow, newScrollPos, obstruction, offsetShift, originalScrollPos, predictFirstVisibleRow, predictLastVisibleRow, snap, viewportHeight, viewportIsBody;
2249
+ var $element, $viewport, elementDims, firstElementRow, lastElementRow, newScrollPos, obstruction, offsetShift, originalScrollPos, predictFirstVisibleRow, predictLastVisibleRow, snap, viewportHeight, viewportIsDocument;
2164
2250
  options = u.options(options);
2165
2251
  $element = $(elementOrSelector);
2166
- $viewport = viewportOf($element, options.viewport);
2252
+ $viewport = options.viewport ? $(options.viewport) : viewportOf($element);
2167
2253
  snap = u.option(options.snap, config.snap);
2168
- viewportIsBody = $viewport.is('body');
2169
- viewportHeight = viewportIsBody ? u.clientSize().height : $viewport.height();
2254
+ viewportIsDocument = $viewport.is(document);
2255
+ viewportHeight = viewportIsDocument ? u.clientSize().height : $viewport.height();
2170
2256
  originalScrollPos = $viewport.scrollTop();
2171
2257
  newScrollPos = originalScrollPos;
2172
2258
  offsetShift = void 0;
2173
2259
  obstruction = void 0;
2174
- if (viewportIsBody) {
2260
+ if (viewportIsDocument) {
2175
2261
  obstruction = measureObstruction();
2176
2262
  offsetShift = 0;
2177
2263
  } else {
@@ -2208,7 +2294,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2208
2294
  }
2209
2295
  };
2210
2296
  viewportSelector = function() {
2211
- return config.viewports.join(', ');
2297
+ return u.multiSelector(config.viewports);
2212
2298
  };
2213
2299
 
2214
2300
  /**
@@ -2220,16 +2306,10 @@ This modules contains functions to scroll the viewport and reveal contained elem
2220
2306
  @method up.layout.viewportOf
2221
2307
  @param {String|Element|jQuery} selectorOrElement
2222
2308
  */
2223
- viewportOf = function(selectorOrElement, viewportSelectorOrElement) {
2224
- var $element, $viewport, vieportSelector;
2309
+ viewportOf = function(selectorOrElement) {
2310
+ var $element, $viewport;
2225
2311
  $element = $(selectorOrElement);
2226
- $viewport = void 0;
2227
- if (u.isJQuery(viewportSelectorOrElement)) {
2228
- $viewport = viewportSelectorOrElement;
2229
- } else {
2230
- vieportSelector = u.presence(viewportSelectorOrElement) || viewportSelector();
2231
- $viewport = $element.closest(vieportSelector);
2232
- }
2312
+ $viewport = viewportSelector().seekUp($element);
2233
2313
  $viewport.length || u.error("Could not find viewport for %o", $element);
2234
2314
  return $viewport;
2235
2315
  };
@@ -2246,7 +2326,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2246
2326
  viewportsIn = function(selectorOrElement) {
2247
2327
  var $element;
2248
2328
  $element = $(selectorOrElement);
2249
- return u.findWithSelf($element, viewportSelector());
2329
+ return viewportSelector().findWithSelf($element);
2250
2330
  };
2251
2331
 
2252
2332
  /**
@@ -2256,7 +2336,7 @@ This modules contains functions to scroll the viewport and reveal contained elem
2256
2336
  @method up.layout.viewports
2257
2337
  */
2258
2338
  viewports = function() {
2259
- return $(viewportSelector());
2339
+ return viewportSelector().select();
2260
2340
  };
2261
2341
 
2262
2342
  /**
@@ -2273,14 +2353,18 @@ This modules contains functions to scroll the viewport and reveal contained elem
2273
2353
  @return Object<String, Number>
2274
2354
  */
2275
2355
  scrollTops = function() {
2276
- var $viewport, i, len, ref, topsBySelector, viewport;
2356
+ var $viewport, i, key, len, ref, topsBySelector, viewport;
2277
2357
  topsBySelector = {};
2278
2358
  ref = config.viewports;
2279
2359
  for (i = 0, len = ref.length; i < len; i++) {
2280
2360
  viewport = ref[i];
2281
2361
  $viewport = $(viewport);
2282
2362
  if ($viewport.length) {
2283
- topsBySelector[viewport] = $viewport.scrollTop();
2363
+ key = viewport;
2364
+ if (viewport === document) {
2365
+ key = 'document';
2366
+ }
2367
+ topsBySelector[key] = $viewport.scrollTop();
2284
2368
  }
2285
2369
  }
2286
2370
  return topsBySelector;
@@ -2312,20 +2396,30 @@ This modules contains functions to scroll the viewport and reveal contained elem
2312
2396
  viewports configured in `up.layout.defaults('viewports')`.
2313
2397
 
2314
2398
  @method up.layout.restoreScroll
2315
- @param {String} [options.within]
2399
+ @param {jQuery} [options.around]
2400
+ If set, only restores viewports that are either an ancestor
2401
+ or descendant of the given element.
2316
2402
  @protected
2317
2403
  */
2318
2404
  restoreScroll = function(options) {
2319
- var $matchingViewport, $viewports, results, scrollTop, selector, tops;
2405
+ var $ancestorViewports, $descendantViewports, $matchingViewport, $viewports, key, results, right, scrollTop, tops;
2320
2406
  if (options == null) {
2321
2407
  options = {};
2322
2408
  }
2323
- $viewports = options.within ? viewportsIn(options.within) : viewports();
2409
+ $viewports = void 0;
2410
+ if (options.around) {
2411
+ $descendantViewports = viewportsIn(options.around);
2412
+ $ancestorViewports = viewportOf(options.around);
2413
+ $viewports = $ancestorViewports.add($descendantViewports);
2414
+ } else {
2415
+ $viewports = viewports();
2416
+ }
2324
2417
  tops = lastScrollTops.get(up.history.url());
2325
2418
  results = [];
2326
- for (selector in tops) {
2327
- scrollTop = tops[selector];
2328
- $matchingViewport = $viewports.filter(selector);
2419
+ for (key in tops) {
2420
+ scrollTop = tops[key];
2421
+ right = key === 'document' ? document : key;
2422
+ $matchingViewport = $viewports.filter(right);
2329
2423
  results.push(up.scroll($matchingViewport, scrollTop, {
2330
2424
  duration: 0
2331
2425
  }));
@@ -2494,7 +2588,7 @@ We need to work on this page:
2494
2588
  scrolling its containing viewport.
2495
2589
  @param {Boolean} [options.restoreScroll=`false`]
2496
2590
  If set to true, Up.js will try to restore the scroll position
2497
- of all the viewports within the updated element. The position
2591
+ of all the viewports around or below the updated element. The position
2498
2592
  will be reset to the last known top position before a previous
2499
2593
  history change for the current URL.
2500
2594
  @param {Boolean} [options.cache]
@@ -2639,7 +2733,7 @@ We need to work on this page:
2639
2733
  }
2640
2734
  if (options.restoreScroll) {
2641
2735
  up.layout.restoreScroll({
2642
- within: $new
2736
+ around: $new
2643
2737
  });
2644
2738
  }
2645
2739
  autofocus($new);
data/dist/up.min.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,C,S,A,E,P,T,D,O,z,U,j,M,F,W,I,N,L,q,H,J,R,K,X,B,G,Q,V,_,Z,Y,te,ee,ne,re,oe,ue,ie,ae,se,le,ce,pe,fe,de,me,he,ve,ge,ye,be,we,ke,$e,xe,Ce,Se,Ae,Ee,Pe,Te,De,Oe;return ne=function(e){var n,r;return n=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?n:(r=!0,n=e.apply(null,o))}},P=function(t,e){return e=e||{},e.url=t,o(e)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},X=function(t,e){return(""===e||"80"===e)&&"http:"===t||"443"===e&&"https:"===t},ae=function(t,e){var n,r,o;return n=null,B(t)?(n=$("<a>").attr({href:t}).get(0),z(n.hostname)&&(n.href=n.href)):n=Pe(t),r=n.protocol+"//"+n.hostname,X(n.protocol,n.port)||(r+=":"+n.port),o=n.pathname,"/"!==o[0]&&(o="/"+o),(null!=e?e.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=e?e.hash:void 0)===!0&&(r+=n.hash),(null!=e?e.search:void 0)!==!1&&(r+=n.search),r},ie=function(t){return t?t.toUpperCase():"GET"},e=function(t){var e,n,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+=">",e=$(s),n&&e.appendTo(n),0===c&&(r=e),n=e}return r},d=function(t,e){var n;return n=document.createElement(t),R(e)&&(n.innerHTML=e),n},g=function(){var e,n;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],n="[UP] "+n,console.debug.apply(console,[n].concat(t.call(e)))},Oe=function(){var e,n;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],n="[UP] "+n,console.warn.apply(console,[n].concat(t.call(e)))},k=function(){var e,n,r;throw n=1<=arguments.length?t.call(arguments,0):[],n[0]="[UP] "+n[0],console.error.apply(console,n),r=xe(n),e=de($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),e.addClass("up-error"),e.text(r),new Error(r)},r=/\%[odisf]/g,xe=function(t){var e,n,o;return o=t[0],e=0,n=50,o.replace(r,function(){var r,o;return e+=1,r=t[e],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>n&&(r=r.substr(0,n)+"\u2026"),r='"'+r+'"'):"number"===o?r=r.toString():(r=JSON.stringify(r),r.length>n&&(r=r.substr(0,n)+"\u2026")),r})},h=function(t){var e,n,r,o,u,i,a;for(g("Creating selector from element %o",t),n=(e=t.attr("class"))?e.split(" "):[],r=t.attr("id"),a=t.prop("tagName").toLowerCase(),r&&(a+="#"+r),o=0,i=n.length;i>o;o++)u=n[o],a+="."+u;return a},m=function(t){var e,n,r,o,u,i,a,s,l,c,p,f;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},e="(?:.|\\n)*?",u=function(t){return"("+t+")"},f=new RegExp(l("head")+e+l("title")+u(e)+i("title")+e+i("body"),"i"),o=new RegExp(l("body")+u(e)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),n=d("body",r[1]),s.appendChild(n),(p=t.match(f))&&(a=d("head"),s.appendChild(a),c=d("title",p[1]),a.appendChild(c)),s):d("div",t)},C=$.extend,Ee=$.trim,_=Object.keys||function(t){var e,n,r,o;for(o=[],e=0,r=t.length;r>e;e++)n=t[e],t.hasOwnProperty(n)&&o.push(n);return o},b=function(t,e){var n,r,o,u,i;for(i=[],n=o=0,u=t.length;u>o;n=++o)r=t[n],i.push(e(r,n));return i},te=b,T=function(t){return t},Se=function(t,e){var n,r,o,u;for(u=[],n=r=0,o=t-1;o>=0?o>=r:r>=o;n=o>=0?++r:--r)u.push(e(n));return u},q=function(t){return null===t},G=function(t){return void 0===t},j=function(t){return!G(t)},L=function(t){return G(t)||q(t)},W=function(t){return!L(t)},z=function(t){return L(t)||J(t)&&0===_(t).length||0===t.length},de=function(t,e){return null==e&&(e=R),e(t)?t:null},R=function(t){return!z(t)},F=function(t){return"function"==typeof t},B=function(t){return"string"==typeof t},H=function(t){return"number"==typeof t},I=function(t){return"object"==typeof t&&!!t},J=function(t){return I(t)||"function"==typeof t},M=function(t){return!(!t||1!==t.nodeType)},N=function(t){return t instanceof jQuery},K=function(t){return J(t)&&F(t.then)},U=function(t){return K(t)&&F(t.resolve)},D=function(t){return W(t)?t:void 0},O=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Ae=function(t){return Array.prototype.slice.call(t)},p=function(t){return O(t)?t.slice():C({},t)},Pe=function(t){return N(t)?t.get(0):t},re=function(t,e){return C(p(t),e)},fe=function(t,e){var n,r,o,u;if(o=t?p(t):{},e)for(r in e)n=e[r],u=o[r],W(u)?J(n)&&J(u)&&(o[r]=fe(u,n)):o[r]=n;return o},pe=function(){var e,n,r,o,u,i;for(n=1<=arguments.length?t.call(arguments,0):[],u=null,r=0,o=n.length;o>r;r++)if(e=n[r],i=e,F(i)&&(i=i()),W(i)){u=i;break}return u},y=function(t,e){var n,r,o,u;for(u=null,r=0,o=t.length;o>r;r++)if(n=t[r],e(n)){u=n;break}return u},s=function(t){return we(t,W)},Te=function(t){var e;return e={},we(t,function(t){return e.hasOwnProperty(t)?!1:e[t]=!0})},we=function(t,e){var n;return n=[],b(t,function(t){return e(t)?n.push(t):void 0}),n},me=function(){var e,n,r,o;return e=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++)n=r[t],u.push(e.attr(n));return u}(),y(o,R)},ue=function(t){return setTimeout(t,0)},Z=function(t){return t[t.length-1]},a=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},be=ne(function(){var t,e,n;return t=$("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),t.appendTo(document.body),e=t.get(0),n=e.offsetWidth-e.clientWidth,t.remove(),n}),le=function(t){var e;return e=void 0,function(){return null!=t&&(e=t()),t=void 0,e}},Ce=function(t,e,n){var r,o;return o=t.css(_(e)),t.css(e),r=function(){return t.css(o)},n?(n(),r()):le(r)},E=function(t){var e,n;return n=t.css(["transform","-webkit-transform"]),z(n)?(e=function(){return t.css(n)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):e=function(){},e},v=function(t,e,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=fe(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":_(e).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=E(o),l=Ce(o,a),o.css(e),u.then(s),u.then(l),o.data(n,u),u.then(function(){return o.removeData(n)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(e),ye())},n="up-animation-promise",A=function(t){return $(t).each(function(){var t;return(t=$(this).data(n))?t.resolve():void 0})},ee=function(t,e){var n,r,o;return r=(null!=e?e.relative:void 0)?t.position():t.offset(),n={left:r.left,top:r.top},(null!=e?e.inner:void 0)?(n.width=t.width(),n.height=t.height()):(n.width=t.outerWidth(),n.height=t.outerHeight()),(null!=e?e.full:void 0)&&(o=a(),n.right=o.width-(n.left+n.width),n.bottom=o.height-(n.top+n.height)),n},f=function(t,e){var n,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)n=u[r],i.push(n.specified?e.attr(n.name,n.value):void 0);return i},S=function(t,e){return t.find(e).addBack(e)},x=function(t){return 27===t.keyCode},$e=function(t,e){return 0===t.indexOf(e)},w=function(t,e){return t.indexOf(e)===t.length-e.length},c=function(t,e){return t.indexOf(e)>=0},i=function(t,e){var n;switch(n=t.attr(e)){case"false":return!1;case"true":return!0;case"":return!0;default:return n}},Y=function(t){return t.getResponseHeader("X-Up-Location")},oe=function(t){return t.getResponseHeader("X-Up-Method")},ce=function(){var e,n,r,o,u,i;for(i=arguments[0],o=2<=arguments.length?t.call(arguments,1):[],e={},n=0,u=o.length;u>n;n++)r=o[n],i.hasOwnProperty(r)&&(e[r]=i[r]);return e},Q=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},V=function(t){var e;return e=G(t.button)||0===t.button,e&&Q(t)},ge=function(){var t;return t=$.Deferred(),t.resolve(),t},ye=function(){return ge().promise()},se=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},ve=function(){var e,n;return e=1<=arguments.length?t.call(arguments,0):[],n=$.when.apply($,e),n.resolve=function(){return b(e,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},n},ke=function(t,e){var n,r,o;r=[];for(n in e)o=e[n],r.push(L(t.attr(n))?t.attr(n,o):void 0);return r},he=function(t,e){var n;return n=t.indexOf(e),n>=0?(t.splice(n,1),e):void 0},u=function(e){var n,r,o,u,i,a,s,l,c,f;return c=void 0,r=function(){return c={}},r(),i=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],e.log?(n[0]="["+e.log+"] "+n[0],g.apply(null,n)):void 0},a=function(){return L(e.size)?void 0:F(e.size)?e.size():H(e.size)?e.size:k("Invalid size config: %o",e.size)},o=function(){return L(e.expiry)?void 0:F(e.expiry)?e.expiry():H(e.expiry)?e.expiry:k("Invalid expiry config: %o",e.expiry)},s=function(t){return e.key?e.key(t):t.toString()},Ee=function(){var t,e,n,r;return r=p(_(c)),n=a(),n&&r.length>n&&(t=null,e=null,b(r,function(n){var r,o;return r=c[n],o=r.timestamp,!e||e>o?(t=n,e=o):void 0}),t)?delete c[t]:void 0},n=function(t,e){var n;return n=P(t),j(n)?l(e,n):void 0},f=function(){return(new Date).valueOf()},l=function(t,e){var n;return n=s(t),c[n]={timestamp:f(),value:e}},he=function(t){var e;return e=s(t),delete c[e]},u=function(t){var e,n;return e=o(),e?(n=f()-t.timestamp,n<o()):!0},P=function(t,e){var n,r;return null==e&&(e=void 0),r=s(t),(n=c[r])?u(n)?(i("Cache hit for %o",t),n.value):(i("Discarding stale cache entry for %o",t),he(t),e):(i("Cache miss for %o",t),e)},{alias:n,get:P,set:l,remove:he,clear:r}},l=function(t){var e,n;return null==t&&(t={}),n={ensureKeyExists:function(e){return t.hasOwnProperty(e)||k("Unknown setting %o",e)},reset:function(){var r,o,u,i;for(i=p(Object.getOwnPropertyNames(n)),r=0,u=i.length;u>r;r++)o=i[r],c(e,o)||delete n[o];return n.update(p(t))},update:function(t){var e,r,o;if(t){if(B(t))return n.ensureKeyExists(t),n[t];r=[];for(e in t)o=t[e],n.ensureKeyExists(e),r.push(n[e]=o);return r}return n}},e=Object.getOwnPropertyNames(n),n.reset(),n},De=function(t){var e,n;return t=Pe(t),e=t.parentNode,n=Ae(t.childNodes),b(n,function(n){return e.insertBefore(n,t)}),e.removeChild(t)},{presentAttr:me,createElement:d,normalizeUrl:ae,normalizeMethod:ie,createElementFromHtml:m,$createElementFromSelector:e,createSelectorFromElement:h,get:P,ajax:o,extend:C,copy:p,merge:re,options:fe,option:pe,error:k,debug:g,warn:Oe,each:b,map:te,identity:T,times:Se,detect:y,select:we,compact:s,uniq:Te,last:Z,isNull:q,isDefined:j,isUndefined:G,isGiven:W,isMissing:L,isPresent:R,isBlank:z,presence:de,isObject:J,isFunction:F,isString:B,isElement:M,isJQuery:N,isPromise:K,isDeferred:U,isHash:I,ifGiven:D,isUnmodifiedKeyEvent:Q,isUnmodifiedMouseEvent:V,nullJquery:se,unJquery:Pe,nextFrame:ue,measure:ee,temporaryCss:Ce,cssAnimate:v,finishCssAnimate:A,forceCompositing:E,escapePressed:x,copyAttributes:f,findWithSelf:S,contains:c,startsWith:$e,endsWith:w,isArray:O,toArray:Ae,castedAttr:i,locationFromXhr:Y,methodFromXhr:oe,clientSize:a,only:ce,trim:Ee,keys:_,resolvedPromise:ye,resolvedDeferred:ge,resolvableWhen:ve,setMissingAttrs:ke,remove:he,memoize:ne,scrollbarWidth:be,config:l,cache:u,unwrapElement:De}}()}.call(this),function(){up.browser=function(){var t,e,n,r,o,u,i,a,s;return a=up.util,i=function(t,e){var n,r,o,u,i,s;return null==e&&(e={}),i=a.option(e.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(s=e.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),n=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",a.isDefined(r)&&a.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),s&&n.attr("target",s),n.hide().append(u).appendTo("body"),n.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},s=function(){return location.href},r=function(){var t,e,n,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(e=window.console).info||(e.info=s),(n=window.console).error||(n.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)},n=a.memoize(function(){return a.isDefined(history.pushState)}),t=a.memoize(function(){return"transition"in document.documentElement.style}),e=a.memoize(function(){return"oninput"in document.createElement("input")}),o=function(){var t,e,n,r,o;return o=$.fn.jquery,r=o.split("."),e=parseInt(r[0]),n=parseInt(r[1]),t=e>=2||1===e&&n>=9,t||a.error("jQuery %o found, but Up.js requires 1.9+",o)},u=a.memoize(function(){return a.isDefined(document.addEventListener)}),{url:s,ensureConsoleExists:r,loadPage:i,canPushState:n,canCssAnimation:t,canInputEvent:e,isSupported:u,ensureRecentJquery:o}}()}.call(this),function(){var t=[].slice;up.bus=function(){var e,n,r,o,u,i,a,s,l;return l=up.util,e={},r={},i=function(){return e=l.copy(r)},n=function(t){return e[t]||(e[t]=[])},a=function(){var t,n,o;r={},o=[];for(n in e)t=e[n],o.push(r[n]=l.copy(t));return o},u=function(t,e){var r,o,u,i;for(i=t.split(" "),o=0,u=i.length;u>o;o++)r=i[o],n(r).push(e);return function(){return s(t,e)}},s=function(t,e){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(n(r),e));return a},o=function(){var e,r,o;return o=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],r=n(o),l.each(r,function(t){return t.apply(null,e)})},u("framework:ready",a),u("framework:reset",i),{on:u,off:s,emit:o}}()}.call(this),function(){var t=[].slice;up.magic=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,e="up-destroyable",n="up-destroyer",f=[],l=null,p=function(t,e,n){var r,o;if(up.browser.isSupported())return r=[t,e,function(t){return n.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},i=[],s=null,u=function(){var e,n,r;return r=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=e.pop(),n=g.options(e[0],{batch:!1}),i.push({selector:r,callback:u,batch:n.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(e),r.data(n,u)):void 0},o=function(t){var e,n,o,a;for(g.debug("Compiling fragment %o",t),a=[],n=0,o=i.length;o>n;n++)u=i[n],e=g.findWithSelf(t,u.selector),a.push(e.length?u.batch?r(u,e,e.get()):e.each(function(){return r(u,$(this),this)}):void 0);return a},c=function(t){return g.findWithSelf(t,"."+e).each(function(){var t,e;return t=$(this),(e=t.data(n))()})},a=function(t){var e,n;return e=$(t),n=e.attr("up-data"),g.isString(n)&&""!==g.trim(n)?JSON.parse(n):{}},v=function(){return l=g.copy(f),s=g.copy(i)},h=function(){var t,e,n,r;for(e=0,n=f.length;n>e;e++)t=f[e],g.contains(l,t)||(r=$(document)).off.apply(r,t);return f=g.copy(l),i=g.copy(s)},m=function(t){var e;return e=$(t),up.bus.emit("fragment:ready",e),e},d=function(t){return p("keydown","body",function(e){return g.escapePressed(e)?t(e):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 e;return e=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,e)}}.call(this),function(){up.history=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h;return h=up.util,e=h.config({popTargets:["body"],restoreScroll:!0}),l=void 0,u=void 0,d=function(){return e.reset(),l=void 0,u=void 0},i=function(t){return h.normalizeUrl(t,{hash:!0})},n=function(){return i(up.browser.url())},r=function(t){return i(t)===n()},a=function(t){return console.log("observing new url %o",t),u&&(l=u,u=void 0),u=t},f=function(t,e){return o("replace",t,e)},c=function(t,e){return o("push",t,e)},o=function(e,o,u){var i,s;return u=h.options(u,{force:!1}),u.force||!r(o)?up.browser.canPushState()?(i=e+"State",s=t(),h.debug("Changing history to URL %o (%o)",o,e),window.history[i](s,"",o),a(n())):h.error("This browser doesn't support history.pushState"):void 0},t=function(){return{fromUp:!0}},m=function(t){var r,o;return o=n(),h.debug("Restoring state %o (now on "+o+")",t),r=e.popTargets.join(", "),up.replace(r,o,{history:!1,reveal:!1,transition:"none",saveScroll:!1,restoreScroll:e.restoreScroll})},s=function(t){var e;return h.debug("History state popped to URL %o",n()),a(n()),up.layout.saveScroll({url:l}),e=t.originalEvent.state,(null!=e?e.fromUp:void 0)?m(e):h.debug("Discarding unknown state %o",e)},up.browser.canPushState()&&(p=function(){return $(window).on("popstate",s),f(n(),{force:!0})},"undefined"!=typeof jasmine&&null!==jasmine?p():setTimeout(p,100)),up.compiler("[up-back]",function(t){return console.log("up-back",t,l),h.isPresent(l)?(h.setMissingAttrs(t,{"up-href":l,"up-restore-scroll":""}),t.removeAttr("up-back"),up.link.makeFollowable(t)):void 0}),up.bus.on("framework:reset",d),{defaults:e.update,push:c,replace:f,url:n,previousUrl:function(){return l},normalizeUrl:i}}()}.call(this),function(){var t=[].slice;up.layout=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return f=up.util,n=f.config({duration:0,viewports:["body",".up-modal","[up-viewport]"],fixedTop:["[up-fixed~=top]"],fixedBottom:["[up-fixed~=bottom]"],snap:50,substance:150,easing:"swing"}),o=f.cache({size:30,key:up.history.normalizeUrl}),i=function(){return n.reset(),o.clear()},e="up-scroll-promise",c=function(t,o,u){var i,a,s,l,c;return i=$(t),u=f.options(u),s=f.option(u.duration,n.duration),l=f.option(u.easing,n.easing),r(i),s>0?(a=$.Deferred(),i.data(e,a),a.then(function(){return i.removeData(e),i.finish()}),c={scrollTop:o},i.animate(c,{duration:s,easing:l,complete:function(){return a.resolve()}}),a):(i.scrollTop(o),f.resolvedDeferred())},r=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},u=function(){var e,r,o,u;return o=function(t,e){var n,r;return n=$(t),r=n.css(e),f.isPresent(r)||f.error("Fixed element %o must have a CSS attribute %o",n,e),parseInt(r)+n.height()},r=function(){var t,e,r,i;for(r=$(n.fixedTop.join(", ")),i=[],t=0,e=r.length;e>t;t++)u=r[t],i.push(o(u,"top"));return i}(),e=function(){var t,e,r,i;for(r=$(n.fixedBottom.join(", ")),i=[],t=0,e=r.length;e>t;t++)u=r[t],i.push(o(u,"bottom"));return i}(),{top:Math.max.apply(Math,[0].concat(t.call(r))),bottom:Math.max.apply(Math,[0].concat(t.call(e)))}},s=function(t,e){var r,o,i,a,s,l,p,m,h,v,g,y,b,w;return e=f.options(e),r=$(t),o=d(r,e.viewport),y=f.option(e.snap,n.snap),w=o.is("body"),b=w?f.clientSize().height:o.height(),h=o.scrollTop(),l=h,m=void 0,p=void 0,w?(p=u(),m=0):(p={top:0,bottom:0},m=h),v=function(){return l+p.top},g=function(){return l+b-p.bottom-1},i=f.measure(r,{relative:!0}),a=i.top+m,s=a+Math.min(i.height,n.substance)-1,s>g()&&(l+=s-g()),a<v()&&(l=a-p.top),y>l&&(l=0),l!==h?c(o,l,e):f.resolvedDeferred()},m=function(){return n.viewports.join(", ")},d=function(t,e){var n,r,o;return n=$(t),r=void 0,f.isJQuery(e)?r=e:(o=f.presence(e)||m(),r=n.closest(o)),r.length||f.error("Could not find viewport for %o",n),r},v=function(t){var e;return e=$(t),f.findWithSelf(e,m())},h=function(){return $(m())},p=function(){var t,e,r,o,u,i;for(u={},o=n.viewports,e=0,r=o.length;r>e;e++)i=o[e],t=$(i),t.length&&(u[i]=t.scrollTop());return u},l=function(t){var e,n;return null==t&&(t={}),n=f.option(t.url,up.history.url()),e=f.option(t.tops,p()),o.set(n,e)},a=function(t){var e,n,r,u,i,a;null==t&&(t={}),n=t.within?v(t.within):h(),a=o.get(up.history.url()),r=[];for(i in a)u=a[i],e=n.filter(i),r.push(up.scroll(e,u,{duration:0}));return r},up.bus.on("framework:reset",i),{reveal:s,scroll:c,finishScrolling:r,defaults:n.update,viewportOf:d,viewportsIn:v,viewports:h,scrollTops:p,saveScroll:l,restoreScroll:a}}(),up.scroll=up.layout.scroll,up.reveal=up.layout.reveal}.call(this),function(){up.flow=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,m=function(t,e){var n;return n=$(t),g.isPresent(e)&&(e=g.normalizeUrl(e)),n.attr("up-source",e)},h=function(t){var e;return e=$(t).closest("[up-source]"),g.presence(e.attr("up-source"))||up.browser.url()},p=function(t,e,n){var r,o,u;return g.debug("Replace %o with %o",t,e),n=g.options(n),u=g.presence(t)?t:g.createSelectorFromElement($(t)),up.browser.canPushState()||n.history===!1?(o={url:e,method:n.method,selector:u,cache:n.cache,preload:n.preload},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=g.locationFromXhr(a))&&(g.debug("Location from server: %o",s),l={url:s,method:g.methodFromXhr(a),selector:u},up.proxy.alias(o,l),e=s),n.history!==!1&&(n.history=e),n.source!==!1&&(n.source=e),n.preload?void 0:i(u,t,n)}),r.fail(g.error),r):(n.preload||up.browser.loadPage(e,g.only(n,"method")),g.resolvedPromise())},i=function(t,e,n){var o,u,i,a,c,p,f,d;for(n=g.options(n,{historyMethod:"push"}),n.source=g.option(n.source,n.history),p=l(e),n.title||(n.title=p.title()),n.saveScroll!==!1&&up.layout.saveScroll(),c=s(t,n),f=[],i=0,a=c.length;a>i;i++)d=c[i],u=r(d.selector),o=p.find(d.selector).first(),f.push(v(u,o,d.pseudoClass,d.transition,n));return f},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var e;return e="Could not find selector %o in current body HTML","#"===e[0]&&(e+=" (avoid using IDs)"),g.error(e,t)},l=function(t){var e;return e=g.createElementFromHtml(t),{title:function(){var t;return null!=(t=e.querySelector("title"))?t.textContent:void 0},find:function(n){var r;return(r=e.querySelector(n))?$(r):g.error("Could not find selector %o in response %o",n,t)}}},d=function(t,e){return e.reveal?up.reveal(t):g.resolvedDeferred()},n=function(e,n){return"function"==typeof n.insert&&n.insert(e),n.history&&(n.title&&(document.title=n.title),up.history[n.historyMethod](n.history)),n.source!==!1&&m(e,n.source),n.restoreScroll&&up.layout.restoreScroll({within:e}),t(e),up.ready(e)},v=function(t,r,o,u,i){var a,s;return u||(u="none"),up.motion.finish(t),o?(s="before"===o?"prepend":"append",a=r.contents().wrap('<span class="up-insertion"></span>').parent(),t[s](a),g.copyAttributes(r,t),n(a.children(),i),d(a,i).then(function(){return up.animate(a,u,i)}).then(function(){g.unwrapElement(a)})):d(t,i).then(function(){return e(t,{animation:function(){return r.insertBefore(t),n(r,i),t.is("body")&&"none"!==u&&g.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})})},s=function(t,e){var n,r,o,u,i,a,s,l,c,p,f;for(p=e.transition||e.animation||"none",n=/\ *,\ */,r=t.split(n),g.isPresent(p)&&(f=p.split(n)),a=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],l=s.match(/^(.+?)(?:\:(before|after))?$/),c=f[o]||g.last(f),a.push({selector:l[1],pseudoClass:l[2],transition:c});return a},t=function(t){var e,n;return n="[autofocus]:last",e=g.findWithSelf(t,n),e.length&&e.get(0)!==document.activeElement?e.focus():void 0},a=function(t){var e;return e=".up-ghost, .up-destroying",0===t.closest(e).length},o=function(t){var e,n,r,o,u,i;for(o=$(t).get(),n=null,u=0,i=o.length;i>u;u++)if(r=o[u],e=$(r),a(e)){n=e;break}return n},e=function(t,e){var n,r,o;return n=$(t),e=g.options(e,{animation:"none"}),r=up.motion.animateOptions(e),n.addClass("up-destroying"),g.isPresent(e.url)&&up.history.push(e.url),g.isPresent(e.title)&&(document.title=e.title),up.bus.emit("fragment:destroy",n),o=g.presence(e.animation,g.isPromise)||up.motion.animate(n,e.animation,r),o.then(function(){return n.remove()}),o},c=function(t,e){var n;return e=g.options(e,{cache:!1}),n=e.url||h(t),p(t,n,e)},f=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return m(document.body,up.browser.url())}),{replace:p,reload:c,destroy:e,implant:i,reset:f,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(){up.motion=function(){var t,e,n,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=w.config({duration:300,delay:0,easing:"ease"}),h=function(){return o=w.copy(a),b=w.copy(s),i.reset()},e=function(t,r,o){var i;return i=$(t),c(i),o=n(o),("none"===r||r===!1)&&d(),w.isFunction(r)?u(r(i,o),r):w.isString(r)?e(i,l(r),o):w.isHash(r)?w.cssAnimate(i,r,o):w.error("Unknown animation type %o",r)},n=function(t,e){var n;return null==e&&(e=null),t=w.options(t),n={},n.easing=w.option(t.easing,null!=e?e.attr("up-easing"):void 0,i.easing),n.duration=Number(w.option(t.duration,null!=e?e.attr("up-duration"):void 0,i.duration)),n.delay=Number(w.option(t.delay,null!=e?e.attr("up-delay"):void 0,i.delay)),n},l=function(t){return o[t]||w.error("Unknown animation %o",r)},t="up-ghosting-promise",k=function(e,n,r){var o,u,i,a;return u=null,o=null,w.temporaryCss(n,{display:"none"},function(){return u=m(e),u.$ghost.addClass("up-destroying"),u.$bounds.addClass("up-destroying")}),w.temporaryCss(e,{display:"none"},function(){return o=m(n)}),e.css({visibility:"hidden"}),a=w.temporaryCss(n,{display:"none"}),i=r(u.$ghost,o.$ghost),e.data(t,i),n.data(t,i),i.then(function(){return e.removeData(t),n.removeData(t),u.$bounds.remove(),o.$bounds.remove(),e.css({display:"none"}),a()}),i},c=function(t){return $(t).each(function(){var t;return t=$(this),w.finishCssAnimate(t),p(t)})},p=function(e){var n;return(n=e.data(t))?(w.debug("Canceling existing ghosting on %o",e),"function"==typeof n.resolve?n.resolve():void 0):void 0},u=function(t,e){return w.isDeferred(t)?t:w.error("Did not return a promise with .then and .resolve methods: %o",e)},f=function(t,r,i,a){var s,l,p,m,h;return up.browser.canCssAnimation()?(a=n(a),l=$(t),s=$(r),c(l),c(s),"none"===i||i===!1?d():(h=w.presence(i,w.isFunction)||b[i])?k(l,s,function(t,e){return u(h(t,e,a),i)}):(p=o[i])?(l.hide(),e(s,p,a)):w.isString(i)&&i.indexOf("/")>=0?(m=i.split("/"),h=function(t,n,r){return v(e(t,m[0],r),e(n,m[1],r))},f(l,s,h,a)):w.error("Unknown transition %o",i)):w.resolvedDeferred()},m=function(t){var e,n,r,o;return o=w.measure(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({position:"static"===t.css("position")?"static":"relative",top:"",right:"",bottom:"",left:"",width:"100%",height:"100%"}),n.addClass("up-ghost"),e=$('<div class="up-bounds"></div>'),e.css({position:"absolute"}),e.css(o),n.appendTo(e),e.insertBefore(t),r=n.offset().top-t.offset().top,0!==r&&e.css({top:o.top-r}),{$ghost:n,$bounds:e}},y=function(t,e){return b[t]=e},r=function(t,e){return o[t]=e},g=function(){return a=w.copy(o),s=w.copy(b)},v=w.resolvableWhen,d=w.resolvedDeferred,r("none",d),r("fade-in",function(t,n){return t.css({opacity:0}),e(t,{opacity:1},n)}),r("fade-out",function(t,n){return t.css({opacity:1}),e(t,{opacity:0},n)}),r("move-to-top",function(t,n){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),e(t,{"margin-top":"-"+o+"px"},n)}),r("move-from-top",function(t,n){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),e(t,{"margin-top":"0px"},n)}),r("move-to-bottom",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":"0px"}),e(t,{"margin-top":o+"px"},n)}),r("move-from-bottom",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":o+"px"}),e(t,{"margin-top":"0px"},n)}),r("move-to-left",function(t,n){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),e(t,{"margin-left":"-"+o+"px"},n)}),r("move-from-left",function(t,n){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),e(t,{"margin-left":"0px"},n)}),r("move-to-right",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":"0px"}),e(t,{"margin-left":o+"px"},n)}),r("move-from-right",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":o+"px"}),e(t,{"margin-left":"0px"},n)}),r("roll-down",function(t,n){var r,o;return r=t.height(),o=w.temporaryCss(t,{height:"0px",overflow:"hidden"}),e(t,{height:r+"px"},n).then(o)}),y("none",d),y("move-left",function(t,n,r){return v(e(t,"move-to-left",r),e(n,"move-from-right",r))}),y("move-right",function(t,n,r){return v(e(t,"move-to-right",r),e(n,"move-from-left",r))}),y("move-up",function(t,n,r){return v(e(t,"move-to-top",r),e(n,"move-from-bottom",r))}),y("move-down",function(t,n,r){return v(e(t,"move-to-bottom",r),e(n,"move-from-top",r))}),y("cross-fade",function(t,n,r){return v(e(t,"fade-out",r),e(n,"fade-in",r))}),up.bus.on("framework:ready",g),up.bus.on("framework:reset",h),{morph:f,animate:e,animateOptions:n,finish:c,transition:y,animation:r,defaults:i.update,none:d,when:v,prependGhost:m}}(),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,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,C,S,A,E,P,T;return T=up.util,t=void 0,C=void 0,u=void 0,k=void 0,i=void 0,d=T.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5}),s=function(t){return w(t),[t.url,t.method,t.data,t.selector].join("|")},a=T.cache({size:function(){return d.cacheSize},expiry:function(){return d.cacheExpiry},key:s,log:"up.proxy"}),m=a.get,E=a.set,S=a.remove,f=a.clear,c=function(){return clearTimeout(C),C=null},l=function(){return clearTimeout(u),u=null},A=function(){return t=null,c(),l(),k=0,d.reset(),i=!1,a.clear()},A(),r=a.alias,w=function(t){return t._normalized||(t.method=T.normalizeMethod(t.method),t.url&&(t.url=T.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},n=function(t){var e,n,r,o,u;return e=t.cache===!0,n=t.cache===!1,u=T.only(t,"url","method","data","selector","_normalized"),r=!0,v(u)||e?(o=m(u))&&!n?r="pending"===o.state():(o=g(u),E(u,o)):(f(),o=g(u)),r&&!t.preload&&(b(),o.then(y)),o},e=["GET","OPTIONS","HEAD"],h=function(){return 0===k},o=function(){return k>0},b=function(){var t,e;return e=h(),k+=1,e?(t=function(){return o()?(up.bus.emit("proxy:busy"),i=!0):void 0},d.busyDelay>0?u=setTimeout(t,d.busyDelay):t()):void 0},y=function(){return k-=1,h()&&i?(up.bus.emit("proxy:idle"),i=!1):void 0},g=function(t){var e;return up.bus.emit("proxy:load",t),e=T.ajax(t),e.then(function(){return up.bus.emit("proxy:receive",t)}),e},v=function(t){return w(t),T.contains(e,t.method)},p=function(e){var n,r;return r=parseInt(T.presentAttr(e,"up-delay"))||d.preloadDelay,e.is(t)?void 0:(t=e,c(),n=function(){return x(e)},P(n,r))},P=function(t,e){return C=setTimeout(t,e)},x=function(t,e){var n,r;return n=$(t),e=T.options(e),r=up.link.followMethod(n,e),v({method:r})?(T.debug("Preloading %o",n),e.preload=!0,up.link.follow(n,e)):(T.debug("Won't preload %o due to unsafe method %o",n,r),T.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(t,e){return up.link.childClicked(t,e)?void 0:p(e)}),up.bus.on("framework:reset",A),{preload:x,ajax:n,get:m,set:E,alias:r,clear:f,remove:S,idle:h,busy:o,defaults:d.update}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,makeFollowable,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,e){var n;return e=u.options(e),n=u.option(e.target,"body"),up.replace(n,t,e)},follow=function(t,e){var n,r,o;return n=$(t),e=u.options(e),o=u.option(n.attr("up-href"),n.attr("href")),r=u.option(e.target,n.attr("up-target"),"body"),e.transition=u.option(e.transition,u.castedAttr(n,"up-transition"),u.castedAttr(n,"up-animation")),e.history=u.option(e.history,u.castedAttr(n,"up-history")),e.reveal=u.option(e.reveal,u.castedAttr(n,"up-reveal"),!0),e.cache=u.option(e.cache,u.castedAttr(n,"up-cache")),e.restoreScroll=u.option(e.restoreScroll,u.castedAttr(n,"up-restore-scroll")),e.method=followMethod(n,e),e=u.merge(e,up.motion.animateOptions(e,n)),up.replace(r,o,e)},followMethod=function(t,e){return e=u.options(e),u.option(e.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,e){return shouldProcessLinkEvent(t,e)?e.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(e)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,e){return shouldProcessLinkEvent(t,e)?(t.preventDefault(),follow(e)):void 0}),childClicked=function(t,e){var n,r;return n=$(t.target),r=n.closest("a, [up-href]"),r.length&&e.find(r).length},shouldProcessLinkEvent=function(t,e){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,e)},makeFollowable=function(t){var e;return e=$(t),u.isMissing(e.attr("up-target"))&&u.isMissing(e.attr("up-follow"))?e.attr("up-follow",""):void 0
2
- },up.on("click","a[up-follow], [up-href][up-follow]",function(t,e){return shouldProcessLinkEvent(t,e)?e.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(e)):void 0}),up.compiler("[up-expand]",function(t){var e,n,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,n=0,r=s.length;r>n;n++)e=s[n],i=e.name,i.match(l)&&(a[i]=e.value);return u.setMissingAttrs(t,a),t.removeAttr("up-expand"),makeFollowable(t)}),up.compiler("[up-dash]",function(t){var e,n;return n=u.castedAttr(t,"up-dash"),e={"up-preload":"true","up-instant":"true"},n===!0?e["up-follow"]="":e["up-target"]=n,u.setMissingAttrs(t,e),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,makeFollowable:makeFollowable,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,e){var n,r,o,i,a,s,l,c,p,f,d,m;return n=$(t).closest("form"),e=u.options(e),c=u.option(e.target,n.attr("up-target"),"body"),r=u.option(e.failTarget,n.attr("up-fail-target"),function(){return u.createSelectorFromElement(n)}),i=u.option(e.history,u.castedAttr(n,"up-history"),!0),p=u.option(e.transition,u.castedAttr(n,"up-transition")),o=u.option(e.failTransition,u.castedAttr(n,"up-fail-transition"),p),a=u.option(e.method,n.attr("up-method"),n.attr("data-method"),n.attr("method"),"post").toUpperCase(),s={},s.reveal=u.option(e.reveal,u.castedAttr(n,"up-reveal"),!0),s.cache=u.option(e.cache,u.castedAttr(n,"up-cache")),s.restoreScroll=u.option(e.restoreScroll,u.castedAttr(n,"up-restore-scroll")),s=u.extend(s,up.motion.animateOptions(e,n)),m=u.option(e.cache,u.castedAttr(n,"up-cache")),d=u.option(e.url,n.attr("action"),up.browser.url()),n.addClass("up-active"),up.browser.canPushState()||i===!1?(l={url:d,method:a,data:n.serialize(),selector:c,cache:m},f=function(t){var e;return d=void 0,u.isGiven(i)&&(i===!1||u.isString(i)?d=i:(e=u.locationFromXhr(t))?d=e:"GET"===l.type&&(d=l.url+"?"+l.data)),u.option(d,!1)},up.proxy.ajax(l).always(function(){return n.removeClass("up-active")}).done(function(t,e,n){var r;return r=u.merge(s,{history:f(n),transition:p}),up.flow.implant(c,t,r)}).fail(function(t){var e,n;return n=t.responseText,e=u.merge(s,{transition:o}),up.flow.implant(r,n,e)})):void n.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,e;return e=$field.val(),t=u.isNull(knownValue),knownValue===e||(knownValue=e,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[e,$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,e){return t.preventDefault(),submit(e)}),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,e,n,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,u=void 0,n=d.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"}),c=function(){return e(),n.reset()},p=function(t,e,n){var r,o;return o=d.measure(t,{full:!0}),r=function(){switch(n){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.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",n)}}(),e.attr("up-position",n),e.css(r),a(e)},a=function(t){var e,n,r,o,u,i,a;if(n=d.measure(t,{full:!0}),r=null,o=null,n.right<0&&(r=-n.right),n.bottom<0&&(o=-n.bottom),n.left<0&&(r=n.left),n.top<0&&(o=n.top),r&&((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(e=parseInt(t.css("bottom")))return t.css("bottom",e+o)}},l=function(){var t;return t=$(".up-popup"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},i=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,e,n){var r,o;return o=d.$createElementFromSelector(".up-popup"),n&&o.attr("up-sticky",""),r=d.$createElementFromSelector(e),r.appendTo(o),o.appendTo(document.body),l(),o.hide(),o},m=function(t,e,n,r,o){return e.show(),p(t,e,n),up.animate(e,r,o)},s=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"),n.position),s=d.option(r.animation,u.attr("up-animation"),n.openAnimation),f=d.option(r.sticky,d.castedAttr(u,"up-sticky")),l=up.browser.canPushState()?d.option(r.history,d.castedAttr(u,"up-history"),!1):!1,a=up.motion.animateOptions(r,u),e(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},e=function(t){var e;return e=$(".up-popup"),e.length?(t=d.options(t,{animation:n.closeAnimation,url:e.attr("up-previous-url"),title:e.attr("up-previous-title")}),u=void 0,up.destroy(e,t)):d.resolvedPromise()},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(i(),e())},r=function(t){var e;return e=$(t),e.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():s(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-popup").length||n.closest("[up-popup]").length?void 0:e()}),up.bus.on("fragment:ready",function(e){var n;return r(e)?(n=e.attr("up-source"))?u=n:void 0:t()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-popup")?e():void 0}),up.bus.on("framework:reset",c),{open:s,close:e,source:f,defaults:n.update,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,r=m.config({maxWidth:void 0,minWidth:void 0,width:void 0,height:void 0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",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>'}}),i=void 0,c=function(){return n(),i=void 0,r.reset()},d=function(){var t;return t=r.template,m.isFunction(t)?t(r):t},l=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t){var e,n,r,o;return r=$(d()),t.sticky&&r.attr("up-sticky",""),r.attr("up-previous-url",up.browser.url()),r.attr("up-previous-title",document.title),n=r.find(".up-modal-dialog"),m.isPresent(t.width)&&n.css("width",t.width),m.isPresent(t.maxWidth)&&n.css("max-width",t.maxWidth),m.isPresent(t.height)&&n.css("height",t.height),e=r.find(".up-modal-content"),o=m.$createElementFromSelector(t.selector),o.appendTo(e),r.appendTo(document.body),l(),r.hide(),r},h=void 0,p=function(){var t,e,n;return n=m.scrollbarWidth(),t=parseInt($("body").css("padding-right")),e=n+t,h=m.temporaryCss($("body"),{"padding-right":e+"px","overflow-y":"hidden"})},v=function(t,e,n){var r;return up.bus.emit("modal:open"),p(),t.show(),r=up.animate(t,e,n),r.then(function(){return up.bus.emit("modal:opened")}),r},s=function(){var e,o,i,a,s,l,c,p,f,d,h,g,y;return s=1<=arguments.length?t.call(arguments,0):[],!m.isObject(s[0])||m.isElement(s[0])||m.isJQuery(s[0])?(e=$(s[0]),f=s[1]):(e=m.nullJquery(),f=s[0]),f=m.options(f),g=m.option(f.url,e.attr("up-href"),e.attr("href")),d=m.option(f.target,e.attr("up-modal"),"body"),y=m.option(f.width,e.attr("up-width"),r.width),p=m.option(f.maxWidth,e.attr("up-max-width"),r.maxWidth),l=m.option(f.height,e.attr("up-height"),r.height),a=m.option(f.animation,e.attr("up-animation"),r.openAnimation),h=m.option(f.sticky,m.castedAttr(e,"up-sticky")),c=up.browser.canPushState()?m.option(f.history,m.castedAttr(e,"up-history"),!0):!1,i=up.motion.animateOptions(f,e),n(),o=u({selector:d,width:y,maxWidth:p,height:l,sticky:h}),up.replace(d,g,{history:c,insert:function(){return v(o,a,i)}})},f=function(){return i},n=function(t){var e,n;return e=$(".up-modal"),e.length?(t=m.options(t,{animation:r.closeAnimation,url:e.attr("up-previous-url"),title:e.attr("up-previous-title")}),i=void 0,up.bus.emit("modal:close"),n=up.destroy(e,t),n.then(function(){return h(),up.bus.emit("modal:closed")}),n):m.resolvedPromise()},e=function(){return $(".up-modal").is("[up-sticky]")?void 0:(a(),n())},o=function(t){var e;return e=$(t),e.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():s(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(t){var n;if(o(t)){if(n=t.attr("up-source"))return i=n}else if(!up.popup.contains(t))return e()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",c),{open:s,close:n,source:f,defaults:r.update,contains:o}}()}.call(this),function(){up.tooltip=function(){var t,e,n,r,o;return o=up.util,r=function(t,e,n){var r,u,i;return u=o.measure(t),i=o.measure(e),r=function(){switch(n){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",n)}}(),e.attr("up-position",n),e.css(r)},e=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},n=function(n,u){var i,a,s,l,c,p;return null==u&&(u={}),i=$(n),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,o.castedAttr(i,"up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=e(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var e;return e=$(".up-tooltip"),e.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(e,t)):void 0},up.compiler("[up-tooltip]",function(e){return e.on("mouseover",function(){return n(e)}),e.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:n,close:t}}()}.call(this),function(){up.navigation=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,u=m.config({currentClasses:["up-current"]}),c=function(){return u.reset()},i=function(){var t;return t=u.currentClasses,t=t.concat(["up-current"]),t=m.uniq(t),t.join(" ")},t="up-active",e=["a","[up-href]","[up-alias]"],r=e.join(", "),o=function(){var t,n,r;for(r=[],t=0,n=e.length;n>t;t++)d=e[t],r.push(d+"[up-instant]");return r}().join(", "),n="."+t,l=function(t){return m.isPresent(t)?m.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},f=function(t){var e,n,r,o,u,i,a,s,c,p;for(s=[],i=["href","up-href","up-alias"],n=0,o=i.length;o>n;n++)if(e=i[n],c=m.presentAttr(t,e))for(p="up-alias"===e?c.split(" "):[c],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=l(a),s.push(a));return s},v=function(t){var e,n,r,o;return t=m.compact(t),r=function(t){return"*"===t.substr(-1)?n(t.slice(0,-1)):e(t)},e=function(e){return m.contains(t,e)},n=function(e){return m.detect(t,function(t){return 0===t.indexOf(e)})},o=function(t){return m.detect(t,r)},{matchesAny:o}},s=function(){var t,e;return t=v([l(up.browser.url()),l(up.modal.source()),l(up.popup.source())]),e=i(),m.each($(r),function(n){var r,o;return r=$(n),o=f(r),t.matchesAny(o)?r.addClass(e):r.removeClass(e)})},p=function(e){return h(),e=a(e),e.addClass(t)},a=function(t){return m.presence(t.parents(r))||t},h=function(){return $(n).removeClass(t)},up.on("click",r,function(t,e){return m.isUnmodifiedMouseEvent(t)&&!e.is("[up-instant]")?p(e):void 0}),up.on("mousedown",o,function(t,e){return m.isUnmodifiedMouseEvent(t)?p(e):void 0}),up.bus.on("fragment:ready",function(){return h(),s()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?s():void 0}),up.bus.on("framework:reset",c),{defaults:u.update}}()}.call(this),function(){up.slot=function(){var t,e,n;return n=up.util,e=function(t){return""!==n.trim(t.html())},t=function(t){return n.findWithSelf(t,"[up-slot]").each(function(){var t;return t=$(this),e(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 e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,S,C,A,E,P,T,D,U,O,z,M,j,F,W,I,N,L,q,H,J,R,K,X,B,G,Q,V,_,Z,Y,te,ee,ne,re,oe,ue,ie,ae,se,le,ce,pe,fe,de,me,he,ve,ge,ye,be,we,ke,$e,xe,Se,Ce,Ae,Ee,Pe,Te,De,Ue,Oe,ze,Me;return oe=function(e){var n,r;return n=void 0,r=!1,function(){var o;return o=1<=arguments.length?t.call(arguments,0):[],r?n:(r=!0,n=e.apply(null,o))}},D=function(t,e){return e=e||{},e.url=t,o(e)},o=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},G=function(t,e){return(""===e||"80"===e)&&"http:"===t||"443"===e&&"https:"===t},ce=function(t,e){var n,r,o;return n=null,Q(t)?(n=$("<a>").attr({href:t}).get(0),M(n.hostname)&&(n.href=n.href)):n=Ue(t),r=n.protocol+"//"+n.hostname,G(n.protocol,n.port)||(r+=":"+n.port),o=n.pathname,"/"!==o[0]&&(o="/"+o),(null!=e?e.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),r+=o,(null!=e?e.hash:void 0)===!0&&(r+=n.hash),(null!=e?e.search:void 0)!==!1&&(r+=n.search),r},le=function(t){return t?t.toUpperCase():"GET"},e=function(t){var e,n,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+=">",e=$(s),n&&e.appendTo(n),0===c&&(r=e),n=e}return r},m=function(t,e){var n;return n=document.createElement(t),X(e)&&(n.innerHTML=e),n},y=function(){var e,n;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],n="[UP] "+n,console.debug.apply(console,[n].concat(t.call(e)))},Me=function(){var e,n;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],n="[UP] "+n,console.warn.apply(console,[n].concat(t.call(e)))},S=function(){var e,n,r;throw n=1<=arguments.length?t.call(arguments,0):[],n[0]="[UP] "+n[0],console.error.apply(console,n),r=Ae(n),e=ve($(".up-error"))||$('<div class="up-error"></div>').prependTo("body"),e.addClass("up-error"),e.text(r),new Error(r)},r=/\%[odisf]/g,Ae=function(t){var e,n,o;return o=t[0],e=0,n=50,o.replace(r,function(){var r,o;return e+=1,r=t[e],o=typeof r,"string"===o?(r=r.replace(/\s+/g," "),r.length>n&&(r=r.substr(0,n)+"\u2026"),r='"'+r+'"'):"number"===o?r=r.toString():(r=JSON.stringify(r),r.length>n&&(r=r.substr(0,n)+"\u2026")),r})},v=function(t){var e,n,r,o,u,i,a;for(y("Creating selector from element %o",t),n=(e=t.attr("class"))?e.split(" "):[],r=t.attr("id"),a=t.prop("tagName").toLowerCase(),r&&(a+="#"+r),o=0,i=n.length;i>o;o++)u=n[o],a+="."+u;return a},h=function(t){var e,n,r,o,u,i,a,s,l,c,p,f;return l=function(t){return"<"+t+"(?: [^>]*)?>"},i=function(t){return"</"+t+">"},e="(?:.|\\n)*?",u=function(t){return"("+t+")"},f=new RegExp(l("head")+e+l("title")+u(e)+i("title")+e+i("body"),"i"),o=new RegExp(l("body")+u(e)+i("body"),"i"),(r=t.match(o))?(s=document.createElement("html"),n=m("body",r[1]),s.appendChild(n),(p=t.match(f))&&(a=m("head"),s.appendChild(a),c=m("title",p[1]),a.appendChild(c)),s):m("div",t)},A=$.extend,De=$.trim,Y=Object.keys||function(t){var e,n,r,o;for(o=[],e=0,r=t.length;r>e;e++)n=t[e],t.hasOwnProperty(n)&&o.push(n);return o},w=function(t,e){var n,r,o,u,i;for(i=[],n=o=0,u=t.length;u>o;n=++o)r=t[n],i.push(e(r,n));return i},ne=w,U=function(t){return t},Pe=function(t,e){var n,r,o,u;for(u=[],n=r=0,o=t-1;o>=0?o>=r:r>=o;n=o>=0?++r:--r)u.push(e(n));return u},J=function(t){return null===t},V=function(t){return void 0===t},F=function(t){return!V(t)},H=function(t){return V(t)||J(t)},N=function(t){return!H(t)},M=function(t){return H(t)||K(t)&&0===Y(t).length||0===t.length},ve=function(t,e){return null==e&&(e=X),e(t)?t:null},X=function(t){return!M(t)},I=function(t){return"function"==typeof t},Q=function(t){return"string"==typeof t},R=function(t){return"number"==typeof t},L=function(t){return"object"==typeof t&&!!t},K=function(t){return L(t)||"function"==typeof t},W=function(t){return!(!t||1!==t.nodeType)},q=function(t){return t instanceof jQuery},B=function(t){return K(t)&&I(t.then)},j=function(t){return B(t)&&I(t.resolve)},O=function(t){return N(t)?t:void 0},z=Array.isArray||function(t){return"[object Array]"===Object.prototype.toString.call(t)},Te=function(t){return Array.prototype.slice.call(t)},f=function(t){return z(t)?t.slice():A({},t)},Ue=function(t){return q(t)?t.get(0):t},ue=function(t,e){return A(f(t),e)},he=function(t,e){var n,r,o,u;if(o=t?f(t):{},e)for(r in e)n=e[r],u=o[r],N(u)?K(n)&&K(u)&&(o[r]=he(u,n)):o[r]=n;return o},me=function(){var e,n,r,o,u,i;for(n=1<=arguments.length?t.call(arguments,0):[],u=void 0,r=0,o=n.length;o>r;r++)if(e=n[r],i=e,I(i)&&(i=i()),N(i)){u=i;break}return u},b=function(t,e){var n,r,o,u;for(u=void 0,r=0,o=t.length;o>r;r++)if(n=t[r],e(n)){u=n;break}return u},u=function(t,e){var n;return n=b(t,e),F(n)},l=function(t){return xe(t,N)},Oe=function(t){var e;return e={},xe(t,function(t){return e.hasOwnProperty(t)?!1:e[t]=!0})},xe=function(t,e){var n;return n=[],w(t,function(t){return e(t)?n.push(t):void 0}),n},ge=function(){var e,n,r,o;return e=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++)n=r[t],u.push(e.attr(n));return u}(),b(o,X)},se=function(t){return setTimeout(t,0)},te=function(t){return t[t.length-1]},s=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},$e=oe(function(){var t,e,n;return t=$("<div>").css({position:"absolute",top:"0",left:"0",width:"50px",height:"50px",overflowY:"scroll"}),t.appendTo(document.body),e=t.get(0),n=e.offsetWidth-e.clientWidth,t.remove(),n}),fe=function(t){var e;return e=void 0,function(){return null!=t&&(e=t()),t=void 0,e}},Ee=function(t,e,n){var r,o;return o=t.css(Y(e)),t.css(e),r=function(){return t.css(o)},n?(n(),r()):fe(r)},T=function(t){var e,n;return n=t.css(["transform","-webkit-transform"]),M(n)?(e=function(){return t.css(n)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):e=function(){},e},g=function(t,e,r){var o,u,i,a,s,l;return o=$(t),up.browser.canCssAnimation()?(r=he(r,{duration:300,delay:0,easing:"ease"}),u=$.Deferred(),a={"transition-property":Y(e).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},s=T(o),l=Ee(o,a),o.css(e),u.then(s),u.then(l),o.data(n,u),u.then(function(){return o.removeData(n)}),i=setTimeout(function(){return u.resolve()},r.duration+r.delay),u.then(function(){return clearTimeout(i)}),u):(o.css(e),ke())},n="up-animation-promise",P=function(t){return $(t).each(function(){var t;return(t=$(this).data(n))?t.resolve():void 0})},re=function(t,e){var n,r,o;return r=(null!=e?e.relative:void 0)?t.position():t.offset(),n={left:r.left,top:r.top},(null!=e?e.inner:void 0)?(n.width=t.width(),n.height=t.height()):(n.width=t.outerWidth(),n.height=t.outerHeight()),(null!=e?e.full:void 0)&&(o=s(),n.right=o.width-(n.left+n.width),n.bottom=o.height-(n.top+n.height)),n},d=function(t,e){var n,r,o,u,i;for(u=t.get(0).attributes,i=[],r=0,o=u.length;o>r;r++)n=u[r],i.push(n.specified?e.attr(n.name,n.value):void 0);return i},E=function(t,e){return t.find(e).addBack(e)},C=function(t){return 27===t.keyCode},Ce=function(t,e){return 0===t.indexOf(e)},x=function(t,e){return t.indexOf(e)===t.length-e.length},p=function(t,e){return t.indexOf(e)>=0},a=function(t,e){var n;switch(n=t.attr(e)){case"false":return!1;case"true":return!0;case"":return!0;default:return n}},ee=function(t){return t.getResponseHeader("X-Up-Location")},ie=function(t){return t.getResponseHeader("X-Up-Method")},de=function(){var e,n,r,o,u,i;for(i=arguments[0],o=2<=arguments.length?t.call(arguments,1):[],e={},n=0,u=o.length;u>n;n++)r=o[n],i.hasOwnProperty(r)&&(e[r]=i[r]);return e},_=function(t){return!(t.metaKey||t.shiftKey||t.ctrlKey)},Z=function(t){var e;return e=V(t.button)||0===t.button,e&&_(t)},we=function(){var t;return t=$.Deferred(),t.resolve(),t},ke=function(){return we().promise()},pe=function(){return{is:function(){return!1},attr:function(){},find:function(){return[]}}},be=function(){var e,n;return e=1<=arguments.length?t.call(arguments,0):[],n=$.when.apply($,e),n.resolve=function(){return w(e,function(t){return"function"==typeof t.resolve?t.resolve():void 0})},n},Se=function(t,e){var n,r,o;r=[];for(n in e)o=e[n],r.push(H(t.attr(n))?t.attr(n,o):void 0);return r},ye=function(t,e){var n;return n=t.indexOf(e),n>=0?(t.splice(n,1),e):void 0},k=function(){return $([])},ae=function(t){var e,n,r,o,i,a,s;for(i={},s=[],n=[],r=0,o=t.length;o>r;r++)a=t[r],Q(a)?s.push(a):n.push(a);return i.parsed=n,s.length&&(e=s.join(", "),i.parsed.push(e)),i.select=function(){return i.find(void 0)},i.find=function(t){var e,n,r,o,u,a;for(n=k(),u=i.parsed,r=0,o=u.length;o>r;r++)a=u[r],e=t?t.find(a):$(a),n=n.add(e);return n},i.findWithSelf=function(t){var e;return e=i.find(t),i.doesMatch(t)&&(e=e.add(t)),e},i.doesMatch=function(t){var e;return e=$(t),u(i.parsed,function(t){return e.is(t)})},i.seekUp=function(t){var e,n,r;for(r=$(t),e=r,n=void 0;e.length;){if(i.doesMatch(e)){n=e;break}e=e.parent()}return n||k()},i},i=function(e){var n,r,o,u,i,a,s,l,c,p;return c=void 0,r=function(){return c={}},r(),i=function(){var n;return n=1<=arguments.length?t.call(arguments,0):[],e.log?(n[0]="["+e.log+"] "+n[0],y.apply(null,n)):void 0},a=function(){return H(e.size)?void 0:I(e.size)?e.size():R(e.size)?e.size:S("Invalid size config: %o",e.size)},o=function(){return H(e.expiry)?void 0:I(e.expiry)?e.expiry():R(e.expiry)?e.expiry:S("Invalid expiry config: %o",e.expiry)},s=function(t){return e.key?e.key(t):t.toString()},De=function(){var t,e,n,r;return r=f(Y(c)),n=a(),n&&r.length>n&&(t=null,e=null,w(r,function(n){var r,o;return r=c[n],o=r.timestamp,!e||e>o?(t=n,e=o):void 0}),t)?delete c[t]:void 0},n=function(t,e){var n;return n=D(t),F(n)?l(e,n):void 0},p=function(){return(new Date).valueOf()},l=function(t,e){var n;return n=s(t),c[n]={timestamp:p(),value:e}},ye=function(t){var e;return e=s(t),delete c[e]},u=function(t){var e,n;return e=o(),e?(n=p()-t.timestamp,n<o()):!0},D=function(t,e){var n,r;return null==e&&(e=void 0),r=s(t),(n=c[r])?u(n)?(i("Cache hit for %o",t),n.value):(i("Discarding stale cache entry for %o",t),ye(t),e):(i("Cache miss for %o",t),e)},{alias:n,get:D,set:l,remove:ye,clear:r}},c=function(t){var e,n;return null==t&&(t={}),n={ensureKeyExists:function(e){return t.hasOwnProperty(e)||S("Unknown setting %o",e)},reset:function(){var r,o,u,i;for(i=f(Object.getOwnPropertyNames(n)),r=0,u=i.length;u>r;r++)o=i[r],p(e,o)||delete n[o];return n.update(f(t))},update:function(t){var e,r,o;if(t){if(Q(t))return n.ensureKeyExists(t),n[t];r=[];for(e in t)o=t[e],n.ensureKeyExists(e),r.push(n[e]=o);return r}return n}},e=Object.getOwnPropertyNames(n),n.reset(),n},ze=function(t){var e,n;return t=Ue(t),e=t.parentNode,n=Te(t.childNodes),w(n,function(n){return e.insertBefore(n,t)}),e.removeChild(t)},{presentAttr:ge,createElement:m,normalizeUrl:ce,normalizeMethod:le,createElementFromHtml:h,$createElementFromSelector:e,createSelectorFromElement:v,get:D,ajax:o,extend:A,copy:f,merge:ue,options:he,option:me,error:S,debug:y,warn:Me,each:w,map:ne,identity:U,times:Pe,any:u,detect:b,select:xe,compact:l,uniq:Oe,last:te,isNull:J,isDefined:F,isUndefined:V,isGiven:N,isMissing:H,isPresent:X,isBlank:M,presence:ve,isObject:K,isFunction:I,isString:Q,isElement:W,isJQuery:q,isPromise:B,isDeferred:j,isHash:L,ifGiven:O,isUnmodifiedKeyEvent:_,isUnmodifiedMouseEvent:Z,nullJquery:pe,unJquery:Ue,nextFrame:se,measure:re,temporaryCss:Ee,cssAnimate:g,finishCssAnimate:P,forceCompositing:T,escapePressed:C,copyAttributes:d,findWithSelf:E,contains:p,startsWith:Ce,endsWith:x,isArray:z,toArray:Te,castedAttr:a,locationFromXhr:ee,methodFromXhr:ie,clientSize:s,only:de,trim:De,keys:Y,resolvedPromise:ke,resolvedDeferred:we,resolvableWhen:be,setMissingAttrs:Se,remove:ye,memoize:oe,scrollbarWidth:$e,config:c,cache:i,unwrapElement:ze,multiSelector:ae,emptyJQuery:k}}()}.call(this),function(){up.browser=function(){var t,e,n,r,o,u,i,a,s;return a=up.util,i=function(t,e){var n,r,o,u,i,s;return null==e&&(e={}),i=a.option(e.method,"get").toLowerCase(),"get"===i?location.href=t:$.rails?(s=e.target,o=$.rails.csrfToken(),r=$.rails.csrfParam(),n=$("<form method='post' action='"+t+"'></form>"),u="<input name='_method' value='"+i+"' type='hidden' />",a.isDefined(r)&&a.isDefined(o)&&(u+="<input name='"+r+"' value='"+o+"' type='hidden' />"),s&&n.attr("target",s),n.hide().append(u).appendTo("body"),n.submit()):error("Can't fake a "+i.toUpperCase()+" request without Rails UJS")},s=function(){return location.href},r=function(){var t,e,n,r,o,u,i,a,s;return window.console||(window.console={}),s=function(){},(t=window.console).log||(t.log=s),(e=window.console).info||(e.info=s),(n=window.console).error||(n.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)},n=a.memoize(function(){return a.isDefined(history.pushState)}),t=a.memoize(function(){return"transition"in document.documentElement.style}),e=a.memoize(function(){return"oninput"in document.createElement("input")}),o=function(){var t,e,n,r,o;return o=$.fn.jquery,r=o.split("."),e=parseInt(r[0]),n=parseInt(r[1]),t=e>=2||1===e&&n>=9,t||a.error("jQuery %o found, but Up.js requires 1.9+",o)},u=a.memoize(function(){return a.isDefined(document.addEventListener)}),{url:s,ensureConsoleExists:r,loadPage:i,canPushState:n,canCssAnimation:t,canInputEvent:e,isSupported:u,ensureRecentJquery:o}}()}.call(this),function(){var t=[].slice;up.bus=function(){var e,n,r,o,u,i,a,s,l;return l=up.util,e={},r={},i=function(){return e=l.copy(r)},n=function(t){return e[t]||(e[t]=[])},a=function(){var t,n,o;r={},o=[];for(n in e)t=e[n],o.push(r[n]=l.copy(t));return o},u=function(t,e){var r,o,u,i;for(i=t.split(" "),o=0,u=i.length;u>o;o++)r=i[o],n(r).push(e);return function(){return s(t,e)}},s=function(t,e){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(n(r),e));return a},o=function(){var e,r,o;return o=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],r=n(o),l.each(r,function(t){return t.apply(null,e)})},u("framework:ready",a),u("framework:reset",i),{on:u,off:s,emit:o}}()}.call(this),function(){var t=[].slice;up.magic=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,e="up-destroyable",n="up-destroyer",f=[],l=null,p=function(t,e,n){var r,o;if(up.browser.isSupported())return r=[t,e,function(t){return n.apply(this,[t,$(this),a(this)])}],f.push(r),(o=$(document)).on.apply(o,r)},i=[],s=null,u=function(){var e,n,r;return r=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],up.browser.isSupported()?(u=e.pop(),n=g.options(e[0],{batch:!1}),i.push({selector:r,callback:u,batch:n.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(e),r.data(n,u)):void 0},o=function(t){var e,n,o,a;for(g.debug("Compiling fragment %o",t),a=[],n=0,o=i.length;o>n;n++)u=i[n],e=g.findWithSelf(t,u.selector),a.push(e.length?u.batch?r(u,e,e.get()):e.each(function(){return r(u,$(this),this)}):void 0);return a},c=function(t){return g.findWithSelf(t,"."+e).each(function(){var t,e;return t=$(this),(e=t.data(n))()})},a=function(t){var e,n;return e=$(t),n=e.attr("up-data"),g.isString(n)&&""!==g.trim(n)?JSON.parse(n):{}},v=function(){return l=g.copy(f),s=g.copy(i)},h=function(){var t,e,n,r;for(e=0,n=f.length;n>e;e++)t=f[e],g.contains(l,t)||(r=$(document)).off.apply(r,t);return f=g.copy(l),i=g.copy(s)},m=function(t){var e;return e=$(t),up.bus.emit("fragment:ready",e),e},d=function(t){return p("keydown","body",function(e){return g.escapePressed(e)?t(e):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 e;return e=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,e)}}.call(this),function(){up.history=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h;return h=up.util,e=h.config({popTargets:["body"],restoreScroll:!0}),l=void 0,u=void 0,d=function(){return e.reset(),l=void 0,u=void 0},i=function(t){return h.normalizeUrl(t,{hash:!0})},n=function(){return i(up.browser.url())},r=function(t){return i(t)===n()},a=function(t){return console.log("observing new url %o",t),u&&(l=u,u=void 0),u=t},f=function(t,e){return o("replace",t,e)},c=function(t,e){return o("push",t,e)},o=function(e,o,u){var i,s;return u=h.options(u,{force:!1}),u.force||!r(o)?up.browser.canPushState()?(i=e+"State",s=t(),h.debug("Changing history to URL %o (%o)",o,e),window.history[i](s,"",o),a(n())):h.error("This browser doesn't support history.pushState"):void 0},t=function(){return{fromUp:!0}},m=function(t){var r,o;return o=n(),h.debug("Restoring state %o (now on "+o+")",t),r=e.popTargets.join(", "),up.replace(r,o,{history:!1,reveal:!1,transition:"none",saveScroll:!1,restoreScroll:e.restoreScroll})},s=function(t){var e;return h.debug("History state popped to URL %o",n()),a(n()),up.layout.saveScroll({url:l}),e=t.originalEvent.state,(null!=e?e.fromUp:void 0)?m(e):h.debug("Discarding unknown state %o",e)},up.browser.canPushState()&&(p=function(){return $(window).on("popstate",s),f(n(),{force:!0})},"undefined"!=typeof jasmine&&null!==jasmine?p():setTimeout(p,100)),up.compiler("[up-back]",function(t){return console.log("up-back",t,l),h.isPresent(l)?(h.setMissingAttrs(t,{"up-href":l,"up-restore-scroll":""}),t.removeAttr("up-back"),up.link.makeFollowable(t)):void 0}),up.bus.on("framework:reset",d),{defaults:e.update,push:c,replace:f,url:n,previousUrl:function(){return l},normalizeUrl:i}}()}.call(this),function(){var t=[].slice;up.layout=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return f=up.util,n=f.config({duration:0,viewports:[document,".up-modal","[up-viewport]"],fixedTop:["[up-fixed~=top]"],fixedBottom:["[up-fixed~=bottom]"],snap:50,substance:150,easing:"swing"}),o=f.cache({size:30,key:up.history.normalizeUrl}),i=function(){return n.reset(),o.clear()},e="up-scroll-promise",c=function(t,o,u){var i,a,s,l,c;return i=$(t),u=f.options(u),s=f.option(u.duration,n.duration),l=f.option(u.easing,n.easing),r(i),s>0?(a=$.Deferred(),i.data(e,a),a.then(function(){return i.removeData(e),i.finish()}),c={scrollTop:o},i.animate(c,{duration:s,easing:l,complete:function(){return a.resolve()}}),a):(i.scrollTop(o),f.resolvedDeferred())},r=function(t){return $(t).each(function(){var t;return(t=$(this).data(e))?t.resolve():void 0})},u=function(){var e,r,o,u;return o=function(t,e){var n,r;return n=$(t),r=n.css(e),f.isPresent(r)||f.error("Fixed element %o must have a CSS attribute %o",n,e),parseInt(r)+n.height()},r=function(){var t,e,r,i;for(r=$(n.fixedTop.join(", ")),i=[],t=0,e=r.length;e>t;t++)u=r[t],i.push(o(u,"top"));return i}(),e=function(){var t,e,r,i;for(r=$(n.fixedBottom.join(", ")),i=[],t=0,e=r.length;e>t;t++)u=r[t],i.push(o(u,"bottom"));return i}(),{top:Math.max.apply(Math,[0].concat(t.call(r))),bottom:Math.max.apply(Math,[0].concat(t.call(e)))}},s=function(t,e){var r,o,i,a,s,l,p,m,h,v,g,y,b,w;return e=f.options(e),r=$(t),o=e.viewport?$(e.viewport):d(r),y=f.option(e.snap,n.snap),w=o.is(document),b=w?f.clientSize().height:o.height(),h=o.scrollTop(),l=h,m=void 0,p=void 0,w?(p=u(),m=0):(p={top:0,bottom:0},m=h),v=function(){return l+p.top},g=function(){return l+b-p.bottom-1},i=f.measure(r,{relative:!0}),a=i.top+m,s=a+Math.min(i.height,n.substance)-1,s>g()&&(l+=s-g()),a<v()&&(l=a-p.top),y>l&&(l=0),l!==h?c(o,l,e):f.resolvedDeferred()},m=function(){return f.multiSelector(n.viewports)},d=function(t){var e,n;return e=$(t),n=m().seekUp(e),n.length||f.error("Could not find viewport for %o",e),n},v=function(t){var e;return e=$(t),m().findWithSelf(e)},h=function(){return m().select()},p=function(){var t,e,r,o,u,i,a;for(i={},u=n.viewports,e=0,o=u.length;o>e;e++)a=u[e],t=$(a),t.length&&(r=a,a===document&&(r="document"),i[r]=t.scrollTop());return i},l=function(t){var e,n;return null==t&&(t={}),n=f.option(t.url,up.history.url()),e=f.option(t.tops,p()),o.set(n,e)},a=function(t){var e,n,r,u,i,a,s,l,c;null==t&&(t={}),u=void 0,t.around?(n=v(t.around),e=d(t.around),u=e.add(n)):u=h(),c=o.get(up.history.url()),a=[];for(i in c)l=c[i],s="document"===i?document:i,r=u.filter(s),a.push(up.scroll(r,l,{duration:0}));return a},up.bus.on("framework:reset",i),{reveal:s,scroll:c,finishScrolling:r,defaults:n.update,viewportOf:d,viewportsIn:v,viewports:h,scrollTops:p,saveScroll:l,restoreScroll:a}}(),up.scroll=up.layout.scroll,up.reveal=up.layout.reveal}.call(this),function(){up.flow=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g;return g=up.util,m=function(t,e){var n;return n=$(t),g.isPresent(e)&&(e=g.normalizeUrl(e)),n.attr("up-source",e)},h=function(t){var e;return e=$(t).closest("[up-source]"),g.presence(e.attr("up-source"))||up.browser.url()},p=function(t,e,n){var r,o,u;return g.debug("Replace %o with %o",t,e),n=g.options(n),u=g.presence(t)?t:g.createSelectorFromElement($(t)),up.browser.canPushState()||n.history===!1?(o={url:e,method:n.method,selector:u,cache:n.cache,preload:n.preload},r=up.proxy.ajax(o),r.done(function(t,r,a){var s,l;return(s=g.locationFromXhr(a))&&(g.debug("Location from server: %o",s),l={url:s,method:g.methodFromXhr(a),selector:u},up.proxy.alias(o,l),e=s),n.history!==!1&&(n.history=e),n.source!==!1&&(n.source=e),n.preload?void 0:i(u,t,n)}),r.fail(g.error),r):(n.preload||up.browser.loadPage(e,g.only(n,"method")),g.resolvedPromise())},i=function(t,e,n){var o,u,i,a,c,p,f,d;for(n=g.options(n,{historyMethod:"push"}),n.source=g.option(n.source,n.history),p=l(e),n.title||(n.title=p.title()),n.saveScroll!==!1&&up.layout.saveScroll(),c=s(t,n),f=[],i=0,a=c.length;a>i;i++)d=c[i],u=r(d.selector),o=p.find(d.selector).first(),f.push(v(u,o,d.pseudoClass,d.transition,n));return f},r=function(t){return o(".up-popup "+t)||o(".up-modal "+t)||o(t)||u(t)},u=function(t){var e;return e="Could not find selector %o in current body HTML","#"===e[0]&&(e+=" (avoid using IDs)"),g.error(e,t)},l=function(t){var e;return e=g.createElementFromHtml(t),{title:function(){var t;return null!=(t=e.querySelector("title"))?t.textContent:void 0},find:function(n){var r;return(r=e.querySelector(n))?$(r):g.error("Could not find selector %o in response %o",n,t)}}},d=function(t,e){return e.reveal?up.reveal(t):g.resolvedDeferred()},n=function(e,n){return"function"==typeof n.insert&&n.insert(e),n.history&&(n.title&&(document.title=n.title),up.history[n.historyMethod](n.history)),n.source!==!1&&m(e,n.source),n.restoreScroll&&up.layout.restoreScroll({around:e}),t(e),up.ready(e)},v=function(t,r,o,u,i){var a,s;return u||(u="none"),up.motion.finish(t),o?(s="before"===o?"prepend":"append",a=r.contents().wrap('<span class="up-insertion"></span>').parent(),t[s](a),g.copyAttributes(r,t),n(a.children(),i),d(a,i).then(function(){return up.animate(a,u,i)}).then(function(){g.unwrapElement(a)})):d(t,i).then(function(){return e(t,{animation:function(){return r.insertBefore(t),n(r,i),t.is("body")&&"none"!==u&&g.error("Cannot apply transitions to body-elements (%o)",u),up.morph(t,r,u,i)}})})},s=function(t,e){var n,r,o,u,i,a,s,l,c,p,f;for(p=e.transition||e.animation||"none",n=/\ *,\ */,r=t.split(n),g.isPresent(p)&&(f=p.split(n)),a=[],o=u=0,i=r.length;i>u;o=++u)s=r[o],l=s.match(/^(.+?)(?:\:(before|after))?$/),c=f[o]||g.last(f),a.push({selector:l[1],pseudoClass:l[2],transition:c});return a},t=function(t){var e,n;return n="[autofocus]:last",e=g.findWithSelf(t,n),e.length&&e.get(0)!==document.activeElement?e.focus():void 0},a=function(t){var e;return e=".up-ghost, .up-destroying",0===t.closest(e).length},o=function(t){var e,n,r,o,u,i;for(o=$(t).get(),n=null,u=0,i=o.length;i>u;u++)if(r=o[u],e=$(r),a(e)){n=e;break}return n},e=function(t,e){var n,r,o;return n=$(t),e=g.options(e,{animation:"none"}),r=up.motion.animateOptions(e),n.addClass("up-destroying"),g.isPresent(e.url)&&up.history.push(e.url),g.isPresent(e.title)&&(document.title=e.title),up.bus.emit("fragment:destroy",n),o=g.presence(e.animation,g.isPromise)||up.motion.animate(n,e.animation,r),o.then(function(){return n.remove()}),o},c=function(t,e){var n;return e=g.options(e,{cache:!1}),n=e.url||h(t),p(t,n,e)},f=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return m(document.body,up.browser.url())}),{replace:p,reload:c,destroy:e,implant:i,reset:f,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(){up.motion=function(){var t,e,n,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=w.config({duration:300,delay:0,easing:"ease"}),h=function(){return o=w.copy(a),b=w.copy(s),i.reset()},e=function(t,r,o){var i;return i=$(t),c(i),o=n(o),("none"===r||r===!1)&&d(),w.isFunction(r)?u(r(i,o),r):w.isString(r)?e(i,l(r),o):w.isHash(r)?w.cssAnimate(i,r,o):w.error("Unknown animation type %o",r)},n=function(t,e){var n;return null==e&&(e=null),t=w.options(t),n={},n.easing=w.option(t.easing,null!=e?e.attr("up-easing"):void 0,i.easing),n.duration=Number(w.option(t.duration,null!=e?e.attr("up-duration"):void 0,i.duration)),n.delay=Number(w.option(t.delay,null!=e?e.attr("up-delay"):void 0,i.delay)),n},l=function(t){return o[t]||w.error("Unknown animation %o",r)},t="up-ghosting-promise",k=function(e,n,r){var o,u,i,a;return u=null,o=null,w.temporaryCss(n,{display:"none"},function(){return u=m(e),u.$ghost.addClass("up-destroying"),u.$bounds.addClass("up-destroying")}),w.temporaryCss(e,{display:"none"},function(){return o=m(n)}),e.css({visibility:"hidden"}),a=w.temporaryCss(n,{display:"none"}),i=r(u.$ghost,o.$ghost),e.data(t,i),n.data(t,i),i.then(function(){return e.removeData(t),n.removeData(t),u.$bounds.remove(),o.$bounds.remove(),e.css({display:"none"}),a()}),i},c=function(t){return $(t).each(function(){var t;return t=$(this),w.finishCssAnimate(t),p(t)})},p=function(e){var n;return(n=e.data(t))?(w.debug("Canceling existing ghosting on %o",e),"function"==typeof n.resolve?n.resolve():void 0):void 0},u=function(t,e){return w.isDeferred(t)?t:w.error("Did not return a promise with .then and .resolve methods: %o",e)},f=function(t,r,i,a){var s,l,p,m,h;return up.browser.canCssAnimation()?(a=n(a),l=$(t),s=$(r),c(l),c(s),"none"===i||i===!1?d():(h=w.presence(i,w.isFunction)||b[i])?k(l,s,function(t,e){return u(h(t,e,a),i)}):(p=o[i])?(l.hide(),e(s,p,a)):w.isString(i)&&i.indexOf("/")>=0?(m=i.split("/"),h=function(t,n,r){return v(e(t,m[0],r),e(n,m[1],r))},f(l,s,h,a)):w.error("Unknown transition %o",i)):w.resolvedDeferred()},m=function(t){var e,n,r,o;return o=w.measure(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({position:"static"===t.css("position")?"static":"relative",top:"",right:"",bottom:"",left:"",width:"100%",height:"100%"}),n.addClass("up-ghost"),e=$('<div class="up-bounds"></div>'),e.css({position:"absolute"}),e.css(o),n.appendTo(e),e.insertBefore(t),r=n.offset().top-t.offset().top,0!==r&&e.css({top:o.top-r}),{$ghost:n,$bounds:e}},y=function(t,e){return b[t]=e},r=function(t,e){return o[t]=e},g=function(){return a=w.copy(o),s=w.copy(b)},v=w.resolvableWhen,d=w.resolvedDeferred,r("none",d),r("fade-in",function(t,n){return t.css({opacity:0}),e(t,{opacity:1},n)}),r("fade-out",function(t,n){return t.css({opacity:1}),e(t,{opacity:0},n)}),r("move-to-top",function(t,n){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"0px"}),e(t,{"margin-top":"-"+o+"px"},n)}),r("move-from-top",function(t,n){var r,o;return r=w.measure(t),o=r.top+r.height,t.css({"margin-top":"-"+o+"px"}),e(t,{"margin-top":"0px"},n)}),r("move-to-bottom",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":"0px"}),e(t,{"margin-top":o+"px"},n)}),r("move-from-bottom",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().height-r.top,t.css({"margin-top":o+"px"}),e(t,{"margin-top":"0px"},n)}),r("move-to-left",function(t,n){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"0px"}),e(t,{"margin-left":"-"+o+"px"},n)}),r("move-from-left",function(t,n){var r,o;return r=w.measure(t),o=r.left+r.width,t.css({"margin-left":"-"+o+"px"}),e(t,{"margin-left":"0px"},n)}),r("move-to-right",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":"0px"}),e(t,{"margin-left":o+"px"},n)}),r("move-from-right",function(t,n){var r,o;return r=w.measure(t),o=w.clientSize().width-r.left,t.css({"margin-left":o+"px"}),e(t,{"margin-left":"0px"},n)}),r("roll-down",function(t,n){var r,o;return r=t.height(),o=w.temporaryCss(t,{height:"0px",overflow:"hidden"}),e(t,{height:r+"px"},n).then(o)}),y("none",d),y("move-left",function(t,n,r){return v(e(t,"move-to-left",r),e(n,"move-from-right",r))}),y("move-right",function(t,n,r){return v(e(t,"move-to-right",r),e(n,"move-from-left",r))}),y("move-up",function(t,n,r){return v(e(t,"move-to-top",r),e(n,"move-from-bottom",r))}),y("move-down",function(t,n,r){return v(e(t,"move-to-bottom",r),e(n,"move-from-top",r))}),y("cross-fade",function(t,n,r){return v(e(t,"fade-out",r),e(n,"fade-in",r))}),up.bus.on("framework:ready",g),up.bus.on("framework:reset",h),{morph:f,animate:e,animateOptions:n,finish:c,transition:y,animation:r,defaults:i.update,none:d,when:v,prependGhost:m}}(),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,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v,g,y,b,w,k,x,S,C,A,E,P,T;return T=up.util,t=void 0,S=void 0,u=void 0,k=void 0,i=void 0,d=T.config({busyDelay:300,preloadDelay:75,cacheSize:70,cacheExpiry:3e5}),s=function(t){return w(t),[t.url,t.method,t.data,t.selector].join("|")},a=T.cache({size:function(){return d.cacheSize},expiry:function(){return d.cacheExpiry},key:s,log:"up.proxy"}),m=a.get,E=a.set,C=a.remove,f=a.clear,c=function(){return clearTimeout(S),S=null},l=function(){return clearTimeout(u),u=null},A=function(){return t=null,c(),l(),k=0,d.reset(),i=!1,a.clear()},A(),r=a.alias,w=function(t){return t._normalized||(t.method=T.normalizeMethod(t.method),t.url&&(t.url=T.normalizeUrl(t.url)),t.selector||(t.selector="body"),t._normalized=!0),t},n=function(t){var e,n,r,o,u;return e=t.cache===!0,n=t.cache===!1,u=T.only(t,"url","method","data","selector","_normalized"),r=!0,v(u)||e?(o=m(u))&&!n?r="pending"===o.state():(o=g(u),E(u,o)):(f(),o=g(u)),r&&!t.preload&&(b(),o.then(y)),o},e=["GET","OPTIONS","HEAD"],h=function(){return 0===k},o=function(){return k>0},b=function(){var t,e;return e=h(),k+=1,e?(t=function(){return o()?(up.bus.emit("proxy:busy"),i=!0):void 0},d.busyDelay>0?u=setTimeout(t,d.busyDelay):t()):void 0},y=function(){return k-=1,h()&&i?(up.bus.emit("proxy:idle"),i=!1):void 0},g=function(t){var e;return up.bus.emit("proxy:load",t),e=T.ajax(t),e.then(function(){return up.bus.emit("proxy:receive",t)}),e},v=function(t){return w(t),T.contains(e,t.method)},p=function(e){var n,r;return r=parseInt(T.presentAttr(e,"up-delay"))||d.preloadDelay,e.is(t)?void 0:(t=e,c(),n=function(){return x(e)},P(n,r))},P=function(t,e){return S=setTimeout(t,e)},x=function(t,e){var n,r;return n=$(t),e=T.options(e),r=up.link.followMethod(n,e),v({method:r})?(T.debug("Preloading %o",n),e.preload=!0,up.link.follow(n,e)):(T.debug("Won't preload %o due to unsafe method %o",n,r),T.resolvedPromise())},up.on("mouseover mousedown touchstart","[up-preload]",function(t,e){return up.link.childClicked(t,e)?void 0:p(e)}),up.bus.on("framework:reset",A),{preload:x,ajax:n,get:m,set:E,alias:r,clear:f,remove:C,idle:h,busy:o,defaults:d.update}}()}.call(this),function(){up.link=function(){var childClicked,follow,followMethod,makeFollowable,shouldProcessLinkEvent,u,visit;return u=up.util,visit=function(t,e){var n;return e=u.options(e),n=u.option(e.target,"body"),up.replace(n,t,e)},follow=function(t,e){var n,r,o;return n=$(t),e=u.options(e),o=u.option(n.attr("up-href"),n.attr("href")),r=u.option(e.target,n.attr("up-target"),"body"),e.transition=u.option(e.transition,u.castedAttr(n,"up-transition"),u.castedAttr(n,"up-animation")),e.history=u.option(e.history,u.castedAttr(n,"up-history")),e.reveal=u.option(e.reveal,u.castedAttr(n,"up-reveal"),!0),e.cache=u.option(e.cache,u.castedAttr(n,"up-cache")),e.restoreScroll=u.option(e.restoreScroll,u.castedAttr(n,"up-restore-scroll")),e.method=followMethod(n,e),e=u.merge(e,up.motion.animateOptions(e,n)),up.replace(r,o,e)
2
+ },followMethod=function(t,e){return e=u.options(e),u.option(e.method,t.attr("up-method"),t.attr("data-method"),"get").toUpperCase()},up.on("click","a[up-target], [up-href][up-target]",function(t,e){return shouldProcessLinkEvent(t,e)?e.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(e)):void 0}),up.on("mousedown","a[up-instant], [up-href][up-instant]",function(t,e){return shouldProcessLinkEvent(t,e)?(t.preventDefault(),follow(e)):void 0}),childClicked=function(t,e){var n,r;return n=$(t.target),r=n.closest("a, [up-href]"),r.length&&e.find(r).length},shouldProcessLinkEvent=function(t,e){return u.isUnmodifiedMouseEvent(t)&&!childClicked(t,e)},makeFollowable=function(t){var e;return e=$(t),u.isMissing(e.attr("up-target"))&&u.isMissing(e.attr("up-follow"))?e.attr("up-follow",""):void 0},up.on("click","a[up-follow], [up-href][up-follow]",function(t,e){return shouldProcessLinkEvent(t,e)?e.is("[up-instant]")?t.preventDefault():(t.preventDefault(),follow(e)):void 0}),up.compiler("[up-expand]",function(t){var e,n,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,n=0,r=s.length;r>n;n++)e=s[n],i=e.name,i.match(l)&&(a[i]=e.value);return u.setMissingAttrs(t,a),t.removeAttr("up-expand"),makeFollowable(t)}),up.compiler("[up-dash]",function(t){var e,n;return n=u.castedAttr(t,"up-dash"),e={"up-preload":"true","up-instant":"true"},n===!0?e["up-follow"]="":e["up-target"]=n,u.setMissingAttrs(t,e),t.removeAttr("up-dash")}),{knife:eval("undefined"!=typeof Knife&&null!==Knife?Knife.point:void 0),visit:visit,follow:follow,makeFollowable:makeFollowable,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,e){var n,r,o,i,a,s,l,c,p,f,d,m;return n=$(t).closest("form"),e=u.options(e),c=u.option(e.target,n.attr("up-target"),"body"),r=u.option(e.failTarget,n.attr("up-fail-target"),function(){return u.createSelectorFromElement(n)}),i=u.option(e.history,u.castedAttr(n,"up-history"),!0),p=u.option(e.transition,u.castedAttr(n,"up-transition")),o=u.option(e.failTransition,u.castedAttr(n,"up-fail-transition"),p),a=u.option(e.method,n.attr("up-method"),n.attr("data-method"),n.attr("method"),"post").toUpperCase(),s={},s.reveal=u.option(e.reveal,u.castedAttr(n,"up-reveal"),!0),s.cache=u.option(e.cache,u.castedAttr(n,"up-cache")),s.restoreScroll=u.option(e.restoreScroll,u.castedAttr(n,"up-restore-scroll")),s=u.extend(s,up.motion.animateOptions(e,n)),m=u.option(e.cache,u.castedAttr(n,"up-cache")),d=u.option(e.url,n.attr("action"),up.browser.url()),n.addClass("up-active"),up.browser.canPushState()||i===!1?(l={url:d,method:a,data:n.serialize(),selector:c,cache:m},f=function(t){var e;return d=void 0,u.isGiven(i)&&(i===!1||u.isString(i)?d=i:(e=u.locationFromXhr(t))?d=e:"GET"===l.type&&(d=l.url+"?"+l.data)),u.option(d,!1)},up.proxy.ajax(l).always(function(){return n.removeClass("up-active")}).done(function(t,e,n){var r;return r=u.merge(s,{history:f(n),transition:p}),up.flow.implant(c,t,r)}).fail(function(t){var e,n;return n=t.responseText,e=u.merge(s,{transition:o}),up.flow.implant(r,n,e)})):void n.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,e;return e=$field.val(),t=u.isNull(knownValue),knownValue===e||(knownValue=e,t)?void 0:(clearTimer(),nextCallback=function(){return callback.apply($field.get(0),[e,$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,e){return t.preventDefault(),submit(e)}),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,e,n,r,o,u,i,a,s,l,c,p,f,d,m;return d=up.util,u=void 0,n=d.config({openAnimation:"fade-in",closeAnimation:"fade-out",position:"bottom-right"}),c=function(){return e(),n.reset()},p=function(t,e,n){var r,o;return o=d.measure(t,{full:!0}),r=function(){switch(n){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.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",n)}}(),e.attr("up-position",n),e.css(r),a(e)},a=function(t){var e,n,r,o,u,i,a;if(n=d.measure(t,{full:!0}),r=null,o=null,n.right<0&&(r=-n.right),n.bottom<0&&(o=-n.bottom),n.left<0&&(r=n.left),n.top<0&&(o=n.top),r&&((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(e=parseInt(t.css("bottom")))return t.css("bottom",e+o)}},l=function(){var t;return t=$(".up-popup"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},i=function(){var t;return t=$(".up-popup"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},o=function(t,e,n){var r,o;return o=d.$createElementFromSelector(".up-popup"),n&&o.attr("up-sticky",""),r=d.$createElementFromSelector(e),r.appendTo(o),o.appendTo(document.body),l(),o.hide(),o},m=function(t,e,n,r,o){return e.show(),p(t,e,n),up.animate(e,r,o)},s=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"),n.position),s=d.option(r.animation,u.attr("up-animation"),n.openAnimation),f=d.option(r.sticky,d.castedAttr(u,"up-sticky")),l=up.browser.canPushState()?d.option(r.history,d.castedAttr(u,"up-history"),!1):!1,a=up.motion.animateOptions(r,u),e(),i=o(u,p,f),up.replace(p,h,{history:l,insert:function(){return m(u,i,c,s,a)}})},f=function(){return u},e=function(t){var e;return e=$(".up-popup"),e.length?(t=d.options(t,{animation:n.closeAnimation,url:e.attr("up-previous-url"),title:e.attr("up-previous-title")}),u=void 0,up.destroy(e,t)):d.resolvedPromise()},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:(i(),e())},r=function(t){var e;return e=$(t),e.closest(".up-popup").length>0},up.on("click","a[up-popup]",function(t,n){return t.preventDefault(),n.is(".up-current")?e():s(n)}),up.on("click","body",function(t){var n;return n=$(t.target),n.closest(".up-popup").length||n.closest("[up-popup]").length?void 0:e()}),up.bus.on("fragment:ready",function(e){var n;return r(e)?(n=e.attr("up-source"))?u=n:void 0:t()}),up.magic.onEscape(function(){return e()}),up.on("click","[up-close]",function(t,n){return n.closest(".up-popup")?e():void 0}),up.bus.on("framework:reset",c),{open:s,close:e,source:f,defaults:n.update,contains:r}}()}.call(this),function(){var t=[].slice;up.modal=function(){var e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,r=m.config({maxWidth:void 0,minWidth:void 0,width:void 0,height:void 0,openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"\xd7",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>'}}),i=void 0,c=function(){return n(),i=void 0,r.reset()},d=function(){var t;return t=r.template,m.isFunction(t)?t(r):t},l=function(){var t;return t=$(".up-modal"),t.attr("up-previous-url",up.browser.url()),t.attr("up-previous-title",document.title)},a=function(){var t;return t=$(".up-modal"),t.removeAttr("up-previous-url"),t.removeAttr("up-previous-title")},u=function(t){var e,n,r,o;return r=$(d()),t.sticky&&r.attr("up-sticky",""),r.attr("up-previous-url",up.browser.url()),r.attr("up-previous-title",document.title),n=r.find(".up-modal-dialog"),m.isPresent(t.width)&&n.css("width",t.width),m.isPresent(t.maxWidth)&&n.css("max-width",t.maxWidth),m.isPresent(t.height)&&n.css("height",t.height),e=r.find(".up-modal-content"),o=m.$createElementFromSelector(t.selector),o.appendTo(e),r.appendTo(document.body),l(),r.hide(),r},h=void 0,p=function(){var t,e,n;return n=m.scrollbarWidth(),t=parseInt($("body").css("padding-right")),e=n+t,h=m.temporaryCss($("body"),{"padding-right":e+"px","overflow-y":"hidden"})},v=function(t,e,n){var r;return up.bus.emit("modal:open"),p(),t.show(),r=up.animate(t,e,n),r.then(function(){return up.bus.emit("modal:opened")}),r},s=function(){var e,o,i,a,s,l,c,p,f,d,h,g,y;return s=1<=arguments.length?t.call(arguments,0):[],!m.isObject(s[0])||m.isElement(s[0])||m.isJQuery(s[0])?(e=$(s[0]),f=s[1]):(e=m.nullJquery(),f=s[0]),f=m.options(f),g=m.option(f.url,e.attr("up-href"),e.attr("href")),d=m.option(f.target,e.attr("up-modal"),"body"),y=m.option(f.width,e.attr("up-width"),r.width),p=m.option(f.maxWidth,e.attr("up-max-width"),r.maxWidth),l=m.option(f.height,e.attr("up-height"),r.height),a=m.option(f.animation,e.attr("up-animation"),r.openAnimation),h=m.option(f.sticky,m.castedAttr(e,"up-sticky")),c=up.browser.canPushState()?m.option(f.history,m.castedAttr(e,"up-history"),!0):!1,i=up.motion.animateOptions(f,e),n(),o=u({selector:d,width:y,maxWidth:p,height:l,sticky:h}),up.replace(d,g,{history:c,insert:function(){return v(o,a,i)}})},f=function(){return i},n=function(t){var e,n;return e=$(".up-modal"),e.length?(t=m.options(t,{animation:r.closeAnimation,url:e.attr("up-previous-url"),title:e.attr("up-previous-title")}),i=void 0,up.bus.emit("modal:close"),n=up.destroy(e,t),n.then(function(){return h(),up.bus.emit("modal:closed")}),n):m.resolvedPromise()},e=function(){return $(".up-modal").is("[up-sticky]")?void 0:(a(),n())},o=function(t){var e;return e=$(t),e.closest(".up-modal").length>0},up.on("click","a[up-modal]",function(t,e){return t.preventDefault(),e.is(".up-current")?n():s(e)}),up.on("click","body",function(t){var e;return e=$(t.target),e.closest(".up-modal-dialog").length||e.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(t){var n;if(o(t)){if(n=t.attr("up-source"))return i=n}else if(!up.popup.contains(t))return e()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,e){return e.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",c),{open:s,close:n,source:f,defaults:r.update,contains:o}}()}.call(this),function(){up.tooltip=function(){var t,e,n,r,o;return o=up.util,r=function(t,e,n){var r,u,i;return u=o.measure(t),i=o.measure(e),r=function(){switch(n){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",n)}}(),e.attr("up-position",n),e.css(r)},e=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},n=function(n,u){var i,a,s,l,c,p;return null==u&&(u={}),i=$(n),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,o.castedAttr(i,"up-animation"),"fade-in"),s=up.motion.animateOptions(u,i),t(),a=e(c),r(i,a,p),up.animate(a,l,s)},t=function(t){var e;return e=$(".up-tooltip"),e.length?(t=o.options(t,{animation:"fade-out"}),t=o.merge(t,up.motion.animateOptions(t)),up.destroy(e,t)):void 0},up.compiler("[up-tooltip]",function(e){return e.on("mouseover",function(){return n(e)}),e.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:n,close:t}}()}.call(this),function(){up.navigation=function(){var t,e,n,r,o,u,i,a,s,l,c,p,f,d,m,h,v;return m=up.util,u=m.config({currentClasses:["up-current"]}),c=function(){return u.reset()},i=function(){var t;return t=u.currentClasses,t=t.concat(["up-current"]),t=m.uniq(t),t.join(" ")},t="up-active",e=["a","[up-href]","[up-alias]"],r=e.join(", "),o=function(){var t,n,r;for(r=[],t=0,n=e.length;n>t;t++)d=e[t],r.push(d+"[up-instant]");return r}().join(", "),n="."+t,l=function(t){return m.isPresent(t)?m.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},f=function(t){var e,n,r,o,u,i,a,s,c,p;for(s=[],i=["href","up-href","up-alias"],n=0,o=i.length;o>n;n++)if(e=i[n],c=m.presentAttr(t,e))for(p="up-alias"===e?c.split(" "):[c],r=0,u=p.length;u>r;r++)a=p[r],"#"!==a&&(a=l(a),s.push(a));return s},v=function(t){var e,n,r,o;return t=m.compact(t),r=function(t){return"*"===t.substr(-1)?n(t.slice(0,-1)):e(t)},e=function(e){return m.contains(t,e)},n=function(e){return m.detect(t,function(t){return 0===t.indexOf(e)})},o=function(t){return m.detect(t,r)},{matchesAny:o}},s=function(){var t,e;return t=v([l(up.browser.url()),l(up.modal.source()),l(up.popup.source())]),e=i(),m.each($(r),function(n){var r,o;return r=$(n),o=f(r),t.matchesAny(o)?r.addClass(e):r.removeClass(e)})},p=function(e){return h(),e=a(e),e.addClass(t)},a=function(t){return m.presence(t.parents(r))||t},h=function(){return $(n).removeClass(t)},up.on("click",r,function(t,e){return m.isUnmodifiedMouseEvent(t)&&!e.is("[up-instant]")?p(e):void 0}),up.on("mousedown",o,function(t,e){return m.isUnmodifiedMouseEvent(t)?p(e):void 0}),up.bus.on("fragment:ready",function(){return h(),s()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?s():void 0}),up.bus.on("framework:reset",c),{defaults:u.update}}()}.call(this),function(){up.slot=function(){var t,e,n;return n=up.util,e=function(t){return""!==n.trim(t.html())},t=function(t){return n.findWithSelf(t,"[up-slot]").each(function(){var t;return t=$(this),e(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);
@@ -53,7 +53,7 @@ up.flow = (->
53
53
  scrolling its containing viewport.
54
54
  @param {Boolean} [options.restoreScroll=`false`]
55
55
  If set to true, Up.js will try to restore the scroll position
56
- of all the viewports within the updated element. The position
56
+ of all the viewports around or below the updated element. The position
57
57
  will be reset to the last known top position before a previous
58
58
  history change for the current URL.
59
59
  @param {Boolean} [options.cache]
@@ -183,7 +183,7 @@ up.flow = (->
183
183
  unless options.source is false
184
184
  setSource($new, options.source)
185
185
  if options.restoreScroll
186
- up.layout.restoreScroll(within: $new)
186
+ up.layout.restoreScroll(around: $new)
187
187
  autofocus($new)
188
188
  # The fragment should be readiet before animating,
189
189
  # so transitions see .up-current classes
@@ -38,7 +38,7 @@ up.layout = (->
38
38
  ###
39
39
  config = u.config
40
40
  duration: 0
41
- viewports: ['body', '.up-modal', '[up-viewport]']
41
+ viewports: [document, '.up-modal', '[up-viewport]']
42
42
  fixedTop: ['[up-fixed~=top]']
43
43
  fixedBottom: ['[up-fixed~=bottom]']
44
44
  snap: 50
@@ -182,29 +182,29 @@ up.layout = (->
182
182
 
183
183
  @method up.reveal
184
184
  @param {String|Element|jQuery} element
185
- @param {String|Element|jQuery} [options.viewport]
186
185
  @param {Number} [options.duration]
187
186
  @param {String} [options.easing]
188
187
  @param {String} [options.snap]
188
+ @param {String|Element|jQuery} [options.viewport]
189
189
  @return {Deferred}
190
190
  A promise that will be resolved when the element is revealed.
191
191
  ###
192
192
  reveal = (elementOrSelector, options) ->
193
193
  options = u.options(options)
194
194
  $element = $(elementOrSelector)
195
- $viewport = viewportOf($element, options.viewport)
195
+ $viewport = if options.viewport then $(options.viewport) else viewportOf($element)
196
196
 
197
197
  snap = u.option(options.snap, config.snap)
198
198
 
199
- viewportIsBody = $viewport.is('body')
200
- viewportHeight = if viewportIsBody then u.clientSize().height else $viewport.height()
199
+ viewportIsDocument = $viewport.is(document)
200
+ viewportHeight = if viewportIsDocument then u.clientSize().height else $viewport.height()
201
201
  originalScrollPos = $viewport.scrollTop()
202
202
  newScrollPos = originalScrollPos
203
203
 
204
204
  offsetShift = undefined
205
205
  obstruction = undefined
206
206
 
207
- if viewportIsBody
207
+ if viewportIsDocument
208
208
  obstruction = measureObstruction()
209
209
  # Within the body, $.position will always return the distance
210
210
  # from the document top and *not* the distance of the viewport
@@ -245,7 +245,7 @@ up.layout = (->
245
245
  u.resolvedDeferred()
246
246
 
247
247
  viewportSelector = ->
248
- config.viewports.join(', ')
248
+ u.multiSelector(config.viewports)
249
249
 
250
250
  ###*
251
251
  Returns the viewport for the given element.
@@ -256,17 +256,9 @@ up.layout = (->
256
256
  @method up.layout.viewportOf
257
257
  @param {String|Element|jQuery} selectorOrElement
258
258
  ###
259
- viewportOf = (selectorOrElement, viewportSelectorOrElement) ->
259
+ viewportOf = (selectorOrElement) ->
260
260
  $element = $(selectorOrElement)
261
- $viewport = undefined
262
- # If someone has handed as a jQuery element, that's the
263
- # view period.
264
- if u.isJQuery(viewportSelectorOrElement)
265
- $viewport = viewportSelectorOrElement
266
- else
267
- vieportSelector = u.presence(viewportSelectorOrElement) || viewportSelector()
268
- $viewport = $element.closest(vieportSelector)
269
-
261
+ $viewport = viewportSelector().seekUp($element)
270
262
  $viewport.length or u.error("Could not find viewport for %o", $element)
271
263
  $viewport
272
264
 
@@ -281,7 +273,7 @@ up.layout = (->
281
273
  ###
282
274
  viewportsIn = (selectorOrElement) ->
283
275
  $element = $(selectorOrElement)
284
- u.findWithSelf($element, viewportSelector())
276
+ viewportSelector().findWithSelf($element)
285
277
 
286
278
  ###*
287
279
  Returns a jQuery collection of all the viewports on the screen.
@@ -290,7 +282,7 @@ up.layout = (->
290
282
  @method up.layout.viewports
291
283
  ###
292
284
  viewports = ->
293
- $(viewportSelector())
285
+ viewportSelector().select()
294
286
 
295
287
  ###*
296
288
  Returns a hash with scroll positions.
@@ -310,7 +302,9 @@ up.layout = (->
310
302
  for viewport in config.viewports
311
303
  $viewport = $(viewport)
312
304
  if $viewport.length
313
- topsBySelector[viewport] = $viewport.scrollTop()
305
+ key = viewport
306
+ key = 'document' if viewport == document
307
+ topsBySelector[key] = $viewport.scrollTop()
314
308
  topsBySelector
315
309
 
316
310
  ###*
@@ -334,20 +328,27 @@ up.layout = (->
334
328
  viewports configured in `up.layout.defaults('viewports')`.
335
329
 
336
330
  @method up.layout.restoreScroll
337
- @param {String} [options.within]
331
+ @param {jQuery} [options.around]
332
+ If set, only restores viewports that are either an ancestor
333
+ or descendant of the given element.
338
334
  @protected
339
335
  ###
340
336
  restoreScroll = (options = {}) ->
341
337
 
342
- $viewports = if options.within
343
- viewportsIn(options.within)
338
+ $viewports = undefined
339
+
340
+ if options.around
341
+ $descendantViewports = viewportsIn(options.around)
342
+ $ancestorViewports = viewportOf(options.around)
343
+ $viewports = $ancestorViewports.add($descendantViewports)
344
344
  else
345
- viewports()
345
+ $viewports = viewports()
346
346
 
347
347
  tops = lastScrollTops.get(up.history.url())
348
348
 
349
- for selector, scrollTop of tops
350
- $matchingViewport = $viewports.filter(selector)
349
+ for key, scrollTop of tops
350
+ right = if key == 'document' then document else key
351
+ $matchingViewport = $viewports.filter(right)
351
352
  up.scroll($matchingViewport, scrollTop, duration: 0)
352
353
 
353
354
  ###*
@@ -295,6 +295,8 @@ up.motion = (->
295
295
  $ghost = $element.clone()
296
296
  $ghost.find('script').remove()
297
297
  $ghost.css
298
+ # If the element had a layout context before, make sure the
299
+ # ghost will have layout context as well (and vice versa).
298
300
  position: if $element.css('position') == 'static' then 'static' else 'relative'
299
301
  top: ''
300
302
  right: ''
@@ -337,7 +337,7 @@ up.util = (->
337
337
  ###
338
338
  option = (args...) ->
339
339
  # This behavior is subtly different from detect!
340
- match = null
340
+ match = undefined
341
341
  for arg in args
342
342
  value = arg
343
343
  value = value() if isFunction(value)
@@ -347,13 +347,17 @@ up.util = (->
347
347
  match
348
348
 
349
349
  detect = (array, tester) ->
350
- match = null
350
+ match = undefined
351
351
  for element in array
352
352
  if tester(element)
353
353
  match = element
354
354
  break
355
355
  match
356
356
 
357
+ any = (array, tester) ->
358
+ match = detect(array, tester)
359
+ isDefined(match)
360
+
357
361
  compact = (array) ->
358
362
  select array, isGiven
359
363
 
@@ -418,6 +422,17 @@ up.util = (->
418
422
  fun = undefined
419
423
  result
420
424
 
425
+ ###*
426
+ # Temporarily sets the CSS for the given element.
427
+ #
428
+ # @method up.util.temporaryCss
429
+ # @param {jQuery} $element
430
+ # @param {Object} css
431
+ # @param {Function} [block]
432
+ # If given, the CSS is set, the block is called and
433
+ # the old CSS is restored.
434
+ # @private
435
+ ###
421
436
  temporaryCss = ($element, css, block) ->
422
437
  oldCss = $element.css(keys(css))
423
438
  $element.css(css)
@@ -629,6 +644,62 @@ up.util = (->
629
644
  array.splice(index, 1)
630
645
  element
631
646
 
647
+ emptyJQuery = ->
648
+ $([])
649
+
650
+ multiSelector = (parts) ->
651
+
652
+ obj = {}
653
+ selectors = []
654
+ elements = []
655
+
656
+ for part in parts
657
+ if isString(part)
658
+ selectors.push(part)
659
+ else
660
+ elements.push(part)
661
+
662
+ obj.parsed = elements
663
+
664
+ if selectors.length
665
+ # Although other methods would work with an array of
666
+ # selectors, we combine them to a single separator for
667
+ # performance reasons.
668
+ combinedSelector = selectors.join(', ')
669
+ obj.parsed.push(combinedSelector)
670
+
671
+ obj.select = ->
672
+ obj.find(undefined)
673
+
674
+ obj.find = ($root) ->
675
+ $result = emptyJQuery()
676
+ for selector in obj.parsed
677
+ $matches = if $root then $root.find(selector) else $(selector)
678
+ $result = $result.add($matches)
679
+ $result
680
+
681
+ obj.findWithSelf = ($start) ->
682
+ $matches = obj.find($start)
683
+ $matches = $matches.add($start) if obj.doesMatch($start)
684
+ $matches
685
+
686
+ obj.doesMatch = (element) ->
687
+ $element = $(element)
688
+ any obj.parsed, (selector) -> $element.is(selector)
689
+
690
+ obj.seekUp = (start) ->
691
+ $start = $(start)
692
+ $element = $start
693
+ $result = undefined
694
+ while $element.length
695
+ if obj.doesMatch($element)
696
+ $result = $element
697
+ break
698
+ $element = $element.parent()
699
+ $result || emptyJQuery()
700
+
701
+ obj
702
+
632
703
  ###*
633
704
  @method up.util.cache
634
705
  @param {Number|Function} [config.size]
@@ -740,7 +811,6 @@ up.util = (->
740
811
  remove: remove
741
812
  clear: clear
742
813
 
743
-
744
814
  config = (factoryOptions = {}) ->
745
815
  hash =
746
816
  ensureKeyExists: (key) ->
@@ -794,6 +864,7 @@ up.util = (->
794
864
  map: map
795
865
  identity: identity
796
866
  times: times
867
+ any: any
797
868
  detect: detect
798
869
  select: select
799
870
  compact: compact
@@ -853,5 +924,7 @@ up.util = (->
853
924
  config: config
854
925
  cache: cache
855
926
  unwrapElement: unwrapElement
927
+ multiSelector: multiSelector
928
+ emptyJQuery: emptyJQuery
856
929
 
857
930
  )()
@@ -1,5 +1,5 @@
1
1
  module Upjs
2
2
  module Rails
3
- VERSION = '0.10.2'
3
+ VERSION = '0.10.3'
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- upjs-rails (0.10.1)
4
+ upjs-rails (0.10.2)
5
5
  rails (>= 3)
6
6
 
7
7
  GEM
@@ -0,0 +1,2 @@
1
+ afterEach ->
2
+ $('body').scrollTop(0)
@@ -35,9 +35,9 @@
35
35
  )
36
36
  event = document.createEvent('MouseEvent')
37
37
  event.initMouseEvent(type,
38
- options.view,
39
38
  options.bubbles,
40
39
  options.cancelable,
40
+ options.view,
41
41
  options.detail,
42
42
  options.screenX,
43
43
  options.screenY,
@@ -10,16 +10,17 @@ describe 'up.layout', ->
10
10
  up.layout.defaults
11
11
  snap: 0
12
12
  substance: 99999
13
+ viewports: [document]
13
14
 
14
- describe 'when the container is body', ->
15
+ describe 'when the viewport is the document', ->
15
16
 
16
17
  beforeEach ->
17
- @$viewport = $('body')
18
- @restoreMargin = u.temporaryCss(@$viewport, 'margin-top': 0)
19
- @$viewport.scrollTop(0)
18
+ $body = $('body')
19
+
20
+ @restoreMargin = u.temporaryCss($body, 'margin-top': 0)
20
21
 
21
22
  @$elements = []
22
- @$container = $('<div class="container">').prependTo(@$viewport)
23
+ @$container = $('<div class="container">').prependTo($body)
23
24
 
24
25
  @clientHeight = u.clientSize().height
25
26
 
@@ -33,29 +34,29 @@ describe 'up.layout', ->
33
34
  @restoreMargin()
34
35
 
35
36
  it 'reveals the given element', ->
36
- up.reveal(@$elements[0], viewport: @$viewport)
37
+ up.reveal(@$elements[0])
37
38
  # ---------------------
38
39
  # [0] 0 .......... ch-1
39
40
  # ---------------------
40
41
  # [1] ch+0 ...... ch+49
41
42
  # [2] ch+50 ... ch+5049
42
- expect(@$viewport.scrollTop()).toBe(0)
43
+ expect($(document).scrollTop()).toBe(0)
43
44
 
44
- up.reveal(@$elements[1], viewport: @$viewport)
45
+ up.reveal(@$elements[1])
45
46
  # ---------------------
46
47
  # [0] 0 .......... ch-1
47
48
  # [1] ch+0 ...... ch+49
48
49
  # ---------------------
49
50
  # [2] ch+50 ... ch+5049
50
- expect(@$viewport.scrollTop()).toBe(50)
51
+ expect($(document).scrollTop()).toBe(50)
51
52
 
52
- up.reveal(@$elements[2], viewport: @$viewport)
53
+ up.reveal(@$elements[2])
53
54
  # [0] 0 .......... ch-1
54
55
  # [1] ch+0 ...... ch+49
55
56
  # ---------------------
56
57
  # [2] ch+50 ... ch+5049
57
58
  # ---------------------
58
- expect(@$viewport.scrollTop()).toBe(@clientHeight + 50)
59
+ expect($(document).scrollTop()).toBe(@clientHeight + 50)
59
60
 
60
61
  it 'snaps to the top if the space above the future-visible area is smaller than the value of config.snap', ->
61
62
 
@@ -63,23 +64,23 @@ describe 'up.layout', ->
63
64
 
64
65
  @$elements[0].css(height: '20px')
65
66
 
66
- up.reveal(@$elements[2], viewport: @$viewport)
67
+ up.reveal(@$elements[2])
67
68
  # [0] 0 ............ 19
68
69
  # [1] 20 ........... 69
69
70
  # ---------------------
70
71
  # [2] 70 ......... 5069
71
72
  # ---------------------
72
- expect(@$viewport.scrollTop()).toBe(70)
73
+ expect($(document).scrollTop()).toBe(70)
73
74
 
74
75
  # Even though we're revealing the second element, the viewport
75
76
  # snaps to the top edge.
76
- up.reveal(@$elements[1], viewport: @$viewport)
77
+ up.reveal(@$elements[1])
77
78
  # ---------------------
78
79
  # [0] 0 ............ 19
79
80
  # [1] 20 ........... 69
80
81
  # ---------------------
81
82
  # [2] 70 ......... 5069
82
- expect(@$viewport.scrollTop()).toBe(0)
83
+ expect($(document).scrollTop()).toBe(0)
83
84
 
84
85
  it 'scrolls far enough so the element is not obstructed by an element fixed to the top', ->
85
86
  $topNav = affix('[up-fixed=top]').css(
@@ -97,9 +98,9 @@ describe 'up.layout', ->
97
98
  # ---------------------
98
99
  # [1] ch+0 ...... ch+49
99
100
  # [2] ch+50 ... ch+5049
100
- expect(@$viewport.scrollTop()).toBe(0) # would need to be -100
101
+ expect($(document).scrollTop()).toBe(0) # would need to be -100
101
102
 
102
- up.reveal(@$elements[1], viewport: @$viewport)
103
+ up.reveal(@$elements[1])
103
104
  # ---------------------
104
105
  # [F] 0 ............ 99
105
106
  # [0] 00000 ...... ch-1
@@ -107,25 +108,25 @@ describe 'up.layout', ->
107
108
  # ---------------------
108
109
  # [2] ch+50 ... ch+5049
109
110
 
110
- expect(@$viewport.scrollTop()).toBe(50)
111
+ expect($(document).scrollTop()).toBe(50)
111
112
 
112
- up.reveal(@$elements[2], viewport: @$viewport)
113
+ up.reveal(@$elements[2])
113
114
  # [0] 00000 ...... ch-1
114
115
  # [1] ch+0 ...... ch+49
115
116
  # ---------------------
116
117
  # [F] 0 ............ 99
117
118
  # [2] ch+50 ... ch+5049
118
119
  # ----------------
119
- expect(@$viewport.scrollTop()).toBe(@clientHeight + 50 - 100)
120
+ expect($(document).scrollTop()).toBe(@clientHeight + 50 - 100)
120
121
 
121
- up.reveal(@$elements[1], viewport: @$viewport)
122
+ up.reveal(@$elements[1])
122
123
  # [0] 00000 ...... ch-1
123
124
  # ---------------------
124
125
  # [F] 0 ............ 99
125
126
  # [1] ch+0 ...... ch+49
126
127
  # [2] ch+50 ... ch+5049
127
128
  # ----------------
128
- expect(@$viewport.scrollTop()).toBe(@clientHeight + 50 - 100 - 50)
129
+ expect($(document).scrollTop()).toBe(@clientHeight + 50 - 100 - 50)
129
130
 
130
131
 
131
132
  it 'scrolls far enough so the element is not obstructed by an element fixed to the bottom', ->
@@ -137,32 +138,32 @@ describe 'up.layout', ->
137
138
  height: '100px'
138
139
  )
139
140
 
140
- up.reveal(@$elements[0], viewport: @$viewport)
141
+ up.reveal(@$elements[0])
141
142
  # ---------------------
142
143
  # [0] 0 .......... ch-1
143
144
  # [F] 0 ............ 99
144
145
  # ---------------------
145
146
  # [1] ch+0 ...... ch+49
146
147
  # [2] ch+50 ... ch+5049
147
- expect(@$viewport.scrollTop()).toBe(0)
148
+ expect($(document).scrollTop()).toBe(0)
148
149
 
149
- up.reveal(@$elements[1], viewport: @$viewport)
150
+ up.reveal(@$elements[1])
150
151
  # ---------------------
151
152
  # [0] 0 .......... ch-1
152
153
  # [1] ch+0 ...... ch+49
153
154
  # [F] 0 ............ 99
154
155
  # ---------------------
155
156
  # [2] ch+50 ... ch+5049
156
- expect(@$viewport.scrollTop()).toBe(150)
157
+ expect($(document).scrollTop()).toBe(150)
157
158
 
158
- up.reveal(@$elements[2], viewport: @$viewport)
159
+ up.reveal(@$elements[2])
159
160
  # ---------------------
160
161
  # [0] 0 .......... ch-1
161
162
  # [1] ch+0 ...... ch+49
162
163
  # ---------------------
163
164
  # [2] ch+50 ... ch+5049
164
165
  # [F] 0 ............ 99
165
- expect(@$viewport.scrollTop()).toBe(@clientHeight + 50)
166
+ expect($(document).scrollTop()).toBe(@clientHeight + 50)
166
167
 
167
168
 
168
169
  describe 'when the viewport is a container with overflow-y: scroll', ->
@@ -173,16 +173,13 @@ describe 'up.motion', ->
173
173
 
174
174
  describe 'up.motion.prependGhost', ->
175
175
 
176
- beforeEach ->
177
- @$element = affix('.element')
178
-
179
176
  afterEach ->
180
- $('.up-bounds, .up-ghost').remove()
177
+ $('.up-bounds, .up-ghost, .fixture').remove()
181
178
 
182
179
  it 'clones the given element into a .up-ghost-bounds container and inserts it as a sibling before the element', ->
183
- @$element.text('element text')
184
- up.motion.prependGhost(@$element)
185
- $bounds = @$element.prev()
180
+ $element = affix('.element').text('element text')
181
+ up.motion.prependGhost($element)
182
+ $bounds = $element.prev()
186
183
  expect($bounds).toExist()
187
184
  expect($bounds).toHaveClass('up-bounds')
188
185
  $ghost = $bounds.children(':first')# $ghost.find('.element')
@@ -191,26 +188,41 @@ describe 'up.motion', ->
191
188
  expect($ghost).toHaveText('element text')
192
189
 
193
190
  it 'removes <script> tags from the cloned element', ->
194
- $('<script></script>').appendTo(@$element)
195
- up.motion.prependGhost(@$element)
191
+ $element = affix('.element')
192
+ $('<script></script>').appendTo($element)
193
+ up.motion.prependGhost($element)
196
194
  $ghost = $('.up-ghost')
197
195
  expect($ghost.find('script')).not.toExist()
198
196
 
199
197
  it 'absolutely positions the ghost over the given element', ->
200
- up.motion.prependGhost(@$element)
198
+ $element = affix('.element')
199
+ up.motion.prependGhost($element)
201
200
  $ghost = $('.up-ghost')
202
- expect($ghost.offset()).toEqual(@$element.offset())
203
- expect($ghost.width()).toEqual(@$element.width())
204
- expect($ghost.height()).toEqual(@$element.height())
201
+ expect($ghost.offset()).toEqual($element.offset())
202
+ expect($ghost.width()).toEqual($element.width())
203
+ expect($ghost.height()).toEqual($element.height())
205
204
 
206
205
  it 'accurately positions the ghost over an element with margins', ->
207
- @$element.css(margin: '40px')
208
- up.motion.prependGhost(@$element)
206
+ $element = affix('.element').css(margin: '40px')
207
+ up.motion.prependGhost($element)
209
208
  $ghost = $('.up-ghost')
210
- expect($ghost.offset()).toEqual(@$element.offset())
209
+ expect($ghost.offset()).toEqual($element.offset())
211
210
 
212
211
  it "doesn't change the position of a child whose margins no longer collapse", ->
213
- $child = $('<div class="child"></div>').css(margin: '40px').appendTo(@$element)
214
- up.motion.prependGhost(@$element)
212
+ $element = affix('.element')
213
+ $child = $('<div class="child"></div>').css(margin: '40px').appendTo($element)
214
+ up.motion.prependGhost($element)
215
215
  $clonedChild = $('.up-ghost .child')
216
216
  expect($clonedChild.offset()).toEqual($child.offset())
217
+
218
+ it 'correctly positions the ghost over an element within a scrolled body', ->
219
+ $body = $('body').css(margin: 0)
220
+ $element1 = $('<div class="fixture"></div>').css(height: '75px').prependTo($body)
221
+ $element2 = $('<div class="fixture"></div>').css(height: '100px').insertAfter($element1)
222
+ $body.scrollTop(17)
223
+ { $bounds, $ghost } = up.motion.prependGhost($element2)
224
+ expect($bounds.css('position')).toBe('absolute')
225
+ expect($bounds.css('top')).toEqual('75px')
226
+ expect($ghost.css('position')).toBe('static')
227
+
228
+ it 'correctly positions the ghost over an element within a viewport with overflow-y: scroll'
@@ -70,10 +70,10 @@ describe 'up.util', ->
70
70
  tester = (element) -> element[0] == 'b'
71
71
  expect(up.util.detect(array, tester)).toEqual('bar')
72
72
 
73
- it "returns null if the given array doesn't contain a matching element", ->
73
+ it "returns undefined if the given array doesn't contain a matching element", ->
74
74
  array = ['foo', 'bar', 'baz']
75
75
  tester = (element) -> element[0] == 'z'
76
- expect(up.util.detect(array, tester)).toBeNull()
76
+ expect(up.util.detect(array, tester)).toBeUndefined()
77
77
 
78
78
  describe 'up.util.config', ->
79
79
 
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.10.2
4
+ version: 0.10.3
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-09-17 00:00:00.000000000 Z
11
+ date: 2015-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -207,6 +207,7 @@ files:
207
207
  - spec_app/spec/javascripts/helpers/mock_clock.js.coffee
208
208
  - spec_app/spec/javascripts/helpers/reset_path.js.coffee
209
209
  - spec_app/spec/javascripts/helpers/reset_up.js.coffee
210
+ - spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee
210
211
  - spec_app/spec/javascripts/helpers/set_timer.js.coffee
211
212
  - spec_app/spec/javascripts/helpers/to_be_around.js.coffee
212
213
  - spec_app/spec/javascripts/helpers/to_end_with.js.coffee