guff-compass 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.editorconfig +21 -0
- data/.gitignore +6 -0
- data/LICENSE.txt +22 -0
- data/README.md +21 -0
- data/demo/bower_components/jquery/.bower.json +21 -0
- data/demo/bower_components/jquery/.editorconfig +43 -0
- data/demo/bower_components/jquery/.gitattributes +2 -0
- data/demo/bower_components/jquery/.gitignore +14 -0
- data/demo/bower_components/jquery/.gitmodules +6 -0
- data/demo/bower_components/jquery/.jshintrc +17 -0
- data/demo/bower_components/jquery/.mailmap +94 -0
- data/demo/bower_components/jquery/AUTHORS.txt +170 -0
- data/demo/bower_components/jquery/CONTRIBUTING.md +216 -0
- data/demo/bower_components/jquery/Gruntfile.js +594 -0
- data/demo/bower_components/jquery/MIT-LICENSE.txt +21 -0
- data/demo/bower_components/jquery/README.md +398 -0
- data/demo/bower_components/jquery/bower.json +11 -0
- data/demo/bower_components/jquery/build/release-notes.js +59 -0
- data/demo/bower_components/jquery/build/release.js +316 -0
- data/demo/bower_components/jquery/component.json +15 -0
- data/demo/bower_components/jquery/composer.json +35 -0
- data/demo/bower_components/jquery/jquery-migrate.js +511 -0
- data/demo/bower_components/jquery/jquery-migrate.min.js +3 -0
- data/demo/bower_components/jquery/jquery.js +9789 -0
- data/demo/bower_components/jquery/jquery.min.js +6 -0
- data/demo/bower_components/jquery/jquery.min.map +1 -0
- data/demo/bower_components/jquery/package.json +38 -0
- data/demo/bower_components/jquery/speed/benchmark.js +15 -0
- data/demo/bower_components/jquery/speed/benchmarker.css +65 -0
- data/demo/bower_components/jquery/speed/benchmarker.js +181 -0
- data/demo/bower_components/jquery/speed/closest.html +39 -0
- data/demo/bower_components/jquery/speed/css.html +82 -0
- data/demo/bower_components/jquery/speed/event.html +58 -0
- data/demo/bower_components/jquery/speed/filter.html +183 -0
- data/demo/bower_components/jquery/speed/find.html +179 -0
- data/demo/bower_components/jquery/speed/index.html +72 -0
- data/demo/bower_components/jquery/speed/jquery-basis.js +6238 -0
- data/demo/bower_components/jquery/speed/slice.vs.concat.html +47 -0
- data/demo/bower_components/jquery/src/.jshintrc +27 -0
- data/demo/bower_components/jquery/src/ajax.js +855 -0
- data/demo/bower_components/jquery/src/ajax/jsonp.js +80 -0
- data/demo/bower_components/jquery/src/ajax/script.js +86 -0
- data/demo/bower_components/jquery/src/ajax/xhr.js +207 -0
- data/demo/bower_components/jquery/src/attributes.js +659 -0
- data/demo/bower_components/jquery/src/callbacks.js +197 -0
- data/demo/bower_components/jquery/src/core.js +981 -0
- data/demo/bower_components/jquery/src/css.js +661 -0
- data/demo/bower_components/jquery/src/data.js +336 -0
- data/demo/bower_components/jquery/src/deferred.js +141 -0
- data/demo/bower_components/jquery/src/deprecated.js +11 -0
- data/demo/bower_components/jquery/src/dimensions.js +41 -0
- data/demo/bower_components/jquery/src/effects.js +732 -0
- data/demo/bower_components/jquery/src/event-alias.js +32 -0
- data/demo/bower_components/jquery/src/event.js +995 -0
- data/demo/bower_components/jquery/src/exports.js +21 -0
- data/demo/bower_components/jquery/src/intro.js +20 -0
- data/demo/bower_components/jquery/src/manipulation.js +744 -0
- data/demo/bower_components/jquery/src/offset.js +169 -0
- data/demo/bower_components/jquery/src/outro.js +2 -0
- data/demo/bower_components/jquery/src/queue.js +146 -0
- data/demo/bower_components/jquery/src/serialize.js +99 -0
- data/demo/bower_components/jquery/src/sizzle-jquery.js +7 -0
- data/demo/bower_components/jquery/src/support.js +246 -0
- data/demo/bower_components/jquery/src/traversing.js +283 -0
- data/demo/bower_components/jquery/src/wrap.js +66 -0
- data/demo/bower_components/jquery/test/.jshintignore +3 -0
- data/demo/bower_components/jquery/test/.jshintrc +60 -0
- data/demo/bower_components/jquery/test/data/1x1.jpg +0 -0
- data/demo/bower_components/jquery/test/data/ajax/unreleasedXHR.html +25 -0
- data/demo/bower_components/jquery/test/data/atom+xml.php +4 -0
- data/demo/bower_components/jquery/test/data/badcall.js +1 -0
- data/demo/bower_components/jquery/test/data/badjson.js +1 -0
- data/demo/bower_components/jquery/test/data/cleanScript.html +10 -0
- data/demo/bower_components/jquery/test/data/core/cc_on.html +22 -0
- data/demo/bower_components/jquery/test/data/dashboard.xml +11 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentLarge.html +17 -0
- data/demo/bower_components/jquery/test/data/dimensions/documentSmall.html +21 -0
- data/demo/bower_components/jquery/test/data/echoData.php +1 -0
- data/demo/bower_components/jquery/test/data/echoQuery.php +1 -0
- data/demo/bower_components/jquery/test/data/errorWithJSON.php +6 -0
- data/demo/bower_components/jquery/test/data/errorWithText.php +5 -0
- data/demo/bower_components/jquery/test/data/etag.php +21 -0
- data/demo/bower_components/jquery/test/data/evalScript.php +1 -0
- data/demo/bower_components/jquery/test/data/event/focusElem.html +16 -0
- data/demo/bower_components/jquery/test/data/event/longLoadScript.php +4 -0
- data/demo/bower_components/jquery/test/data/event/promiseReady.html +17 -0
- data/demo/bower_components/jquery/test/data/event/syncReady.html +23 -0
- data/demo/bower_components/jquery/test/data/headers.php +18 -0
- data/demo/bower_components/jquery/test/data/if_modified_since.php +20 -0
- data/demo/bower_components/jquery/test/data/iframe.html +8 -0
- data/demo/bower_components/jquery/test/data/jquery-1.9.1.ajax_xhr.min.js +5 -0
- data/demo/bower_components/jquery/test/data/json.php +13 -0
- data/demo/bower_components/jquery/test/data/json_obj.js +1 -0
- data/demo/bower_components/jquery/test/data/jsonp.php +14 -0
- data/demo/bower_components/jquery/test/data/manipulation/iframe-denied.html +36 -0
- data/demo/bower_components/jquery/test/data/name.html +1 -0
- data/demo/bower_components/jquery/test/data/name.php +24 -0
- data/demo/bower_components/jquery/test/data/nocontent.php +5 -0
- data/demo/bower_components/jquery/test/data/offset/absolute.html +41 -0
- data/demo/bower_components/jquery/test/data/offset/body.html +26 -0
- data/demo/bower_components/jquery/test/data/offset/fixed.html +34 -0
- data/demo/bower_components/jquery/test/data/offset/relative.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/scroll.html +39 -0
- data/demo/bower_components/jquery/test/data/offset/static.html +31 -0
- data/demo/bower_components/jquery/test/data/offset/table.html +43 -0
- data/demo/bower_components/jquery/test/data/params_html.php +12 -0
- data/demo/bower_components/jquery/test/data/readywaitasset.js +1 -0
- data/demo/bower_components/jquery/test/data/readywaitloader.js +25 -0
- data/demo/bower_components/jquery/test/data/script.php +11 -0
- data/demo/bower_components/jquery/test/data/selector/html5_selector.html +114 -0
- data/demo/bower_components/jquery/test/data/selector/sizzle_cache.html +21 -0
- data/demo/bower_components/jquery/test/data/statusText.php +5 -0
- data/demo/bower_components/jquery/test/data/support/bodyBackground.html +28 -0
- data/demo/bower_components/jquery/test/data/support/boxSizing.html +19 -0
- data/demo/bower_components/jquery/test/data/support/csp.js +3 -0
- data/demo/bower_components/jquery/test/data/support/csp.php +22 -0
- data/demo/bower_components/jquery/test/data/support/shrinkWrapBlocks.html +23 -0
- data/demo/bower_components/jquery/test/data/support/testElementCrash.html +17 -0
- data/demo/bower_components/jquery/test/data/test.html +7 -0
- data/demo/bower_components/jquery/test/data/test.js +3 -0
- data/demo/bower_components/jquery/test/data/test.php +7 -0
- data/demo/bower_components/jquery/test/data/test2.html +5 -0
- data/demo/bower_components/jquery/test/data/test3.html +3 -0
- data/demo/bower_components/jquery/test/data/testinit.js +264 -0
- data/demo/bower_components/jquery/test/data/testrunner.js +371 -0
- data/demo/bower_components/jquery/test/data/testsuite.css +155 -0
- data/demo/bower_components/jquery/test/data/text.php +12 -0
- data/demo/bower_components/jquery/test/data/ua.txt +272 -0
- data/demo/bower_components/jquery/test/data/with_fries.xml +25 -0
- data/demo/bower_components/jquery/test/data/with_fries_over_jsonp.php +7 -0
- data/demo/bower_components/jquery/test/delegatetest.html +228 -0
- data/demo/bower_components/jquery/test/hovertest.html +158 -0
- data/demo/bower_components/jquery/test/index.html +337 -0
- data/demo/bower_components/jquery/test/jquery.js +5 -0
- data/demo/bower_components/jquery/test/localfile.html +75 -0
- data/demo/bower_components/jquery/test/networkerror.html +84 -0
- data/demo/bower_components/jquery/test/readywait.html +70 -0
- data/demo/bower_components/jquery/test/unit/ajax.js +2016 -0
- data/demo/bower_components/jquery/test/unit/attributes.js +1388 -0
- data/demo/bower_components/jquery/test/unit/callbacks.js +342 -0
- data/demo/bower_components/jquery/test/unit/core.js +1360 -0
- data/demo/bower_components/jquery/test/unit/css.js +1056 -0
- data/demo/bower_components/jquery/test/unit/data.js +645 -0
- data/demo/bower_components/jquery/test/unit/deferred.js +436 -0
- data/demo/bower_components/jquery/test/unit/deprecated.js +8 -0
- data/demo/bower_components/jquery/test/unit/dimensions.js +472 -0
- data/demo/bower_components/jquery/test/unit/effects.js +2242 -0
- data/demo/bower_components/jquery/test/unit/event.js +2755 -0
- data/demo/bower_components/jquery/test/unit/exports.js +7 -0
- data/demo/bower_components/jquery/test/unit/manipulation.js +2120 -0
- data/demo/bower_components/jquery/test/unit/offset.js +559 -0
- data/demo/bower_components/jquery/test/unit/queue.js +314 -0
- data/demo/bower_components/jquery/test/unit/selector.js +172 -0
- data/demo/bower_components/jquery/test/unit/serialize.js +148 -0
- data/demo/bower_components/jquery/test/unit/support.js +370 -0
- data/demo/bower_components/jquery/test/unit/traversing.js +797 -0
- data/demo/bower_components/jquery/test/unit/wrap.js +265 -0
- data/demo/bower_components/jquery/test/xhtml.php +5 -0
- data/demo/index.html +347 -0
- data/demo/styles/main.css +208 -0
- data/demo/styles/main.scss +138 -0
- data/docs/docco.css +506 -0
- data/docs/guff.html +1127 -0
- data/docs/public/fonts/aller-bold.eot +0 -0
- data/docs/public/fonts/aller-bold.ttf +0 -0
- data/docs/public/fonts/aller-bold.woff +0 -0
- data/docs/public/fonts/aller-light.eot +0 -0
- data/docs/public/fonts/aller-light.ttf +0 -0
- data/docs/public/fonts/aller-light.woff +0 -0
- data/docs/public/fonts/novecento-bold.eot +0 -0
- data/docs/public/fonts/novecento-bold.ttf +0 -0
- data/docs/public/fonts/novecento-bold.woff +0 -0
- data/docs/public/stylesheets/normalize.css +375 -0
- data/guff.gemspec +16 -0
- data/guff.scss +514 -0
- data/gulpfile.js +67 -0
- data/lib/guff.rb +4 -0
- data/lib/stylesheets/_guff.scss +514 -0
- data/package.json +19 -0
- data/src/_functions.scss +57 -0
- data/src/_mixins.scss +301 -0
- data/src/_reset.scss +67 -0
- data/src/_settings.scss +22 -0
- data/src/_typography.scss +67 -0
- metadata +259 -0
@@ -0,0 +1,2242 @@
|
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
// Can't test what ain't there
|
4
|
+
if ( !jQuery.fx ) {
|
5
|
+
return;
|
6
|
+
}
|
7
|
+
|
8
|
+
var off = jQuery.fx.off;
|
9
|
+
|
10
|
+
module("effects", {
|
11
|
+
teardown: function() {
|
12
|
+
jQuery.fx.off = off;
|
13
|
+
return moduleTeardown.apply( this, arguments );
|
14
|
+
}
|
15
|
+
});
|
16
|
+
|
17
|
+
test("sanity check", function() {
|
18
|
+
expect(1);
|
19
|
+
ok( jQuery("#dl:visible, #qunit-fixture:visible, #foo:visible").length === 3, "QUnit state is correct for testing effects" );
|
20
|
+
});
|
21
|
+
|
22
|
+
test("show() basic", 2, function() {
|
23
|
+
var div,
|
24
|
+
hiddendiv = jQuery("div.hidden");
|
25
|
+
|
26
|
+
hiddendiv.hide().show();
|
27
|
+
|
28
|
+
equal( hiddendiv.css("display"), "block", "Make sure a pre-hidden div is visible." );
|
29
|
+
|
30
|
+
div = jQuery("<div>").hide().appendTo("#qunit-fixture").show();
|
31
|
+
|
32
|
+
equal( div.css("display"), "block", "Make sure pre-hidden divs show" );
|
33
|
+
|
34
|
+
// Clean up the detached node
|
35
|
+
div.remove();
|
36
|
+
|
37
|
+
QUnit.expectJqData(hiddendiv, "olddisplay");
|
38
|
+
});
|
39
|
+
|
40
|
+
test("show()", 27, function () {
|
41
|
+
var div, speeds, old, test,
|
42
|
+
displaysActual, displaysExpected,
|
43
|
+
hiddendiv = jQuery("div.hidden");
|
44
|
+
|
45
|
+
equal(jQuery.css( hiddendiv[0], "display"), "none", "hiddendiv is display: none");
|
46
|
+
|
47
|
+
hiddendiv.css("display", "block");
|
48
|
+
equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
|
49
|
+
|
50
|
+
hiddendiv.show();
|
51
|
+
equal(jQuery.css( hiddendiv[0], "display"), "block", "hiddendiv is display: block");
|
52
|
+
|
53
|
+
hiddendiv.css("display","");
|
54
|
+
|
55
|
+
displaysActual = [];
|
56
|
+
displaysExpected = [];
|
57
|
+
|
58
|
+
div = jQuery("#fx-queue div").slice(0, 4);
|
59
|
+
div.show().each(function() {
|
60
|
+
notEqual(this.style.display, "none", "don't change any <div> with display block");
|
61
|
+
});
|
62
|
+
|
63
|
+
speeds = {
|
64
|
+
"null speed": null,
|
65
|
+
"undefined speed": undefined,
|
66
|
+
"false speed": false
|
67
|
+
};
|
68
|
+
|
69
|
+
jQuery.each(speeds, function(name, speed) {
|
70
|
+
var pass = true;
|
71
|
+
div.hide().show(speed).each(function() {
|
72
|
+
if ( this.style.display === "none" ) {
|
73
|
+
pass = false;
|
74
|
+
}
|
75
|
+
});
|
76
|
+
ok( pass, "Show with " + name);
|
77
|
+
});
|
78
|
+
|
79
|
+
jQuery.each(speeds, function(name, speed) {
|
80
|
+
var pass = true;
|
81
|
+
div.hide().show(speed, function() {
|
82
|
+
pass = false;
|
83
|
+
});
|
84
|
+
ok( pass, "Show with " + name + " does not call animate callback" );
|
85
|
+
});
|
86
|
+
|
87
|
+
// Tolerate data from show()/hide()
|
88
|
+
QUnit.expectJqData(div, "olddisplay");
|
89
|
+
|
90
|
+
// #show-tests * is set display: none in CSS
|
91
|
+
jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
92
|
+
|
93
|
+
old = jQuery("#test-table").show().css("display") !== "table";
|
94
|
+
jQuery("#test-table").remove();
|
95
|
+
|
96
|
+
test = {
|
97
|
+
"div" : "block",
|
98
|
+
"p" : "block",
|
99
|
+
"a" : "inline",
|
100
|
+
"code" : "inline",
|
101
|
+
"pre" : "block",
|
102
|
+
"span" : "inline",
|
103
|
+
"table" : old ? "block" : "table",
|
104
|
+
"thead" : old ? "block" : "table-header-group",
|
105
|
+
"tbody" : old ? "block" : "table-row-group",
|
106
|
+
"tr" : old ? "block" : "table-row",
|
107
|
+
"th" : old ? "block" : "table-cell",
|
108
|
+
"td" : old ? "block" : "table-cell",
|
109
|
+
"ul" : "block",
|
110
|
+
"li" : old ? "block" : "list-item"
|
111
|
+
};
|
112
|
+
|
113
|
+
jQuery.each(test, function(selector, expected) {
|
114
|
+
var elem = jQuery(selector, "#show-tests").show();
|
115
|
+
equal( elem.css("display"), expected, "Show using correct display type for " + selector );
|
116
|
+
});
|
117
|
+
|
118
|
+
jQuery("#show-tests").remove();
|
119
|
+
|
120
|
+
// Make sure that showing or hiding a text node doesn't cause an error
|
121
|
+
jQuery("<div>test</div> text <span>test</span>").show().remove();
|
122
|
+
jQuery("<div>test</div> text <span>test</span>").hide().remove();
|
123
|
+
});
|
124
|
+
|
125
|
+
test("show(Number) - other displays", function() {
|
126
|
+
expect(15);
|
127
|
+
QUnit.reset();
|
128
|
+
stop();
|
129
|
+
|
130
|
+
// #show-tests * is set display: none in CSS
|
131
|
+
jQuery("#qunit-fixture").append("<div id='show-tests'><div><p><a href='#'></a></p><code></code><pre></pre><span></span></div><table><thead><tr><th></th></tr></thead><tbody><tr><td></td></tr></tbody></table><ul><li></li></ul></div><table id='test-table'></table>");
|
132
|
+
|
133
|
+
var test,
|
134
|
+
old = jQuery("#test-table").show().css("display") !== "table",
|
135
|
+
num = 0;
|
136
|
+
jQuery("#test-table").remove();
|
137
|
+
|
138
|
+
test = {
|
139
|
+
"div" : "block",
|
140
|
+
"p" : "block",
|
141
|
+
"a" : "inline",
|
142
|
+
"code" : "inline",
|
143
|
+
"pre" : "block",
|
144
|
+
"span" : "inline",
|
145
|
+
"table" : old ? "block" : "table",
|
146
|
+
"thead" : old ? "block" : "table-header-group",
|
147
|
+
"tbody" : old ? "block" : "table-row-group",
|
148
|
+
"tr" : old ? "block" : "table-row",
|
149
|
+
"th" : old ? "block" : "table-cell",
|
150
|
+
"td" : old ? "block" : "table-cell",
|
151
|
+
"ul" : "block",
|
152
|
+
"li" : old ? "block" : "list-item"
|
153
|
+
};
|
154
|
+
|
155
|
+
jQuery.each(test, function(selector, expected) {
|
156
|
+
var elem = jQuery(selector, "#show-tests").show(1, function() {
|
157
|
+
equal( elem.css("display"), expected, "Show using correct display type for " + selector );
|
158
|
+
if ( ++num === 15 ) {
|
159
|
+
start();
|
160
|
+
}
|
161
|
+
});
|
162
|
+
});
|
163
|
+
|
164
|
+
jQuery("#show-tests").remove();
|
165
|
+
});
|
166
|
+
|
167
|
+
// Supports #7397
|
168
|
+
test("Persist correct display value", function() {
|
169
|
+
expect(3);
|
170
|
+
QUnit.reset();
|
171
|
+
stop();
|
172
|
+
|
173
|
+
// #show-tests * is set display: none in CSS
|
174
|
+
jQuery("#qunit-fixture").append("<div id='show-tests'><span style='position:absolute;'>foo</span></div>");
|
175
|
+
|
176
|
+
var $span = jQuery("#show-tests span"),
|
177
|
+
displayNone = $span.css("display"),
|
178
|
+
display = "";
|
179
|
+
|
180
|
+
$span.show();
|
181
|
+
|
182
|
+
display = $span.css("display");
|
183
|
+
|
184
|
+
$span.hide();
|
185
|
+
|
186
|
+
$span.fadeIn(100, function() {
|
187
|
+
equal($span.css("display"), display, "Expecting display: " + display);
|
188
|
+
$span.fadeOut(100, function () {
|
189
|
+
equal($span.css("display"), displayNone, "Expecting display: " + displayNone);
|
190
|
+
$span.fadeIn(100, function() {
|
191
|
+
equal($span.css("display"), display, "Expecting display: " + display);
|
192
|
+
start();
|
193
|
+
});
|
194
|
+
});
|
195
|
+
});
|
196
|
+
|
197
|
+
QUnit.expectJqData($span, "olddisplay");
|
198
|
+
});
|
199
|
+
|
200
|
+
test("animate(Hash, Object, Function)", function() {
|
201
|
+
expect(1);
|
202
|
+
stop();
|
203
|
+
var hash = {opacity: "show"},
|
204
|
+
hashCopy = jQuery.extend({}, hash);
|
205
|
+
jQuery("#foo").animate(hash, 0, function() {
|
206
|
+
equal( hash.opacity, hashCopy.opacity, "Check if animate changed the hash parameter" );
|
207
|
+
start();
|
208
|
+
});
|
209
|
+
});
|
210
|
+
|
211
|
+
test("animate relative values", function() {
|
212
|
+
stop();
|
213
|
+
|
214
|
+
var value = 40,
|
215
|
+
bases = [ "%", "px", "em" ],
|
216
|
+
adjustments = [ "px", "em" ],
|
217
|
+
container = jQuery("<div></div>")
|
218
|
+
.css({ position: "absolute", height: "50em", width: "50em" }),
|
219
|
+
animations = bases.length * adjustments.length;
|
220
|
+
|
221
|
+
expect( 2 * animations );
|
222
|
+
|
223
|
+
jQuery.each( bases, function( _, baseUnit ) {
|
224
|
+
jQuery.each( adjustments, function( _, adjustUnit ) {
|
225
|
+
var base = value + baseUnit,
|
226
|
+
adjust = { height: "+=2" + adjustUnit, width: "-=2" + adjustUnit },
|
227
|
+
elem = jQuery("<div></div>")
|
228
|
+
.appendTo( container.clone().appendTo("#qunit-fixture") )
|
229
|
+
.css({
|
230
|
+
position: "absolute",
|
231
|
+
height: base,
|
232
|
+
width: value + adjustUnit
|
233
|
+
}),
|
234
|
+
baseScale = elem[ 0 ].offsetHeight / value,
|
235
|
+
adjustScale = elem[ 0 ].offsetWidth / value;
|
236
|
+
|
237
|
+
elem.css( "width", base ).animate( adjust, 100, function() {
|
238
|
+
equal( this.offsetHeight, value * baseScale + 2 * adjustScale,
|
239
|
+
baseUnit + "+=" + adjustUnit );
|
240
|
+
equal( this.offsetWidth, value * baseScale - 2 * adjustScale,
|
241
|
+
baseUnit + "-=" + adjustUnit );
|
242
|
+
|
243
|
+
if ( --animations === 0 ) {
|
244
|
+
start();
|
245
|
+
}
|
246
|
+
});
|
247
|
+
});
|
248
|
+
});
|
249
|
+
});
|
250
|
+
|
251
|
+
test("animate negative height", function() {
|
252
|
+
expect(1);
|
253
|
+
stop();
|
254
|
+
jQuery("#foo").animate({ height: -100 }, 100, function() {
|
255
|
+
equal( this.offsetHeight, 0, "Verify height." );
|
256
|
+
start();
|
257
|
+
});
|
258
|
+
});
|
259
|
+
|
260
|
+
test("animate negative margin", function() {
|
261
|
+
expect(1);
|
262
|
+
stop();
|
263
|
+
jQuery("#foo").animate({ "marginTop": -100 }, 100, function() {
|
264
|
+
equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
|
265
|
+
start();
|
266
|
+
});
|
267
|
+
});
|
268
|
+
|
269
|
+
test("animate negative margin with px", function() {
|
270
|
+
expect(1);
|
271
|
+
stop();
|
272
|
+
jQuery("#foo").animate({ marginTop: "-100px" }, 100, function() {
|
273
|
+
equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
|
274
|
+
start();
|
275
|
+
});
|
276
|
+
});
|
277
|
+
|
278
|
+
test("animate negative padding", function() {
|
279
|
+
expect(1);
|
280
|
+
stop();
|
281
|
+
jQuery("#foo").animate({ "paddingBottom": -100 }, 100, function() {
|
282
|
+
equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
|
283
|
+
start();
|
284
|
+
});
|
285
|
+
});
|
286
|
+
|
287
|
+
test("animate block as inline width/height", function() {
|
288
|
+
expect(3);
|
289
|
+
|
290
|
+
var span = jQuery("<span>").css("display", "inline-block").appendTo("body"),
|
291
|
+
expected = span.css("display");
|
292
|
+
|
293
|
+
span.remove();
|
294
|
+
|
295
|
+
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
|
296
|
+
stop();
|
297
|
+
|
298
|
+
jQuery("#foo").css({ display: "inline", width: "", height: "" }).animate({ width: 42, height: 42 }, 100, function() {
|
299
|
+
equal( jQuery(this).css("display"), jQuery.support.inlineBlockNeedsLayout ? "inline" : "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
300
|
+
equal( this.offsetWidth, 42, "width was animated" );
|
301
|
+
equal( this.offsetHeight, 42, "height was animated" );
|
302
|
+
start();
|
303
|
+
});
|
304
|
+
|
305
|
+
// Browser doesn't support inline-block
|
306
|
+
} else {
|
307
|
+
ok( true, "Browser doesn't support inline-block" );
|
308
|
+
ok( true, "Browser doesn't support inline-block" );
|
309
|
+
ok( true, "Browser doesn't support inline-block" );
|
310
|
+
}
|
311
|
+
});
|
312
|
+
|
313
|
+
test("animate native inline width/height", function() {
|
314
|
+
expect(3);
|
315
|
+
|
316
|
+
var span = jQuery("<span>").css("display", "inline-block").appendTo("body"),
|
317
|
+
expected = span.css("display");
|
318
|
+
|
319
|
+
span.remove();
|
320
|
+
|
321
|
+
if ( jQuery.support.inlineBlockNeedsLayout || expected === "inline-block" ) {
|
322
|
+
stop();
|
323
|
+
jQuery("#foo").css({ display: "", width: "", height: "" })
|
324
|
+
.append("<span>text</span>")
|
325
|
+
.children("span")
|
326
|
+
.animate({ width: 42, height: 42 }, 100, function() {
|
327
|
+
equal( jQuery(this).css("display"), "inline-block", "inline-block was set on non-floated inline element when animating width/height" );
|
328
|
+
equal( this.offsetWidth, 42, "width was animated" );
|
329
|
+
equal( this.offsetHeight, 42, "height was animated" );
|
330
|
+
start();
|
331
|
+
});
|
332
|
+
|
333
|
+
// Browser doesn't support inline-block
|
334
|
+
} else {
|
335
|
+
ok( true, "Browser doesn't support inline-block" );
|
336
|
+
ok( true, "Browser doesn't support inline-block" );
|
337
|
+
ok( true, "Browser doesn't support inline-block" );
|
338
|
+
}
|
339
|
+
});
|
340
|
+
|
341
|
+
test( "animate block width/height", function() {
|
342
|
+
expect( 3 );
|
343
|
+
stop();
|
344
|
+
|
345
|
+
jQuery("<div>").appendTo("#qunit-fixture").css({
|
346
|
+
display: "block",
|
347
|
+
width: 20,
|
348
|
+
height: 20,
|
349
|
+
paddingLeft: 60
|
350
|
+
}).animate({
|
351
|
+
width: 42,
|
352
|
+
height: 42
|
353
|
+
}, {
|
354
|
+
duration: 100,
|
355
|
+
step: function() {
|
356
|
+
if ( jQuery( this ).width() > 42 ) {
|
357
|
+
ok( false, "width was incorrectly augmented during animation" );
|
358
|
+
}
|
359
|
+
},
|
360
|
+
complete: function() {
|
361
|
+
equal( jQuery( this ).css("display"), "block", "inline-block was not set on block element when animating width/height" );
|
362
|
+
equal( jQuery( this ).width(), 42, "width was animated" );
|
363
|
+
equal( jQuery( this ).height(), 42, "height was animated" );
|
364
|
+
start();
|
365
|
+
}
|
366
|
+
});
|
367
|
+
});
|
368
|
+
|
369
|
+
test("animate table width/height", function() {
|
370
|
+
expect(1);
|
371
|
+
stop();
|
372
|
+
|
373
|
+
var displayMode = jQuery("#table").css("display") !== "table" ? "block" : "table";
|
374
|
+
|
375
|
+
jQuery("#table").animate({ width: 42, height: 42 }, 100, function() {
|
376
|
+
equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
|
377
|
+
start();
|
378
|
+
});
|
379
|
+
});
|
380
|
+
|
381
|
+
test("animate table-row width/height", function() {
|
382
|
+
expect(3);
|
383
|
+
stop();
|
384
|
+
var displayMode,
|
385
|
+
tr = jQuery("#table")
|
386
|
+
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
|
387
|
+
.html("<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
|
388
|
+
.find("tr");
|
389
|
+
|
390
|
+
// IE<8 uses "block" instead of the correct display type
|
391
|
+
displayMode = tr.css("display") !== "table-row" ? "block" : "table-row";
|
392
|
+
|
393
|
+
tr.animate({ width: 10, height: 10 }, 100, function() {
|
394
|
+
equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
|
395
|
+
equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
|
396
|
+
equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
|
397
|
+
start();
|
398
|
+
});
|
399
|
+
});
|
400
|
+
|
401
|
+
test("animate table-cell width/height", function() {
|
402
|
+
expect(3);
|
403
|
+
stop();
|
404
|
+
var displayMode,
|
405
|
+
td = jQuery("#table")
|
406
|
+
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
|
407
|
+
.html("<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
|
408
|
+
.find("td");
|
409
|
+
|
410
|
+
// IE<8 uses "block" instead of the correct display type
|
411
|
+
displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell";
|
412
|
+
|
413
|
+
td.animate({ width: 10, height: 10 }, 100, function() {
|
414
|
+
equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
|
415
|
+
equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
|
416
|
+
equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
|
417
|
+
start();
|
418
|
+
});
|
419
|
+
});
|
420
|
+
|
421
|
+
test("animate percentage(%) on width/height", function() {
|
422
|
+
expect( 2 );
|
423
|
+
|
424
|
+
var $div = jQuery("<div style='position:absolute;top:-999px;left:-999px;width:60px;height:60px;'><div style='width:50%;height:50%;'></div></div>")
|
425
|
+
.appendTo("#qunit-fixture").children("div");
|
426
|
+
|
427
|
+
stop();
|
428
|
+
$div.animate({ width: "25%", height: "25%" }, 13, function() {
|
429
|
+
var $this = jQuery(this);
|
430
|
+
equal( $this.css("width"), "15px", "Width was animated to 15px rather than 25px");
|
431
|
+
equal( $this.css("height"), "15px", "Height was animated to 15px rather than 25px");
|
432
|
+
start();
|
433
|
+
});
|
434
|
+
});
|
435
|
+
|
436
|
+
test("animate resets overflow-x and overflow-y when finished", function() {
|
437
|
+
expect(2);
|
438
|
+
stop();
|
439
|
+
jQuery("#foo")
|
440
|
+
.css({ display: "block", width: 20, height: 20, overflowX: "visible", overflowY: "auto" })
|
441
|
+
.animate({ width: 42, height: 42 }, 100, function() {
|
442
|
+
equal( this.style.overflowX, "visible", "overflow-x is visible" );
|
443
|
+
equal( this.style.overflowY, "auto", "overflow-y is auto" );
|
444
|
+
start();
|
445
|
+
});
|
446
|
+
});
|
447
|
+
|
448
|
+
/* // This test ends up being flaky depending upon the CPU load
|
449
|
+
test("animate option (queue === false)", function () {
|
450
|
+
expect(1);
|
451
|
+
stop();
|
452
|
+
|
453
|
+
var order = [];
|
454
|
+
|
455
|
+
var $foo = jQuery("#foo");
|
456
|
+
$foo.animate({width:"100px"}, 3000, function () {
|
457
|
+
// should finish after unqueued animation so second
|
458
|
+
order.push(2);
|
459
|
+
deepEqual( order, [ 1, 2 ], "Animations finished in the correct order" );
|
460
|
+
start();
|
461
|
+
});
|
462
|
+
$foo.animate({fontSize:"2em"}, {queue:false, duration:10, complete:function () {
|
463
|
+
// short duration and out of queue so should finish first
|
464
|
+
order.push(1);
|
465
|
+
}});
|
466
|
+
});
|
467
|
+
*/
|
468
|
+
|
469
|
+
asyncTest( "animate option { queue: false }", function() {
|
470
|
+
expect( 2 );
|
471
|
+
var foo = jQuery( "#foo" );
|
472
|
+
|
473
|
+
foo.animate({
|
474
|
+
fontSize: "2em"
|
475
|
+
}, {
|
476
|
+
queue: false,
|
477
|
+
duration: 10,
|
478
|
+
complete: function() {
|
479
|
+
ok( true, "Animation Completed" );
|
480
|
+
start();
|
481
|
+
}
|
482
|
+
});
|
483
|
+
|
484
|
+
equal( foo.queue().length, 0, "Queue is empty" );
|
485
|
+
});
|
486
|
+
|
487
|
+
asyncTest( "animate option { queue: true }", function() {
|
488
|
+
expect( 2 );
|
489
|
+
var foo = jQuery( "#foo" );
|
490
|
+
|
491
|
+
foo.animate({
|
492
|
+
fontSize: "2em"
|
493
|
+
}, {
|
494
|
+
queue: true,
|
495
|
+
duration: 10,
|
496
|
+
complete: function() {
|
497
|
+
ok( true, "Animation Completed" );
|
498
|
+
start();
|
499
|
+
}
|
500
|
+
});
|
501
|
+
|
502
|
+
notEqual( foo.queue().length, 0, "Default queue is not empty" );
|
503
|
+
});
|
504
|
+
|
505
|
+
asyncTest( "animate option { queue: 'name' }", function() {
|
506
|
+
expect( 5 );
|
507
|
+
var foo = jQuery( "#foo" ),
|
508
|
+
origWidth = parseFloat( foo.css("width") ),
|
509
|
+
order = [];
|
510
|
+
|
511
|
+
foo.animate( { width: origWidth + 100 }, {
|
512
|
+
queue: "name",
|
513
|
+
duration: 1,
|
514
|
+
complete: function() {
|
515
|
+
|
516
|
+
// second callback function
|
517
|
+
order.push( 2 );
|
518
|
+
equal( parseFloat( foo.css("width") ), origWidth + 100, "Animation ended" );
|
519
|
+
equal( foo.queue("name").length, 1, "Queue length of 'name' queue" );
|
520
|
+
}
|
521
|
+
}).queue( "name", function() {
|
522
|
+
|
523
|
+
// last callback function
|
524
|
+
deepEqual( order, [ 1, 2 ], "Callbacks in expected order" );
|
525
|
+
start();
|
526
|
+
});
|
527
|
+
|
528
|
+
setTimeout( function() {
|
529
|
+
|
530
|
+
// this is the first callback function that should be called
|
531
|
+
order.push( 1 );
|
532
|
+
equal( parseFloat( foo.css("width") ), origWidth, "Animation does not start on its own." );
|
533
|
+
equal( foo.queue("name").length, 2, "Queue length of 'name' queue" );
|
534
|
+
foo.dequeue( "name" );
|
535
|
+
}, 100 );
|
536
|
+
|
537
|
+
});
|
538
|
+
|
539
|
+
test("animate with no properties", function() {
|
540
|
+
expect(2);
|
541
|
+
|
542
|
+
var foo,
|
543
|
+
divs = jQuery("div"),
|
544
|
+
count = 0;
|
545
|
+
|
546
|
+
divs.animate({}, function(){
|
547
|
+
count++;
|
548
|
+
});
|
549
|
+
|
550
|
+
equal( divs.length, count, "Make sure that callback is called for each element in the set." );
|
551
|
+
|
552
|
+
stop();
|
553
|
+
|
554
|
+
foo = jQuery("#foo");
|
555
|
+
|
556
|
+
foo.animate({});
|
557
|
+
foo.animate({top: 10}, 100, function(){
|
558
|
+
ok( true, "Animation was properly dequeued." );
|
559
|
+
start();
|
560
|
+
});
|
561
|
+
});
|
562
|
+
|
563
|
+
test("animate duration 0", function() {
|
564
|
+
expect(11);
|
565
|
+
|
566
|
+
stop();
|
567
|
+
|
568
|
+
var $elem,
|
569
|
+
$elems = jQuery([{ a:0 },{ a:0 }]),
|
570
|
+
counter = 0;
|
571
|
+
|
572
|
+
equal( jQuery.timers.length, 0, "Make sure no animation was running from another test" );
|
573
|
+
|
574
|
+
$elems.eq(0).animate( {a:1}, 0, function(){
|
575
|
+
ok( true, "Animate a simple property." );
|
576
|
+
counter++;
|
577
|
+
});
|
578
|
+
|
579
|
+
// Failed until [6115]
|
580
|
+
equal( jQuery.timers.length, 0, "Make sure synchronic animations are not left on jQuery.timers" );
|
581
|
+
|
582
|
+
equal( counter, 1, "One synchronic animations" );
|
583
|
+
|
584
|
+
$elems.animate( { a:2 }, 0, function(){
|
585
|
+
ok( true, "Animate a second simple property." );
|
586
|
+
counter++;
|
587
|
+
});
|
588
|
+
|
589
|
+
equal( counter, 3, "Multiple synchronic animations" );
|
590
|
+
|
591
|
+
$elems.eq(0).animate( {a:3}, 0, function(){
|
592
|
+
ok( true, "Animate a third simple property." );
|
593
|
+
counter++;
|
594
|
+
});
|
595
|
+
$elems.eq(1).animate( {a:3}, 200, function(){
|
596
|
+
counter++;
|
597
|
+
// Failed until [6115]
|
598
|
+
equal( counter, 5, "One synchronic and one asynchronic" );
|
599
|
+
start();
|
600
|
+
});
|
601
|
+
|
602
|
+
$elem = jQuery("<div />");
|
603
|
+
$elem.show(0, function(){
|
604
|
+
ok(true, "Show callback with no duration");
|
605
|
+
});
|
606
|
+
$elem.hide(0, function(){
|
607
|
+
ok(true, "Hide callback with no duration");
|
608
|
+
});
|
609
|
+
|
610
|
+
// manually clean up detached elements
|
611
|
+
$elem.remove();
|
612
|
+
});
|
613
|
+
|
614
|
+
test("animate hyphenated properties", function() {
|
615
|
+
expect(1);
|
616
|
+
stop();
|
617
|
+
|
618
|
+
jQuery("#foo")
|
619
|
+
.css("font-size", 10)
|
620
|
+
.animate({"font-size": 20}, 200, function() {
|
621
|
+
equal( this.style.fontSize, "20px", "The font-size property was animated." );
|
622
|
+
start();
|
623
|
+
});
|
624
|
+
});
|
625
|
+
|
626
|
+
test("animate non-element", function() {
|
627
|
+
expect(1);
|
628
|
+
stop();
|
629
|
+
|
630
|
+
var obj = { test: 0 };
|
631
|
+
|
632
|
+
jQuery(obj).animate({test: 200}, 200, function(){
|
633
|
+
equal( obj.test, 200, "The custom property should be modified." );
|
634
|
+
start();
|
635
|
+
});
|
636
|
+
});
|
637
|
+
|
638
|
+
test("stop()", function() {
|
639
|
+
expect( 4 );
|
640
|
+
stop();
|
641
|
+
|
642
|
+
var $one, $two,
|
643
|
+
$foo = jQuery("#foo"),
|
644
|
+
tests = 2,
|
645
|
+
w = 0;
|
646
|
+
|
647
|
+
$foo.hide().css( "width", 200 )
|
648
|
+
.animate( { "width": "show" }, 1500 );
|
649
|
+
|
650
|
+
setTimeout(function() {
|
651
|
+
var nw = $foo.css("width");
|
652
|
+
notEqual( parseFloat( nw ), w, "An animation occurred " + nw + " " + w + "px" );
|
653
|
+
$foo.stop();
|
654
|
+
|
655
|
+
nw = $foo.css("width");
|
656
|
+
notEqual( parseFloat( nw ), w, "Stop didn't reset the animation " + nw + " " + w + "px" );
|
657
|
+
setTimeout(function() {
|
658
|
+
$foo.removeData();
|
659
|
+
$foo.removeData(undefined, true);
|
660
|
+
equal( nw, $foo.css("width"), "The animation didn't continue" );
|
661
|
+
if ( --tests === 0 ) {
|
662
|
+
start();
|
663
|
+
}
|
664
|
+
}, 100);
|
665
|
+
}, 100);
|
666
|
+
|
667
|
+
$one = jQuery("#fadein");
|
668
|
+
$two = jQuery("#show");
|
669
|
+
$one.fadeTo(100, 0, function() {
|
670
|
+
$one.stop();
|
671
|
+
});
|
672
|
+
setTimeout(function() {
|
673
|
+
$two.fadeTo(100, 0, function() {
|
674
|
+
equal( $two.css("opacity"), "0", "Stop does not interfere with animations on other elements (#6641)" );
|
675
|
+
// Reset styles
|
676
|
+
$one.add( $two ).css("opacity", "");
|
677
|
+
if ( --tests === 0 ) {
|
678
|
+
start();
|
679
|
+
}
|
680
|
+
});
|
681
|
+
}, 50);
|
682
|
+
});
|
683
|
+
|
684
|
+
test("stop() - several in queue", function() {
|
685
|
+
expect( 5 );
|
686
|
+
|
687
|
+
var nw, time,
|
688
|
+
$foo = jQuery( "#foo" );
|
689
|
+
|
690
|
+
// default duration is 400ms, so 800px ensures we aren't 0 or 1 after 1ms
|
691
|
+
$foo.hide().css( "width", 800 );
|
692
|
+
|
693
|
+
$foo.animate({ "width": "show" }, 400, "linear");
|
694
|
+
$foo.animate({ "width": "hide" });
|
695
|
+
$foo.animate({ "width": "show" });
|
696
|
+
|
697
|
+
// could be replaced by something nicer using sinon.
|
698
|
+
time = jQuery.now();
|
699
|
+
while( time === jQuery.now() ) {}
|
700
|
+
|
701
|
+
jQuery.fx.tick();
|
702
|
+
equal( $foo.queue().length, 3, "3 in the queue" );
|
703
|
+
|
704
|
+
nw = $foo.css( "width" );
|
705
|
+
notEqual( parseFloat( nw ), 1, "An animation occurred " + nw );
|
706
|
+
$foo.stop();
|
707
|
+
|
708
|
+
equal( $foo.queue().length, 2, "2 in the queue" );
|
709
|
+
nw = $foo.css( "width" );
|
710
|
+
notEqual( parseFloat( nw ), 1, "Stop didn't reset the animation " + nw );
|
711
|
+
|
712
|
+
$foo.stop( true );
|
713
|
+
|
714
|
+
equal( $foo.queue().length, 0, "0 in the queue" );
|
715
|
+
});
|
716
|
+
|
717
|
+
test("stop(clearQueue)", function() {
|
718
|
+
expect(4);
|
719
|
+
stop();
|
720
|
+
|
721
|
+
var $foo = jQuery("#foo"),
|
722
|
+
w = 0;
|
723
|
+
$foo.hide().css( "width", 200 ).css("width");
|
724
|
+
|
725
|
+
$foo.animate({ "width": "show" }, 1000);
|
726
|
+
$foo.animate({ "width": "hide" }, 1000);
|
727
|
+
$foo.animate({ "width": "show" }, 1000);
|
728
|
+
setTimeout(function(){
|
729
|
+
var nw = $foo.css("width");
|
730
|
+
ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px");
|
731
|
+
$foo.stop(true);
|
732
|
+
|
733
|
+
nw = $foo.css("width");
|
734
|
+
ok( parseFloat( nw ) !== w, "Stop didn't reset the animation " + nw + " " + w + "px");
|
735
|
+
|
736
|
+
equal( $foo.queue().length, 0, "The animation queue was cleared" );
|
737
|
+
setTimeout(function(){
|
738
|
+
equal( nw, $foo.css("width"), "The animation didn't continue" );
|
739
|
+
start();
|
740
|
+
}, 100);
|
741
|
+
}, 100);
|
742
|
+
});
|
743
|
+
|
744
|
+
test("stop(clearQueue, gotoEnd)", function() {
|
745
|
+
expect(1);
|
746
|
+
stop();
|
747
|
+
|
748
|
+
var $foo = jQuery("#foo"),
|
749
|
+
w = 0;
|
750
|
+
$foo.hide().css( "width", 200 ).css("width");
|
751
|
+
|
752
|
+
$foo.animate({ width: "show" }, 1000);
|
753
|
+
$foo.animate({ width: "hide" }, 1000);
|
754
|
+
$foo.animate({ width: "show" }, 1000);
|
755
|
+
$foo.animate({ width: "hide" }, 1000);
|
756
|
+
setTimeout(function(){
|
757
|
+
var nw = $foo.css("width");
|
758
|
+
ok( parseFloat( nw ) !== w, "An animation occurred " + nw + " " + w + "px");
|
759
|
+
$foo.stop(false, true);
|
760
|
+
|
761
|
+
nw = $foo.css("width");
|
762
|
+
// Disabled, being flaky
|
763
|
+
//equal( nw, 1, "Stop() reset the animation" );
|
764
|
+
|
765
|
+
setTimeout(function(){
|
766
|
+
// Disabled, being flaky
|
767
|
+
//equal( $foo.queue().length, 2, "The next animation continued" );
|
768
|
+
$foo.stop(true);
|
769
|
+
start();
|
770
|
+
}, 100);
|
771
|
+
}, 100);
|
772
|
+
});
|
773
|
+
|
774
|
+
asyncTest( "stop( queue, ..., ... ) - Stop single queues", function() {
|
775
|
+
expect( 3 );
|
776
|
+
var saved,
|
777
|
+
foo = jQuery("#foo").css({ width: 200, height: 200 });
|
778
|
+
|
779
|
+
foo.animate({
|
780
|
+
width: 400
|
781
|
+
},{
|
782
|
+
duration: 500,
|
783
|
+
complete: function() {
|
784
|
+
equal( parseFloat( foo.css("width") ), 400, "Animation completed for standard queue" );
|
785
|
+
equal( parseFloat( foo.css("height") ), saved, "Height was not changed after the second stop");
|
786
|
+
start();
|
787
|
+
}
|
788
|
+
});
|
789
|
+
|
790
|
+
foo.animate({
|
791
|
+
height: 400
|
792
|
+
},{
|
793
|
+
duration: 1000,
|
794
|
+
queue: "height"
|
795
|
+
}).dequeue("height").stop( "height", false, true );
|
796
|
+
|
797
|
+
equal( parseFloat( foo.css("height") ), 400, "Height was stopped with gotoEnd" );
|
798
|
+
|
799
|
+
foo.animate({
|
800
|
+
height: 200
|
801
|
+
},{
|
802
|
+
duration: 1000,
|
803
|
+
queue: "height"
|
804
|
+
}).dequeue( "height" ).stop( "height", false, false );
|
805
|
+
saved = parseFloat( foo.css("height") );
|
806
|
+
});
|
807
|
+
|
808
|
+
test("toggle()", function() {
|
809
|
+
expect(6);
|
810
|
+
var x = jQuery("#foo");
|
811
|
+
ok( x.is(":visible"), "is visible" );
|
812
|
+
x.toggle();
|
813
|
+
ok( x.is(":hidden"), "is hidden" );
|
814
|
+
x.toggle();
|
815
|
+
ok( x.is(":visible"), "is visible again" );
|
816
|
+
|
817
|
+
x.toggle(true);
|
818
|
+
ok( x.is(":visible"), "is visible" );
|
819
|
+
x.toggle(false);
|
820
|
+
ok( x.is(":hidden"), "is hidden" );
|
821
|
+
x.toggle(true);
|
822
|
+
ok( x.is(":visible"), "is visible again" );
|
823
|
+
});
|
824
|
+
|
825
|
+
test( "jQuery.fx.prototype.cur() - <1.8 Back Compat", 7, function() {
|
826
|
+
var div = jQuery( "<div></div>" ).appendTo( "#qunit-fixture" ).css({
|
827
|
+
color: "#ABC",
|
828
|
+
border: "5px solid black",
|
829
|
+
left: "auto",
|
830
|
+
marginBottom: "-11000px"
|
831
|
+
})[0];
|
832
|
+
|
833
|
+
equal(
|
834
|
+
( new jQuery.fx( div, {}, "color" ) ).cur(),
|
835
|
+
jQuery.css( div, "color" ),
|
836
|
+
"Return the same value as jQuery.css for complex properties (bug #7912)"
|
837
|
+
);
|
838
|
+
|
839
|
+
strictEqual(
|
840
|
+
( new jQuery.fx( div, {}, "borderLeftWidth" ) ).cur(),
|
841
|
+
5,
|
842
|
+
"Return simple values parsed as Float"
|
843
|
+
);
|
844
|
+
|
845
|
+
// backgroundPosition actually returns 0% 0% in most browser
|
846
|
+
// this fakes a "" return
|
847
|
+
// hook now gets called twice because Tween will grab the current
|
848
|
+
// value as it is being newed
|
849
|
+
jQuery.cssHooks.backgroundPosition = {
|
850
|
+
get: function() {
|
851
|
+
ok( true, "hook used" );
|
852
|
+
return "";
|
853
|
+
}
|
854
|
+
};
|
855
|
+
|
856
|
+
strictEqual(
|
857
|
+
( new jQuery.fx( div, {}, "backgroundPosition" ) ).cur(),
|
858
|
+
0,
|
859
|
+
"Return 0 when jQuery.css returns an empty string"
|
860
|
+
);
|
861
|
+
|
862
|
+
delete jQuery.cssHooks.backgroundPosition;
|
863
|
+
|
864
|
+
strictEqual(
|
865
|
+
( new jQuery.fx( div, {}, "left" ) ).cur(),
|
866
|
+
0,
|
867
|
+
"Return 0 when jQuery.css returns 'auto'"
|
868
|
+
);
|
869
|
+
|
870
|
+
equal(
|
871
|
+
( new jQuery.fx( div, {}, "marginBottom" ) ).cur(),
|
872
|
+
-11000,
|
873
|
+
"support negative values < -10000 (bug #7193)"
|
874
|
+
);
|
875
|
+
|
876
|
+
jQuery( div ).remove();
|
877
|
+
});
|
878
|
+
|
879
|
+
test("Overflow and Display", function() {
|
880
|
+
expect(4);
|
881
|
+
stop();
|
882
|
+
|
883
|
+
var
|
884
|
+
testClass = jQuery.makeTest("Overflow and Display")
|
885
|
+
.addClass("overflow inline"),
|
886
|
+
testStyle = jQuery.makeTest("Overflow and Display (inline style)")
|
887
|
+
.css({ overflow: "visible", display: "inline" }),
|
888
|
+
remaining = 2,
|
889
|
+
done = function() {
|
890
|
+
equal( jQuery.css( this, "overflow" ), "visible", "Overflow should be 'visible'" );
|
891
|
+
equal( jQuery.css( this, "display" ), "inline", "Display should be 'inline'" );
|
892
|
+
|
893
|
+
if ( --remaining === 0 ) {
|
894
|
+
start();
|
895
|
+
}
|
896
|
+
};
|
897
|
+
|
898
|
+
testClass.add( testStyle )
|
899
|
+
.addClass("widewidth")
|
900
|
+
.text("Some sample text.")
|
901
|
+
.before("text before")
|
902
|
+
.after("text after")
|
903
|
+
.animate({ opacity: 0.5 }, "slow", done );
|
904
|
+
});
|
905
|
+
|
906
|
+
jQuery.each({
|
907
|
+
"CSS Auto": function( elem, prop ) {
|
908
|
+
jQuery( elem ).addClass( "auto" + prop )
|
909
|
+
.text( "This is a long string of text." );
|
910
|
+
return "";
|
911
|
+
},
|
912
|
+
"JS Auto": function( elem, prop ) {
|
913
|
+
jQuery( elem ).css( prop, "" )
|
914
|
+
.text( "This is a long string of text." );
|
915
|
+
return "";
|
916
|
+
},
|
917
|
+
"CSS 100": function( elem, prop ) {
|
918
|
+
jQuery( elem ).addClass( "large" + prop );
|
919
|
+
return "";
|
920
|
+
},
|
921
|
+
"JS 100": function( elem, prop ) {
|
922
|
+
jQuery( elem ).css( prop, prop === "opacity" ? 1 : "100px" );
|
923
|
+
return prop === "opacity" ? 1 : 100;
|
924
|
+
},
|
925
|
+
"CSS 50": function( elem, prop ) {
|
926
|
+
jQuery( elem ).addClass( "med" + prop );
|
927
|
+
return "";
|
928
|
+
},
|
929
|
+
"JS 50": function( elem, prop ) {
|
930
|
+
jQuery( elem ).css( prop, prop === "opacity" ? 0.50 : "50px" );
|
931
|
+
return prop === "opacity" ? 0.5 : 50;
|
932
|
+
},
|
933
|
+
"CSS 0": function( elem, prop ) {
|
934
|
+
jQuery( elem ).addClass( "no" + prop );
|
935
|
+
return "";
|
936
|
+
},
|
937
|
+
"JS 0": function( elem, prop ) {
|
938
|
+
jQuery( elem ).css( prop, prop === "opacity" ? 0 : "0px" );
|
939
|
+
return 0;
|
940
|
+
}
|
941
|
+
}, function( fn, f ) {
|
942
|
+
jQuery.each({
|
943
|
+
"show": function( elem, prop ) {
|
944
|
+
jQuery( elem ).hide( ).addClass( "wide" + prop );
|
945
|
+
return "show";
|
946
|
+
},
|
947
|
+
"hide": function( elem, prop ) {
|
948
|
+
jQuery( elem ).addClass( "wide" + prop );
|
949
|
+
return "hide";
|
950
|
+
},
|
951
|
+
"100": function( elem, prop ) {
|
952
|
+
jQuery( elem ).addClass( "wide" + prop );
|
953
|
+
return prop === "opacity" ? 1 : 100;
|
954
|
+
},
|
955
|
+
"50": function( elem, prop ) {
|
956
|
+
return prop === "opacity" ? 0.50 : 50;
|
957
|
+
},
|
958
|
+
"0": function( elem ) {
|
959
|
+
jQuery( elem ).addClass( "noback" );
|
960
|
+
return 0;
|
961
|
+
}
|
962
|
+
}, function( tn, t ) {
|
963
|
+
test(fn + " to " + tn, function() {
|
964
|
+
var num, anim,
|
965
|
+
elem = jQuery.makeTest( fn + " to " + tn ),
|
966
|
+
t_w = t( elem, "width" ),
|
967
|
+
f_w = f( elem, "width" ),
|
968
|
+
t_h = t( elem, "height" ),
|
969
|
+
f_h = f( elem, "height" ),
|
970
|
+
t_o = t( elem, "opacity" ),
|
971
|
+
f_o = f( elem, "opacity" );
|
972
|
+
|
973
|
+
if ( f_o === "" ) {
|
974
|
+
f_o = 1;
|
975
|
+
}
|
976
|
+
|
977
|
+
num = 0;
|
978
|
+
// TODO: uncrowd this
|
979
|
+
if ( t_h === "show" ) {num++;}
|
980
|
+
if ( t_w === "show" ) {num++;}
|
981
|
+
if ( t_w === "hide" || t_w === "show" ) {num++;}
|
982
|
+
if ( t_h === "hide" || t_h === "show" ) {num++;}
|
983
|
+
if ( t_o === "hide" || t_o === "show" ) {num++;}
|
984
|
+
if ( t_w === "hide" ) {num++;}
|
985
|
+
if ( t_o.constructor === Number ) {num += 2;}
|
986
|
+
if ( t_w.constructor === Number ) {num += 2;}
|
987
|
+
if ( t_h.constructor === Number ) {num +=2;}
|
988
|
+
|
989
|
+
expect( num );
|
990
|
+
stop();
|
991
|
+
|
992
|
+
anim = { width: t_w, height: t_h, opacity: t_o };
|
993
|
+
|
994
|
+
elem.animate(anim, 50);
|
995
|
+
|
996
|
+
jQuery.when( elem ).done(function( elem ) {
|
997
|
+
var cur_o, cur_w, cur_h, old_h;
|
998
|
+
|
999
|
+
elem = elem[ 0 ];
|
1000
|
+
|
1001
|
+
if ( t_w === "show" ) {
|
1002
|
+
equal( elem.style.display, "block", "Showing, display should block: " + elem.style.display );
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
if ( t_w === "hide" || t_w === "show" ) {
|
1006
|
+
ok( f_w === "" ? elem.style.width === f_w : elem.style.width.indexOf( f_w ) === 0, "Width must be reset to " + f_w + ": " + elem.style.width );
|
1007
|
+
}
|
1008
|
+
|
1009
|
+
if ( t_h === "hide" || t_h === "show" ) {
|
1010
|
+
ok( f_h === "" ? elem.style.height === f_h : elem.style.height.indexOf( f_h ) === 0, "Height must be reset to " + f_h + ": " + elem.style.height );
|
1011
|
+
}
|
1012
|
+
|
1013
|
+
cur_o = jQuery.style(elem, "opacity");
|
1014
|
+
|
1015
|
+
if ( f_o !== jQuery.css(elem, "opacity") ) {
|
1016
|
+
f_o = f( elem, "opacity" );
|
1017
|
+
}
|
1018
|
+
|
1019
|
+
// The only time an _empty_string_ will be matched is in IE
|
1020
|
+
// otherwise, the correct values will be tested as usual
|
1021
|
+
if ( f_o === "" ) {
|
1022
|
+
f_o = 1;
|
1023
|
+
}
|
1024
|
+
// See above
|
1025
|
+
if ( cur_o === "" ) {
|
1026
|
+
cur_o = 1;
|
1027
|
+
}
|
1028
|
+
|
1029
|
+
if ( t_o === "hide" || t_o === "show" ) {
|
1030
|
+
equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o );
|
1031
|
+
}
|
1032
|
+
|
1033
|
+
if ( t_w === "hide" ) {
|
1034
|
+
equal( elem.style.display, "none", "Hiding, display should be none: " + elem.style.display );
|
1035
|
+
}
|
1036
|
+
|
1037
|
+
if ( t_o.constructor === Number ) {
|
1038
|
+
equal( cur_o, t_o, "Final opacity should be " + t_o + ": " + cur_o );
|
1039
|
+
|
1040
|
+
ok( jQuery.css(elem, "opacity") !== "" || cur_o === t_o, "Opacity should be explicitly set to " + t_o + ", is instead: " + cur_o );
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
if ( t_w.constructor === Number ) {
|
1044
|
+
equal( elem.style.width, t_w + "px", "Final width should be " + t_w + ": " + elem.style.width );
|
1045
|
+
|
1046
|
+
cur_w = jQuery.css( elem,"width" );
|
1047
|
+
|
1048
|
+
ok( elem.style.width !== "" || cur_w === t_w, "Width should be explicitly set to " + t_w + ", is instead: " + cur_w );
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
if ( t_h.constructor === Number ) {
|
1052
|
+
equal( elem.style.height, t_h + "px", "Final height should be " + t_h + ": " + elem.style.height );
|
1053
|
+
|
1054
|
+
cur_h = jQuery.css( elem,"height" );
|
1055
|
+
|
1056
|
+
ok( elem.style.height !== "" || cur_h === t_h, "Height should be explicitly set to " + t_h + ", is instead: " + cur_h );
|
1057
|
+
}
|
1058
|
+
|
1059
|
+
if ( t_h === "show" ) {
|
1060
|
+
old_h = jQuery.css( elem, "height" );
|
1061
|
+
jQuery( elem ).append("<br/>Some more text<br/>and some more...");
|
1062
|
+
|
1063
|
+
if ( /Auto/.test( fn ) ) {
|
1064
|
+
notEqual( jQuery.css( elem, "height" ), old_h, "Make sure height is auto." );
|
1065
|
+
} else {
|
1066
|
+
equal( jQuery.css( elem, "height" ), old_h, "Make sure height is not auto." );
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
// manually remove generated element
|
1071
|
+
jQuery( elem ).remove();
|
1072
|
+
|
1073
|
+
start();
|
1074
|
+
});
|
1075
|
+
});
|
1076
|
+
});
|
1077
|
+
});
|
1078
|
+
|
1079
|
+
asyncTest("Effects chaining", function() {
|
1080
|
+
var remaining = 16,
|
1081
|
+
shrinkwrap = jQuery.support.shrinkWrapBlocks,
|
1082
|
+
props = [ "opacity", "height", "width", "display", "overflow" ],
|
1083
|
+
setup = function( name, selector, hiddenOverflow ) {
|
1084
|
+
var $el = jQuery( selector );
|
1085
|
+
return $el.data( getProps( $el[0], hiddenOverflow ) ).data( "name", name );
|
1086
|
+
},
|
1087
|
+
assert = function() {
|
1088
|
+
var data = jQuery.data( this ),
|
1089
|
+
name = data.name;
|
1090
|
+
delete data.name;
|
1091
|
+
|
1092
|
+
deepEqual( getProps( this ), data, name );
|
1093
|
+
|
1094
|
+
jQuery.removeData( this );
|
1095
|
+
if ( --remaining === 0 ) {
|
1096
|
+
start();
|
1097
|
+
}
|
1098
|
+
},
|
1099
|
+
getProps = function( el, hiddenOverflow ) {
|
1100
|
+
var obj = {};
|
1101
|
+
jQuery.each( props, function( i, prop ) {
|
1102
|
+
obj[ prop ] = prop === "overflow" && hiddenOverflow ? "hidden" : el.style[ prop ] || jQuery.css( el, prop );
|
1103
|
+
});
|
1104
|
+
return obj;
|
1105
|
+
};
|
1106
|
+
|
1107
|
+
expect( remaining );
|
1108
|
+
|
1109
|
+
// We need to pass jQuery.support.shrinkWrapBlocks for all methods that
|
1110
|
+
// set overflow hidden (slide* and show/hide with speed)
|
1111
|
+
setup( ".fadeOut().fadeIn()", "#fadein div" ).fadeOut("fast").fadeIn( "fast", assert );
|
1112
|
+
setup( ".fadeIn().fadeOut()", "#fadeout div" ).fadeIn("fast").fadeOut( "fast", assert );
|
1113
|
+
setup( ".hide().show()", "#show div", shrinkwrap ).hide("fast").show( "fast", assert );
|
1114
|
+
setup( ".show().hide()", "#hide div", shrinkwrap ).show("fast").hide( "fast", assert );
|
1115
|
+
setup( ".show().hide(easing)", "#easehide div", shrinkwrap ).show("fast").hide( "fast", "linear", assert );
|
1116
|
+
setup( ".toggle().toggle() - in", "#togglein div", shrinkwrap ).toggle("fast").toggle( "fast", assert );
|
1117
|
+
setup( ".toggle().toggle() - out", "#toggleout div", shrinkwrap ).toggle("fast").toggle( "fast", assert );
|
1118
|
+
setup( ".toggle().toggle(easing) - out", "#easetoggleout div", shrinkwrap ).toggle("fast").toggle( "fast", "linear", assert );
|
1119
|
+
setup( ".slideDown().slideUp()", "#slidedown div", shrinkwrap ).slideDown("fast").slideUp( "fast", assert );
|
1120
|
+
setup( ".slideUp().slideDown()", "#slideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", assert );
|
1121
|
+
setup( ".slideUp().slideDown(easing)", "#easeslideup div", shrinkwrap ).slideUp("fast").slideDown( "fast", "linear", assert );
|
1122
|
+
setup( ".slideToggle().slideToggle() - in", "#slidetogglein div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert );
|
1123
|
+
setup( ".slideToggle().slideToggle() - out", "#slidetoggleout div", shrinkwrap ).slideToggle("fast").slideToggle( "fast", assert );
|
1124
|
+
setup( ".fadeToggle().fadeToggle() - in", "#fadetogglein div" ).fadeToggle("fast").fadeToggle( "fast", assert );
|
1125
|
+
setup( ".fadeToggle().fadeToggle() - out", "#fadetoggleout div" ).fadeToggle("fast").fadeToggle( "fast", assert );
|
1126
|
+
setup( ".fadeTo(0.5).fadeTo(1.0, easing)", "#fadeto div" ).fadeTo( "fast", 0.5 ).fadeTo( "fast", 1.0, "linear", assert );
|
1127
|
+
});
|
1128
|
+
|
1129
|
+
jQuery.makeTest = function( text ){
|
1130
|
+
var elem = jQuery("<div></div>")
|
1131
|
+
.attr( "id", "test" + jQuery.makeTest.id++ )
|
1132
|
+
.addClass("box");
|
1133
|
+
|
1134
|
+
jQuery("<h4></h4>")
|
1135
|
+
.text( text )
|
1136
|
+
.appendTo("#fx-tests")
|
1137
|
+
.after( elem );
|
1138
|
+
|
1139
|
+
return elem;
|
1140
|
+
};
|
1141
|
+
|
1142
|
+
jQuery.makeTest.id = 1;
|
1143
|
+
|
1144
|
+
test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function () {
|
1145
|
+
expect(4);
|
1146
|
+
stop();
|
1147
|
+
|
1148
|
+
var $checkedtest = jQuery("#checkedtest");
|
1149
|
+
$checkedtest.hide().show("fast", function() {
|
1150
|
+
ok( jQuery("input[type='radio']", $checkedtest).first().attr("checked"), "Check first radio still checked." );
|
1151
|
+
ok( !jQuery("input[type='radio']", $checkedtest).last().attr("checked"), "Check last radio still NOT checked." );
|
1152
|
+
ok( jQuery("input[type='checkbox']", $checkedtest).first().attr("checked"), "Check first checkbox still checked." );
|
1153
|
+
ok( !jQuery("input[type='checkbox']", $checkedtest).last().attr("checked"), "Check last checkbox still NOT checked." );
|
1154
|
+
start();
|
1155
|
+
});
|
1156
|
+
});
|
1157
|
+
|
1158
|
+
test( "interrupt toggle", function() {
|
1159
|
+
expect( 24 );
|
1160
|
+
stop();
|
1161
|
+
|
1162
|
+
var longDuration = 2000,
|
1163
|
+
shortDuration = 500,
|
1164
|
+
remaining = 0,
|
1165
|
+
$elems = jQuery(".chain-test"),
|
1166
|
+
finish = function() {
|
1167
|
+
if ( !(--remaining) ) {
|
1168
|
+
start();
|
1169
|
+
}
|
1170
|
+
};
|
1171
|
+
|
1172
|
+
jQuery.each( { slideToggle: "height", fadeToggle: "opacity", toggle: "width" }, function( method, prop ) {
|
1173
|
+
var $methodElems = $elems.filter( "[id^='" + method.toLowerCase() + "']" ).each(function() {
|
1174
|
+
// Don't end test until we're done with this element
|
1175
|
+
remaining++;
|
1176
|
+
|
1177
|
+
// Save original property value for comparison
|
1178
|
+
jQuery.data( this, "startVal", jQuery( this ).css( prop ) );
|
1179
|
+
|
1180
|
+
// Expect olddisplay data from our .hide() call below
|
1181
|
+
QUnit.expectJqData( this, "olddisplay" );
|
1182
|
+
});
|
1183
|
+
|
1184
|
+
// Interrupt a hiding toggle
|
1185
|
+
$methodElems[ method ]( longDuration );
|
1186
|
+
setTimeout(function() {
|
1187
|
+
$methodElems.stop().each(function() {
|
1188
|
+
notEqual( jQuery( this ).css( prop ), jQuery.data( this, "startVal" ), ".stop() before completion of hiding ." + method + "() - #" + this.id );
|
1189
|
+
});
|
1190
|
+
|
1191
|
+
// Restore
|
1192
|
+
$methodElems[ method ]( shortDuration, function() {
|
1193
|
+
var id = this.id,
|
1194
|
+
$elem = jQuery( this ),
|
1195
|
+
startVal = $elem.data("startVal");
|
1196
|
+
|
1197
|
+
$elem.removeData("startVal");
|
1198
|
+
|
1199
|
+
equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
|
1200
|
+
|
1201
|
+
// Interrupt a showing toggle
|
1202
|
+
$elem.hide()[ method ]( longDuration );
|
1203
|
+
setTimeout(function() {
|
1204
|
+
$elem.stop();
|
1205
|
+
notEqual( $elem.css( prop ), startVal, ".stop() before completion of showing ." + method + "() - #" + id );
|
1206
|
+
|
1207
|
+
// Restore
|
1208
|
+
$elem[ method ]( shortDuration, function() {
|
1209
|
+
equal( $elem.css( prop ), startVal, "original value restored by ." + method + "() - #" + id );
|
1210
|
+
finish();
|
1211
|
+
});
|
1212
|
+
}, shortDuration );
|
1213
|
+
});
|
1214
|
+
}, shortDuration );
|
1215
|
+
});
|
1216
|
+
});
|
1217
|
+
|
1218
|
+
test("animate with per-property easing", function(){
|
1219
|
+
|
1220
|
+
expect(5);
|
1221
|
+
stop();
|
1222
|
+
|
1223
|
+
var data = { a:0, b:0, c:0 },
|
1224
|
+
_test1_called = false,
|
1225
|
+
_test2_called = false,
|
1226
|
+
_default_test_called = false,
|
1227
|
+
props = {
|
1228
|
+
a: [ 100, "_test1" ],
|
1229
|
+
b: [ 100, "_test2" ],
|
1230
|
+
c: 100
|
1231
|
+
};
|
1232
|
+
|
1233
|
+
jQuery.easing["_test1"] = function(p) {
|
1234
|
+
_test1_called = true;
|
1235
|
+
return p;
|
1236
|
+
};
|
1237
|
+
|
1238
|
+
jQuery.easing["_test2"] = function(p) {
|
1239
|
+
_test2_called = true;
|
1240
|
+
return p;
|
1241
|
+
};
|
1242
|
+
|
1243
|
+
jQuery.easing["_default_test"] = function(p) {
|
1244
|
+
_default_test_called = true;
|
1245
|
+
return p;
|
1246
|
+
};
|
1247
|
+
|
1248
|
+
jQuery(data).animate( props, 400, "_default_test", function(){
|
1249
|
+
start();
|
1250
|
+
|
1251
|
+
ok( _test1_called, "Easing function (_test1) called" );
|
1252
|
+
ok( _test2_called, "Easing function (_test2) called" );
|
1253
|
+
ok( _default_test_called, "Easing function (_default) called" );
|
1254
|
+
equal( props.a[ 1 ], "_test1", "animate does not change original props (per-property easing would be lost)");
|
1255
|
+
equal( props.b[ 1 ], "_test2", "animate does not change original props (per-property easing would be lost)");
|
1256
|
+
});
|
1257
|
+
|
1258
|
+
});
|
1259
|
+
|
1260
|
+
test("animate with CSS shorthand properties", function(){
|
1261
|
+
expect(11);
|
1262
|
+
stop();
|
1263
|
+
|
1264
|
+
var _default_count = 0,
|
1265
|
+
_special_count = 0,
|
1266
|
+
propsBasic = { "padding": "10 20 30" },
|
1267
|
+
propsSpecial = { "padding": [ "1 2 3", "_special" ] };
|
1268
|
+
|
1269
|
+
jQuery.easing._default = function(p) {
|
1270
|
+
if ( p >= 1 ) {
|
1271
|
+
_default_count++;
|
1272
|
+
}
|
1273
|
+
return p;
|
1274
|
+
};
|
1275
|
+
|
1276
|
+
jQuery.easing._special = function(p) {
|
1277
|
+
if ( p >= 1 ) {
|
1278
|
+
_special_count++;
|
1279
|
+
}
|
1280
|
+
return p;
|
1281
|
+
};
|
1282
|
+
|
1283
|
+
jQuery("#foo")
|
1284
|
+
.animate( propsBasic, 200, "_default", function() {
|
1285
|
+
equal( this.style.paddingTop, "10px", "padding-top was animated" );
|
1286
|
+
equal( this.style.paddingLeft, "20px", "padding-left was animated" );
|
1287
|
+
equal( this.style.paddingRight, "20px", "padding-right was animated" );
|
1288
|
+
equal( this.style.paddingBottom, "30px", "padding-bottom was animated" );
|
1289
|
+
equal( _default_count, 4, "per-animation default easing called for each property" );
|
1290
|
+
_default_count = 0;
|
1291
|
+
})
|
1292
|
+
.animate( propsSpecial, 200, "_default", function() {
|
1293
|
+
equal( this.style.paddingTop, "1px", "padding-top was animated again" );
|
1294
|
+
equal( this.style.paddingLeft, "2px", "padding-left was animated again" );
|
1295
|
+
equal( this.style.paddingRight, "2px", "padding-right was animated again" );
|
1296
|
+
equal( this.style.paddingBottom, "3px", "padding-bottom was animated again" );
|
1297
|
+
equal( _default_count, 0, "per-animation default easing not called" );
|
1298
|
+
equal( _special_count, 4, "special easing called for each property" );
|
1299
|
+
|
1300
|
+
jQuery(this).css("padding", "0");
|
1301
|
+
delete jQuery.easing._default;
|
1302
|
+
delete jQuery.easing._special;
|
1303
|
+
start();
|
1304
|
+
});
|
1305
|
+
});
|
1306
|
+
|
1307
|
+
test("hide hidden elements, with animation (bug #7141)", function() {
|
1308
|
+
expect(3);
|
1309
|
+
QUnit.reset();
|
1310
|
+
stop();
|
1311
|
+
|
1312
|
+
var div = jQuery("<div style='display:none'></div>").appendTo("#qunit-fixture");
|
1313
|
+
equal( div.css("display"), "none", "Element is hidden by default" );
|
1314
|
+
div.hide(1, function () {
|
1315
|
+
ok( !jQuery._data(div, "olddisplay"), "olddisplay is undefined after hiding an already-hidden element" );
|
1316
|
+
div.show(1, function () {
|
1317
|
+
equal( div.css("display"), "block", "Show a double-hidden element" );
|
1318
|
+
start();
|
1319
|
+
});
|
1320
|
+
});
|
1321
|
+
});
|
1322
|
+
|
1323
|
+
test("animate unit-less properties (#4966)", 2, function() {
|
1324
|
+
stop();
|
1325
|
+
var div = jQuery( "<div style='z-index: 0; position: absolute;'></div>" ).appendTo( "#qunit-fixture" );
|
1326
|
+
equal( div.css( "z-index" ), "0", "z-index is 0" );
|
1327
|
+
div.animate({ zIndex: 2 }, function() {
|
1328
|
+
equal( div.css( "z-index" ), "2", "z-index is 2" );
|
1329
|
+
start();
|
1330
|
+
});
|
1331
|
+
});
|
1332
|
+
|
1333
|
+
test( "animate properties missing px w/ opacity as last (#9074)", 2, function() {
|
1334
|
+
expect( 6 );
|
1335
|
+
stop();
|
1336
|
+
var div = jQuery( "<div style='position: absolute; margin-left: 0; left: 0px;'></div>" )
|
1337
|
+
.appendTo( "#qunit-fixture" );
|
1338
|
+
function cssInt( prop ) {
|
1339
|
+
return parseInt( div.css( prop ), 10 );
|
1340
|
+
}
|
1341
|
+
equal( cssInt( "marginLeft" ), 0, "Margin left is 0" );
|
1342
|
+
equal( cssInt( "left" ), 0, "Left is 0" );
|
1343
|
+
div.animate({
|
1344
|
+
left: 200,
|
1345
|
+
marginLeft: 200,
|
1346
|
+
opacity: 0
|
1347
|
+
}, 2000);
|
1348
|
+
setTimeout(function() {
|
1349
|
+
var ml = cssInt( "marginLeft" ),
|
1350
|
+
l = cssInt( "left" );
|
1351
|
+
notEqual( ml, 0, "Margin left is not 0 after partial animate" );
|
1352
|
+
notEqual( ml, 200, "Margin left is not 200 after partial animate" );
|
1353
|
+
notEqual( l, 0, "Left is not 0 after partial animate" );
|
1354
|
+
notEqual( l, 200, "Left is not 200 after partial animate" );
|
1355
|
+
div.stop().remove();
|
1356
|
+
start();
|
1357
|
+
}, 500);
|
1358
|
+
});
|
1359
|
+
|
1360
|
+
test("callbacks should fire in correct order (#9100)", function() {
|
1361
|
+
expect( 1 );
|
1362
|
+
|
1363
|
+
stop();
|
1364
|
+
var a = 1,
|
1365
|
+
cb = 0;
|
1366
|
+
|
1367
|
+
jQuery("<p data-operation='*2'></p><p data-operation='^2'></p>")
|
1368
|
+
.appendTo("#qunit-fixture")
|
1369
|
+
// The test will always pass if no properties are animated or if the duration is 0
|
1370
|
+
.animate({ fontSize: 12 }, 13, function() {
|
1371
|
+
a *= jQuery(this).data("operation") === "*2" ? 2 : a;
|
1372
|
+
cb++;
|
1373
|
+
if ( cb === 2 ) {
|
1374
|
+
equal( a, 4, "test value has been *2 and _then_ ^2");
|
1375
|
+
start();
|
1376
|
+
}
|
1377
|
+
});
|
1378
|
+
});
|
1379
|
+
|
1380
|
+
asyncTest( "callbacks that throw exceptions will be removed (#5684)", function() {
|
1381
|
+
expect( 2 );
|
1382
|
+
|
1383
|
+
var foo = jQuery( "#foo" );
|
1384
|
+
|
1385
|
+
function testException() {
|
1386
|
+
}
|
1387
|
+
|
1388
|
+
foo.animate({ height: 1 }, 1, function() {
|
1389
|
+
throw new testException();
|
1390
|
+
});
|
1391
|
+
|
1392
|
+
// this test thoroughly abuses undocumented methods - please feel free to update
|
1393
|
+
// with any changes internally to these functions.
|
1394
|
+
|
1395
|
+
// make sure that the standard timer loop will NOT run.
|
1396
|
+
jQuery.fx.stop();
|
1397
|
+
|
1398
|
+
setTimeout(function() {
|
1399
|
+
|
1400
|
+
// the first call to fx.tick should raise the callback exception
|
1401
|
+
raises( jQuery.fx.tick, testException, "Exception was thrown" );
|
1402
|
+
|
1403
|
+
// the second call shouldn't
|
1404
|
+
jQuery.fx.tick();
|
1405
|
+
|
1406
|
+
ok( true, "Test completed without throwing a second exception" );
|
1407
|
+
|
1408
|
+
start();
|
1409
|
+
}, 1);
|
1410
|
+
});
|
1411
|
+
|
1412
|
+
test("animate will scale margin properties individually", function() {
|
1413
|
+
expect( 2 );
|
1414
|
+
stop();
|
1415
|
+
|
1416
|
+
var foo = jQuery( "#foo" ).css({
|
1417
|
+
"margin": 0,
|
1418
|
+
"marginLeft": 100
|
1419
|
+
});
|
1420
|
+
|
1421
|
+
ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
|
1422
|
+
|
1423
|
+
foo.animate({
|
1424
|
+
"margin": 200
|
1425
|
+
}).stop();
|
1426
|
+
|
1427
|
+
ok( foo.css( "marginLeft") !== foo.css( "marginRight" ), "The margin properties are different");
|
1428
|
+
|
1429
|
+
// clean up for next test
|
1430
|
+
foo.css({
|
1431
|
+
"marginLeft": "",
|
1432
|
+
"marginRight": "",
|
1433
|
+
"marginTop": "",
|
1434
|
+
"marginBottom": ""
|
1435
|
+
});
|
1436
|
+
start();
|
1437
|
+
});
|
1438
|
+
|
1439
|
+
test("Do not append px to 'fill-opacity' #9548", 1, function() {
|
1440
|
+
var $div = jQuery("<div>").appendTo("#qunit-fixture");
|
1441
|
+
|
1442
|
+
$div.css("fill-opacity", 0).animate({ "fill-opacity": 1.0 }, 0, function () {
|
1443
|
+
equal( jQuery(this).css("fill-opacity"), 1, "Do not append px to 'fill-opacity'");
|
1444
|
+
$div.remove();
|
1445
|
+
});
|
1446
|
+
});
|
1447
|
+
|
1448
|
+
test("line-height animates correctly (#13855)", function() {
|
1449
|
+
expect( 12 );
|
1450
|
+
stop();
|
1451
|
+
|
1452
|
+
var
|
1453
|
+
animated = jQuery(
|
1454
|
+
"<p style='line-height: 4;'>unitless</p>" +
|
1455
|
+
"<p style='line-height: 50px;'>px</p>" +
|
1456
|
+
"<p style='line-height: 420%;'>percent</p>" +
|
1457
|
+
"<p style='line-height: 2.5em;'>em</p>"
|
1458
|
+
).appendTo("#qunit-fixture"),
|
1459
|
+
initialHeight = jQuery.map( animated, function( el ) {
|
1460
|
+
return jQuery( el ).height();
|
1461
|
+
});
|
1462
|
+
|
1463
|
+
animated.animate( { "line-height": "hide" }, 1500 );
|
1464
|
+
setTimeout(function() {
|
1465
|
+
animated.each(function( i ) {
|
1466
|
+
var label = jQuery.text( this ),
|
1467
|
+
initial = initialHeight[ i ],
|
1468
|
+
height = jQuery( this ).height();
|
1469
|
+
ok( height < initial, "hide " + label + ": upper bound" );
|
1470
|
+
ok( height > initial / 2, "hide " + label + ": lower bound" );
|
1471
|
+
});
|
1472
|
+
animated.stop( true, true ).hide().animate( { "line-height": "show" }, 1500 );
|
1473
|
+
setTimeout(function() {
|
1474
|
+
animated.each(function( i ) {
|
1475
|
+
var label = jQuery.text( this ),
|
1476
|
+
initial = initialHeight[ i ],
|
1477
|
+
height = jQuery( this ).height();
|
1478
|
+
ok( height < initial / 2, "show " + label + ": upper bound" );
|
1479
|
+
});
|
1480
|
+
animated.stop( true, true );
|
1481
|
+
start();
|
1482
|
+
}, 400 );
|
1483
|
+
}, 400 );
|
1484
|
+
});
|
1485
|
+
|
1486
|
+
// Start 1.8 Animation tests
|
1487
|
+
asyncTest( "jQuery.Animation( object, props, opts )", 4, function() {
|
1488
|
+
var animation,
|
1489
|
+
testObject = {
|
1490
|
+
"foo": 0,
|
1491
|
+
"bar": 1,
|
1492
|
+
"width": 100
|
1493
|
+
},
|
1494
|
+
testDest = {
|
1495
|
+
"foo": 1,
|
1496
|
+
"bar": 0,
|
1497
|
+
"width": 200
|
1498
|
+
};
|
1499
|
+
|
1500
|
+
animation = jQuery.Animation( testObject, testDest, { "duration": 1 });
|
1501
|
+
animation.done(function() {
|
1502
|
+
for ( var prop in testDest ) {
|
1503
|
+
equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
|
1504
|
+
}
|
1505
|
+
animation.done(function() {
|
1506
|
+
deepEqual( testObject, testDest, "No unexpected properties" );
|
1507
|
+
start();
|
1508
|
+
});
|
1509
|
+
});
|
1510
|
+
});
|
1511
|
+
|
1512
|
+
asyncTest( "Animate Option: step: function( percent, tween )", 1, function() {
|
1513
|
+
var counter = {};
|
1514
|
+
jQuery( "#foo" ).animate({
|
1515
|
+
prop1: 1,
|
1516
|
+
prop2: 2,
|
1517
|
+
prop3: 3
|
1518
|
+
}, {
|
1519
|
+
duration: 1,
|
1520
|
+
step: function( value, tween ) {
|
1521
|
+
var calls = counter[ tween.prop ] = counter[ tween.prop ] || [];
|
1522
|
+
// in case this is called multiple times for either, lets store it in
|
1523
|
+
// 0 or 1 in the array
|
1524
|
+
calls[ value === 0 ? 0 : 1 ] = value;
|
1525
|
+
}
|
1526
|
+
}).queue( function( next ) {
|
1527
|
+
deepEqual( counter, {
|
1528
|
+
prop1: [0, 1],
|
1529
|
+
prop2: [0, 2],
|
1530
|
+
prop3: [0, 3]
|
1531
|
+
}, "Step function was called once at 0% and once at 100% for each property");
|
1532
|
+
next();
|
1533
|
+
start();
|
1534
|
+
});
|
1535
|
+
});
|
1536
|
+
|
1537
|
+
asyncTest( "Animate callbacks have correct context", 2, function() {
|
1538
|
+
var foo = jQuery( "#foo" );
|
1539
|
+
foo.animate({
|
1540
|
+
height: 10
|
1541
|
+
}, 10, function() {
|
1542
|
+
equal( foo[ 0 ], this, "Complete callback after stop(true) `this` is element" );
|
1543
|
+
}).stop( true, true );
|
1544
|
+
foo.animate({
|
1545
|
+
height: 100
|
1546
|
+
}, 10, function() {
|
1547
|
+
equal( foo[ 0 ], this, "Complete callback `this` is element" );
|
1548
|
+
start();
|
1549
|
+
});
|
1550
|
+
});
|
1551
|
+
|
1552
|
+
asyncTest( "User supplied callback called after show when fx off (#8892)", 2, function() {
|
1553
|
+
var foo = jQuery( "#foo" );
|
1554
|
+
jQuery.fx.off = true;
|
1555
|
+
foo.hide();
|
1556
|
+
foo.fadeIn( 500, function() {
|
1557
|
+
ok( jQuery( this ).is( ":visible" ), "Element is visible in callback" );
|
1558
|
+
foo.fadeOut( 500, function() {
|
1559
|
+
ok( jQuery( this ).is( ":hidden" ), "Element is hidden in callback" );
|
1560
|
+
jQuery.fx.off = false;
|
1561
|
+
start();
|
1562
|
+
});
|
1563
|
+
});
|
1564
|
+
});
|
1565
|
+
|
1566
|
+
test( "animate should set display for disconnected nodes", function() {
|
1567
|
+
expect( 18 );
|
1568
|
+
|
1569
|
+
var i = 0,
|
1570
|
+
methods = {
|
1571
|
+
toggle: [ 1 ],
|
1572
|
+
slideToggle: [],
|
1573
|
+
fadeIn: [],
|
1574
|
+
fadeTo: [ "fast", 0.5 ],
|
1575
|
+
slideDown: [ "fast" ],
|
1576
|
+
show: [ 1 ],
|
1577
|
+
animate: [{ width: "show" }]
|
1578
|
+
},
|
1579
|
+
$divTest = jQuery("<div>test</div>"),
|
1580
|
+
// parentNode = null
|
1581
|
+
$divEmpty = jQuery("<div/>"),
|
1582
|
+
$divNone = jQuery("<div style='display: none;'/>"),
|
1583
|
+
$divInline = jQuery("<div style='display: inline;'/>");
|
1584
|
+
|
1585
|
+
strictEqual( $divTest.show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = document fragment" );
|
1586
|
+
strictEqual( $divEmpty.show()[ 0 ].style.display, "block", "set display with show() for element with parentNode = null" );
|
1587
|
+
strictEqual( $divNone.show()[ 0 ].style.display, "block", "show() should change display if it already set to none" );
|
1588
|
+
strictEqual( $divInline.show()[ 0 ].style.display, "inline", "show() should not change display if it already set" );
|
1589
|
+
|
1590
|
+
QUnit.expectJqData( $divTest[ 0 ], "olddisplay" );
|
1591
|
+
QUnit.expectJqData( $divEmpty[ 0 ], "olddisplay" );
|
1592
|
+
QUnit.expectJqData( $divNone[ 0 ], "olddisplay" );
|
1593
|
+
|
1594
|
+
stop();
|
1595
|
+
jQuery.each( methods, function( name, opt ) {
|
1596
|
+
jQuery.each([
|
1597
|
+
|
1598
|
+
// parentNode = document fragment
|
1599
|
+
jQuery("<div>test</div>"),
|
1600
|
+
|
1601
|
+
// parentNode = null
|
1602
|
+
jQuery("<div/>")
|
1603
|
+
|
1604
|
+
], function() {
|
1605
|
+
var callback = [function () {
|
1606
|
+
strictEqual( this.style.display, "block", "set display to block with " + name );
|
1607
|
+
|
1608
|
+
QUnit.expectJqData( this, "olddisplay" );
|
1609
|
+
|
1610
|
+
if ( ++i === 14 ) {
|
1611
|
+
start();
|
1612
|
+
}
|
1613
|
+
}];
|
1614
|
+
jQuery.fn[ name ].apply( this, opt.concat( callback ) );
|
1615
|
+
});
|
1616
|
+
});
|
1617
|
+
});
|
1618
|
+
|
1619
|
+
asyncTest("Animation callback should not show animated element as :animated (#7157)", 1, function() {
|
1620
|
+
var foo = jQuery( "#foo" );
|
1621
|
+
|
1622
|
+
foo.animate({
|
1623
|
+
opacity: 0
|
1624
|
+
}, 100, function() {
|
1625
|
+
ok( !foo.is(":animated"), "The element is not animated" );
|
1626
|
+
start();
|
1627
|
+
});
|
1628
|
+
});
|
1629
|
+
|
1630
|
+
asyncTest( "hide called on element within hidden parent should set display to none (#10045)", 3, function() {
|
1631
|
+
var hidden = jQuery(".hidden"),
|
1632
|
+
elems = jQuery("<div>hide</div><div>hide0</div><div>hide1</div>");
|
1633
|
+
|
1634
|
+
hidden.append( elems );
|
1635
|
+
|
1636
|
+
jQuery.when(
|
1637
|
+
elems.eq( 0 ).hide(),
|
1638
|
+
elems.eq( 1 ).hide( 0 ),
|
1639
|
+
elems.eq( 2 ).hide( 1 )
|
1640
|
+
).done(function() {
|
1641
|
+
strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element within hidden parent should set display to none" );
|
1642
|
+
strictEqual( elems.get( 1 ).style.display, "none", "hide( 0 ) called on element within hidden parent should set display to none" );
|
1643
|
+
strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element within hidden parent should set display to none" );
|
1644
|
+
|
1645
|
+
elems.remove();
|
1646
|
+
start();
|
1647
|
+
});
|
1648
|
+
});
|
1649
|
+
|
1650
|
+
asyncTest( "hide, fadeOut and slideUp called on element width height and width = 0 should set display to none", 5, function() {
|
1651
|
+
var foo = jQuery("#foo"),
|
1652
|
+
i = 0,
|
1653
|
+
elems = jQuery();
|
1654
|
+
|
1655
|
+
for ( ; i < 5; i++ ) {
|
1656
|
+
elems = elems.add("<div style='width:0;height:0;'></div>");
|
1657
|
+
}
|
1658
|
+
|
1659
|
+
foo.append( elems );
|
1660
|
+
|
1661
|
+
jQuery.when(
|
1662
|
+
elems.eq( 0 ).hide(),
|
1663
|
+
elems.eq( 1 ).hide( jQuery.noop ),
|
1664
|
+
elems.eq( 2 ).hide( 1 ),
|
1665
|
+
elems.eq( 3 ).fadeOut(),
|
1666
|
+
elems.eq( 4 ).slideUp()
|
1667
|
+
).done(function() {
|
1668
|
+
strictEqual( elems.get( 0 ).style.display, "none", "hide() called on element width height and width = 0 should set display to none" );
|
1669
|
+
strictEqual( elems.get( 1 ).style.display, "none",
|
1670
|
+
"hide( jQuery.noop ) called on element width height and width = 0 should set display to none" );
|
1671
|
+
strictEqual( elems.get( 2 ).style.display, "none", "hide( 1 ) called on element width height and width = 0 should set display to none" );
|
1672
|
+
strictEqual( elems.get( 3 ).style.display, "none", "fadeOut() called on element width height and width = 0 should set display to none" );
|
1673
|
+
strictEqual( elems.get( 4 ).style.display, "none", "slideUp() called on element width height and width = 0 should set display to none" );
|
1674
|
+
|
1675
|
+
start();
|
1676
|
+
});
|
1677
|
+
});
|
1678
|
+
|
1679
|
+
asyncTest( "Handle queue:false promises", 10, function() {
|
1680
|
+
var foo = jQuery( "#foo" ).clone().andSelf(),
|
1681
|
+
step = 1;
|
1682
|
+
|
1683
|
+
foo.animate({
|
1684
|
+
top: 1
|
1685
|
+
}, {
|
1686
|
+
duration: 10,
|
1687
|
+
queue: false,
|
1688
|
+
complete: function() {
|
1689
|
+
ok( step++ <= 2, "Step one or two" );
|
1690
|
+
}
|
1691
|
+
}).animate({
|
1692
|
+
bottom: 1
|
1693
|
+
}, {
|
1694
|
+
duration: 10,
|
1695
|
+
complete: function() {
|
1696
|
+
ok( step > 2 && step < 5, "Step three or four" );
|
1697
|
+
step++;
|
1698
|
+
}
|
1699
|
+
});
|
1700
|
+
|
1701
|
+
foo.promise().done( function() {
|
1702
|
+
equal( step++, 5, "steps 1-5: queue:false then queue:fx done" );
|
1703
|
+
foo.animate({
|
1704
|
+
top: 10
|
1705
|
+
}, {
|
1706
|
+
duration: 10,
|
1707
|
+
complete: function() {
|
1708
|
+
ok( step > 5 && step < 8, "Step six or seven" );
|
1709
|
+
step++;
|
1710
|
+
}
|
1711
|
+
}).animate({
|
1712
|
+
bottom: 10
|
1713
|
+
}, {
|
1714
|
+
duration: 10,
|
1715
|
+
queue: false,
|
1716
|
+
complete: function() {
|
1717
|
+
ok( step > 7 && step < 10, "Step eight or nine" );
|
1718
|
+
step++;
|
1719
|
+
}
|
1720
|
+
}).promise().done( function() {
|
1721
|
+
equal( step++, 10, "steps 6-10: queue:fx then queue:false" );
|
1722
|
+
start();
|
1723
|
+
});
|
1724
|
+
|
1725
|
+
});
|
1726
|
+
});
|
1727
|
+
|
1728
|
+
asyncTest( "multiple unqueued and promise", 4, function() {
|
1729
|
+
var foo = jQuery( "#foo" ),
|
1730
|
+
step = 1;
|
1731
|
+
foo.animate({
|
1732
|
+
marginLeft: 300
|
1733
|
+
}, {
|
1734
|
+
duration: 500,
|
1735
|
+
queue: false,
|
1736
|
+
complete: function() {
|
1737
|
+
strictEqual( step++, 2, "Step 2" );
|
1738
|
+
}
|
1739
|
+
}).animate({
|
1740
|
+
top: 100
|
1741
|
+
}, {
|
1742
|
+
duration: 1000,
|
1743
|
+
queue: false,
|
1744
|
+
complete: function() {
|
1745
|
+
strictEqual( step++, 3, "Step 3" );
|
1746
|
+
}
|
1747
|
+
}).animate({}, {
|
1748
|
+
duration: 2000,
|
1749
|
+
queue: false,
|
1750
|
+
complete: function() {
|
1751
|
+
// no properties is a non-op and finishes immediately
|
1752
|
+
strictEqual( step++, 1, "Step 1" );
|
1753
|
+
}
|
1754
|
+
}).promise().done( function() {
|
1755
|
+
strictEqual( step++, 4, "Step 4" );
|
1756
|
+
start();
|
1757
|
+
});
|
1758
|
+
});
|
1759
|
+
|
1760
|
+
asyncTest( "animate does not change start value for non-px animation (#7109)", 1, function() {
|
1761
|
+
var parent = jQuery( "<div><div></div></div>" ).css({ width: 284, height: 1 }).appendTo( "#qunit-fixture" ),
|
1762
|
+
child = parent.children().css({ fontSize: "98.6in", width: "0.01em", height: 1 }),
|
1763
|
+
actual = parseFloat( child.css( "width" ) ),
|
1764
|
+
computed = [];
|
1765
|
+
|
1766
|
+
child.animate({ width: "0%" }, {
|
1767
|
+
duration: 1,
|
1768
|
+
step: function() {
|
1769
|
+
computed.push( parseFloat( child.css( "width" ) ) );
|
1770
|
+
}
|
1771
|
+
}).queue( function( next ) {
|
1772
|
+
var ratio = computed[ 0 ] / actual;
|
1773
|
+
ok( ratio > 0.9 && ratio < 1.1 , "Starting width was close enough" );
|
1774
|
+
next();
|
1775
|
+
parent.remove();
|
1776
|
+
start();
|
1777
|
+
});
|
1778
|
+
});
|
1779
|
+
|
1780
|
+
asyncTest( "non-px animation handles non-numeric start (#11971)", 2, function() {
|
1781
|
+
var foo = jQuery("#foo"),
|
1782
|
+
initial = foo.css("backgroundPositionX");
|
1783
|
+
|
1784
|
+
if ( !initial ) {
|
1785
|
+
expect(1);
|
1786
|
+
ok( true, "Style property not understood" );
|
1787
|
+
start();
|
1788
|
+
return;
|
1789
|
+
}
|
1790
|
+
|
1791
|
+
foo.animate({ backgroundPositionX: "42%" }, {
|
1792
|
+
duration: 1,
|
1793
|
+
progress: function( anim, percent ) {
|
1794
|
+
if ( percent ) {
|
1795
|
+
return;
|
1796
|
+
}
|
1797
|
+
|
1798
|
+
if ( parseFloat( initial ) ) {
|
1799
|
+
equal( jQuery.style( this, "backgroundPositionX" ), initial, "Numeric start preserved" );
|
1800
|
+
} else {
|
1801
|
+
equal( jQuery.style( this, "backgroundPositionX" ), "0%", "Non-numeric start zeroed" );
|
1802
|
+
}
|
1803
|
+
},
|
1804
|
+
done: function() {
|
1805
|
+
equal( jQuery.style( this, "backgroundPositionX" ), "42%", "End reached" );
|
1806
|
+
start();
|
1807
|
+
}
|
1808
|
+
});
|
1809
|
+
});
|
1810
|
+
|
1811
|
+
asyncTest("Animation callbacks (#11797)", 15, function() {
|
1812
|
+
var targets = jQuery("#foo").children(),
|
1813
|
+
done = false,
|
1814
|
+
expectedProgress = 0;
|
1815
|
+
|
1816
|
+
targets.eq( 0 ).animate( {}, {
|
1817
|
+
duration: 1,
|
1818
|
+
start: function() {
|
1819
|
+
ok( true, "empty: start" );
|
1820
|
+
},
|
1821
|
+
progress: function( anim, percent ) {
|
1822
|
+
equal( percent, 0, "empty: progress 0" );
|
1823
|
+
},
|
1824
|
+
done: function() {
|
1825
|
+
ok( true, "empty: done" );
|
1826
|
+
},
|
1827
|
+
fail: function() {
|
1828
|
+
ok( false, "empty: fail" );
|
1829
|
+
},
|
1830
|
+
always: function() {
|
1831
|
+
ok( true, "empty: always" );
|
1832
|
+
done = true;
|
1833
|
+
}
|
1834
|
+
});
|
1835
|
+
|
1836
|
+
ok( done, "empty: done immediately" );
|
1837
|
+
|
1838
|
+
done = false;
|
1839
|
+
targets.eq( 1 ).animate({
|
1840
|
+
opacity: 0
|
1841
|
+
}, {
|
1842
|
+
duration: 1,
|
1843
|
+
start: function() {
|
1844
|
+
ok( true, "stopped: start" );
|
1845
|
+
},
|
1846
|
+
progress: function( anim, percent ) {
|
1847
|
+
equal( percent, 0, "stopped: progress 0" );
|
1848
|
+
},
|
1849
|
+
done: function() {
|
1850
|
+
ok( false, "stopped: done" );
|
1851
|
+
},
|
1852
|
+
fail: function() {
|
1853
|
+
ok( true, "stopped: fail" );
|
1854
|
+
},
|
1855
|
+
always: function() {
|
1856
|
+
ok( true, "stopped: always" );
|
1857
|
+
done = true;
|
1858
|
+
}
|
1859
|
+
}).stop();
|
1860
|
+
|
1861
|
+
ok( done, "stopped: stopped immediately" );
|
1862
|
+
|
1863
|
+
targets.eq( 2 ).animate({
|
1864
|
+
opacity: 0
|
1865
|
+
}, {
|
1866
|
+
duration: 1,
|
1867
|
+
start: function() {
|
1868
|
+
ok( true, "async: start" );
|
1869
|
+
},
|
1870
|
+
progress: function( anim, percent ) {
|
1871
|
+
// occasionally the progress handler is called twice in first frame.... *shrug*
|
1872
|
+
if ( percent === 0 && expectedProgress === 1 ) {
|
1873
|
+
return;
|
1874
|
+
}
|
1875
|
+
equal( percent, expectedProgress, "async: progress " + expectedProgress );
|
1876
|
+
// once at 0, once at 1
|
1877
|
+
expectedProgress++;
|
1878
|
+
},
|
1879
|
+
done: function() {
|
1880
|
+
ok( true, "async: done" );
|
1881
|
+
},
|
1882
|
+
fail: function() {
|
1883
|
+
ok( false, "async: fail" );
|
1884
|
+
},
|
1885
|
+
always: function() {
|
1886
|
+
ok( true, "async: always" );
|
1887
|
+
start();
|
1888
|
+
}
|
1889
|
+
});
|
1890
|
+
});
|
1891
|
+
|
1892
|
+
test( "Animate properly sets overflow hidden when animating width/height (#12117)", 8, function() {
|
1893
|
+
jQuery.each( [ "height", "width" ], function( _, prop ) {
|
1894
|
+
jQuery.each( [ 100, 0 ], function( _, value ) {
|
1895
|
+
var div = jQuery("<div>").css( "overflow", "auto" ),
|
1896
|
+
props = {};
|
1897
|
+
props[ prop ] = value;
|
1898
|
+
div.animate( props, 1 );
|
1899
|
+
equal( div.css( "overflow" ), "hidden",
|
1900
|
+
"overflow: hidden set when animating " + prop + " to " + value );
|
1901
|
+
div.stop();
|
1902
|
+
if ( jQuery.support.shrinkWrapBlocks ) {
|
1903
|
+
ok( true, "cannot restore overflow, shrinkWrapBlocks" );
|
1904
|
+
} else {
|
1905
|
+
equal( div.css( "overflow" ), "auto",
|
1906
|
+
"overflow: auto restored after animating " + prop + " to " + value );
|
1907
|
+
}
|
1908
|
+
});
|
1909
|
+
});
|
1910
|
+
});
|
1911
|
+
|
1912
|
+
test( "Each tick of the timer loop uses a fresh time (#12837)", function() {
|
1913
|
+
var lastVal, current,
|
1914
|
+
tmp = jQuery({
|
1915
|
+
test: 0
|
1916
|
+
});
|
1917
|
+
expect( 3 );
|
1918
|
+
tmp.animate({
|
1919
|
+
test: 100
|
1920
|
+
}, {
|
1921
|
+
step: function( p, fx ) {
|
1922
|
+
ok( fx.now !== lastVal, "Current value is not the last value: " + lastVal + " - " + fx.now );
|
1923
|
+
lastVal = fx.now;
|
1924
|
+
}
|
1925
|
+
});
|
1926
|
+
current = jQuery.now();
|
1927
|
+
// intentionally empty, we want to spin wheels until the time changes.
|
1928
|
+
while ( current === jQuery.now() ) { }
|
1929
|
+
|
1930
|
+
// now that we have a new time, run another tick
|
1931
|
+
jQuery.fx.tick();
|
1932
|
+
|
1933
|
+
current = jQuery.now();
|
1934
|
+
// intentionally empty, we want to spin wheels until the time changes.
|
1935
|
+
while ( current === jQuery.now() ) { }
|
1936
|
+
|
1937
|
+
jQuery.fx.tick();
|
1938
|
+
tmp.stop();
|
1939
|
+
});
|
1940
|
+
|
1941
|
+
test( "Animations with 0 duration don't ease (#12273)", 1, function() {
|
1942
|
+
jQuery.easing.test = function() {
|
1943
|
+
ok( false, "Called easing" );
|
1944
|
+
};
|
1945
|
+
|
1946
|
+
jQuery( "#foo" ).animate({
|
1947
|
+
height: 100
|
1948
|
+
}, {
|
1949
|
+
duration: 0,
|
1950
|
+
easing: "test",
|
1951
|
+
complete: function() {
|
1952
|
+
equal( jQuery( this ).height(), 100, "Height is 100" );
|
1953
|
+
}
|
1954
|
+
});
|
1955
|
+
|
1956
|
+
delete jQuery.easing.test;
|
1957
|
+
});
|
1958
|
+
|
1959
|
+
jQuery.map([ "toggle", "slideToggle", "fadeToggle" ], function ( method ) {
|
1960
|
+
// this test would look a lot better if we were using something to override
|
1961
|
+
// the default timers
|
1962
|
+
var duration = 1500;
|
1963
|
+
asyncTest( "toggle state tests: " + method + " (#8685)", function() {
|
1964
|
+
function secondToggle() {
|
1965
|
+
var stopped = parseFloat( element.css( check ) );
|
1966
|
+
tested = false;
|
1967
|
+
element[ method ]({
|
1968
|
+
duration: duration,
|
1969
|
+
step: function( p, fx ) {
|
1970
|
+
if ( fx.pos > 0.1 && fx.prop === check && !tested ) {
|
1971
|
+
tested = true;
|
1972
|
+
equal( fx.start, stopped, check + " starts at " + stopped + " where it stopped" );
|
1973
|
+
equal( fx.end, original, check + " ending value is " + original );
|
1974
|
+
element.stop();
|
1975
|
+
}
|
1976
|
+
},
|
1977
|
+
always: start
|
1978
|
+
});
|
1979
|
+
}
|
1980
|
+
|
1981
|
+
var tested,
|
1982
|
+
original,
|
1983
|
+
check = method === "slideToggle" ? "height" : "opacity",
|
1984
|
+
element = jQuery("#foo").height( 200 );
|
1985
|
+
|
1986
|
+
expect( 4 );
|
1987
|
+
|
1988
|
+
element[ method ]({
|
1989
|
+
duration: duration,
|
1990
|
+
easing: "linear",
|
1991
|
+
step: function( p, fx ) {
|
1992
|
+
if ( fx.pos > 0.1 && fx.prop === check && !tested ) {
|
1993
|
+
tested = true;
|
1994
|
+
original = fx.start;
|
1995
|
+
ok( fx.start !== 0, check + " is starting at " + original + " on first toggle (non-zero)" );
|
1996
|
+
equal( fx.end, 0, check + " is ending at 0 on first toggle" );
|
1997
|
+
element.stop();
|
1998
|
+
}
|
1999
|
+
},
|
2000
|
+
always: secondToggle
|
2001
|
+
});
|
2002
|
+
});
|
2003
|
+
});
|
2004
|
+
|
2005
|
+
test( "jQuery.fx.start & jQuery.fx.stop hook points", function() {
|
2006
|
+
var oldStart = jQuery.fx.start,
|
2007
|
+
oldStop = jQuery.fx.stop,
|
2008
|
+
foo = jQuery({ foo: 0 });
|
2009
|
+
|
2010
|
+
expect( 3 );
|
2011
|
+
|
2012
|
+
jQuery.fx.start = function() {
|
2013
|
+
ok( true, "start called" );
|
2014
|
+
};
|
2015
|
+
jQuery.fx.stop = function() {
|
2016
|
+
ok( true, "stop called" );
|
2017
|
+
};
|
2018
|
+
|
2019
|
+
// calls start
|
2020
|
+
foo.animate({ foo: 1 }, { queue: false });
|
2021
|
+
// calls start
|
2022
|
+
foo.animate({ foo: 2 }, { queue: false });
|
2023
|
+
foo.stop();
|
2024
|
+
// calls stop
|
2025
|
+
jQuery.fx.tick();
|
2026
|
+
|
2027
|
+
// cleanup
|
2028
|
+
jQuery.fx.start = oldStart;
|
2029
|
+
jQuery.fx.stop = oldStop;
|
2030
|
+
});
|
2031
|
+
|
2032
|
+
test( ".finish() completes all queued animations", function() {
|
2033
|
+
var animations = {
|
2034
|
+
top: 100,
|
2035
|
+
left: 100,
|
2036
|
+
height: 100,
|
2037
|
+
width: 100
|
2038
|
+
},
|
2039
|
+
div = jQuery("<div>");
|
2040
|
+
|
2041
|
+
expect( 11 );
|
2042
|
+
|
2043
|
+
jQuery.each( animations, function( prop, value ) {
|
2044
|
+
var anim = {};
|
2045
|
+
anim[ prop ] = value;
|
2046
|
+
// the delay shouldn't matter at all!
|
2047
|
+
div.css( prop, 1 ).animate( anim, function() {
|
2048
|
+
ok( true, "Called animation callback for " + prop );
|
2049
|
+
}).delay( 100 );
|
2050
|
+
});
|
2051
|
+
equal( div.queue().length, 8, "8 animations in the queue" );
|
2052
|
+
div.finish();
|
2053
|
+
jQuery.each( animations, function( prop, value ) {
|
2054
|
+
equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
|
2055
|
+
});
|
2056
|
+
equal( div.queue().length, 0, "empty queue when done" );
|
2057
|
+
equal( div.is(":animated"), false, ":animated doesn't match" );
|
2058
|
+
|
2059
|
+
// cleanup
|
2060
|
+
div.remove();
|
2061
|
+
// leaves a "shadow timer" which does nothing around, need to force a tick
|
2062
|
+
jQuery.fx.tick();
|
2063
|
+
});
|
2064
|
+
|
2065
|
+
test( ".finish( false ) - unqueued animations", function() {
|
2066
|
+
var animations = {
|
2067
|
+
top: 100,
|
2068
|
+
left: 100,
|
2069
|
+
height: 100,
|
2070
|
+
width: 100
|
2071
|
+
},
|
2072
|
+
div = jQuery("<div>");
|
2073
|
+
|
2074
|
+
expect( 10 );
|
2075
|
+
|
2076
|
+
jQuery.each( animations, function( prop, value ) {
|
2077
|
+
var anim = {};
|
2078
|
+
anim[ prop ] = value;
|
2079
|
+
div.css( prop, 1 ).animate( anim, {
|
2080
|
+
queue: false,
|
2081
|
+
complete: function() {
|
2082
|
+
ok( true, "Called animation callback for " + prop );
|
2083
|
+
}
|
2084
|
+
});
|
2085
|
+
});
|
2086
|
+
equal( div.queue().length, 0, "0 animations in the queue" );
|
2087
|
+
div.finish( false );
|
2088
|
+
jQuery.each( animations, function( prop, value ) {
|
2089
|
+
equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
|
2090
|
+
});
|
2091
|
+
equal( div.is(":animated"), false, ":animated doesn't match" );
|
2092
|
+
|
2093
|
+
// cleanup
|
2094
|
+
div.remove();
|
2095
|
+
// leaves a "shadow timer" which does nothing around, need to force a tick
|
2096
|
+
jQuery.fx.tick();
|
2097
|
+
});
|
2098
|
+
|
2099
|
+
test( ".finish( \"custom\" ) - custom queue animations", function() {
|
2100
|
+
var animations = {
|
2101
|
+
top: 100,
|
2102
|
+
left: 100,
|
2103
|
+
height: 100,
|
2104
|
+
width: 100
|
2105
|
+
},
|
2106
|
+
div = jQuery("<div>");
|
2107
|
+
|
2108
|
+
expect( 11 );
|
2109
|
+
|
2110
|
+
jQuery.each( animations, function( prop, value ) {
|
2111
|
+
var anim = {};
|
2112
|
+
anim[ prop ] = value;
|
2113
|
+
div.css( prop, 1 ).animate( anim, {
|
2114
|
+
queue: "custom",
|
2115
|
+
complete: function() {
|
2116
|
+
ok( true, "Called animation callback for " + prop );
|
2117
|
+
}
|
2118
|
+
});
|
2119
|
+
});
|
2120
|
+
equal( div.queue( "custom" ).length, 4, "4 animations in the queue" );
|
2121
|
+
// start the first animation
|
2122
|
+
div.dequeue( "custom" );
|
2123
|
+
equal( div.is(":animated"), true, ":animated matches" );
|
2124
|
+
div.finish( "custom" );
|
2125
|
+
jQuery.each( animations, function( prop, value ) {
|
2126
|
+
equal( parseFloat( div.css( prop ) ), value, prop + " finished at correct value" );
|
2127
|
+
});
|
2128
|
+
equal( div.is(":animated"), false, ":animated doesn't match" );
|
2129
|
+
|
2130
|
+
// cleanup
|
2131
|
+
div.remove();
|
2132
|
+
// leaves a "shadow timer" which does nothing around, need to force a tick
|
2133
|
+
jQuery.fx.tick();
|
2134
|
+
});
|
2135
|
+
|
2136
|
+
test( ".finish() calls finish of custom queue functions", function() {
|
2137
|
+
function queueTester( next, hooks ) {
|
2138
|
+
hooks.stop = function( gotoEnd ) {
|
2139
|
+
inside++;
|
2140
|
+
equal( this, div[0] );
|
2141
|
+
ok( gotoEnd, "hooks.stop(true) called");
|
2142
|
+
};
|
2143
|
+
}
|
2144
|
+
var div = jQuery( "<div>" ),
|
2145
|
+
inside = 0,
|
2146
|
+
outside = 0;
|
2147
|
+
|
2148
|
+
expect( 6 );
|
2149
|
+
queueTester.finish = function() {
|
2150
|
+
outside++;
|
2151
|
+
ok( true, "Finish called on custom queue function" );
|
2152
|
+
};
|
2153
|
+
|
2154
|
+
div.queue( queueTester ).queue( queueTester ).queue( queueTester ).finish();
|
2155
|
+
|
2156
|
+
equal( inside, 1, "1 stop(true) callback" );
|
2157
|
+
equal( outside, 2, "2 finish callbacks" );
|
2158
|
+
|
2159
|
+
div.remove();
|
2160
|
+
});
|
2161
|
+
|
2162
|
+
asyncTest( ".finish() is applied correctly when multiple elements were animated (#13937)", function() {
|
2163
|
+
expect( 3 );
|
2164
|
+
|
2165
|
+
var elems = jQuery("<a>0</a><a>1</a><a>2</a>");
|
2166
|
+
|
2167
|
+
elems.animate( { opacity: 0 }, 1500 ).animate( { opacity: 1 }, 1500 );
|
2168
|
+
setTimeout(function() {
|
2169
|
+
elems.eq( 1 ).finish();
|
2170
|
+
ok( !elems.eq( 1 ).queue().length, "empty queue for .finish()ed element" );
|
2171
|
+
ok( elems.eq( 0 ).queue().length, "non-empty queue for preceding element" );
|
2172
|
+
ok( elems.eq( 2 ).queue().length, "non-empty queue for following element" );
|
2173
|
+
elems.stop( true );
|
2174
|
+
|
2175
|
+
// setTimeout needed in order to avoid setInterval/setTimeout execution bug in FF
|
2176
|
+
window.setTimeout(function() {
|
2177
|
+
start();
|
2178
|
+
}, 1000 );
|
2179
|
+
}, 100 );
|
2180
|
+
});
|
2181
|
+
|
2182
|
+
asyncTest( "slideDown() after stop() (#13483)", 2, function() {
|
2183
|
+
var ul = jQuery( "<ul style='height: 100px;display: block'></ul>" ),
|
2184
|
+
origHeight = ul.height();
|
2185
|
+
|
2186
|
+
// First test. slideUp() -> stop() in the middle -> slideDown() until the end
|
2187
|
+
ul.slideUp( 1000 );
|
2188
|
+
setTimeout( function() {
|
2189
|
+
ul.stop( true );
|
2190
|
+
ul.slideDown( 1, function() {
|
2191
|
+
equal( ul.height(), origHeight, "slideDown() after interrupting slideUp() with stop(). Height must be in original value" );
|
2192
|
+
|
2193
|
+
// Second test. slideDown() -> stop() in the middle -> slideDown() until the end
|
2194
|
+
ul.slideUp( 1, function() {
|
2195
|
+
ul.slideDown( 1000 );
|
2196
|
+
setTimeout( function() {
|
2197
|
+
ul.stop( true );
|
2198
|
+
ul.slideDown( 1, function() {
|
2199
|
+
equal( ul.height(), origHeight, "slideDown() after interrupting slideDown() with stop(). Height must be in original value" );
|
2200
|
+
|
2201
|
+
// Cleanup
|
2202
|
+
ul.remove();
|
2203
|
+
start();
|
2204
|
+
});
|
2205
|
+
}, 500 );
|
2206
|
+
});
|
2207
|
+
|
2208
|
+
});
|
2209
|
+
}, 500 );
|
2210
|
+
});
|
2211
|
+
|
2212
|
+
asyncTest( "fadeIn() after stop() (related to #13483)", 2, function() {
|
2213
|
+
var ul = jQuery( "<ul style='height: 100px;display: block; opacity: 1'></ul>" ),
|
2214
|
+
origOpacity = ul.css( "opacity" );
|
2215
|
+
|
2216
|
+
// First test. fadeOut() -> stop() in the middle -> fadeIn() until the end
|
2217
|
+
ul.fadeOut( 1000 );
|
2218
|
+
setTimeout( function() {
|
2219
|
+
ul.stop( true );
|
2220
|
+
ul.fadeIn( 1, function() {
|
2221
|
+
equal( ul.css( "opacity" ), origOpacity, "fadeIn() after interrupting fadeOut() with stop(). Opacity must be in original value" );
|
2222
|
+
|
2223
|
+
// Second test. fadeIn() -> stop() in the middle -> fadeIn() until the end
|
2224
|
+
ul.fadeOut( 1, function() {
|
2225
|
+
ul.fadeIn( 1000 );
|
2226
|
+
setTimeout( function() {
|
2227
|
+
ul.stop( true );
|
2228
|
+
ul.fadeIn( 1, function() {
|
2229
|
+
equal( ul.css("opacity"), origOpacity, "fadeIn() after interrupting fadeIn() with stop(). Opacity must be in original value" );
|
2230
|
+
|
2231
|
+
// Cleanup
|
2232
|
+
ul.remove();
|
2233
|
+
start();
|
2234
|
+
});
|
2235
|
+
}, 500 );
|
2236
|
+
});
|
2237
|
+
|
2238
|
+
});
|
2239
|
+
}, 500 );
|
2240
|
+
});
|
2241
|
+
|
2242
|
+
})();
|