upjs-rails 0.2.2 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +44 -0
- data/dist/up.js +165 -72
- data/dist/up.min.js +1 -1
- data/lib/assets/javascripts/up/flow.js.coffee +20 -14
- data/lib/assets/javascripts/up/history.js.coffee +6 -4
- data/lib/assets/javascripts/up/magic.js.coffee +30 -18
- data/lib/assets/javascripts/up/modal.js.coffee +3 -1
- data/lib/assets/javascripts/up/motion.js.coffee +48 -22
- data/lib/assets/javascripts/up/util.js.coffee +31 -12
- data/lib/upjs/rails/version.rb +1 -1
- data/spec_app/Gemfile.lock +1 -1
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +7 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58b9bda1086a0ac50783289b009de30dd0ffa228
|
4
|
+
data.tar.gz: 83901a4346b18ede730a146b6409e0b50fc7d4d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 948fc5f12e782d99b428761a381cb8ea61ea5158d47fb1c6ac3820863bd57614a8cd6a89afe89bc408ea71307656824ac65966350247d834869adb1c74c98d99
|
7
|
+
data.tar.gz: 364e9d0048c8d594f2de7786ee7d4f559179683e71fe4de6dafe7e084cc263e814f8cadf3bcae9911e34073be32c916bebe015375390c016115729b15bf69b78
|
data/README.md
CHANGED
@@ -3,3 +3,47 @@
|
|
3
3
|
Up.js gives your traditional web application fast-responding views with minimal changes to your code and development style. If you require modern UX but don't want to pay the Javascript MVC complexity tax, Up.js can be a solution for you.
|
4
4
|
|
5
5
|
See [upjs.io](http://upjs.io) for more information and API documentation.
|
6
|
+
|
7
|
+
|
8
|
+
## Running tests
|
9
|
+
|
10
|
+
Overview:
|
11
|
+
|
12
|
+
- This currently requires Ruby
|
13
|
+
- There's a Rails app in `spec_app`
|
14
|
+
- Jasmine tests live in `spec_app/spec/javascripts`
|
15
|
+
- There are also some Cucumber integration tests left in `spec_app/features`, but this is legacy code.
|
16
|
+
Testing with Jasmine works so well that we want the entire test suite to become pure-JS Jasmine specs.
|
17
|
+
|
18
|
+
To run Jasmine tests:
|
19
|
+
|
20
|
+
- Install Ruby 2.1.2
|
21
|
+
- `cd` into `spec_app`
|
22
|
+
- Install dependencies by running `bundle install`
|
23
|
+
- Start the Rails server
|
24
|
+
- Access `http://localhost:3000/specs`
|
25
|
+
|
26
|
+
|
27
|
+
## Making a new release
|
28
|
+
|
29
|
+
We are currently feeding three release channels:
|
30
|
+
|
31
|
+
- Manual download from Github
|
32
|
+
- Bower
|
33
|
+
- Rubygems (as the `upjs-rails` gem)
|
34
|
+
|
35
|
+
To make a new Release, start with the gem:
|
36
|
+
|
37
|
+
- Edit `lib/upjs/rails/version.rb` and bump the version number. Use [semantic versioning](http://semver.org/).
|
38
|
+
- Commit and push the version bump
|
39
|
+
- From the project root, type `rake release`. This will publish a new gem version to Rubygems.org.
|
40
|
+
It will also push a tag for this version, which Bower requires for its own versioning scheme.
|
41
|
+
|
42
|
+
Now make the release for manual download and bower:
|
43
|
+
|
44
|
+
- From the project root, type `rake assets:compile`
|
45
|
+
- This will output minified JS and CSS files to the `dist` folder
|
46
|
+
- Commit and push the generated files
|
47
|
+
|
48
|
+
|
49
|
+
|
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, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, detect, each, error, escapePressed, extend, findWithSelf, get, ifGiven, isArray, isBlank, isDefined, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, last, locationFromXhr, measure, merge, nextFrame, normalizeUrl, option, options, prependGhost, presence, presentAttr, select, temporaryCss, unwrap;
|
28
|
+
var $createElementFromSelector, ajax, castsToFalse, castsToTrue, clientSize, contains, copy, copyAttributes, createElement, createElementFromHtml, createSelectorFromElement, cssAnimate, detect, each, error, escapePressed, extend, findWithSelf, forceCompositing, get, ifGiven, isArray, isBlank, isDefined, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, last, locationFromXhr, measure, merge, nextFrame, normalizeUrl, option, options, prependGhost, presence, presentAttr, select, temporaryCss, unwrap;
|
29
29
|
get = function(url, options) {
|
30
30
|
options = options || {};
|
31
31
|
options.url = url;
|
@@ -189,7 +189,7 @@ If you use them in your own code, you will get hurt.
|
|
189
189
|
return !isMissing(object);
|
190
190
|
};
|
191
191
|
isBlank = function(object) {
|
192
|
-
return isMissing(object) || (object.length === 0);
|
192
|
+
return isMissing(object) || (isObject(object) && Object.keys(object).length === 0) || (object.length === 0);
|
193
193
|
};
|
194
194
|
presence = function(object, checker) {
|
195
195
|
if (checker == null) {
|
@@ -357,6 +357,22 @@ If you use them in your own code, you will get hurt.
|
|
357
357
|
return memo;
|
358
358
|
}
|
359
359
|
};
|
360
|
+
forceCompositing = function($element) {
|
361
|
+
var memo, oldTransforms;
|
362
|
+
oldTransforms = $element.css(['transform', '-webkit-transform']);
|
363
|
+
if (isBlank(oldTransforms)) {
|
364
|
+
memo = function() {
|
365
|
+
return $element.css(oldTransforms);
|
366
|
+
};
|
367
|
+
$element.css({
|
368
|
+
'transform': 'translateZ(0)',
|
369
|
+
'-webkit-transform': 'translateZ(0)'
|
370
|
+
});
|
371
|
+
} else {
|
372
|
+
memo = function() {};
|
373
|
+
}
|
374
|
+
return memo;
|
375
|
+
};
|
360
376
|
|
361
377
|
/**
|
362
378
|
Animates the given element's CSS properties using CSS transitions.
|
@@ -378,7 +394,7 @@ If you use them in your own code, you will get hurt.
|
|
378
394
|
A promise for the animation's end.
|
379
395
|
*/
|
380
396
|
cssAnimate = function(elementOrSelector, lastFrame, opts) {
|
381
|
-
var $element, deferred, transition, withoutTransition;
|
397
|
+
var $element, deferred, transition, withoutCompositing, withoutTransition;
|
382
398
|
opts = options(opts, {
|
383
399
|
duration: 300,
|
384
400
|
delay: 0,
|
@@ -392,8 +408,10 @@ If you use them in your own code, you will get hurt.
|
|
392
408
|
'transition-delay': opts.delay + "ms",
|
393
409
|
'transition-timing-function': opts.easing
|
394
410
|
};
|
411
|
+
withoutCompositing = forceCompositing($element);
|
395
412
|
withoutTransition = temporaryCss($element, transition);
|
396
413
|
$element.css(lastFrame);
|
414
|
+
deferred.then(withoutCompositing);
|
397
415
|
deferred.then(withoutTransition);
|
398
416
|
setTimeout((function() {
|
399
417
|
return deferred.resolve();
|
@@ -405,10 +423,15 @@ If you use them in your own code, you will get hurt.
|
|
405
423
|
coordinates = (options != null ? options.relative : void 0) ? $element.position() : $element.offset();
|
406
424
|
box = {
|
407
425
|
left: coordinates.left,
|
408
|
-
top: coordinates.top
|
409
|
-
width: $element.outerWidth(),
|
410
|
-
height: $element.outerHeight()
|
426
|
+
top: coordinates.top
|
411
427
|
};
|
428
|
+
if (options != null ? options.inner : void 0) {
|
429
|
+
box.width = $element.width();
|
430
|
+
box.height = $element.height();
|
431
|
+
} else {
|
432
|
+
box.width = $element.outerWidth();
|
433
|
+
box.height = $element.outerHeight();
|
434
|
+
}
|
412
435
|
if (options != null ? options.full : void 0) {
|
413
436
|
viewport = clientSize();
|
414
437
|
box.right = viewport.width - (box.left + box.width);
|
@@ -432,18 +455,20 @@ If you use them in your own code, you will get hurt.
|
|
432
455
|
};
|
433
456
|
prependGhost = function($element) {
|
434
457
|
var $ghost, dimensions;
|
435
|
-
dimensions = measure($element
|
458
|
+
dimensions = measure($element, {
|
459
|
+
relative: true,
|
460
|
+
inner: true
|
461
|
+
});
|
436
462
|
$ghost = $element.clone();
|
437
463
|
$ghost.find('script').remove();
|
438
464
|
$ghost.css({
|
439
465
|
right: '',
|
440
466
|
bottom: '',
|
441
|
-
margin: 0,
|
442
467
|
position: 'absolute'
|
443
468
|
});
|
444
469
|
$ghost.css(dimensions);
|
445
470
|
$ghost.addClass('up-ghost');
|
446
|
-
return $ghost.
|
471
|
+
return $ghost.insertBefore($element);
|
447
472
|
};
|
448
473
|
findWithSelf = function($element, selector) {
|
449
474
|
return $element.find(selector).addBack(selector);
|
@@ -502,6 +527,7 @@ If you use them in your own code, you will get hurt.
|
|
502
527
|
measure: measure,
|
503
528
|
temporaryCss: temporaryCss,
|
504
529
|
cssAnimate: cssAnimate,
|
530
|
+
forceCompositing: forceCompositing,
|
505
531
|
prependGhost: prependGhost,
|
506
532
|
escapePressed: escapePressed,
|
507
533
|
copyAttributes: copyAttributes,
|
@@ -510,7 +536,8 @@ If you use them in your own code, you will get hurt.
|
|
510
536
|
isArray: isArray,
|
511
537
|
castsToTrue: castsToTrue,
|
512
538
|
castsToFalse: castsToFalse,
|
513
|
-
locationFromXhr: locationFromXhr
|
539
|
+
locationFromXhr: locationFromXhr,
|
540
|
+
clientSize: clientSize
|
514
541
|
};
|
515
542
|
})();
|
516
543
|
|
@@ -741,6 +768,10 @@ We need to work on this page:
|
|
741
768
|
options = u.options(options, {
|
742
769
|
historyMethod: 'push'
|
743
770
|
});
|
771
|
+
if (options.history === 'false') {
|
772
|
+
options.history = null;
|
773
|
+
}
|
774
|
+
options.source = u.option(options.source, options.history);
|
744
775
|
htmlElement = u.createElementFromHtml(html);
|
745
776
|
options.title || (options.title = (_ref = htmlElement.querySelector("title")) != null ? _ref.textContent : void 0);
|
746
777
|
_ref1 = implantSteps(selector, options);
|
@@ -758,22 +789,18 @@ We need to work on this page:
|
|
758
789
|
return _results;
|
759
790
|
};
|
760
791
|
elementsInserted = function($new, options) {
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
if (options.history) {
|
768
|
-
if (options.title) {
|
769
|
-
document.title = options.title;
|
770
|
-
}
|
771
|
-
up.history[options.historyMethod](options.history);
|
792
|
+
if (typeof options.insert === "function") {
|
793
|
+
options.insert($new);
|
794
|
+
}
|
795
|
+
if (options.history) {
|
796
|
+
if (options.title) {
|
797
|
+
document.title = options.title;
|
772
798
|
}
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
799
|
+
up.history[options.historyMethod](options.history);
|
800
|
+
}
|
801
|
+
setSource($new, options.source);
|
802
|
+
autofocus($new);
|
803
|
+
return up.ready($new);
|
777
804
|
};
|
778
805
|
swapElements = function($old, $new, pseudoClass, transition, options) {
|
779
806
|
var $addedChildren, insertionMethod;
|
@@ -929,9 +956,11 @@ We need to work on this page:
|
|
929
956
|
*/
|
930
957
|
|
931
958
|
(function() {
|
959
|
+
var __slice = [].slice;
|
960
|
+
|
932
961
|
up.magic = (function() {
|
933
|
-
var DESTROYABLE_CLASS, DESTROYER_KEY, awaken, awakeners, compile, defaultAwakeners, defaultLiveDescriptions, destroy, live, liveDescriptions, onEscape, ready, reset, snapshot,
|
934
|
-
|
962
|
+
var DESTROYABLE_CLASS, DESTROYER_KEY, applyAwakener, awaken, awakeners, compile, defaultAwakeners, defaultLiveDescriptions, destroy, live, liveDescriptions, onEscape, ready, reset, snapshot, u;
|
963
|
+
u = up.util;
|
935
964
|
DESTROYABLE_CLASS = 'up-destroyable';
|
936
965
|
DESTROYER_KEY = 'up-destroyer';
|
937
966
|
|
@@ -968,6 +997,10 @@ We need to work on this page:
|
|
968
997
|
@method up.awaken
|
969
998
|
@param {String} selector
|
970
999
|
The selector to match.
|
1000
|
+
@param {Boolean} [options.batch=false]
|
1001
|
+
If set to `true` and a fragment insertion contains multiple
|
1002
|
+
elements matching the selector, `awakener` is only called once
|
1003
|
+
with a jQuery collection containing all matching elements.
|
971
1004
|
@param {Function($element)} awakener
|
972
1005
|
The function to call when a matching element is inserted.
|
973
1006
|
The function takes the new element as the first argument (as a jQuery object).
|
@@ -978,31 +1011,50 @@ We need to work on this page:
|
|
978
1011
|
*/
|
979
1012
|
awakeners = [];
|
980
1013
|
defaultAwakeners = null;
|
981
|
-
awaken = function(
|
1014
|
+
awaken = function() {
|
1015
|
+
var args, awakener, options, selector;
|
1016
|
+
selector = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
1017
|
+
awakener = args.pop();
|
1018
|
+
options = u.options(args[0], {
|
1019
|
+
batch: false
|
1020
|
+
});
|
982
1021
|
return awakeners.push({
|
983
1022
|
selector: selector,
|
984
|
-
callback: awakener
|
1023
|
+
callback: awakener,
|
1024
|
+
batch: options.batch
|
985
1025
|
});
|
986
1026
|
};
|
1027
|
+
applyAwakener = function(awakener, $jqueryElement, nativeElement) {
|
1028
|
+
var destroyer;
|
1029
|
+
destroyer = awakener.callback.apply(nativeElement, [$jqueryElement]);
|
1030
|
+
if (u.isFunction(destroyer)) {
|
1031
|
+
$jqueryElement.addClass(DESTROYABLE_CLASS);
|
1032
|
+
return $jqueryElement.data(DESTROYER_KEY, destroyer);
|
1033
|
+
}
|
1034
|
+
};
|
987
1035
|
compile = function($fragment) {
|
988
|
-
var awakener, _i, _len, _results;
|
1036
|
+
var $matches, awakener, _i, _len, _results;
|
1037
|
+
console.log("Compiling fragment", $fragment);
|
989
1038
|
_results = [];
|
990
1039
|
for (_i = 0, _len = awakeners.length; _i < _len; _i++) {
|
991
1040
|
awakener = awakeners[_i];
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
997
|
-
$
|
998
|
-
|
1041
|
+
$matches = u.findWithSelf($fragment, awakener.selector);
|
1042
|
+
if ($matches.length) {
|
1043
|
+
if (awakener.batch) {
|
1044
|
+
_results.push(applyAwakener(awakener, $matches, $matches.get()));
|
1045
|
+
} else {
|
1046
|
+
_results.push($matches.each(function() {
|
1047
|
+
return applyAwakener(awakener, $(this), this);
|
1048
|
+
}));
|
999
1049
|
}
|
1000
|
-
}
|
1050
|
+
} else {
|
1051
|
+
_results.push(void 0);
|
1052
|
+
}
|
1001
1053
|
}
|
1002
1054
|
return _results;
|
1003
1055
|
};
|
1004
1056
|
destroy = function($fragment) {
|
1005
|
-
return
|
1057
|
+
return u.findWithSelf($fragment, "." + DESTROYABLE_CLASS).each(function() {
|
1006
1058
|
var $element, destroyer;
|
1007
1059
|
$element = $(this);
|
1008
1060
|
destroyer = $element.data(DESTROYER_KEY);
|
@@ -1018,8 +1070,8 @@ We need to work on this page:
|
|
1018
1070
|
@method up.magic.snapshot
|
1019
1071
|
*/
|
1020
1072
|
snapshot = function() {
|
1021
|
-
defaultLiveDescriptions =
|
1022
|
-
return defaultAwakeners =
|
1073
|
+
defaultLiveDescriptions = u.copy(liveDescriptions);
|
1074
|
+
return defaultAwakeners = u.copy(awakeners);
|
1023
1075
|
};
|
1024
1076
|
|
1025
1077
|
/**
|
@@ -1033,12 +1085,12 @@ We need to work on this page:
|
|
1033
1085
|
var description, _i, _len, _ref;
|
1034
1086
|
for (_i = 0, _len = liveDescriptions.length; _i < _len; _i++) {
|
1035
1087
|
description = liveDescriptions[_i];
|
1036
|
-
if (!
|
1088
|
+
if (!u.contains(defaultLiveDescriptions, description)) {
|
1037
1089
|
(_ref = $(document)).off.apply(_ref, description);
|
1038
1090
|
}
|
1039
1091
|
}
|
1040
|
-
liveDescriptions =
|
1041
|
-
return awakeners =
|
1092
|
+
liveDescriptions = u.copy(defaultLiveDescriptions);
|
1093
|
+
return awakeners = u.copy(defaultAwakeners);
|
1042
1094
|
};
|
1043
1095
|
|
1044
1096
|
/**
|
@@ -1061,7 +1113,7 @@ We need to work on this page:
|
|
1061
1113
|
};
|
1062
1114
|
onEscape = function(handler) {
|
1063
1115
|
return live('keydown', 'body', function(event) {
|
1064
|
-
if (
|
1116
|
+
if (u.escapePressed(event)) {
|
1065
1117
|
return handler(event);
|
1066
1118
|
}
|
1067
1119
|
});
|
@@ -1122,8 +1174,11 @@ We need to work on this page:
|
|
1122
1174
|
@param {String} url
|
1123
1175
|
@protected
|
1124
1176
|
*/
|
1125
|
-
replace = function(url) {
|
1126
|
-
|
1177
|
+
replace = function(url, options) {
|
1178
|
+
options = u.options(options, {
|
1179
|
+
force: false
|
1180
|
+
});
|
1181
|
+
if (options.force || !isCurrentUrl(url)) {
|
1127
1182
|
return manipulate("replace", url);
|
1128
1183
|
}
|
1129
1184
|
};
|
@@ -1154,12 +1209,14 @@ We need to work on this page:
|
|
1154
1209
|
historyMethod: 'replace'
|
1155
1210
|
});
|
1156
1211
|
} else {
|
1157
|
-
return console.log("
|
1212
|
+
return console.log("strange state", state);
|
1158
1213
|
}
|
1159
1214
|
};
|
1160
1215
|
setTimeout((function() {
|
1161
1216
|
$(window).on("popstate", pop);
|
1162
|
-
return replace(up.browser.url()
|
1217
|
+
return replace(up.browser.url(), {
|
1218
|
+
force: true
|
1219
|
+
});
|
1163
1220
|
}), 200);
|
1164
1221
|
return {
|
1165
1222
|
push: push,
|
@@ -1193,9 +1250,9 @@ We need to work on this page:
|
|
1193
1250
|
|
1194
1251
|
(function() {
|
1195
1252
|
up.motion = (function() {
|
1196
|
-
var animate, animation, animations, assertIsPromise,
|
1253
|
+
var animate, animation, animations, assertIsPromise, config, defaultAnimations, defaultTransitions, defaults, findAnimation, morph, none, reset, snapshot, transition, transitions, u, withGhosts;
|
1197
1254
|
u = up.util;
|
1198
|
-
|
1255
|
+
config = {
|
1199
1256
|
duration: 300,
|
1200
1257
|
delay: 0,
|
1201
1258
|
easing: 'ease'
|
@@ -1205,6 +1262,16 @@ We need to work on this page:
|
|
1205
1262
|
transitions = {};
|
1206
1263
|
defaultTransitions = {};
|
1207
1264
|
|
1265
|
+
/**
|
1266
|
+
@method up.modal.defaults
|
1267
|
+
@param {Number} options.duration
|
1268
|
+
@param {Number} options.delay
|
1269
|
+
@param {String} options.easing
|
1270
|
+
*/
|
1271
|
+
defaults = function(options) {
|
1272
|
+
return u.extend(config, options);
|
1273
|
+
};
|
1274
|
+
|
1208
1275
|
/**
|
1209
1276
|
Animates an element.
|
1210
1277
|
|
@@ -1234,7 +1301,7 @@ We need to work on this page:
|
|
1234
1301
|
animate = function(elementOrSelector, animation, options) {
|
1235
1302
|
var $element;
|
1236
1303
|
$element = $(elementOrSelector);
|
1237
|
-
options = u.options(options,
|
1304
|
+
options = u.options(options, config);
|
1238
1305
|
if (u.isFunction(animation)) {
|
1239
1306
|
return assertIsPromise(animation($element, options), ["Animation did not return a Promise", animation]);
|
1240
1307
|
} else if (u.isString(animation)) {
|
@@ -1289,8 +1356,8 @@ We need to work on this page:
|
|
1289
1356
|
The following transitions are pre-registered:
|
1290
1357
|
|
1291
1358
|
- `cross-fade`
|
1292
|
-
- `move-
|
1293
|
-
- `move-
|
1359
|
+
- `move-up`
|
1360
|
+
- `move-down`
|
1294
1361
|
- `move-left`
|
1295
1362
|
- `move-right`
|
1296
1363
|
- `none`
|
@@ -1313,7 +1380,7 @@ We need to work on this page:
|
|
1313
1380
|
*/
|
1314
1381
|
morph = function(source, target, transitionOrName, options) {
|
1315
1382
|
var $new, $old, animation, parts, transition;
|
1316
|
-
options = u.options(
|
1383
|
+
options = u.options(config);
|
1317
1384
|
$old = $(source);
|
1318
1385
|
$new = $(target);
|
1319
1386
|
transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName];
|
@@ -1397,67 +1464,91 @@ We need to work on this page:
|
|
1397
1464
|
}, options);
|
1398
1465
|
});
|
1399
1466
|
animation('move-to-top', function($ghost, options) {
|
1467
|
+
var box, travelDistance;
|
1468
|
+
box = u.measure($ghost);
|
1469
|
+
travelDistance = box.top + box.height;
|
1400
1470
|
$ghost.css({
|
1401
|
-
'margin-top': '
|
1471
|
+
'margin-top': '0px'
|
1402
1472
|
});
|
1403
1473
|
return animate($ghost, {
|
1404
|
-
'margin-top':
|
1474
|
+
'margin-top': "-" + travelDistance + "px"
|
1405
1475
|
}, options);
|
1406
1476
|
});
|
1407
1477
|
animation('move-from-top', function($ghost, options) {
|
1478
|
+
var box, travelDistance;
|
1479
|
+
box = u.measure($ghost);
|
1480
|
+
travelDistance = box.top + box.height;
|
1408
1481
|
$ghost.css({
|
1409
|
-
'margin-top':
|
1482
|
+
'margin-top': "-" + travelDistance + "px"
|
1410
1483
|
});
|
1411
1484
|
return animate($ghost, {
|
1412
|
-
'margin-top': '
|
1485
|
+
'margin-top': '0px'
|
1413
1486
|
}, options);
|
1414
1487
|
});
|
1415
1488
|
animation('move-to-bottom', function($ghost, options) {
|
1489
|
+
var box, travelDistance;
|
1490
|
+
box = u.measure($ghost);
|
1491
|
+
travelDistance = u.clientSize().height - box.top;
|
1416
1492
|
$ghost.css({
|
1417
|
-
'margin-top': '
|
1493
|
+
'margin-top': '0px'
|
1418
1494
|
});
|
1419
1495
|
return animate($ghost, {
|
1420
|
-
'margin-top':
|
1496
|
+
'margin-top': travelDistance + "px"
|
1421
1497
|
}, options);
|
1422
1498
|
});
|
1423
1499
|
animation('move-from-bottom', function($ghost, options) {
|
1500
|
+
var box, travelDistance;
|
1501
|
+
box = u.measure($ghost);
|
1502
|
+
travelDistance = u.clientSize().height - box.top;
|
1424
1503
|
$ghost.css({
|
1425
|
-
'margin-top':
|
1504
|
+
'margin-top': travelDistance + "px"
|
1426
1505
|
});
|
1427
1506
|
return animate($ghost, {
|
1428
|
-
'margin-top': '
|
1507
|
+
'margin-top': '0px'
|
1429
1508
|
}, options);
|
1430
1509
|
});
|
1431
1510
|
animation('move-to-left', function($ghost, options) {
|
1511
|
+
var box, travelDistance;
|
1512
|
+
box = u.measure($ghost);
|
1513
|
+
travelDistance = box.left + box.width;
|
1432
1514
|
$ghost.css({
|
1433
|
-
'margin-left': '
|
1515
|
+
'margin-left': '0px'
|
1434
1516
|
});
|
1435
1517
|
return animate($ghost, {
|
1436
|
-
'margin-left':
|
1518
|
+
'margin-left': "-" + travelDistance + "px"
|
1437
1519
|
}, options);
|
1438
1520
|
});
|
1439
1521
|
animation('move-from-left', function($ghost, options) {
|
1522
|
+
var box, travelDistance;
|
1523
|
+
box = u.measure($ghost);
|
1524
|
+
travelDistance = box.left + box.width;
|
1440
1525
|
$ghost.css({
|
1441
|
-
'margin-left':
|
1526
|
+
'margin-left': "-" + travelDistance + "px"
|
1442
1527
|
});
|
1443
1528
|
return animate($ghost, {
|
1444
|
-
'margin-left': '
|
1529
|
+
'margin-left': '0px'
|
1445
1530
|
}, options);
|
1446
1531
|
});
|
1447
1532
|
animation('move-to-right', function($ghost, options) {
|
1533
|
+
var box, travelDistance;
|
1534
|
+
box = u.measure($ghost);
|
1535
|
+
travelDistance = u.clientSize().width - box.left;
|
1448
1536
|
$ghost.css({
|
1449
|
-
'margin-left': '
|
1537
|
+
'margin-left': '0px'
|
1450
1538
|
});
|
1451
1539
|
return animate($ghost, {
|
1452
|
-
'margin-left':
|
1540
|
+
'margin-left': travelDistance + "px"
|
1453
1541
|
}, options);
|
1454
1542
|
});
|
1455
1543
|
animation('move-from-right', function($ghost, options) {
|
1544
|
+
var box, travelDistance;
|
1545
|
+
box = u.measure($ghost);
|
1546
|
+
travelDistance = u.clientSize().width - box.left;
|
1456
1547
|
$ghost.css({
|
1457
|
-
'margin-left':
|
1548
|
+
'margin-left': travelDistance + "px"
|
1458
1549
|
});
|
1459
1550
|
return animate($ghost, {
|
1460
|
-
'margin-left': '
|
1551
|
+
'margin-left': '0px'
|
1461
1552
|
}, options);
|
1462
1553
|
});
|
1463
1554
|
animation('roll-down', function($ghost, options) {
|
@@ -1494,6 +1585,7 @@ We need to work on this page:
|
|
1494
1585
|
animate: animate,
|
1495
1586
|
transition: transition,
|
1496
1587
|
animation: animation,
|
1588
|
+
defaults: defaults,
|
1497
1589
|
none: none
|
1498
1590
|
};
|
1499
1591
|
})();
|
@@ -2391,12 +2483,13 @@ We need to work on this page:
|
|
2391
2483
|
up.on('click', 'body', function(event, $body) {
|
2392
2484
|
var $target;
|
2393
2485
|
$target = $(event.target);
|
2394
|
-
if (!($target.closest('.up-dialog').length || $target.closest('[up-modal]').length)) {
|
2486
|
+
if (!($target.closest('.up-modal-dialog').length || $target.closest('[up-modal]').length)) {
|
2395
2487
|
return close();
|
2396
2488
|
}
|
2397
2489
|
});
|
2398
2490
|
up.bus.on('fragment:ready', function($fragment) {
|
2399
2491
|
if (!$fragment.closest('.up-modal').length) {
|
2492
|
+
console.log('fragment inserted', $fragment, $fragment.closest('.up-modal'));
|
2400
2493
|
return autoclose();
|
2401
2494
|
}
|
2402
2495
|
});
|
data/dist/up.min.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
(function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,r,e,o,u,i,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,T,S,C,E,A,F,U,x,P,j,O,D,H,z,M,W,G,I,X,L,N,V,q,B,J,Q,_,R;return b=function(t,n){return n=n||{},n.url=t,r(n)},r=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},D=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},L=function(t,n){var r,e,o;return r=H(t)?$("<a>").attr({href:t}).get(0):R(t),e=r.protocol+"//"+r.hostname,D(r.protocol,r.port)||(e+=":"+r.port),o=r.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),e+=o,(null!=n?n.hash:void 0)===!0&&(e+=r.hash),(null!=n?n.search:void 0)!==!1&&(e+=r.search),e},n=function(t){var n,r,e,o,u,i,a,s,c,p,l,f,m,d,h,v;for(l=t.split(/[ >]/),e=null,p=m=0,h=l.length;h>m;p=++m){for(i=l[p],u=i.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=u.length;v>d;d++)switch(a=u[d],a[0]){case".":o.push(a.substr(1));break;case"#":c=a.substr(1);break;default:f=a}s="<"+f,o.length&&(s+=' class="'+o.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=$(s),r&&n.appendTo(r),0===p&&(e=n),r=n}return e},c=function(t,n){var r;return r=document.createElement(t),r.innerHTML=n,r},h=function(){var n,r;throw n=1<=arguments.length?t.call(arguments,0):[],r=1===n.length&&up.util.isString(n[0])?n[0]:JSON.stringify(n),console.log.apply(console,["[UP] Error: "+r].concat(t.call(n))),alert(r),r},l=function(t){var n,r,e,o,u,i,a;for(console.log("Creating selector from element",t),r=(n=t.attr("class"))?n.split(" "):[],e=t.attr("id"),u=t.prop("tagName").toLowerCase(),e&&(u+="#"+e),i=0,a=r.length;a>i;i++)o=r[i],u+="."+o;return u},p=function(t){var n,r,e;return n=/<html>((?:.|\n)*)<\/html>/i,r=void 0,r=(e=t.match(n))?e[1]:"<html><body>"+t+"</body></html>",c("html",r)},g=$.extend,d=function(t,n){var r,e,o,u,i;for(i=[],r=o=0,u=t.length;u>o;r=++o)e=t[r],i.push(n(e,r));return i},x=function(t){return null===t},z=function(t){return void 0===t},S=function(t){return!z(t)},U=function(t){return z(t)||x(t)},E=function(t){return!U(t)},T=function(t){return U(t)||0===t.length},B=function(t,n){return null==n&&(n=j),n(t)?t:null},j=function(t){return!T(t)},C=function(t){return"function"==typeof t},H=function(t){return"string"==typeof t},A=function(t){return"object"==typeof t&&!!t},P=function(t){return A(t)||"function"==typeof t},F=function(t){return t instanceof jQuery},O=function(t){return C(t.then)},w=function(t){return E(t)?t:void 0},k=Array.isArray,a=function(t){return k(t)?t.slice():g({},t)},R=function(t){return F(t)?t.get(0):t},I=function(t,n){return g(a(t),n)},V=function(t,n){var r,e,o,u;if(o=t?a(t):{},n)for(e in n)r=n[e],u=o[e],E(u)?P(r)&&P(u)&&(o[e]=V(u,r)):o[e]=r;return o},N=function(){var n,r;return n=1<=arguments.length?t.call(arguments,0):[],r=null,n.every(function(t){var n;return n=t,C(n)&&(n=n()),j(n)?(r=n,!1):!0}),r},m=function(t,n){var r;return r=null,t.every(function(t){return n(t)?(r=t,!1):!0}),r},Q=function(t,n){var r;return r=[],d(t,function(t){return n(t)?r.push(t):void 0}),r},J=function(){var n,r,e,o;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,u;for(u=[],t=0,o=e.length;o>t;t++)r=e[t],u.push(n.attr(r));return u}(),m(o,j)},X=function(t){return setTimeout(t,0)},M=function(t){return t[t.length-1]},u=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},_=function(t,n,r){var e,o;return o=t.css(Object.keys(n)),t.css(n),e=function(){return t.css(o)},r?(r(),e()):e},f=function(t,n,r){var e,o,u,i;return r=V(r,{duration:300,delay:0,easing:"ease"}),e=$(t),o=$.Deferred(),u={"transition-property":Object.keys(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},i=_(e,u),e.css(n),o.then(i),setTimeout(function(){return o.resolve()},r.duration+r.delay),o.promise()},G=function(t,n){var r,e,o;return e=(null!=n?n.relative:void 0)?t.position():t.offset(),r={left:e.left,top:e.top,width:t.outerWidth(),height:t.outerHeight()},(null!=n?n.full:void 0)&&(o=u(),r.right=o.width-(r.left+r.width),r.bottom=o.height-(r.top+r.height)),r},s=function(t,n){var r,e,o,u,i;for(u=t.get(0).attributes,i=[],e=0,o=u.length;o>e;e++)r=u[e],i.push(r.specified?n.attr(r.name,r.value):void 0);return i},q=function(t){var n,r;return r=G(t),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",margin:0,position:"absolute"}),n.css(r),n.addClass("up-ghost"),n.prependTo(document.body)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},i=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},e=function(t){return"false"===String(t)},W=function(t){return t.getResponseHeader("X-Up-Current-Location")},{presentAttr:J,createElement:c,normalizeUrl:L,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:b,ajax:r,extend:g,copy:a,merge:I,options:V,option:N,error:h,each:d,detect:m,select:Q,last:M,isNull:x,isDefined:S,isUndefined:z,isGiven:E,isMissing:U,isPresent:j,isBlank:T,presence:B,isObject:P,isFunction:C,isString:H,isJQuery:F,isPromise:O,isHash:A,ifGiven:w,unwrap:R,nextFrame:X,measure:G,temporaryCss:_,cssAnimate:f,prependGhost:q,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:i,isArray:k,castsToTrue:o,castsToFalse:e,locationFromXhr:W}}()}.call(this),function(){up.browser=function(){var t;return t=function(){return location.href},{url:t}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,r,e,o,u,i,a;return n={},e={},r=function(t){return n[t]||(n[t]=[])},a=function(){var t,r,o;e={},o=[];for(r in n)t=n[r],o.push(e[r]=up.util.copy(t));return o},i=function(){return n=up.util.copy(e)},u=function(t,n){return r(t).push(n)},o=function(){var n,e,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],console.log("bus emitting",o,n),e=r(o),up.util.each(e,function(t){return t.apply(null,n)})},u("framework:ready",a),u("framework:reset",i),{on:u,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,r,e,o,u,i,a,s,c,p,l;return l=up.util,s=function(t,n){var r;return r=$(t),l.isPresent(n)&&(n=l.normalizeUrl(n)),r.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),l.presence(n.attr("up-source"))||up.browser.url()},i=function(t,n,r){var o;return r=l.options(r),o=l.presence(t)?t:l.createSelectorFromElement($(t)),l.ajax({url:n,selector:o}).done(function(t,u,i){var a;return(a=l.locationFromXhr(i))&&(n=a),(l.isMissing(r.history)||l.castsToTrue(r.history))&&(r.history=n),(l.isMissing(r.source)||l.castsToTrue(r.source))&&(r.source=n),e(o,t,r)}).fail(l.error)},e=function(t,n,r){var e,u,i,a,s,c,f,m,d,h;for(r=l.options(r,{historyMethod:"push"}),a=l.createElementFromHtml(n),r.title||(r.title=null!=(m=a.querySelector("title"))?m.textContent:void 0),d=o(t,r),h=[],c=0,f=d.length;f>c;c++)s=d[c],u=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector)),(i=a.querySelector(s.selector))?(e=$(i),h.push(p(u,e,s.pseudoClass,s.transition,r))):h.push(l.error("Could not find selector ("+s.selector+") in response ("+n+")"));return h},r=function(n,r){return n.each(function(){var n;return n=$(this),"function"==typeof r.insert&&r.insert(n),r.history&&(r.title&&(document.title=r.title),up.history[r.historyMethod](r.history)),s(n,l.presence(r.source)||r.history),t(n),up.ready(n)})},p=function(t,e,o,u,i){var a,s;return u||(u="none"),o?(s="before"===o?"prepend":"append",a=e.children(),t[s](e.contents()),l.copyAttributes(e,t),r(a,i),up.animate(e,u)):n(t,{animation:function(){return e.insertAfter(t),r(e,i),t.is("body")&&"none"!==u&&l.error("Cannot apply transitions to body-elements",u),up.morph(t,e,u)}})},o=function(t,n){var r,e,o,u,i,a,s,c,p,f,m;for(s=n.transition||n.animation||"none",r=/\ *,\ */,e=t.split(r),l.isPresent(s)&&(c=s.split(r)),m=[],o=p=0,f=e.length;f>p;o=++p)u=e[o],i=u.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:i[1],pseudoClass:i[2],transition:a});return m},t=function(t){var n,r;return r="[autofocus]:last",n=l.findWithSelf(t,r),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var r,e;return r=$(t),n=l.options(n,{animation:"none"}),r.addClass("up-destroying"),l.isPresent(n.url)&&up.history.push(n.url),l.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",r),e=l.presence(n.animation,l.isPromise)||up.motion.animate(r,n.animation),e.then(function(){return r.remove()})},u=function(t){var n;return n=c(t),i(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:i,reload:u,destroy:n,implant:e,reset:a}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){up.magic=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d;return d=up.util,t="up-destroyable",n="up-destroyer",c=[],i=null,s=function(t,n,r){var e,o;return e=[t,n,function(t){return r.apply(this,[t,$(this)])}],c.push(e),(o=$(document)).on.apply(o,e)},e=[],u=null,r=function(t,n){return e.push({selector:t,callback:n})},o=function(r){var o,u,i,a;for(a=[],u=0,i=e.length;i>u;u++)o=e[u],a.push(d.findWithSelf(r,o.selector).each(function(){var r,e;return r=$(this),e=o.callback.apply(this,[r]),d.isFunction(e)?(r.addClass(t),r.data(n,e)):void 0}));return a},a=function(r){return d.findWithSelf(r,"."+t).each(function(){var t,r;return t=$(this),(r=t.data(n))()})},m=function(){return i=d.copy(c),u=d.copy(e)},f=function(){var t,n,r,o;for(n=0,r=c.length;r>n;n++)t=c[n],d.contains(i,t)||(o=$(document)).off.apply(o,t);return c=d.copy(i),e=d.copy(u)},l=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},p=function(t){return s("keydown","body",function(n){return d.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return l(document.body)}),up.bus.on("fragment:ready",o),up.bus.on("fragment:destroy",a),up.bus.on("framework:ready",m),up.bus.on("framework:reset",f),{awaken:r,on:s,ready:l,onEscape:p}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,r,e,o,u;return u=up.util,t=function(t){return u.normalizeUrl(t,{hash:!0})===u.normalizeUrl(up.browser.url(),{hash:!0})},o=function(r){return t(r)?void 0:n("replace",r)},e=function(r){return t(r)?void 0:n("push",r)},n=function(t,n){return t+="State",window.history[t]({fromUp:!0},"",n)},r=function(t){var n;return n=t.originalEvent.state,console.log("popping state",n),console.log("current href",up.browser.url()),(null!=n?n.fromUp:void 0)?up.visit(up.browser.url(),{historyMethod:"replace"}):console.log("null state")},setTimeout(function(){return $(window).on("popstate",r),o(up.browser.url())},200),{push:e,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,r,e,o,u,i,a,s,c,p,l,f,m,d,h;return d=up.util,u={duration:300,delay:0,easing:"ease"},r={},o={},m={},i={},t=function(n,r,o){var i;return i=$(n),o=d.options(o,u),d.isFunction(r)?e(r(i,o),["Animation did not return a Promise",r]):d.isString(r)?t(i,a(r),o):d.isHash(r)?d.cssAnimate(i,r,o):d.error("Unknown animation type",r)},a=function(t){return r[t]||d.error("Unknown animation",n)},h=function(t,n,r){var e,o,u,i;return o=null,e=null,d.temporaryCss(n,{display:"none"},function(){return o=d.prependGhost(t).addClass("up-destroying")}),d.temporaryCss(t,{display:"none"},function(){return e=d.prependGhost(n)}),t.css({visibility:"hidden"}),u=d.temporaryCss(n,{display:"none"}),i=r(o,e),i.then(function(){return o.remove(),e.remove(),t.css({display:"none"}),u()})},e=function(t,n){return d.isPromise(t)||d.error.apply(d,n),t},s=function(n,o,i,a){var c,p,l,f,v;return a=d.options(u),p=$(n),c=$(o),v=d.presence(i,d.isFunction)||m[i],v?h(p,c,function(t,n){return e(v(t,n,a),["Transition did not return a promise",i])}):(l=r[i])?(p.hide(),t(c,l,a)):d.isString(i)&&i.indexOf("/")>=0?(f=i.split("/"),v=function(n,r,e){return $.when(t(n,f[0],e),t(r,f[1],e))},s(p,c,v,a)):d.error("Unknown transition: "+i)},f=function(t,n){return m[t]=n},n=function(t,n){return r[t]=n},l=function(){return o=d.copy(r),i=d.copy(m)},p=function(){return r=d.copy(o),m=d.copy(i)},c=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},n("none",c),n("fade-in",function(n,r){return n.css({opacity:0}),t(n,{opacity:1},r)}),n("fade-out",function(n,r){return n.css({opacity:1}),t(n,{opacity:0},r)}),n("move-to-top",function(n,r){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"-100%"},r)}),n("move-from-top",function(n,r){return n.css({"margin-top":"-100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-bottom",function(n,r){return n.css({"margin-top":"0%"}),t(n,{"margin-top":"100%"},r)}),n("move-from-bottom",function(n,r){return n.css({"margin-top":"100%"}),t(n,{"margin-top":"0%"},r)}),n("move-to-left",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"-100%"},r)}),n("move-from-left",function(n,r){return n.css({"margin-left":"-100%"}),t(n,{"margin-left":"0%"},r)}),n("move-to-right",function(n,r){return n.css({"margin-left":"0%"}),t(n,{"margin-left":"100%"},r)}),n("move-from-right",function(n,r){return n.css({"margin-left":"100%"}),t(n,{"margin-left":"0%"},r)}),n("roll-down",function(n,r){var e,o;return e=n.height(),o=d.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:e+"px"},r).then(o)}),f("none",c),f("move-left",function(n,r,e){return $.when(t(n,"move-to-left",e),t(r,"move-from-right",e))}),f("move-right",function(n,r,e){return $.when(t(n,"move-to-right",e),t(r,"move-from-left",e))}),f("move-up",function(n,r,e){return $.when(t(n,"move-to-top",e),t(r,"move-from-bottom",e))}),f("move-down",function(n,r,e){return $.when(t(n,"move-to-bottom",e),t(r,"move-from-top",e))}),f("cross-fade",function(n,r,e){return $.when(t(n,"fade-out",e),t(r,"fade-in",e))}),up.bus.on("framework:ready",l),up.bus.on("framework:reset",p),{morph:s,animate:t,transition:f,animation:n,none:c}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.link=function(){var t,n,r,e,o;return e=up.util,o=function(t,n){return console.log("up.visit",t),up.replace("body",t,n)},t=function(t,n){var r,o,u;return r=$(t),n=e.options(n),u=e.option(r.attr("href"),r.attr("up-follow")),o=e.option(n.target,r.attr("up-target"),"body"),n.transition=e.option(n.transition,r.attr("up-transition"),r.attr("up-animation")),n.history=e.option(n.history,r.attr("up-history")),up.replace(o,u,n)},n=function(t){var n;return n=$(t),n.is("a")||e.presentAttr(n,"up-follow")?n:n.find("a:first")},r=function(t){var r;return(r=n(t))?e.option(r.attr("href"),r.attr("up-follow")):void 0},up.on("click","a[up-target]",function(n,r){return n.preventDefault(),t(r)}),up.on("click","[up-follow]",function(r,e){var o;return o=function(){var t,n;return t=$(r.target),n=t.closest("a, [up-follow]"),n.length&&e.find(n).length},o()?void 0:(r.preventDefault(),t(n(e)))}),{visit:o,follow:t,resolve:n,resolveUrl:r}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var r,e,o,i,a,s,c,p,l,f;return r=$(t).closest("form"),n=u.options(n),c=u.option(n.target,r.attr("up-target"),"body"),e=u.option(n.failTarget,r.attr("up-fail-target"),function(){return u.createSelectorFromElement(r)}),i=u.option(n.history,r.attr("up-history"),!0),p=u.option(n.transition,r.attr("up-transition")),o=u.option(n.failTransition,r.attr("up-fail-transition")),a=u.option(n.method,r.attr("up-method"),r.attr("data-method"),r.attr("method"),"post").toUpperCase(),f=u.option(n.url,r.attr("action"),up.browser.url()),r.addClass("up-active"),s={url:f,type:a,data:r.serialize(),selector:c},l=function(t){var n;return f=i?"false"===i?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return r.removeClass("up-active")}).done(function(t,n,r){return up.flow.implant(c,t,{history:l(r),transition:p})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(e,n,{transition:o})})},observe=function(fieldOrSelector,options){var $field,callback,check,clearTimer,codeOnChange,knownValue,resetTimer,startTimer,timer;return $field=$(fieldOrSelector),options=u.options(options,{frequency:500}),knownValue=null,timer=null,callback=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("observe: No change callback given"),check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:callback.apply($field.get(0),[n,$field])},resetTimer=function(){return timer?(clearTimer(),startTimer()):void 0},clearTimer=function(){return clearInterval(timer),timer=null},startTimer=function(){return timer=setInterval(check,options.frequency)},$field.bind("keyup click mousemove",resetTimer),check(),startTimer(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,r,e,o,u,i,a,s,c,p;return c=up.util,r={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(r,t)},a=function(t,n,r){var e,o;return o=c.measure(t,{full:!0}),e=function(){switch(r){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return c.error("Unknown origin",r)}}(),n.attr("up-origin",r),n.css(e),u(n)},u=function(t){var n,r,e,o,u,i,a;if(r=c.measure(t,{full:!0}),e=null,o=null,r.right<0&&(e=-r.right),r.bottom<0&&(o=-r.bottom),r.left<0&&(e=r.left),r.top<0&&(o=r.top),e&&((u=parseInt(t.css("left")))?t.css("left",u-e):(i=parseInt(t.css("right")))&&t.css("right",i+e)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},e=function(t,n,r){var e,o;return o=c.$createElementFromSelector(".up-popup"),r&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),e=c.$createElementFromSelector(n),e.appendTo(o),o.appendTo(document.body),o.hide(),o},p=function(t,n,r,e){return n.show(),a(t,n,r),up.animate(n,e)},i=function(t,o){var u,i,a,s,l,f,m,d;return u=$(t),o=c.options(o),d=c.option(u.attr("href")),f=c.option(o.target,u.attr("up-popup"),"body"),l=c.option(o.origin,u.attr("up-origin"),r.origin),a=c.option(o.animation,u.attr("up-animation"),r.openAnimation),m=c.option(o.sticky,u.is("[up-sticky]")),s=c.option(o.history,u.attr("up-history"),!1),n(),i=e(u,f,m),up.replace(f,d,{history:s,insert:function(){return p(u,i,l,a)}})},s=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=c.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,r){return t.preventDefault(),r.is(".up-current")?n():i(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-popup").length||r.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,r){return r.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,r,e,o,u,i,a,s,c;return s=up.util,r={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return s.extend(r,t)},a=function(){var t;return t=r.template,s.isFunction(t)?t(r):t},e=function(t,n,r,e){var o,u,i,c;return i=$(a()),e&&i.attr("up-sticky",""),i.attr("up-previous-url",up.browser.url()),i.attr("up-previous-title",document.title),u=i.find(".up-modal-dialog"),s.isPresent(n)&&u.css("width",n),s.isPresent(r)&&u.css("height",r),o=u.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),i.appendTo(document.body),i.hide(),i},c=function(t,n){return t.show(),up.animate(t,n)},u=function(t,o){var u,i,a,p,l,f,m,d,h;return u=$(t),o=s.options(o),d=s.option(u.attr("href")),f=s.option(o.target,u.attr("up-modal"),"body"),h=s.option(o.width,u.attr("up-width"),r.width),p=s.option(o.height,u.attr("up-height"),r.height),a=s.option(o.animation,u.attr("up-animation"),r.openAnimation),m=s.option(o.sticky,u.is("[up-sticky]")),l=s.option(o.history,u.attr("up-history"),!0),n(),i=e(f,h,p,m),up.replace(f,d,{history:l,insert:function(){return c(i,a)}})},i=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-modal"),n.length?(t=s.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:n()},up.on("click","a[up-modal]",function(t,r){return t.preventDefault(),r.is(".up-current")?n():u(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-dialog").length||r.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,r){return r.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:i,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,r,e,o;return o=up.util,e=function(t,n,r){var e,u,i;return u=o.measure(t),i=o.measure(n),e=function(){switch(r){case"top":return{left:u.left+.5*(u.width-i.width),top:u.top-i.height};case"bottom":return{left:u.left+.5*(u.width-i.width),top:u.top+u.height};default:return o.error("Unknown origin",r)}}(),n.attr("up-origin",r),n.css(e)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},r=function(r,u){var i,a,s,c,p;return null==u&&(u={}),i=$(r),c=o.option(u.html,i.attr("up-tooltip")),p=o.option(u.origin,i.attr("up-origin"),"top"),s=o.option(u.animation,i.attr("up-animation"),"fade-in"),t(),a=n(c),e(i,a,p),up.animate(a,s,u)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return r(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:r,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,r,e,o,u,i,a,s,c;return s=up.util,t="up-active",n="up-current",e="a[href], a[up-target], [up-follow], [up-modal], [up-popup]",r="."+t,i=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},u=function(){var t,r,o;return o=i(up.browser.url()),t=i(up.modal.source()),r=i(up.popup.source()),s.each($(e),function(e){var u,a;return u=$(e),a=up.link.resolveUrl(u),a=i(a),a===o||a===t||a===r?u.addClass(n):u.removeClass(n)})},a=function(n){return c(),n=o(n),n.addClass(t)},o=function(t){return s.presence(t.parents(e))||t},c=function(){return $(r).removeClass(t)},up.on("click",e,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return c(),u()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?u():void 0})}()}.call(this),function(){up.marker=function(){var t,n;return n=function(t){return""!==t.html().trim()},t=function(t){return up.util.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")})}.call(this);
|
1
|
+
(function(){window.up={}}).call(this),function(){var t=[].slice;up.util=function(){var n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v,g,y,b,w,k,T,S,x,C,E,A,F,U,P,j,z,O,D,H,M,W,G,I,X,L,N,V,q,B,Z,J,Q,_,R;return w=function(t,n){return n=n||{},n.url=t,r(n)},r=function(t){return t.selector&&(t.headers={"X-Up-Selector":t.selector}),$.ajax(t)},D=function(t,n){return(""===n||"80"===n)&&"http:"===t||"443"===n&&"https:"===t},N=function(t,n){var r,e,o;return r=H(t)?$("<a>").attr({href:t}).get(0):R(t),e=r.protocol+"//"+r.hostname,D(r.protocol,r.port)||(e+=":"+r.port),o=r.pathname,(null!=n?n.stripTrailingSlash:void 0)===!0&&(o=o.replace(/\/$/,"")),e+=o,(null!=n?n.hash:void 0)===!0&&(e+=r.hash),(null!=n?n.search:void 0)!==!1&&(e+=r.search),e},n=function(t){var n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;for(l=t.split(/[ >]/),e=null,p=m=0,h=l.length;h>m;p=++m){for(u=l[p],i=u.match(/(^|\.|\#)[A-Za-z0-9\-_]+/g),f="div",o=[],c=null,d=0,v=i.length;v>d;d++)switch(a=i[d],a[0]){case".":o.push(a.substr(1));break;case"#":c=a.substr(1);break;default:f=a}s="<"+f,o.length&&(s+=' class="'+o.join(" ")+'"'),c&&(s+=' id="'+c+'"'),s+=">",n=$(s),r&&n.appendTo(r),0===p&&(e=n),r=n}return e},c=function(t,n){var r;return r=document.createElement(t),r.innerHTML=n,r},h=function(){var n,r;throw n=1<=arguments.length?t.call(arguments,0):[],r=1===n.length&&up.util.isString(n[0])?n[0]:JSON.stringify(n),console.log.apply(console,["[UP] Error: "+r].concat(t.call(n))),alert(r),r},l=function(t){var n,r,e,o,i,u,a;for(console.log("Creating selector from element",t),r=(n=t.attr("class"))?n.split(" "):[],e=t.attr("id"),i=t.prop("tagName").toLowerCase(),e&&(i+="#"+e),u=0,a=r.length;a>u;u++)o=r[u],i+="."+o;return i},p=function(t){var n,r,e;return n=/<html>((?:.|\n)*)<\/html>/i,r=void 0,r=(e=t.match(n))?e[1]:"<html><body>"+t+"</body></html>",c("html",r)},g=$.extend,d=function(t,n){var r,e,o,i,u;for(u=[],r=o=0,i=t.length;i>o;r=++o)e=t[r],u.push(n(e,r));return u},P=function(t){return null===t},M=function(t){return void 0===t},x=function(t){return!M(t)},U=function(t){return M(t)||P(t)},E=function(t){return!U(t)},S=function(t){return U(t)||j(t)&&0===Object.keys(t).length||0===t.length},Z=function(t,n){return null==n&&(n=z),n(t)?t:null},z=function(t){return!S(t)},C=function(t){return"function"==typeof t},H=function(t){return"string"==typeof t},A=function(t){return"object"==typeof t&&!!t},j=function(t){return A(t)||"function"==typeof t},F=function(t){return t instanceof jQuery},O=function(t){return C(t.then)},k=function(t){return E(t)?t:void 0},T=Array.isArray,a=function(t){return T(t)?t.slice():g({},t)},R=function(t){return F(t)?t.get(0):t},X=function(t,n){return g(a(t),n)},q=function(t,n){var r,e,o,i;if(o=t?a(t):{},n)for(e in n)r=n[e],i=o[e],E(i)?j(r)&&j(i)&&(o[e]=q(i,r)):o[e]=r;return o},V=function(){var n,r;return n=1<=arguments.length?t.call(arguments,0):[],r=null,n.every(function(t){var n;return n=t,C(n)&&(n=n()),z(n)?(r=n,!1):!0}),r},m=function(t,n){var r;return r=null,t.every(function(t){return n(t)?(r=t,!1):!0}),r},Q=function(t,n){var r;return r=[],d(t,function(t){return n(t)?r.push(t):void 0}),r},J=function(){var n,r,e,o;return n=arguments[0],e=2<=arguments.length?t.call(arguments,1):[],o=function(){var t,o,i;for(i=[],t=0,o=e.length;o>t;t++)r=e[t],i.push(n.attr(r));return i}(),m(o,z)},L=function(t){return setTimeout(t,0)},W=function(t){return t[t.length-1]},i=function(){var t;return t=document.documentElement,{width:t.clientWidth,height:t.clientHeight}},_=function(t,n,r){var e,o;return o=t.css(Object.keys(n)),t.css(n),e=function(){return t.css(o)},r?(r(),e()):e},b=function(t){var n,r;return r=t.css(["transform","-webkit-transform"]),S(r)?(n=function(){return t.css(r)},t.css({transform:"translateZ(0)","-webkit-transform":"translateZ(0)"})):n=function(){},n},f=function(t,n,r){var e,o,i,u,a;return r=q(r,{duration:300,delay:0,easing:"ease"}),e=$(t),o=$.Deferred(),i={"transition-property":Object.keys(n).join(", "),"transition-duration":r.duration+"ms","transition-delay":r.delay+"ms","transition-timing-function":r.easing},u=b(e),a=_(e,i),e.css(n),o.then(u),o.then(a),setTimeout(function(){return o.resolve()},r.duration+r.delay),o.promise()},I=function(t,n){var r,e,o;return e=(null!=n?n.relative:void 0)?t.position():t.offset(),r={left:e.left,top:e.top},(null!=n?n.inner:void 0)?(r.width=t.width(),r.height=t.height()):(r.width=t.outerWidth(),r.height=t.outerHeight()),(null!=n?n.full:void 0)&&(o=i(),r.right=o.width-(r.left+r.width),r.bottom=o.height-(r.top+r.height)),r},s=function(t,n){var r,e,o,i,u;for(i=t.get(0).attributes,u=[],e=0,o=i.length;o>e;e++)r=i[e],u.push(r.specified?n.attr(r.name,r.value):void 0);return u},B=function(t){var n,r;return r=I(t,{relative:!0,inner:!0}),n=t.clone(),n.find("script").remove(),n.css({right:"",bottom:"",position:"absolute"}),n.css(r),n.addClass("up-ghost"),n.insertBefore(t)},y=function(t,n){return t.find(n).addBack(n)},v=function(t){return 27===t.keyCode},u=function(t,n){return t.indexOf(n)>=0},o=function(t){return"true"===String(t)},e=function(t){return"false"===String(t)},G=function(t){return t.getResponseHeader("X-Up-Current-Location")},{presentAttr:J,createElement:c,normalizeUrl:N,createElementFromHtml:p,$createElementFromSelector:n,createSelectorFromElement:l,get:w,ajax:r,extend:g,copy:a,merge:X,options:q,option:V,error:h,each:d,detect:m,select:Q,last:W,isNull:P,isDefined:x,isUndefined:M,isGiven:E,isMissing:U,isPresent:z,isBlank:S,presence:Z,isObject:j,isFunction:C,isString:H,isJQuery:F,isPromise:O,isHash:A,ifGiven:k,unwrap:R,nextFrame:L,measure:I,temporaryCss:_,cssAnimate:f,forceCompositing:b,prependGhost:B,escapePressed:v,copyAttributes:s,findWithSelf:y,contains:u,isArray:T,castsToTrue:o,castsToFalse:e,locationFromXhr:G,clientSize:i}}()}.call(this),function(){up.browser=function(){var t;return t=function(){return location.href},{url:t}}()}.call(this),function(){var t=[].slice;up.bus=function(){var n,r,e,o,i,u,a;return n={},e={},r=function(t){return n[t]||(n[t]=[])},a=function(){var t,r,o;e={},o=[];for(r in n)t=n[r],o.push(e[r]=up.util.copy(t));return o},u=function(){return n=up.util.copy(e)},i=function(t,n){return r(t).push(n)},o=function(){var n,e,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],console.log("bus emitting",o,n),e=r(o),up.util.each(e,function(t){return t.apply(null,n)})},i("framework:ready",a),i("framework:reset",u),{on:i,emit:o}}()}.call(this),function(){up.flow=function(){var t,n,r,e,o,i,u,a,s,c,p,l;return l=up.util,s=function(t,n){var r;return r=$(t),l.isPresent(n)&&(n=l.normalizeUrl(n)),r.attr("up-source",n)},c=function(t){var n;return n=$(t).closest("[up-source]"),l.presence(n.attr("up-source"))||up.browser.url()},u=function(t,n,r){var o;return r=l.options(r),o=l.presence(t)?t:l.createSelectorFromElement($(t)),l.ajax({url:n,selector:o}).done(function(t,i,u){var a;return(a=l.locationFromXhr(u))&&(n=a),(l.isMissing(r.history)||l.castsToTrue(r.history))&&(r.history=n),(l.isMissing(r.source)||l.castsToTrue(r.source))&&(r.source=n),e(o,t,r)}).fail(l.error)},e=function(t,n,r){var e,i,u,a,s,c,f,m,d,h;for(r=l.options(r,{historyMethod:"push"}),"false"===r.history&&(r.history=null),r.source=l.option(r.source,r.history),a=l.createElementFromHtml(n),r.title||(r.title=null!=(m=a.querySelector("title"))?m.textContent:void 0),d=o(t,r),h=[],c=0,f=d.length;f>c;c++)s=d[c],i=l.presence($(".up-popup "+s.selector))||l.presence($(".up-modal "+s.selector))||l.presence($(s.selector)),(u=a.querySelector(s.selector))?(e=$(u),h.push(p(i,e,s.pseudoClass,s.transition,r))):h.push(l.error("Could not find selector ("+s.selector+") in response ("+n+")"));return h},r=function(n,r){return"function"==typeof r.insert&&r.insert(n),r.history&&(r.title&&(document.title=r.title),up.history[r.historyMethod](r.history)),s(n,r.source),t(n),up.ready(n)},p=function(t,e,o,i,u){var a,s;return i||(i="none"),o?(s="before"===o?"prepend":"append",a=e.children(),t[s](e.contents()),l.copyAttributes(e,t),r(a,u),up.animate(e,i)):n(t,{animation:function(){return e.insertAfter(t),r(e,u),t.is("body")&&"none"!==i&&l.error("Cannot apply transitions to body-elements",i),up.morph(t,e,i)}})},o=function(t,n){var r,e,o,i,u,a,s,c,p,f,m;for(s=n.transition||n.animation||"none",r=/\ *,\ */,e=t.split(r),l.isPresent(s)&&(c=s.split(r)),m=[],o=p=0,f=e.length;f>p;o=++p)i=e[o],u=i.match(/^(.+?)(?:\:(before|after))?$/),a=c[o]||l.last(c),m.push({selector:u[1],pseudoClass:u[2],transition:a});return m},t=function(t){var n,r;return r="[autofocus]:last",n=l.findWithSelf(t,r),n.length&&n.get(0)!==document.activeElement?n.focus():void 0},n=function(t,n){var r,e;return r=$(t),n=l.options(n,{animation:"none"}),r.addClass("up-destroying"),l.isPresent(n.url)&&up.history.push(n.url),l.isPresent(n.title)&&(document.title=n.title),up.bus.emit("fragment:destroy",r),e=l.presence(n.animation,l.isPromise)||up.motion.animate(r,n.animation),e.then(function(){return r.remove()})},i=function(t){var n;return n=c(t),u(t,n)},a=function(){return up.bus.emit("framework:reset")},up.bus.on("app:ready",function(){return s(document.body,up.browser.url())}),{replace:u,reload:i,destroy:n,implant:e,reset:a}}(),up.replace=up.flow.replace,up.reload=up.flow.reload,up.destroy=up.flow.destroy,up.reset=up.flow.reset}.call(this),function(){var t=[].slice;up.magic=function(){var n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;return v=up.util,n="up-destroyable",r="up-destroyer",l=[],s=null,p=function(t,n,r){var e,o;return e=[t,n,function(t){return r.apply(this,[t,$(this)])}],l.push(e),(o=$(document)).on.apply(o,e)},i=[],a=null,o=function(){var n,r,e,o;return o=arguments[0],n=2<=arguments.length?t.call(arguments,1):[],r=n.pop(),e=v.options(n[0],{batch:!1}),i.push({selector:o,callback:r,batch:e.batch})},e=function(t,e,o){var i;return i=t.callback.apply(o,[e]),v.isFunction(i)?(e.addClass(n),e.data(r,i)):void 0},u=function(t){var n,r,o,u,a;for(console.log("Compiling fragment",t),a=[],o=0,u=i.length;u>o;o++)r=i[o],n=v.findWithSelf(t,r.selector),a.push(n.length?r.batch?e(r,n,n.get()):n.each(function(){return e(r,$(this),this)}):void 0);return a},c=function(t){return v.findWithSelf(t,"."+n).each(function(){var t,n;return t=$(this),(n=t.data(r))()})},h=function(){return s=v.copy(l),a=v.copy(i)},d=function(){var t,n,r,e;for(n=0,r=l.length;r>n;n++)t=l[n],v.contains(s,t)||(e=$(document)).off.apply(e,t);return l=v.copy(s),i=v.copy(a)},m=function(t){var n;return n=$(t),up.bus.emit("fragment:ready",n),n},f=function(t){return p("keydown","body",function(n){return v.escapePressed(n)?t(n):void 0})},up.bus.on("app:ready",function(){return m(document.body)}),up.bus.on("fragment:ready",u),up.bus.on("fragment:destroy",c),up.bus.on("framework:ready",h),up.bus.on("framework:reset",d),{awaken:o,on:p,ready:m,onEscape:f}}(),up.awaken=up.magic.awaken,up.on=up.magic.on,up.ready=up.magic.ready}.call(this),function(){up.history=function(){var t,n,r,e,o,i;return i=up.util,t=function(t){return i.normalizeUrl(t,{hash:!0})===i.normalizeUrl(up.browser.url(),{hash:!0})},o=function(r,e){return e=i.options(e,{force:!1}),e.force||!t(r)?n("replace",r):void 0},e=function(r){return t(r)?void 0:n("push",r)},n=function(t,n){return t+="State",window.history[t]({fromUp:!0},"",n)},r=function(t){var n;return n=t.originalEvent.state,console.log("popping state",n),console.log("current href",up.browser.url()),(null!=n?n.fromUp:void 0)?up.visit(up.browser.url(),{historyMethod:"replace"}):console.log("strange state",n)},setTimeout(function(){return $(window).on("popstate",r),o(up.browser.url(),{force:!0})},200),{push:e,replace:o}}()}.call(this),function(){up.motion=function(){var t,n,r,e,o,i,u,a,s,c,p,l,f,m,d,h,v;return h=up.util,o={duration:300,delay:0,easing:"ease"},r={},i={},d={},u={},a=function(t){return h.extend(o,t)},t=function(n,r,i){var u;return u=$(n),i=h.options(i,o),h.isFunction(r)?e(r(u,i),["Animation did not return a Promise",r]):h.isString(r)?t(u,s(r),i):h.isHash(r)?h.cssAnimate(u,r,i):h.error("Unknown animation type",r)},s=function(t){return r[t]||h.error("Unknown animation",n)},v=function(t,n,r){var e,o,i,u;return o=null,e=null,h.temporaryCss(n,{display:"none"},function(){return o=h.prependGhost(t).addClass("up-destroying")}),h.temporaryCss(t,{display:"none"},function(){return e=h.prependGhost(n)}),t.css({visibility:"hidden"}),i=h.temporaryCss(n,{display:"none"}),u=r(o,e),u.then(function(){return o.remove(),e.remove(),t.css({display:"none"}),i()})},e=function(t,n){return h.isPromise(t)||h.error.apply(h,n),t},c=function(n,i,u,a){var s,p,l,f,m;return a=h.options(o),p=$(n),s=$(i),m=h.presence(u,h.isFunction)||d[u],m?v(p,s,function(t,n){return e(m(t,n,a),["Transition did not return a promise",u])}):(l=r[u])?(p.hide(),t(s,l,a)):h.isString(u)&&u.indexOf("/")>=0?(f=u.split("/"),m=function(n,r,e){return $.when(t(n,f[0],e),t(r,f[1],e))},c(p,s,m,a)):h.error("Unknown transition: "+u)},m=function(t,n){return d[t]=n},n=function(t,n){return r[t]=n},f=function(){return i=h.copy(r),u=h.copy(d)},l=function(){return r=h.copy(i),d=h.copy(u)},p=function(){var t;return t=$.Deferred(),t.resolve(),t.promise()},n("none",p),n("fade-in",function(n,r){return n.css({opacity:0}),t(n,{opacity:1},r)}),n("fade-out",function(n,r){return n.css({opacity:1}),t(n,{opacity:0},r)}),n("move-to-top",function(n,r){var e,o;return e=h.measure(n),o=e.top+e.height,n.css({"margin-top":"0px"}),t(n,{"margin-top":"-"+o+"px"},r)}),n("move-from-top",function(n,r){var e,o;return e=h.measure(n),o=e.top+e.height,n.css({"margin-top":"-"+o+"px"}),t(n,{"margin-top":"0px"},r)}),n("move-to-bottom",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().height-e.top,n.css({"margin-top":"0px"}),t(n,{"margin-top":o+"px"},r)}),n("move-from-bottom",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().height-e.top,n.css({"margin-top":o+"px"}),t(n,{"margin-top":"0px"},r)}),n("move-to-left",function(n,r){var e,o;return e=h.measure(n),o=e.left+e.width,n.css({"margin-left":"0px"}),t(n,{"margin-left":"-"+o+"px"},r)}),n("move-from-left",function(n,r){var e,o;return e=h.measure(n),o=e.left+e.width,n.css({"margin-left":"-"+o+"px"}),t(n,{"margin-left":"0px"},r)}),n("move-to-right",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().width-e.left,n.css({"margin-left":"0px"}),t(n,{"margin-left":o+"px"},r)}),n("move-from-right",function(n,r){var e,o;return e=h.measure(n),o=h.clientSize().width-e.left,n.css({"margin-left":o+"px"}),t(n,{"margin-left":"0px"},r)}),n("roll-down",function(n,r){var e,o;return e=n.height(),o=h.temporaryCss(n,{height:"0px",overflow:"hidden"}),t(n,{height:e+"px"},r).then(o)}),m("none",p),m("move-left",function(n,r,e){return $.when(t(n,"move-to-left",e),t(r,"move-from-right",e))}),m("move-right",function(n,r,e){return $.when(t(n,"move-to-right",e),t(r,"move-from-left",e))}),m("move-up",function(n,r,e){return $.when(t(n,"move-to-top",e),t(r,"move-from-bottom",e))}),m("move-down",function(n,r,e){return $.when(t(n,"move-to-bottom",e),t(r,"move-from-top",e))}),m("cross-fade",function(n,r,e){return $.when(t(n,"fade-out",e),t(r,"fade-in",e))}),up.bus.on("framework:ready",f),up.bus.on("framework:reset",l),{morph:c,animate:t,transition:m,animation:n,defaults:a,none:p}}(),up.transition=up.motion.transition,up.animation=up.motion.animation,up.morph=up.motion.morph,up.animate=up.motion.animate}.call(this),function(){up.link=function(){var t,n,r,e,o;return e=up.util,o=function(t,n){return console.log("up.visit",t),up.replace("body",t,n)},t=function(t,n){var r,o,i;return r=$(t),n=e.options(n),i=e.option(r.attr("href"),r.attr("up-follow")),o=e.option(n.target,r.attr("up-target"),"body"),n.transition=e.option(n.transition,r.attr("up-transition"),r.attr("up-animation")),n.history=e.option(n.history,r.attr("up-history")),up.replace(o,i,n)},n=function(t){var n;return n=$(t),n.is("a")||e.presentAttr(n,"up-follow")?n:n.find("a:first")},r=function(t){var r;return(r=n(t))?e.option(r.attr("href"),r.attr("up-follow")):void 0},up.on("click","a[up-target]",function(n,r){return n.preventDefault(),t(r)}),up.on("click","[up-follow]",function(r,e){var o;return o=function(){var t,n;return t=$(r.target),n=t.closest("a, [up-follow]"),n.length&&e.find(n).length},o()?void 0:(r.preventDefault(),t(n(e)))}),{visit:o,follow:t,resolve:n,resolveUrl:r}}(),up.visit=up.link.visit,up.follow=up.link.follow}.call(this),function(){up.form=function(){var observe,submit,u;return u=up.util,submit=function(t,n){var r,e,o,i,a,s,c,p,l,f;return r=$(t).closest("form"),n=u.options(n),c=u.option(n.target,r.attr("up-target"),"body"),e=u.option(n.failTarget,r.attr("up-fail-target"),function(){return u.createSelectorFromElement(r)}),i=u.option(n.history,r.attr("up-history"),!0),p=u.option(n.transition,r.attr("up-transition")),o=u.option(n.failTransition,r.attr("up-fail-transition")),a=u.option(n.method,r.attr("up-method"),r.attr("data-method"),r.attr("method"),"post").toUpperCase(),f=u.option(n.url,r.attr("action"),up.browser.url()),r.addClass("up-active"),s={url:f,type:a,data:r.serialize(),selector:c},l=function(t){var n;return f=i?"false"===i?!1:u.isString(i)?i:(n=u.locationFromXhr(t))?n:"GET"===s.type?s.url+"?"+s.data:void 0:void 0,u.option(f,!1)},u.ajax(s).always(function(){return r.removeClass("up-active")}).done(function(t,n,r){return up.flow.implant(c,t,{history:l(r),transition:p})}).fail(function(t){var n;return n=t.responseText,up.flow.implant(e,n,{transition:o})})},observe=function(fieldOrSelector,options){var $field,callback,check,clearTimer,codeOnChange,knownValue,resetTimer,startTimer,timer;return $field=$(fieldOrSelector),options=u.options(options,{frequency:500}),knownValue=null,timer=null,callback=null,(codeOnChange=$field.attr("up-observe"))?callback=function(value,$field){return eval(codeOnChange)}:options.change?callback=options.change:u.error("observe: No change callback given"),check=function(){var t,n;return n=$field.val(),t=_.isNull(knownValue),knownValue===n||(knownValue=n,t)?void 0:callback.apply($field.get(0),[n,$field])},resetTimer=function(){return timer?(clearTimer(),startTimer()):void 0},clearTimer=function(){return clearInterval(timer),timer=null},startTimer=function(){return timer=setInterval(check,options.frequency)},$field.bind("keyup click mousemove",resetTimer),check(),startTimer(),clearTimer},up.on("submit","form[up-target]",function(t,n){return t.preventDefault(),submit(n)}),up.awaken("[up-observe]",function(t){return observe(t)}),{submit:submit,observe:observe}}(),up.submit=up.form.submit,up.observe=up.form.observe}.call(this),function(){up.popup=function(){var t,n,r,e,o,i,u,a,s,c,p;return c=up.util,r={openAnimation:"fade-in",closeAnimation:"fade-out",origin:"bottom-right"},o=function(t){return c.extend(r,t)},a=function(t,n,r){var e,o;return o=c.measure(t,{full:!0}),e=function(){switch(r){case"bottom-right":return{right:o.right,top:o.top+o.height};case"bottom-left":return{left:o.left,top:o.bottom+o.height};case"top-right":return{right:o.right,bottom:o.top};case"top-left":return{left:o.left,bottom:o.top};default:return c.error("Unknown origin",r)}}(),n.attr("up-origin",r),n.css(e),i(n)},i=function(t){var n,r,e,o,i,u,a;if(r=c.measure(t,{full:!0}),e=null,o=null,r.right<0&&(e=-r.right),r.bottom<0&&(o=-r.bottom),r.left<0&&(e=r.left),r.top<0&&(o=r.top),e&&((i=parseInt(t.css("left")))?t.css("left",i-e):(u=parseInt(t.css("right")))&&t.css("right",u+e)),o){if(a=parseInt(t.css("top")))return t.css("top",a-o);if(n=parseInt(t.css("bottom")))return t.css("bottom",n+o)}},e=function(t,n,r){var e,o;return o=c.$createElementFromSelector(".up-popup"),r&&o.attr("up-sticky",""),o.attr("up-previous-url",up.browser.url()),o.attr("up-previous-title",document.title),e=c.$createElementFromSelector(n),e.appendTo(o),o.appendTo(document.body),o.hide(),o},p=function(t,n,r,e){return n.show(),a(t,n,r),up.animate(n,e)},u=function(t,o){var i,u,a,s,l,f,m,d;return i=$(t),o=c.options(o),d=c.option(i.attr("href")),f=c.option(o.target,i.attr("up-popup"),"body"),l=c.option(o.origin,i.attr("up-origin"),r.origin),a=c.option(o.animation,i.attr("up-animation"),r.openAnimation),m=c.option(o.sticky,i.is("[up-sticky]")),s=c.option(o.history,i.attr("up-history"),!1),n(),u=e(i,f,m),up.replace(f,d,{history:s,insert:function(){return p(i,u,l,a)}})},s=function(){var t;return t=$(".up-popup"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-popup"),n.length?(t=c.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-popup").is("[up-sticky]")?void 0:n()},up.on("click","a[up-popup]",function(t,r){return t.preventDefault(),r.is(".up-current")?n():u(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-popup").length||r.closest("[up-popup]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-popup").length?void 0:t()}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,r){return r.closest(".up-popup")?n():void 0}),up.bus.on("framework:reset",n),{open:u,close:n,source:s,defaults:o}}()}.call(this),function(){up.modal=function(){var t,n,r,e,o,i,u,a,s,c;return s=up.util,r={width:"auto",height:"auto",openAnimation:"fade-in",closeAnimation:"fade-out",closeLabel:"X",template:function(t){return'<div class="up-modal">\n <div class="up-modal-dialog">\n <div class="up-modal-close" up-close>'+t.closeLabel+'</div>\n <div class="up-modal-content"></div>\n </div>\n</div>'}},o=function(t){return s.extend(r,t)},a=function(){var t;return t=r.template,s.isFunction(t)?t(r):t},e=function(t,n,r,e){var o,i,u,c;return u=$(a()),e&&u.attr("up-sticky",""),u.attr("up-previous-url",up.browser.url()),u.attr("up-previous-title",document.title),i=u.find(".up-modal-dialog"),s.isPresent(n)&&i.css("width",n),s.isPresent(r)&&i.css("height",r),o=i.find(".up-modal-content"),c=s.$createElementFromSelector(t),c.appendTo(o),u.appendTo(document.body),u.hide(),u},c=function(t,n){return t.show(),up.animate(t,n)},i=function(t,o){var i,u,a,p,l,f,m,d,h;return i=$(t),o=s.options(o),d=s.option(i.attr("href")),f=s.option(o.target,i.attr("up-modal"),"body"),h=s.option(o.width,i.attr("up-width"),r.width),p=s.option(o.height,i.attr("up-height"),r.height),a=s.option(o.animation,i.attr("up-animation"),r.openAnimation),m=s.option(o.sticky,i.is("[up-sticky]")),l=s.option(o.history,i.attr("up-history"),!0),n(),u=e(f,h,p,m),up.replace(f,d,{history:l,insert:function(){return c(u,a)}})},u=function(){var t;return t=$(".up-modal"),t.is(".up-destroying")?void 0:t.find("[up-source]").attr("up-source")},n=function(t){var n;return n=$(".up-modal"),n.length?(t=s.options(t,{animation:r.closeAnimation,url:n.attr("up-previous-url"),title:n.attr("up-previous-title")}),up.destroy(n,t)):void 0},t=function(){return $(".up-modal").is("[up-sticky]")?void 0:n()},up.on("click","a[up-modal]",function(t,r){return t.preventDefault(),r.is(".up-current")?n():i(r)}),up.on("click","body",function(t){var r;return r=$(t.target),r.closest(".up-modal-dialog").length||r.closest("[up-modal]").length?void 0:n()}),up.bus.on("fragment:ready",function(n){return n.closest(".up-modal").length?void 0:(console.log("fragment inserted",n,n.closest(".up-modal")),t())}),up.magic.onEscape(function(){return n()}),up.on("click","[up-close]",function(t,r){return r.closest(".up-modal")?n():void 0}),up.bus.on("framework:reset",n),{open:i,close:n,source:u,defaults:o}}()}.call(this),function(){up.tooltip=function(){var t,n,r,e,o;return o=up.util,e=function(t,n,r){var e,i,u;return i=o.measure(t),u=o.measure(n),e=function(){switch(r){case"top":return{left:i.left+.5*(i.width-u.width),top:i.top-u.height};case"bottom":return{left:i.left+.5*(i.width-u.width),top:i.top+i.height};default:return o.error("Unknown origin",r)}}(),n.attr("up-origin",r),n.css(e)},n=function(t){return o.$createElementFromSelector(".up-tooltip").html(t).appendTo(document.body)},r=function(r,i){var u,a,s,c,p;return null==i&&(i={}),u=$(r),c=o.option(i.html,u.attr("up-tooltip")),p=o.option(i.origin,u.attr("up-origin"),"top"),s=o.option(i.animation,u.attr("up-animation"),"fade-in"),t(),a=n(c),e(u,a,p),up.animate(a,s,i)},t=function(t){var n;return n=$(".up-tooltip"),n.length?(t=o.options(t,{animation:"fade-out"}),up.destroy(n,t)):void 0},up.awaken("[up-tooltip]",function(n){return n.on("mouseover",function(){return r(n)}),n.on("mouseout",function(){return t()})}),up.on("click","body",function(){return t()}),up.bus.on("framework:reset",t),up.magic.onEscape(function(){return t()}),{open:r,close:t}}()}.call(this),function(){up.navigation=function(){var t,n,r,e,o,i,u,a,s,c;return s=up.util,t="up-active",n="up-current",e="a[href], a[up-target], [up-follow], [up-modal], [up-popup]",r="."+t,u=function(t){return s.isPresent(t)?s.normalizeUrl(t,{search:!1,stripTrailingSlash:!0}):void 0},i=function(){var t,r,o;return o=u(up.browser.url()),t=u(up.modal.source()),r=u(up.popup.source()),s.each($(e),function(e){var i,a;return i=$(e),a=up.link.resolveUrl(i),a=u(a),a===o||a===t||a===r?i.addClass(n):i.removeClass(n)})},a=function(n){return c(),n=o(n),n.addClass(t)},o=function(t){return s.presence(t.parents(e))||t},c=function(){return $(r).removeClass(t)},up.on("click",e,function(t,n){return a(n)}),up.bus.on("fragment:ready",function(){return c(),i()}),up.bus.on("fragment:destroy",function(t){return t.is(".up-modal, .up-popup")?i():void 0})}()}.call(this),function(){up.marker=function(){var t,n;return n=function(t){return""!==t.html().trim()},t=function(t){return up.util.findWithSelf(t,"[up-marker]").each(function(){var t;return t=$(this),n(t)?void 0:t.hide()})},up.bus.on("fragment:ready",t)}()}.call(this),function(){up.bus.emit("framework:ready"),$(document).on("ready",function(){return up.bus.emit("app:ready")})}.call(this);
|
@@ -95,6 +95,12 @@ up.flow = (->
|
|
95
95
|
options = u.options(options,
|
96
96
|
historyMethod: 'push'
|
97
97
|
)
|
98
|
+
|
99
|
+
if options.history == 'false'
|
100
|
+
options.history = null
|
101
|
+
|
102
|
+
options.source = u.option(options.source, options.history)
|
103
|
+
|
98
104
|
# jQuery cannot construct transient elements that contain <html> or <body> tags,
|
99
105
|
# so we're using the native browser API to grep through the HTML
|
100
106
|
htmlElement = u.createElementFromHtml(html)
|
@@ -115,26 +121,26 @@ up.flow = (->
|
|
115
121
|
u.error("Could not find selector (#{step.selector}) in response (#{html})")
|
116
122
|
|
117
123
|
elementsInserted = ($new, options) ->
|
118
|
-
$new
|
119
|
-
|
120
|
-
options.
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
# so transitions see .up-current classes
|
130
|
-
up.ready($element)
|
124
|
+
options.insert?($new)
|
125
|
+
if options.history
|
126
|
+
document.title = options.title if options.title
|
127
|
+
up.history[options.historyMethod](options.history)
|
128
|
+
# Remember where the element came from so we can
|
129
|
+
# offer reload functionality.
|
130
|
+
setSource($new, options.source)
|
131
|
+
autofocus($new)
|
132
|
+
# The fragment should be readiet before animating,
|
133
|
+
# so transitions see .up-current classes
|
134
|
+
up.ready($new)
|
131
135
|
|
132
136
|
swapElements = ($old, $new, pseudoClass, transition, options) ->
|
133
137
|
transition ||= 'none'
|
134
138
|
if pseudoClass
|
135
139
|
insertionMethod = if pseudoClass == 'before' then 'prepend' else 'append'
|
136
140
|
# Keep a reference to the children append/prepend because
|
137
|
-
# we need to compile them further down
|
141
|
+
# we need to compile them further down. Note that since we're
|
142
|
+
# prepending/appending instead of rpelacing, `$new` will not
|
143
|
+
# actually be inserted into the DOM, only its children.
|
138
144
|
$addedChildren = $new.children()
|
139
145
|
# Insert contents() instead of $children since contents()
|
140
146
|
# also includes text nodes.
|
@@ -25,8 +25,10 @@ up.history = (->
|
|
25
25
|
@param {String} url
|
26
26
|
@protected
|
27
27
|
###
|
28
|
-
replace = (url) ->
|
29
|
-
|
28
|
+
replace = (url, options) ->
|
29
|
+
options = u.options(options, force: false)
|
30
|
+
if options.force || !isCurrentUrl(url)
|
31
|
+
manipulate("replace", url)
|
30
32
|
|
31
33
|
###*
|
32
34
|
@method up.history.push
|
@@ -47,13 +49,13 @@ up.history = (->
|
|
47
49
|
if state?.fromUp
|
48
50
|
up.visit up.browser.url(), historyMethod: 'replace'
|
49
51
|
else
|
50
|
-
console.log "
|
52
|
+
console.log "strange state", state
|
51
53
|
|
52
54
|
# Defeat an unnecessary popstate that some browsers trigger on pageload (Chrome?).
|
53
55
|
# We should check in 2016 if we can remove this.
|
54
56
|
setTimeout (->
|
55
57
|
$(window).on "popstate", pop
|
56
|
-
replace(up.browser.url())
|
58
|
+
replace(up.browser.url(), force: true)
|
57
59
|
), 200
|
58
60
|
|
59
61
|
push: push
|
@@ -20,7 +20,7 @@ We need to work on this page:
|
|
20
20
|
###
|
21
21
|
up.magic = (->
|
22
22
|
|
23
|
-
|
23
|
+
u = up.util
|
24
24
|
|
25
25
|
DESTROYABLE_CLASS = 'up-destroyable'
|
26
26
|
DESTROYER_KEY = 'up-destroyer'
|
@@ -57,6 +57,10 @@ up.magic = (->
|
|
57
57
|
@method up.awaken
|
58
58
|
@param {String} selector
|
59
59
|
The selector to match.
|
60
|
+
@param {Boolean} [options.batch=false]
|
61
|
+
If set to `true` and a fragment insertion contains multiple
|
62
|
+
elements matching the selector, `awakener` is only called once
|
63
|
+
with a jQuery collection containing all matching elements.
|
60
64
|
@param {Function($element)} awakener
|
61
65
|
The function to call when a matching element is inserted.
|
62
66
|
The function takes the new element as the first argument (as a jQuery object).
|
@@ -68,25 +72,33 @@ up.magic = (->
|
|
68
72
|
awakeners = []
|
69
73
|
defaultAwakeners = null
|
70
74
|
|
71
|
-
awaken = (selector,
|
75
|
+
awaken = (selector, args...) ->
|
76
|
+
awakener = args.pop()
|
77
|
+
options = u.options(args[0], batch: false)
|
72
78
|
awakeners.push
|
73
79
|
selector: selector
|
74
80
|
callback: awakener
|
81
|
+
batch: options.batch
|
82
|
+
|
83
|
+
applyAwakener = (awakener, $jqueryElement, nativeElement) ->
|
84
|
+
destroyer = awakener.callback.apply(nativeElement, [$jqueryElement])
|
85
|
+
if u.isFunction(destroyer)
|
86
|
+
$jqueryElement.addClass(DESTROYABLE_CLASS)
|
87
|
+
$jqueryElement.data(DESTROYER_KEY, destroyer)
|
75
88
|
|
76
89
|
compile = ($fragment) ->
|
77
|
-
|
90
|
+
console.log("Compiling fragment", $fragment)
|
78
91
|
for awakener in awakeners
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
$
|
86
|
-
$element.data(DESTROYER_KEY, destroyer)
|
92
|
+
# console.log("running", awakener.selector, "on", $fragment)
|
93
|
+
$matches = u.findWithSelf($fragment, awakener.selector)
|
94
|
+
if $matches.length
|
95
|
+
if awakener.batch
|
96
|
+
applyAwakener(awakener, $matches, $matches.get())
|
97
|
+
else
|
98
|
+
$matches.each -> applyAwakener(awakener, $(this), this)
|
87
99
|
|
88
100
|
destroy = ($fragment) ->
|
89
|
-
|
101
|
+
u.findWithSelf($fragment, ".#{DESTROYABLE_CLASS}").each ->
|
90
102
|
$element = $(this)
|
91
103
|
destroyer = $element.data(DESTROYER_KEY)
|
92
104
|
destroyer()
|
@@ -99,8 +111,8 @@ up.magic = (->
|
|
99
111
|
@method up.magic.snapshot
|
100
112
|
###
|
101
113
|
snapshot = ->
|
102
|
-
defaultLiveDescriptions =
|
103
|
-
defaultAwakeners =
|
114
|
+
defaultLiveDescriptions = u.copy(liveDescriptions)
|
115
|
+
defaultAwakeners = u.copy(awakeners)
|
104
116
|
|
105
117
|
###*
|
106
118
|
Resets the list of registered event listeners to the
|
@@ -111,10 +123,10 @@ up.magic = (->
|
|
111
123
|
###
|
112
124
|
reset = ->
|
113
125
|
for description in liveDescriptions
|
114
|
-
unless
|
126
|
+
unless u.contains(defaultLiveDescriptions, description)
|
115
127
|
$(document).off(description...)
|
116
|
-
liveDescriptions =
|
117
|
-
awakeners =
|
128
|
+
liveDescriptions = u.copy(defaultLiveDescriptions)
|
129
|
+
awakeners = u.copy(defaultAwakeners)
|
118
130
|
|
119
131
|
###*
|
120
132
|
Sends a notification that the given element has been inserted
|
@@ -135,7 +147,7 @@ up.magic = (->
|
|
135
147
|
|
136
148
|
onEscape = (handler) ->
|
137
149
|
live('keydown', 'body', (event) ->
|
138
|
-
if
|
150
|
+
if u.escapePressed(event)
|
139
151
|
handler(event)
|
140
152
|
)
|
141
153
|
|
@@ -171,12 +171,14 @@ up.modal = (->
|
|
171
171
|
# (but not on a modal opener).
|
172
172
|
up.on('click', 'body', (event, $body) ->
|
173
173
|
$target = $(event.target)
|
174
|
-
unless $target.closest('.up-dialog').length || $target.closest('[up-modal]').length
|
174
|
+
unless $target.closest('.up-modal-dialog').length || $target.closest('[up-modal]').length
|
175
175
|
close()
|
176
176
|
)
|
177
177
|
|
178
178
|
up.bus.on('fragment:ready', ($fragment) ->
|
179
179
|
unless $fragment.closest('.up-modal').length
|
180
|
+
console.log('fragment inserted', $fragment, $fragment.closest('.up-modal'))
|
181
|
+
# alert("autoclosing due to inserted fragment")
|
180
182
|
autoclose()
|
181
183
|
)
|
182
184
|
|
@@ -23,7 +23,7 @@ up.motion = (->
|
|
23
23
|
|
24
24
|
u = up.util
|
25
25
|
|
26
|
-
|
26
|
+
config =
|
27
27
|
duration: 300
|
28
28
|
delay: 0
|
29
29
|
easing: 'ease'
|
@@ -33,6 +33,15 @@ up.motion = (->
|
|
33
33
|
transitions = {}
|
34
34
|
defaultTransitions = {}
|
35
35
|
|
36
|
+
###*
|
37
|
+
@method up.modal.defaults
|
38
|
+
@param {Number} options.duration
|
39
|
+
@param {Number} options.delay
|
40
|
+
@param {String} options.easing
|
41
|
+
###
|
42
|
+
defaults = (options) ->
|
43
|
+
u.extend(config, options)
|
44
|
+
|
36
45
|
###*
|
37
46
|
Animates an element.
|
38
47
|
|
@@ -61,7 +70,7 @@ up.motion = (->
|
|
61
70
|
###
|
62
71
|
animate = (elementOrSelector, animation, options) ->
|
63
72
|
$element = $(elementOrSelector)
|
64
|
-
options = u.options(options,
|
73
|
+
options = u.options(options, config)
|
65
74
|
if u.isFunction(animation)
|
66
75
|
assertIsPromise(
|
67
76
|
animation($element, options),
|
@@ -108,8 +117,8 @@ up.motion = (->
|
|
108
117
|
The following transitions are pre-registered:
|
109
118
|
|
110
119
|
- `cross-fade`
|
111
|
-
- `move-
|
112
|
-
- `move-
|
120
|
+
- `move-up`
|
121
|
+
- `move-down`
|
113
122
|
- `move-left`
|
114
123
|
- `move-right`
|
115
124
|
- `none`
|
@@ -131,7 +140,7 @@ up.motion = (->
|
|
131
140
|
A promise for the transition's end.
|
132
141
|
###
|
133
142
|
morph = (source, target, transitionOrName, options) ->
|
134
|
-
options = u.options(
|
143
|
+
options = u.options(config)
|
135
144
|
$old = $(source)
|
136
145
|
$new = $(target)
|
137
146
|
transition = u.presence(transitionOrName, u.isFunction) || transitions[transitionOrName]
|
@@ -209,43 +218,59 @@ up.motion = (->
|
|
209
218
|
)
|
210
219
|
|
211
220
|
animation('move-to-top', ($ghost, options) ->
|
212
|
-
$ghost
|
213
|
-
|
221
|
+
box = u.measure($ghost)
|
222
|
+
travelDistance = box.top + box.height
|
223
|
+
$ghost.css('margin-top': '0px')
|
224
|
+
animate($ghost, { 'margin-top': "-#{travelDistance}px" }, options)
|
214
225
|
)
|
215
226
|
|
216
227
|
animation('move-from-top', ($ghost, options) ->
|
217
|
-
$ghost
|
218
|
-
|
228
|
+
box = u.measure($ghost)
|
229
|
+
travelDistance = box.top + box.height
|
230
|
+
$ghost.css('margin-top': "-#{travelDistance}px")
|
231
|
+
animate($ghost, { 'margin-top': '0px' }, options)
|
219
232
|
)
|
220
233
|
|
221
234
|
animation('move-to-bottom', ($ghost, options) ->
|
222
|
-
$ghost
|
223
|
-
|
235
|
+
box = u.measure($ghost)
|
236
|
+
travelDistance = u.clientSize().height - box.top
|
237
|
+
$ghost.css('margin-top': '0px')
|
238
|
+
animate($ghost, { 'margin-top': "#{travelDistance}px" }, options)
|
224
239
|
)
|
225
240
|
|
226
241
|
animation('move-from-bottom', ($ghost, options) ->
|
227
|
-
$ghost
|
228
|
-
|
242
|
+
box = u.measure($ghost)
|
243
|
+
travelDistance = u.clientSize().height - box.top
|
244
|
+
$ghost.css('margin-top': "#{travelDistance}px")
|
245
|
+
animate($ghost, { 'margin-top': '0px' }, options)
|
229
246
|
)
|
230
247
|
|
231
248
|
animation('move-to-left', ($ghost, options) ->
|
232
|
-
$ghost
|
233
|
-
|
249
|
+
box = u.measure($ghost)
|
250
|
+
travelDistance = box.left + box.width
|
251
|
+
$ghost.css('margin-left': '0px')
|
252
|
+
animate($ghost, { 'margin-left': "-#{travelDistance}px" }, options)
|
234
253
|
)
|
235
254
|
|
236
255
|
animation('move-from-left', ($ghost, options) ->
|
237
|
-
$ghost
|
238
|
-
|
256
|
+
box = u.measure($ghost)
|
257
|
+
travelDistance = box.left + box.width
|
258
|
+
$ghost.css('margin-left': "-#{travelDistance}px")
|
259
|
+
animate($ghost, { 'margin-left': '0px' }, options)
|
239
260
|
)
|
240
261
|
|
241
262
|
animation('move-to-right', ($ghost, options) ->
|
242
|
-
$ghost
|
243
|
-
|
263
|
+
box = u.measure($ghost)
|
264
|
+
travelDistance = u.clientSize().width - box.left
|
265
|
+
$ghost.css('margin-left': '0px')
|
266
|
+
animate($ghost, { 'margin-left': "#{travelDistance}px" }, options)
|
244
267
|
)
|
245
268
|
|
246
269
|
animation('move-from-right', ($ghost, options) ->
|
247
|
-
$ghost
|
248
|
-
|
270
|
+
box = u.measure($ghost)
|
271
|
+
travelDistance = u.clientSize().width - box.left
|
272
|
+
$ghost.css('margin-left': "#{travelDistance}px")
|
273
|
+
animate($ghost, { 'margin-left': '0px' }, options)
|
249
274
|
)
|
250
275
|
|
251
276
|
animation('roll-down', ($ghost, options) ->
|
@@ -293,7 +318,7 @@ up.motion = (->
|
|
293
318
|
animate($new, 'fade-in', options)
|
294
319
|
)
|
295
320
|
)
|
296
|
-
|
321
|
+
|
297
322
|
up.bus.on 'framework:ready', snapshot
|
298
323
|
up.bus.on 'framework:reset', reset
|
299
324
|
|
@@ -301,6 +326,7 @@ up.motion = (->
|
|
301
326
|
animate: animate
|
302
327
|
transition: transition
|
303
328
|
animation: animation
|
329
|
+
defaults: defaults
|
304
330
|
none: none
|
305
331
|
|
306
332
|
)()
|
@@ -136,8 +136,8 @@ up.util = (->
|
|
136
136
|
!isMissing(object)
|
137
137
|
|
138
138
|
isBlank = (object) ->
|
139
|
-
isMissing(object) || # null or undefined
|
140
|
-
|
139
|
+
isMissing(object) || # null or undefined
|
140
|
+
(isObject(object) && Object.keys(object).length == 0) ||
|
141
141
|
(object.length == 0) # String, Array, jQuery
|
142
142
|
|
143
143
|
presence = (object, checker = isPresent) ->
|
@@ -254,11 +254,7 @@ up.util = (->
|
|
254
254
|
height: element.clientHeight
|
255
255
|
|
256
256
|
temporaryCss = ($element, css, block) ->
|
257
|
-
|
258
257
|
oldCss = $element.css(Object.keys(css))
|
259
|
-
# oldCss = {}
|
260
|
-
# for property of css
|
261
|
-
# oldCss[property] = $element.css(property)
|
262
258
|
$element.css(css)
|
263
259
|
memo = -> $element.css(oldCss)
|
264
260
|
if block
|
@@ -266,7 +262,19 @@ up.util = (->
|
|
266
262
|
memo()
|
267
263
|
else
|
268
264
|
memo
|
269
|
-
|
265
|
+
|
266
|
+
forceCompositing = ($element) ->
|
267
|
+
oldTransforms = $element.css(['transform', '-webkit-transform'])
|
268
|
+
if isBlank(oldTransforms)
|
269
|
+
memo = -> $element.css(oldTransforms)
|
270
|
+
$element.css
|
271
|
+
'transform': 'translateZ(0)'
|
272
|
+
'-webkit-transform': 'translateZ(0)' # Safari
|
273
|
+
else
|
274
|
+
memo = ->
|
275
|
+
memo
|
276
|
+
|
277
|
+
|
270
278
|
###*
|
271
279
|
Animates the given element's CSS properties using CSS transitions.
|
272
280
|
|
@@ -300,8 +308,10 @@ up.util = (->
|
|
300
308
|
'transition-duration': "#{opts.duration}ms"
|
301
309
|
'transition-delay': "#{opts.delay}ms"
|
302
310
|
'transition-timing-function': opts.easing
|
311
|
+
withoutCompositing = forceCompositing($element)
|
303
312
|
withoutTransition = temporaryCss($element, transition)
|
304
313
|
$element.css(lastFrame)
|
314
|
+
deferred.then(withoutCompositing)
|
305
315
|
deferred.then(withoutTransition)
|
306
316
|
setTimeout((-> deferred.resolve()), opts.duration + opts.delay)
|
307
317
|
deferred.promise()
|
@@ -315,8 +325,14 @@ up.util = (->
|
|
315
325
|
box =
|
316
326
|
left: coordinates.left
|
317
327
|
top: coordinates.top
|
318
|
-
|
319
|
-
|
328
|
+
|
329
|
+
if options?.inner
|
330
|
+
box.width = $element.width()
|
331
|
+
box.height = $element.height()
|
332
|
+
else
|
333
|
+
box.width = $element.outerWidth()
|
334
|
+
box.height = $element.outerHeight()
|
335
|
+
|
320
336
|
if options?.full
|
321
337
|
viewport = clientSize()
|
322
338
|
box.right = viewport.width - (box.left + box.width)
|
@@ -329,17 +345,18 @@ up.util = (->
|
|
329
345
|
$target.attr(attr.name, attr.value)
|
330
346
|
|
331
347
|
prependGhost = ($element) ->
|
332
|
-
dimensions = measure($element)
|
348
|
+
dimensions = measure($element, relative: true, inner: true)
|
333
349
|
$ghost = $element.clone()
|
334
350
|
$ghost.find('script').remove()
|
335
351
|
$ghost.css
|
336
352
|
right: ''
|
337
353
|
bottom: ''
|
338
|
-
margin: 0
|
354
|
+
# margin: 0
|
339
355
|
position: 'absolute'
|
340
356
|
$ghost.css(dimensions)
|
341
357
|
$ghost.addClass('up-ghost')
|
342
|
-
$ghost.
|
358
|
+
$ghost.insertBefore($element)
|
359
|
+
# $ghost.prependTo(document.body)
|
343
360
|
|
344
361
|
findWithSelf = ($element, selector) ->
|
345
362
|
$element.find(selector).addBack(selector)
|
@@ -413,6 +430,7 @@ up.util = (->
|
|
413
430
|
measure: measure
|
414
431
|
temporaryCss: temporaryCss
|
415
432
|
cssAnimate: cssAnimate
|
433
|
+
forceCompositing: forceCompositing
|
416
434
|
prependGhost: prependGhost
|
417
435
|
escapePressed: escapePressed
|
418
436
|
copyAttributes: copyAttributes
|
@@ -422,6 +440,7 @@ up.util = (->
|
|
422
440
|
castsToTrue: castsToTrue
|
423
441
|
castsToFalse: castsToFalse
|
424
442
|
locationFromXhr: locationFromXhr
|
443
|
+
clientSize: clientSize
|
425
444
|
# memoArray: memoArray
|
426
445
|
# replaceInPlace: replaceInPlace
|
427
446
|
|
data/lib/upjs/rails/version.rb
CHANGED
data/spec_app/Gemfile.lock
CHANGED
@@ -27,3 +27,10 @@ describe 'up.util', ->
|
|
27
27
|
|
28
28
|
it 'returns false for an array with at least one element', ->
|
29
29
|
expect(up.util.isBlank(['element'])).toBe(false)
|
30
|
+
|
31
|
+
it 'returns true for an empty object', ->
|
32
|
+
expect(up.util.isBlank({})).toBe(true)
|
33
|
+
|
34
|
+
it 'returns true for an object with at least one key', ->
|
35
|
+
expect(up.util.isBlank({key: 'value'})).toBe(false)
|
36
|
+
|
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.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henning Koch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|