forked from bitovi/jquerypp
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathresize_test.js
More file actions
73 lines (50 loc) · 1.88 KB
/
resize_test.js
File metadata and controls
73 lines (50 loc) · 1.88 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
70
71
72
73
steal('funcunit/qunit', 'jquerypp/event/resize').then(function() {
module("jquerypp/event/resize")
test("resize hits only children in order", function() {
var ids = []
record = function( ev ) {
if($(this).is(document.body)) {
ids.push('body');
} else {
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.tagName.toLowerCase(), '1', '1.1', '1.2', '2']);
ids = [];
$(window).trigger("resize");
same(ids, [document.body.tagName.toLowerCase(), '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.tagName.toLowerCase())
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.tagName.toLowerCase(), '1']);
$(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();
});
})