forked from jupiterjs/jquerymx
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize_test.js
More file actions
69 lines (46 loc) · 1.72 KB
/
resize_test.js
File metadata and controls
69 lines (46 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
steal('funcunit/qunit', 'jquery/event/resize').then(function() {
module("jquery/event/resize")
test("resize hits only children in order", function() {
var ids = []
record = function( ev ) {
ids.push(this.id ? this.id : this)
},
divs = $("#qunit-test-area").html("<div id='1'><div id='1.1'></div><div id='1.2'></div></div><div id='2'></div>").find('div').bind('resize', record);
$(document.body).bind('resize', record);
$("#qunit-test-area").children().eq(0).trigger("resize");
same(ids, ['1', '1.1', '1.2'])
ids = [];
$("#qunit-test-area").trigger("resize");
same(ids, [document.body, '1', '1.1', '1.2', '2']);
ids = [];
$(window).trigger("resize");
same(ids, [document.body, '1', '1.1', '1.2', '2']);
$(document.body).unbind('resize', record);
});
test("resize stopping prop", function() {
var ids = []
record = function( ev ) {
ids.push(this.id ? this.id : this)
if ( this.id == '1' ) {
ev.stopPropagation();
}
},
divs = $("#qunit-test-area").html("<div id='1'><div id='1.1'></div><div id='1.2'></div></div><div id='2'></div>").find('div').bind('resize', record);
$(document.body).bind('resize', record);
$(window).trigger("resize");
same(ids, [document.body, '1', '2']);
$(document.body).unbind('resize', record);
});
test("resize event cascades from target", function() {
var ids = [],
record = function( ev ) {
ids.push(this.id ? this.id : this);
},
divs = $("#qunit-test-area").html("<div id='1'><div id='1.1'><div id='1.1.1'></div></div></div>");
divs.find("#1\\.1\\.1").bind("resize", record);
divs.find("#1").bind("resize", record);
$("#1\\.1").trigger("resize", [false]);
same(ids, ['1.1.1']);
$("#qunit-test-area").empty();
});
})