unpoly-rails 0.20.0 → 0.21.0
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.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +28 -0
- data/README.md +1 -1
- data/dist/unpoly.js +195 -94
- data/dist/unpoly.min.js +3 -3
- data/lib/assets/javascripts/unpoly/form.js.coffee +23 -24
- data/lib/assets/javascripts/unpoly/layout.js.coffee +16 -0
- data/lib/assets/javascripts/unpoly/link.js.coffee +3 -2
- data/lib/assets/javascripts/unpoly/log.js.coffee +1 -1
- data/lib/assets/javascripts/unpoly/motion.js.coffee +17 -19
- data/lib/assets/javascripts/unpoly/syntax.js.coffee +83 -23
- data/lib/assets/javascripts/unpoly/util.js.coffee +18 -7
- data/lib/unpoly/rails/version.rb +1 -1
- data/spec_app/spec/javascripts/up/flow_spec.js.coffee +83 -4
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +8 -8
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +47 -0
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +76 -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: 073e4830deaf5d1a5bcb5c021f12574b0667225b
|
4
|
+
data.tar.gz: ca7cefb937a6a874a1978991e7412dd125199ca4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7af376508ef0086147a8ea8227ac2b5d77fb7f86d40396237d9889942725c27984da000dc83317d831e1a931e6eeb328f05dfd88364bb4c370d923214cd46fe
|
7
|
+
data.tar.gz: f026aa47769d84312e78e50dae936c5cd1eb5e332942ab71dd8a1e0962446be16a5a4285f57b565394be9094e8b6bb9057ba713df151319946bef214d87846d9
|
data/CHANGELOG.md
CHANGED
@@ -10,15 +10,43 @@ Unreleased
|
|
10
10
|
|
11
11
|
### Compatible changes
|
12
12
|
|
13
|
+
|
14
|
+
### Breaking changes
|
15
|
+
|
16
|
+
|
17
|
+
0.21.0
|
18
|
+
------
|
19
|
+
|
20
|
+
### Compatible changes
|
21
|
+
|
22
|
+
- New function `up.macro`. This registers a [compiler](/up.compiler) that is run before all other compilers.
|
23
|
+
- [`up.compiler`](/up.compiler) has a new options `{ priority }`. Compilers with higher priorities are run first.
|
24
|
+
- Fix a bug where trying to apply another transition on an element could throw a *Maximum call stack exceeded*
|
25
|
+
error if the element was already transitioning.
|
26
|
+
|
13
27
|
### Breaking changes
|
14
28
|
|
29
|
+
- `up-toggle` has been renamed to `up-switch`
|
30
|
+
|
15
31
|
|
16
32
|
0.20.0
|
17
33
|
------
|
18
34
|
|
19
35
|
- The project has been renamed to *Unpoly*.
|
36
|
+
- All functions remain in the `up` namespace, so e.g. `up.replace` is still called `up.replace`.
|
37
|
+
- All UJS functionality remains unchanged, so e.g. `up-target` is still called `up-target`.
|
20
38
|
- The Bower package has been renamed to `unpoly`.
|
21
39
|
- The Ruby gem for the Rails bindings has been renamed to `unpoly-rails`.
|
40
|
+
- The new Javascript and stylesheet assets are:
|
41
|
+
- [`unpoly.js`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly.js)
|
42
|
+
- [`unpoly.min.js`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly.min.js)
|
43
|
+
- [`unpoly.css`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly.css)
|
44
|
+
- [`unpoly.min.css`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly.min.css)
|
45
|
+
- If you're using the Bootstrap integration the new assets are:
|
46
|
+
- [`unpoly-bootstrap3.js`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly-bootstrap3.js)
|
47
|
+
- [`unpoly-bootstrap3.min.js`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly-bootstrap3.min.js)
|
48
|
+
- [`unpoly-bootstrap3.css`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly-bootstrap3.css)
|
49
|
+
- [`unpoly-bootstrap3.min.css`](https://raw.githubusercontent.com/unpoly/unpoly/master/dist/unpoly-bootstrap3.min.css)
|
22
50
|
|
23
51
|
|
24
52
|
0.19.0
|
data/README.md
CHANGED
@@ -71,5 +71,5 @@ Always run `rake assets:compile` before `rake release` so the git tag points to
|
|
71
71
|
Credits
|
72
72
|
-------
|
73
73
|
|
74
|
-
- [Henning Koch](mailto:henning.koch@makandra.de) from
|
74
|
+
- [Henning Koch](mailto:henning.koch@makandra.de) from [makandra](http://www.makandra.com) ([@triskweline](https://twitter.com/triskweline) on Twitter)
|
75
75
|
|
data/dist/unpoly.js
CHANGED
@@ -27,7 +27,7 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
27
27
|
@function up.util.memoize
|
28
28
|
@internal
|
29
29
|
*/
|
30
|
-
var $createElementFromSelector, $createPlaceholder,
|
30
|
+
var $createElementFromSelector, $createPlaceholder, ANIMATION_DEFERRED_KEY, all, any, cache, castedAttr, clientSize, compact, config, contains, copy, copyAttributes, createElement, createElementFromHtml, cssAnimate, detect, each, error, escapePressed, except, extend, findWithSelf, finishCssAnimate, fixedToAbsolute, forceCompositing, intersect, isArray, isBlank, isDeferred, isDefined, isElement, isFunction, isGiven, isHash, isJQuery, isMissing, isNull, isNumber, isObject, isPresent, isPromise, isStandardPort, isString, isUndefined, isUnmodifiedKeyEvent, isUnmodifiedMouseEvent, last, locationFromXhr, map, measure, memoize, merge, methodFromXhr, multiSelector, nextFrame, nonUpClasses, normalizeMethod, normalizeUrl, nullJQuery, offsetParent, once, only, option, options, parseUrl, pluckData, presence, presentAttr, reject, remove, requestDataAsArray, requestDataAsQuery, resolvableWhen, resolvedDeferred, resolvedPromise, scrollbarWidth, select, selectorForElement, setMissingAttrs, temporaryCss, times, titleFromXhr, toArray, trim, unJQuery, uniq, unresolvableDeferred, unresolvablePromise, unwrapElement;
|
31
31
|
memoize = function(func) {
|
32
32
|
var cache, cached;
|
33
33
|
cache = void 0;
|
@@ -1067,9 +1067,9 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1067
1067
|
$element.css(lastFrame);
|
1068
1068
|
deferred.then(withoutCompositing);
|
1069
1069
|
deferred.then(withoutTransition);
|
1070
|
-
$element.data(
|
1070
|
+
$element.data(ANIMATION_DEFERRED_KEY, deferred);
|
1071
1071
|
deferred.then(function() {
|
1072
|
-
return $element.removeData(
|
1072
|
+
return $element.removeData(ANIMATION_DEFERRED_KEY);
|
1073
1073
|
});
|
1074
1074
|
endTimeout = setTimeout((function() {
|
1075
1075
|
return deferred.resolve();
|
@@ -1079,7 +1079,7 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1079
1079
|
});
|
1080
1080
|
return deferred;
|
1081
1081
|
};
|
1082
|
-
|
1082
|
+
ANIMATION_DEFERRED_KEY = 'up-animation-deferred';
|
1083
1083
|
|
1084
1084
|
/**
|
1085
1085
|
Completes the animation for the given element by jumping
|
@@ -1097,7 +1097,7 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1097
1097
|
finishCssAnimate = function(elementOrSelector) {
|
1098
1098
|
return $(elementOrSelector).each(function() {
|
1099
1099
|
var existingAnimation;
|
1100
|
-
if (existingAnimation =
|
1100
|
+
if (existingAnimation = pluckData(this, ANIMATION_DEFERRED_KEY)) {
|
1101
1101
|
return existingAnimation.resolve();
|
1102
1102
|
}
|
1103
1103
|
});
|
@@ -1380,12 +1380,12 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1380
1380
|
resolvableWhen = function() {
|
1381
1381
|
var deferreds, joined;
|
1382
1382
|
deferreds = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
1383
|
-
joined = $.when.apply($, deferreds);
|
1384
|
-
joined.resolve = function() {
|
1383
|
+
joined = $.when.apply($, [resolvedDeferred()].concat(slice.call(deferreds)));
|
1384
|
+
joined.resolve = memoize(function() {
|
1385
1385
|
return each(deferreds, function(deferred) {
|
1386
|
-
return
|
1386
|
+
return deferred.resolve();
|
1387
1387
|
});
|
1388
|
-
};
|
1388
|
+
});
|
1389
1389
|
return joined;
|
1390
1390
|
};
|
1391
1391
|
|
@@ -1790,6 +1790,13 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1790
1790
|
$error.text(asString);
|
1791
1791
|
throw new Error(asString);
|
1792
1792
|
};
|
1793
|
+
pluckData = function(elementOrSelector, key) {
|
1794
|
+
var $element, value;
|
1795
|
+
$element = $(elementOrSelector);
|
1796
|
+
value = $element.data(key);
|
1797
|
+
$element.removeData(key);
|
1798
|
+
return value;
|
1799
|
+
};
|
1793
1800
|
return {
|
1794
1801
|
requestDataAsArray: requestDataAsArray,
|
1795
1802
|
requestDataAsQuery: requestDataAsQuery,
|
@@ -1875,7 +1882,8 @@ that might save you from loading something like [Underscore.js](http://underscor
|
|
1875
1882
|
cache: cache,
|
1876
1883
|
unwrapElement: unwrapElement,
|
1877
1884
|
multiSelector: multiSelector,
|
1878
|
-
error: error
|
1885
|
+
error: error,
|
1886
|
+
pluckData: pluckData
|
1879
1887
|
};
|
1880
1888
|
})($);
|
1881
1889
|
|
@@ -2750,10 +2758,12 @@ later.
|
|
2750
2758
|
var slice = [].slice;
|
2751
2759
|
|
2752
2760
|
up.syntax = (function($) {
|
2753
|
-
var DESTROYABLE_CLASS, DESTROYER_KEY, applyCompiler, clean, compile, compiler, compilers, data, reset, snapshot, u;
|
2761
|
+
var DESTROYABLE_CLASS, DESTROYER_KEY, applyCompiler, buildCompiler, clean, compile, compiler, compilers, data, insertCompiler, macro, macros, reset, snapshot, u;
|
2754
2762
|
u = up.util;
|
2755
2763
|
DESTROYABLE_CLASS = 'up-destroyable';
|
2756
2764
|
DESTROYER_KEY = 'up-destroyer';
|
2765
|
+
compilers = [];
|
2766
|
+
macros = [];
|
2757
2767
|
|
2758
2768
|
/**
|
2759
2769
|
Registers a function to be called whenever an element with
|
@@ -2892,6 +2902,10 @@ later.
|
|
2892
2902
|
@function up.compiler
|
2893
2903
|
@param {String} selector
|
2894
2904
|
The selector to match.
|
2905
|
+
@param {Number} [options.priority=0]
|
2906
|
+
The priority of this compilers.
|
2907
|
+
Compilers with a higher priority are run first.
|
2908
|
+
Two compilers with the same priority are run in the order they were registered.
|
2895
2909
|
@param {Boolean} [options.batch=false]
|
2896
2910
|
If set to `true` and a fragment insertion contains multiple
|
2897
2911
|
elements matching the selector, `compiler` is only called once
|
@@ -2914,21 +2928,84 @@ later.
|
|
2914
2928
|
is already handled by [`up.destroy`](/up.destroy).
|
2915
2929
|
@stable
|
2916
2930
|
*/
|
2917
|
-
compilers = [];
|
2918
2931
|
compiler = function() {
|
2919
|
-
var args
|
2932
|
+
var args;
|
2933
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
2934
|
+
return insertCompiler.apply(null, [compilers].concat(slice.call(args)));
|
2935
|
+
};
|
2936
|
+
|
2937
|
+
/**
|
2938
|
+
Registers a [compiler](/up.compiler) that is run before all other compilers.
|
2939
|
+
|
2940
|
+
You can use `up.macro` to register a compiler that sets other UJS attributes.
|
2941
|
+
|
2942
|
+
\#\#\#\# Example
|
2943
|
+
|
2944
|
+
You will sometimes find yourself setting the same combination of UJS attributes again and again:
|
2945
|
+
|
2946
|
+
<a href="/page1" up-target=".content" up-transition="cross-fade" up-duration="300">Page 1</a>
|
2947
|
+
<a href="/page2" up-target=".content" up-transition="cross-fade" up-duration="300">Page 2</a>
|
2948
|
+
<a href="/page3" up-target=".content" up-transition="cross-fade" up-duration="300">Page 3</a>
|
2949
|
+
|
2950
|
+
We would much rather define a new `content-link` attribute that let's us
|
2951
|
+
write the same links like this:
|
2952
|
+
|
2953
|
+
<a href="/page1" content-link>Page 1</a>
|
2954
|
+
<a href="/page2" content-link>Page 2</a>
|
2955
|
+
<a href="/page3" content-link>Page 3</a>
|
2956
|
+
|
2957
|
+
We can define the `content-link` attribute by registering a macro that
|
2958
|
+
sets the `up-target`, `up-transition` and `up-duration` attributes for us:
|
2959
|
+
|
2960
|
+
up.macro('[content-link]', function($link) {
|
2961
|
+
$link.attr('up-target', '.content');
|
2962
|
+
$link.attr('up-transition', 'cross-fade');
|
2963
|
+
$link.attr('up-duration', '300');
|
2964
|
+
});
|
2965
|
+
|
2966
|
+
Examples for built-in macros are [`up-dash`](/up-dash) and [`up-expand`](/up-expand).
|
2967
|
+
|
2968
|
+
@param {String} selector
|
2969
|
+
The selector to match.
|
2970
|
+
@param {Object} options
|
2971
|
+
See options for [`up.compiler`](/up.compiler).
|
2972
|
+
@param {Function($element, data)} compiler
|
2973
|
+
The function to call when a matching element is inserted.
|
2974
|
+
See [`up.compiler`](/up.compiler) for details.
|
2975
|
+
@stable
|
2976
|
+
*/
|
2977
|
+
macro = function() {
|
2978
|
+
var args;
|
2979
|
+
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
2980
|
+
return insertCompiler.apply(null, [macros].concat(slice.call(args)));
|
2981
|
+
};
|
2982
|
+
buildCompiler = function() {
|
2983
|
+
var args, callback, options, selector;
|
2920
2984
|
selector = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
2921
|
-
|
2922
|
-
|
2923
|
-
|
2924
|
-
|
2925
|
-
|
2926
|
-
return compilers.push({
|
2985
|
+
callback = args.pop();
|
2986
|
+
options = u.options(args[0], {
|
2987
|
+
priority: 0
|
2988
|
+
});
|
2989
|
+
return {
|
2927
2990
|
selector: selector,
|
2928
|
-
callback:
|
2991
|
+
callback: callback,
|
2992
|
+
priority: options.priority,
|
2929
2993
|
batch: options.batch,
|
2930
2994
|
keep: options.keep
|
2931
|
-
}
|
2995
|
+
};
|
2996
|
+
};
|
2997
|
+
insertCompiler = function() {
|
2998
|
+
var args, index, newCompiler, oldCompiler, queue;
|
2999
|
+
queue = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
|
3000
|
+
if (!up.browser.isSupported()) {
|
3001
|
+
return;
|
3002
|
+
}
|
3003
|
+
newCompiler = buildCompiler.apply(null, args);
|
3004
|
+
index = 0;
|
3005
|
+
while ((oldCompiler = queue[index]) && (oldCompiler.priority <= newCompiler.priority)) {
|
3006
|
+
index += 1;
|
3007
|
+
}
|
3008
|
+
return queue.splice(index, 0, newCompiler);
|
2932
3009
|
};
|
2933
3010
|
applyCompiler = function(compiler, $jqueryElement, nativeElement) {
|
2934
3011
|
var destroyer, value;
|
@@ -2958,31 +3035,40 @@ later.
|
|
2958
3035
|
options = u.options(options);
|
2959
3036
|
$skipSubtrees = $(options.skip);
|
2960
3037
|
return up.log.group("Compiling fragment %o", $fragment.get(0), function() {
|
2961
|
-
var $matches, i, len, results;
|
3038
|
+
var $matches, i, len, queue, ref, results;
|
3039
|
+
ref = [macros, compilers];
|
2962
3040
|
results = [];
|
2963
|
-
for (i = 0, len =
|
2964
|
-
|
2965
|
-
|
2966
|
-
|
2967
|
-
|
2968
|
-
|
2969
|
-
|
2970
|
-
|
2971
|
-
|
2972
|
-
|
2973
|
-
|
2974
|
-
|
2975
|
-
|
2976
|
-
return applyCompiler(compiler, $matches, $matches.get());
|
2977
|
-
} else {
|
2978
|
-
return $matches.each(function() {
|
2979
|
-
return applyCompiler(compiler, $(this), this);
|
3041
|
+
for (i = 0, len = ref.length; i < len; i++) {
|
3042
|
+
queue = ref[i];
|
3043
|
+
results.push((function() {
|
3044
|
+
var j, len1, results1;
|
3045
|
+
results1 = [];
|
3046
|
+
for (j = 0, len1 = queue.length; j < len1; j++) {
|
3047
|
+
compiler = queue[j];
|
3048
|
+
$matches = u.findWithSelf($fragment, compiler.selector);
|
3049
|
+
$matches = $matches.filter(function() {
|
3050
|
+
var $match;
|
3051
|
+
$match = $(this);
|
3052
|
+
return u.all($skipSubtrees, function(element) {
|
3053
|
+
return $match.closest(element).length === 0;
|
2980
3054
|
});
|
3055
|
+
});
|
3056
|
+
if ($matches.length) {
|
3057
|
+
results1.push(up.log.group((!compiler.isDefault ? "Compiling '%s' on %d element(s)" : void 0), compiler.selector, $matches.length, function() {
|
3058
|
+
if (compiler.batch) {
|
3059
|
+
return applyCompiler(compiler, $matches, $matches.get());
|
3060
|
+
} else {
|
3061
|
+
return $matches.each(function() {
|
3062
|
+
return applyCompiler(compiler, $(this), this);
|
3063
|
+
});
|
3064
|
+
}
|
3065
|
+
}));
|
3066
|
+
} else {
|
3067
|
+
results1.push(void 0);
|
2981
3068
|
}
|
2982
|
-
}
|
2983
|
-
|
2984
|
-
|
2985
|
-
}
|
3069
|
+
}
|
3070
|
+
return results1;
|
3071
|
+
})());
|
2986
3072
|
}
|
2987
3073
|
return results;
|
2988
3074
|
});
|
@@ -3076,6 +3162,7 @@ later.
|
|
3076
3162
|
up.on('up:framework:reset', reset);
|
3077
3163
|
return {
|
3078
3164
|
compiler: compiler,
|
3165
|
+
macro: macro,
|
3079
3166
|
compile: compile,
|
3080
3167
|
clean: clean,
|
3081
3168
|
data: data
|
@@ -3084,6 +3171,8 @@ later.
|
|
3084
3171
|
|
3085
3172
|
up.compiler = up.syntax.compiler;
|
3086
3173
|
|
3174
|
+
up.macro = up.syntax.macro;
|
3175
|
+
|
3087
3176
|
up.ready = function() {
|
3088
3177
|
return up.util.error('up.ready no longer exists. Please use up.hello instead.');
|
3089
3178
|
};
|
@@ -3894,6 +3983,21 @@ This modules contains functions to scroll the viewport and reveal contained elem
|
|
3894
3983
|
<div class="bottom-nav" up-fixed="bottom">...</div>
|
3895
3984
|
|
3896
3985
|
@selector [up-fixed=bottom]
|
3986
|
+
@stable
|
3987
|
+
*/
|
3988
|
+
|
3989
|
+
/**
|
3990
|
+
Marks this element as a navigation anchored to the right edge of the screen
|
3991
|
+
using `position: fixed` or `position:absolute`.
|
3992
|
+
|
3993
|
+
[`up.modal`](/up.modal) will move anchored elements to the left so they
|
3994
|
+
don't appear to move when a modal dialog is opened or closed.
|
3995
|
+
|
3996
|
+
\#\#\#\# Example
|
3997
|
+
|
3998
|
+
<div class="bottom-nav" up-fixed="bottom">...</div>
|
3999
|
+
|
4000
|
+
@selector [up-anchored=right]
|
3897
4001
|
@stable
|
3898
4002
|
*/
|
3899
4003
|
up.on('up:framework:reset', reset);
|
@@ -4851,7 +4955,7 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
4851
4955
|
|
4852
4956
|
(function() {
|
4853
4957
|
up.motion = (function($) {
|
4854
|
-
var
|
4958
|
+
var GHOSTING_DEFERRED_KEY, animate, animateOptions, animation, animations, assertIsDeferred, config, defaultAnimations, defaultTransitions, ensureMorphable, findAnimation, finish, finishGhosting, isEnabled, morph, none, prependCopy, reset, resolvableWhen, skipMorph, snapshot, transition, transitions, u, withGhosts;
|
4855
4959
|
u = up.util;
|
4856
4960
|
animations = {};
|
4857
4961
|
defaultAnimations = {};
|
@@ -5019,9 +5123,9 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
5019
5123
|
findAnimation = function(name) {
|
5020
5124
|
return animations[name] || u.error("Unknown animation %o", name);
|
5021
5125
|
};
|
5022
|
-
|
5126
|
+
GHOSTING_DEFERRED_KEY = 'up-ghosting-deferred';
|
5023
5127
|
withGhosts = function($old, $new, options, block) {
|
5024
|
-
var $viewport, newCopy, newScrollTop, oldCopy, oldScrollTop,
|
5128
|
+
var $viewport, deferred, newCopy, newScrollTop, oldCopy, oldScrollTop, showNew;
|
5025
5129
|
oldCopy = void 0;
|
5026
5130
|
newCopy = void 0;
|
5027
5131
|
oldScrollTop = void 0;
|
@@ -5031,8 +5135,6 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
5031
5135
|
display: 'none'
|
5032
5136
|
}, function() {
|
5033
5137
|
oldCopy = prependCopy($old, $viewport);
|
5034
|
-
oldCopy.$ghost.addClass('up-destroying');
|
5035
|
-
oldCopy.$bounds.addClass('up-destroying');
|
5036
5138
|
return oldScrollTop = $viewport.scrollTop();
|
5037
5139
|
});
|
5038
5140
|
u.temporaryCss($old, {
|
@@ -5047,17 +5149,17 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
5047
5149
|
showNew = u.temporaryCss($new, {
|
5048
5150
|
opacity: '0'
|
5049
5151
|
});
|
5050
|
-
|
5051
|
-
$old.data(
|
5052
|
-
$new.data(
|
5053
|
-
|
5054
|
-
$old.removeData(
|
5055
|
-
$new.removeData(
|
5152
|
+
deferred = block(oldCopy.$ghost, newCopy.$ghost);
|
5153
|
+
$old.data(GHOSTING_DEFERRED_KEY, deferred);
|
5154
|
+
$new.data(GHOSTING_DEFERRED_KEY, deferred);
|
5155
|
+
deferred.then(function() {
|
5156
|
+
$old.removeData(GHOSTING_DEFERRED_KEY);
|
5157
|
+
$new.removeData(GHOSTING_DEFERRED_KEY);
|
5056
5158
|
showNew();
|
5057
5159
|
oldCopy.$bounds.remove();
|
5058
5160
|
return newCopy.$bounds.remove();
|
5059
5161
|
});
|
5060
|
-
return
|
5162
|
+
return deferred;
|
5061
5163
|
};
|
5062
5164
|
|
5063
5165
|
/**
|
@@ -5073,20 +5175,20 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
5073
5175
|
@stable
|
5074
5176
|
*/
|
5075
5177
|
finish = function(elementOrSelector) {
|
5076
|
-
|
5077
|
-
|
5178
|
+
var $element;
|
5179
|
+
$element = $(elementOrSelector);
|
5180
|
+
u.finishCssAnimate($element);
|
5181
|
+
return finishGhosting($element);
|
5182
|
+
};
|
5183
|
+
finishGhosting = function($collection) {
|
5184
|
+
return $collection.each(function() {
|
5185
|
+
var $element, existingGhosting;
|
5078
5186
|
$element = $(this);
|
5079
|
-
u.
|
5080
|
-
|
5187
|
+
if (existingGhosting = u.pluckData($element, GHOSTING_DEFERRED_KEY)) {
|
5188
|
+
return existingGhosting.resolve();
|
5189
|
+
}
|
5081
5190
|
});
|
5082
5191
|
};
|
5083
|
-
finishGhosting = function($element) {
|
5084
|
-
var existingGhosting;
|
5085
|
-
if (existingGhosting = $element.data(GHOSTING_PROMISE_KEY)) {
|
5086
|
-
up.puts('Canceling existing ghosting on %o', $element);
|
5087
|
-
return typeof existingGhosting.resolve === "function" ? existingGhosting.resolve() : void 0;
|
5088
|
-
}
|
5089
|
-
};
|
5090
5192
|
assertIsDeferred = function(object, source) {
|
5091
5193
|
if (u.isDeferred(object)) {
|
5092
5194
|
return object;
|
@@ -5167,7 +5269,7 @@ or [transitions](/up.transition) using Javascript or CSS.
|
|
5167
5269
|
$new = $(target);
|
5168
5270
|
ensureMorphable($old, transitionOrName);
|
5169
5271
|
ensureMorphable($new, transitionOrName);
|
5170
|
-
return up.log.group((transitionOrName ? 'Morphing %o to %o (using %
|
5272
|
+
return up.log.group((transitionOrName ? 'Morphing %o to %o (using %s)' : void 0), $old.get(0), $new.get(0), transitionOrName, function() {
|
5171
5273
|
var animation, parsedOptions, parts, transition;
|
5172
5274
|
parsedOptions = u.only(options, 'reveal', 'restoreScroll', 'source');
|
5173
5275
|
parsedOptions = u.extend(parsedOptions, animateOptions(options));
|
@@ -6533,7 +6635,7 @@ Read on
|
|
6533
6635
|
If omitted, the first contained link will be expanded.
|
6534
6636
|
@stable
|
6535
6637
|
*/
|
6536
|
-
up.
|
6638
|
+
up.macro('[up-expand]', function($area) {
|
6537
6639
|
var $childLinks, attribute, i, len, link, name, newAttrs, ref, selector, upAttributePattern;
|
6538
6640
|
$childLinks = $area.find('a, [up-href]');
|
6539
6641
|
if (selector = $area.attr('up-expand')) {
|
@@ -6576,7 +6678,7 @@ Read on
|
|
6576
6678
|
@selector [up-dash]
|
6577
6679
|
@stable
|
6578
6680
|
*/
|
6579
|
-
up.
|
6681
|
+
up.macro('[up-dash]', function($element) {
|
6580
6682
|
var newAttrs, target;
|
6581
6683
|
target = u.castedAttr($element, 'up-dash');
|
6582
6684
|
newAttrs = {
|
@@ -6624,7 +6726,7 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
6624
6726
|
var slice = [].slice;
|
6625
6727
|
|
6626
6728
|
up.form = (function($) {
|
6627
|
-
var autosubmit, config,
|
6729
|
+
var autosubmit, config, currentValuesForSwitch, observe, observeForm, reset, resolveValidateTarget, submit, switchTargets, u, validate;
|
6628
6730
|
u = up.util;
|
6629
6731
|
|
6630
6732
|
/**
|
@@ -7005,7 +7107,7 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7005
7107
|
promise = up.submit($form, options);
|
7006
7108
|
return promise;
|
7007
7109
|
};
|
7008
|
-
|
7110
|
+
currentValuesForSwitch = function($field) {
|
7009
7111
|
var $checkedButton, value, values;
|
7010
7112
|
values = void 0;
|
7011
7113
|
if ($field.is('input[type=checkbox]')) {
|
@@ -7031,7 +7133,7 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7031
7133
|
}
|
7032
7134
|
return values;
|
7033
7135
|
};
|
7034
|
-
|
7136
|
+
currentValuesForSwitch = function($field) {
|
7035
7137
|
var $checkedButton, meta, value, values;
|
7036
7138
|
if ($field.is('input[type=checkbox]')) {
|
7037
7139
|
if ($field.is(':checked')) {
|
@@ -7067,26 +7169,26 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7067
7169
|
/**
|
7068
7170
|
Shows or hides a target selector depending on the value.
|
7069
7171
|
|
7070
|
-
See [`[up-
|
7172
|
+
See [`[up-switch]`](/up-switch) for more documentation and examples.
|
7071
7173
|
|
7072
7174
|
This function does not currently have a very useful API outside
|
7073
|
-
of our use for `up-
|
7175
|
+
of our use for `up-switch`'s UJS behavior, that's why it's currently
|
7074
7176
|
still marked `@internal`.
|
7075
7177
|
|
7076
|
-
@function up.form.
|
7178
|
+
@function up.form.switchTargets
|
7077
7179
|
@param {String|Element|jQuery} fieldOrSelector
|
7078
7180
|
@param {String} [options.target]
|
7079
|
-
The target selectors to
|
7080
|
-
Defaults to an `up-
|
7181
|
+
The target selectors to switch.
|
7182
|
+
Defaults to an `up-switch` attribute on the given field.
|
7081
7183
|
@internal
|
7082
7184
|
*/
|
7083
|
-
|
7185
|
+
switchTargets = function(fieldOrSelector, options) {
|
7084
7186
|
var $field, fieldValues, targets;
|
7085
7187
|
$field = $(fieldOrSelector);
|
7086
7188
|
options = u.options(options);
|
7087
|
-
targets = u.option(options.target, $field.attr('up-
|
7088
|
-
u.isPresent(targets) || u.error("No
|
7089
|
-
fieldValues =
|
7189
|
+
targets = u.option(options.target, $field.attr('up-switch'));
|
7190
|
+
u.isPresent(targets) || u.error("No switch target given for %o", $field.get(0));
|
7191
|
+
fieldValues = currentValuesForSwitch($field);
|
7090
7192
|
return $(targets).each(function() {
|
7091
7193
|
var $target, hideValues, show, showValues;
|
7092
7194
|
$target = $(this);
|
@@ -7359,9 +7461,9 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7359
7461
|
|
7360
7462
|
\#\#\#\# Example
|
7361
7463
|
|
7362
|
-
The triggering input gets an `up-
|
7464
|
+
The triggering input gets an `up-switch` attribute with a selector for the elements to show or hide:
|
7363
7465
|
|
7364
|
-
<select name="advancedness" up-
|
7466
|
+
<select name="advancedness" up-switch=".target">
|
7365
7467
|
<option value="basic">Basic parts</option>
|
7366
7468
|
<option value="advanced">Advanced parts</option>
|
7367
7469
|
<option value="very-advanced">Very advanced parts</option>
|
@@ -7383,7 +7485,7 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7383
7485
|
|
7384
7486
|
For checkboxes you can also use the pseudo-values `:checked` or `:unchecked` like so:
|
7385
7487
|
|
7386
|
-
<input type="checkbox" name="flag" up-
|
7488
|
+
<input type="checkbox" name="flag" up-switch=".target">
|
7387
7489
|
|
7388
7490
|
<div class="target" up-show-for=":checked">
|
7389
7491
|
only shown when checkbox is checked
|
@@ -7392,20 +7494,20 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7392
7494
|
You can also use the pseudo-values `:blank` to match an empty input value,
|
7393
7495
|
or `:present` to match a non-empty input value:
|
7394
7496
|
|
7395
|
-
<input type="text" name="email" up-
|
7497
|
+
<input type="text" name="email" up-switch=".target">
|
7396
7498
|
|
7397
7499
|
<div class="target" up-show-for=":blank">
|
7398
7500
|
please enter an email address
|
7399
7501
|
</div>
|
7400
7502
|
|
7401
|
-
@selector [up-
|
7503
|
+
@selector [up-switch]
|
7402
7504
|
@stable
|
7403
7505
|
*/
|
7404
7506
|
|
7405
7507
|
/**
|
7406
7508
|
Show this element only if a form field has a given value.
|
7407
7509
|
|
7408
|
-
See [`[up-
|
7510
|
+
See [`[up-switch]`](/up-switch) for more documentation and examples.
|
7409
7511
|
|
7410
7512
|
@selector [up-show-for]
|
7411
7513
|
@param up-show-for
|
@@ -7416,19 +7518,18 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7416
7518
|
/**
|
7417
7519
|
Hide this element if a form field has a given value.
|
7418
7520
|
|
7419
|
-
See [`[up-
|
7521
|
+
See [`[up-switch]`](/up-switch) for more documentation and examples.
|
7420
7522
|
|
7421
7523
|
@selector [up-hide-for]
|
7422
7524
|
@param up-hide-for
|
7423
7525
|
A space-separated list of values for which to hide this element.
|
7424
7526
|
@stable
|
7425
7527
|
*/
|
7426
|
-
up.on('change', '[up-
|
7427
|
-
|
7428
|
-
return toggleTargets($field);
|
7528
|
+
up.on('change', '[up-switch]', function(event, $field) {
|
7529
|
+
return switchTargets($field);
|
7429
7530
|
});
|
7430
|
-
up.compiler('[up-
|
7431
|
-
return
|
7531
|
+
up.compiler('[up-switch]', function($field) {
|
7532
|
+
return switchTargets($field);
|
7432
7533
|
});
|
7433
7534
|
|
7434
7535
|
/**
|
@@ -7500,7 +7601,7 @@ open dialogs with sub-forms, etc. all without losing form state.
|
|
7500
7601
|
submit: submit,
|
7501
7602
|
observe: observe,
|
7502
7603
|
validate: validate,
|
7503
|
-
|
7604
|
+
switchTargets: switchTargets
|
7504
7605
|
};
|
7505
7606
|
})(jQuery);
|
7506
7607
|
|