Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
87bd3b5a
Commit
87bd3b5a
authored
Oct 15, 2012
by
Rick Waldron
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix style nit: indent inside if statement
parent
9104a3d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
99 additions
and
99 deletions
+99
-99
deprecated.js
test/unit/deprecated.js
+99
-99
No files found.
test/unit/deprecated.js
View file @
87bd3b5a
if
(
jQuery
.
browser
)
{
if
(
jQuery
.
browser
)
{
module
(
"deprecated"
);
module
(
"deprecated"
);
if
(
jQuery
.
get
&&
!
isLocal
)
{
if
(
jQuery
.
get
&&
!
isLocal
)
{
asyncTest
(
"browser"
,
function
()
{
asyncTest
(
"browser"
,
function
()
{
jQuery
.
get
(
"data/ua.txt"
,
function
(
data
)
{
jQuery
.
get
(
"data/ua.txt"
,
function
(
data
)
{
var
uas
=
data
.
split
(
"
\n
"
);
var
uas
=
data
.
split
(
"
\n
"
);
expect
(
(
uas
.
length
-
1
)
*
2
);
expect
(
(
uas
.
length
-
1
)
*
2
);
jQuery
.
each
(
uas
,
function
()
{
jQuery
.
each
(
uas
,
function
()
{
var
parts
=
this
.
split
(
"
\
t"
),
var
parts
=
this
.
split
(
"
\
t"
),
agent
=
parts
[
2
],
agent
=
parts
[
2
],
ua
;
ua
;
if
(
agent
)
{
if
(
agent
)
{
ua
=
jQuery
.
uaMatch
(
agent
);
ua
=
jQuery
.
uaMatch
(
agent
);
equal
(
ua
.
browser
,
parts
[
0
],
"browser ("
+
agent
+
")"
);
equal
(
ua
.
browser
,
parts
[
0
],
"browser ("
+
agent
+
")"
);
equal
(
ua
.
version
,
parts
[
1
],
"version ("
+
agent
+
")"
);
equal
(
ua
.
version
,
parts
[
1
],
"version ("
+
agent
+
")"
);
}
}
});
start
();
});
});
start
();
});
});
}
test
(
"toggle(Function, Function, ...)"
,
function
()
{
expect
(
16
);
var
count
=
0
,
fn1
=
function
(
e
)
{
count
++
;
},
fn2
=
function
(
e
)
{
count
--
;
},
preventDefault
=
function
(
e
)
{
e
.
preventDefault
();
},
link
=
jQuery
(
"#mark"
);
link
.
click
(
preventDefault
).
click
().
toggle
(
fn1
,
fn2
).
click
().
click
().
click
().
click
().
click
();
equal
(
count
,
1
,
"Check for toggle(fn, fn)"
);
jQuery
(
"#firstp"
).
toggle
(
function
()
{
equal
(
arguments
.
length
,
4
,
"toggle correctly passes through additional triggered arguments, see #1701"
);
},
function
()
{}).
trigger
(
"click"
,
[
1
,
2
,
3
]);
var
first
=
0
;
jQuery
(
"#simon1"
).
one
(
"click"
,
function
()
{
ok
(
true
,
"Execute event only once"
);
jQuery
(
this
).
toggle
(
function
()
{
equal
(
first
++
,
0
,
"toggle(Function,Function) assigned from within one('xxx'), see #1054"
);
},
function
()
{
equal
(
first
,
1
,
"toggle(Function,Function) assigned from within one('xxx'), see #1054"
);
});
return
false
;
}).
click
().
click
().
click
();
var
turn
=
0
;
var
fns
=
[
function
(){
turn
=
1
;
},
function
(){
turn
=
2
;
},
function
(){
turn
=
3
;
}
];
var
$div
=
jQuery
(
"<div> </div>"
).
toggle
(
fns
[
0
],
fns
[
1
],
fns
[
2
]
);
$div
.
click
();
equal
(
turn
,
1
,
"Trying toggle with 3 functions, attempt 1 yields 1"
);
$div
.
click
();
equal
(
turn
,
2
,
"Trying toggle with 3 functions, attempt 2 yields 2"
);
$div
.
click
();
equal
(
turn
,
3
,
"Trying toggle with 3 functions, attempt 3 yields 3"
);
$div
.
click
();
equal
(
turn
,
1
,
"Trying toggle with 3 functions, attempt 4 yields 1"
);
$div
.
click
();
equal
(
turn
,
2
,
"Trying toggle with 3 functions, attempt 5 yields 2"
);
$div
.
unbind
(
"click"
,
fns
[
0
]);
var
data
=
jQuery
.
_data
(
$div
[
0
],
"events"
);
ok
(
!
data
,
"Unbinding one function from toggle unbinds them all"
);
// manually clean up detached elements
$div
.
remove
();
// Test Multi-Toggles
var
a
=
[],
b
=
[];
$div
=
jQuery
(
"<div/>"
);
$div
.
toggle
(
function
(){
a
.
push
(
1
);
},
function
(){
a
.
push
(
2
);
});
$div
.
click
();
deepEqual
(
a
,
[
1
],
"Check that a click worked."
);
$div
.
toggle
(
function
(){
b
.
push
(
1
);
},
function
(){
b
.
push
(
2
);
});
$div
.
click
();
deepEqual
(
a
,
[
1
,
2
],
"Check that a click worked with a second toggle."
);
deepEqual
(
b
,
[
1
],
"Check that a click worked with a second toggle."
);
$div
.
click
();
deepEqual
(
a
,
[
1
,
2
,
1
],
"Check that a click worked with a second toggle, second click."
);
deepEqual
(
b
,
[
1
,
2
],
"Check that a click worked with a second toggle, second click."
);
// manually clean up detached elements
$div
.
remove
();
});
});
}
}
test
(
"toggle(Function, Function, ...)"
,
function
()
{
expect
(
16
);
var
count
=
0
,
fn1
=
function
(
e
)
{
count
++
;
},
fn2
=
function
(
e
)
{
count
--
;
},
preventDefault
=
function
(
e
)
{
e
.
preventDefault
();
},
link
=
jQuery
(
"#mark"
);
link
.
click
(
preventDefault
).
click
().
toggle
(
fn1
,
fn2
).
click
().
click
().
click
().
click
().
click
();
equal
(
count
,
1
,
"Check for toggle(fn, fn)"
);
jQuery
(
"#firstp"
).
toggle
(
function
()
{
equal
(
arguments
.
length
,
4
,
"toggle correctly passes through additional triggered arguments, see #1701"
);
},
function
()
{}).
trigger
(
"click"
,
[
1
,
2
,
3
]);
var
first
=
0
;
jQuery
(
"#simon1"
).
one
(
"click"
,
function
()
{
ok
(
true
,
"Execute event only once"
);
jQuery
(
this
).
toggle
(
function
()
{
equal
(
first
++
,
0
,
"toggle(Function,Function) assigned from within one('xxx'), see #1054"
);
},
function
()
{
equal
(
first
,
1
,
"toggle(Function,Function) assigned from within one('xxx'), see #1054"
);
});
return
false
;
}).
click
().
click
().
click
();
var
turn
=
0
;
var
fns
=
[
function
(){
turn
=
1
;
},
function
(){
turn
=
2
;
},
function
(){
turn
=
3
;
}
];
var
$div
=
jQuery
(
"<div> </div>"
).
toggle
(
fns
[
0
],
fns
[
1
],
fns
[
2
]
);
$div
.
click
();
equal
(
turn
,
1
,
"Trying toggle with 3 functions, attempt 1 yields 1"
);
$div
.
click
();
equal
(
turn
,
2
,
"Trying toggle with 3 functions, attempt 2 yields 2"
);
$div
.
click
();
equal
(
turn
,
3
,
"Trying toggle with 3 functions, attempt 3 yields 3"
);
$div
.
click
();
equal
(
turn
,
1
,
"Trying toggle with 3 functions, attempt 4 yields 1"
);
$div
.
click
();
equal
(
turn
,
2
,
"Trying toggle with 3 functions, attempt 5 yields 2"
);
$div
.
unbind
(
"click"
,
fns
[
0
]);
var
data
=
jQuery
.
_data
(
$div
[
0
],
"events"
);
ok
(
!
data
,
"Unbinding one function from toggle unbinds them all"
);
// manually clean up detached elements
$div
.
remove
();
// Test Multi-Toggles
var
a
=
[],
b
=
[];
$div
=
jQuery
(
"<div/>"
);
$div
.
toggle
(
function
(){
a
.
push
(
1
);
},
function
(){
a
.
push
(
2
);
});
$div
.
click
();
deepEqual
(
a
,
[
1
],
"Check that a click worked."
);
$div
.
toggle
(
function
(){
b
.
push
(
1
);
},
function
(){
b
.
push
(
2
);
});
$div
.
click
();
deepEqual
(
a
,
[
1
,
2
],
"Check that a click worked with a second toggle."
);
deepEqual
(
b
,
[
1
],
"Check that a click worked with a second toggle."
);
$div
.
click
();
deepEqual
(
a
,
[
1
,
2
,
1
],
"Check that a click worked with a second toggle, second click."
);
deepEqual
(
b
,
[
1
,
2
],
"Check that a click worked with a second toggle, second click."
);
// manually clean up detached elements
$div
.
remove
();
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment