|
1 | | -if ( jQuery.browser ) { |
2 | | - module("deprecated"); |
3 | | - |
4 | | - if ( jQuery.get && !isLocal ) { |
5 | | - asyncTest( "browser", function() { |
6 | | - jQuery.get( "data/ua.txt", function( data ) { |
7 | | - var uas = data.split( "\n" ); |
8 | | - expect( (uas.length - 1) * 2 ); |
9 | | - |
10 | | - jQuery.each(uas, function() { |
11 | | - var parts = this.split( "\t" ), |
12 | | - agent = parts[2], |
13 | | - ua; |
14 | | - |
15 | | - if ( agent ) { |
16 | | - ua = jQuery.uaMatch( agent ); |
17 | | - equal( ua.browser, parts[0], "browser (" + agent + ")" ); |
18 | | - equal( ua.version, parts[1], "version (" + agent + ")" ); |
19 | | - } |
20 | | - }); |
21 | | - |
22 | | - start(); |
23 | | - }); |
24 | | - }); |
25 | | - } |
26 | | - |
27 | | - test("toggle(Function, Function, ...)", function() { |
28 | | - expect(16); |
29 | | - |
30 | | - var count = 0, |
31 | | - fn1 = function(e) { count++; }, |
32 | | - fn2 = function(e) { count--; }, |
33 | | - preventDefault = function(e) { e.preventDefault(); }, |
34 | | - link = jQuery("#mark"); |
35 | | - link.click(preventDefault).click().toggle(fn1, fn2).click().click().click().click().click(); |
36 | | - equal( count, 1, "Check for toggle(fn, fn)" ); |
37 | | - |
38 | | - jQuery("#firstp").toggle(function () { |
39 | | - equal(arguments.length, 4, "toggle correctly passes through additional triggered arguments, see #1701" ); |
40 | | - }, function() {}).trigger("click", [ 1, 2, 3 ]); |
41 | | - |
42 | | - var first = 0; |
43 | | - jQuery("#simon1").one("click", function() { |
44 | | - ok( true, "Execute event only once" ); |
45 | | - jQuery(this).toggle(function() { |
46 | | - equal( first++, 0, "toggle(Function,Function) assigned from within one('xxx'), see #1054" ); |
47 | | - }, function() { |
48 | | - equal( first, 1, "toggle(Function,Function) assigned from within one('xxx'), see #1054" ); |
49 | | - }); |
50 | | - return false; |
51 | | - }).click().click().click(); |
52 | | - |
53 | | - var turn = 0; |
54 | | - var fns = [ |
55 | | - function(){ |
56 | | - turn = 1; |
57 | | - }, |
58 | | - function(){ |
59 | | - turn = 2; |
60 | | - }, |
61 | | - function(){ |
62 | | - turn = 3; |
63 | | - } |
64 | | - ]; |
65 | | - |
66 | | - var $div = jQuery("<div> </div>").toggle( fns[0], fns[1], fns[2] ); |
67 | | - $div.click(); |
68 | | - equal( turn, 1, "Trying toggle with 3 functions, attempt 1 yields 1"); |
69 | | - $div.click(); |
70 | | - equal( turn, 2, "Trying toggle with 3 functions, attempt 2 yields 2"); |
71 | | - $div.click(); |
72 | | - equal( turn, 3, "Trying toggle with 3 functions, attempt 3 yields 3"); |
73 | | - $div.click(); |
74 | | - equal( turn, 1, "Trying toggle with 3 functions, attempt 4 yields 1"); |
75 | | - $div.click(); |
76 | | - equal( turn, 2, "Trying toggle with 3 functions, attempt 5 yields 2"); |
77 | | - |
78 | | - $div.unbind("click",fns[0]); |
79 | | - var data = jQuery._data( $div[0], "events" ); |
80 | | - ok( !data, "Unbinding one function from toggle unbinds them all"); |
81 | | - |
82 | | - // manually clean up detached elements |
83 | | - $div.remove(); |
84 | | - |
85 | | - // Test Multi-Toggles |
86 | | - var a = [], b = []; |
87 | | - $div = jQuery("<div/>"); |
88 | | - $div.toggle(function(){ a.push(1); }, function(){ a.push(2); }); |
89 | | - $div.click(); |
90 | | - deepEqual( a, [1], "Check that a click worked." ); |
91 | | - |
92 | | - $div.toggle(function(){ b.push(1); }, function(){ b.push(2); }); |
93 | | - $div.click(); |
94 | | - deepEqual( a, [1,2], "Check that a click worked with a second toggle." ); |
95 | | - deepEqual( b, [1], "Check that a click worked with a second toggle." ); |
96 | | - |
97 | | - $div.click(); |
98 | | - deepEqual( a, [1,2,1], "Check that a click worked with a second toggle, second click." ); |
99 | | - deepEqual( b, [1,2], "Check that a click worked with a second toggle, second click." ); |
100 | | - |
101 | | - // manually clean up detached elements |
102 | | - $div.remove(); |
103 | | - }); |
104 | | - |
105 | | - test("attrFn test", function() { |
106 | | - expect(1); |
107 | | - ok(!!jQuery.attrFn, "attrFnPresent"); |
108 | | - }); |
109 | | - |
110 | | - test("hover pseudo-event", function() { |
111 | | - expect(2); |
112 | | - |
113 | | - var balance = 0; |
114 | | - jQuery( "#firstp" ) |
115 | | - .on( "hovercraft", function() { |
116 | | - ok( false, "hovercraft is full of ills" ); |
117 | | - }) |
118 | | - .on( "click.hover.me.not", function( e ) { |
119 | | - equal( e.handleObj.namespace, "hover.me.not", "hover hack doesn't mangle namespaces" ); |
120 | | - }) |
121 | | - .bind("hover", function( e ) { |
122 | | - if ( e.type === "mouseenter" ) { |
123 | | - balance++; |
124 | | - } else if ( e.type === "mouseleave" ) { |
125 | | - balance--; |
126 | | - } else { |
127 | | - ok( false, "hover pseudo: unknown event type "+e.type ); |
128 | | - } |
129 | | - }) |
130 | | - .trigger("click") |
131 | | - .trigger("mouseenter") |
132 | | - .trigger("mouseleave") |
133 | | - .unbind("hover") |
134 | | - .trigger("mouseenter"); |
135 | | - |
136 | | - equal( balance, 0, "hover pseudo-event" ); |
137 | | - }); |
138 | | - |
139 | | -} |
| 1 | +module("deprecated"); |
0 commit comments