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
476cbd2f
Commit
476cbd2f
authored
Oct 26, 2006
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rolled back Joern's changes. They've been moved to another branch, and will be merged for 1.1.
parent
44e4b36c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
26 deletions
+21
-26
event.js
src/event/event.js
+16
-4
jquery.js
src/jquery/jquery.js
+5
-22
No files found.
src/event/event.js
View file @
476cbd2f
...
@@ -1583,8 +1583,8 @@ new function(){
...
@@ -1583,8 +1583,8 @@ new function(){
var
o
=
e
[
i
];
var
o
=
e
[
i
];
// Handle event binding
// Handle event binding
jQuery
.
fn
[
o
]
=
function
(
f
,
amount
){
jQuery
.
fn
[
o
]
=
function
(
f
){
return
f
?
this
.
bind
(
o
,
f
,
amount
)
:
this
.
trigger
(
o
);
return
f
?
this
.
bind
(
o
,
f
)
:
this
.
trigger
(
o
);
};
};
// Handle event unbinding
// Handle event unbinding
...
@@ -1592,8 +1592,20 @@ new function(){
...
@@ -1592,8 +1592,20 @@ new function(){
// Finally, handle events that only fire once
// Finally, handle events that only fire once
jQuery
.
fn
[
"one"
+
o
]
=
function
(
f
){
jQuery
.
fn
[
"one"
+
o
]
=
function
(
f
){
// use bind with amount param to bind only once
// Attach the event listener
return
this
.
bind
(
o
,
f
,
1
);
return
this
.
each
(
function
(){
var
count
=
0
;
// Add the event
jQuery
.
event
.
add
(
this
,
o
,
function
(
e
){
// If this function has already been executed, stop
if
(
count
++
)
return
true
;
// And execute the bound function
return
f
.
apply
(
this
,
[
e
]);
});
});
};
};
};
};
...
...
src/jquery/jquery.js
View file @
476cbd2f
...
@@ -2271,7 +2271,7 @@ jQuery.extend({
...
@@ -2271,7 +2271,7 @@ jQuery.extend({
handle
:
function
(
event
)
{
handle
:
function
(
event
)
{
if
(
typeof
jQuery
==
"undefined"
)
return
false
;
if
(
typeof
jQuery
==
"undefined"
)
return
false
;
event
=
jQuery
.
event
.
fix
(
event
);
event
=
event
||
jQuery
.
event
.
fix
(
window
.
event
);
// If no correct event was found, fail
// If no correct event was found, fail
if
(
!
event
)
return
false
;
if
(
!
event
)
return
false
;
...
@@ -2295,19 +2295,16 @@ jQuery.extend({
...
@@ -2295,19 +2295,16 @@ jQuery.extend({
},
},
fix
:
function
(
event
)
{
fix
:
function
(
event
)
{
if
(
jQuery
.
browser
.
msie
)
{
if
(
event
)
{
event
=
window
.
event
;
event
.
preventDefault
=
function
()
{
event
.
preventDefault
=
function
()
{
this
.
returnValue
=
false
;
this
.
returnValue
=
false
;
};
};
event
.
stopPropagation
=
function
()
{
event
.
stopPropagation
=
function
()
{
this
.
cancelBubble
=
true
;
this
.
cancelBubble
=
true
;
};
};
event
.
target
=
event
.
srcElement
;
}
else
if
(
jQuery
.
browser
.
safari
&&
event
.
target
.
nodeType
==
3
)
{
event
=
jQuery
.
extend
({},
event
);
event
.
target
=
event
.
target
.
parentNode
;
}
}
return
event
;
return
event
;
}
}
...
@@ -3399,29 +3396,15 @@ jQuery.macros = {
...
@@ -3399,29 +3396,15 @@ jQuery.macros = {
* } )
* } )
* @desc Stop only an event from bubbling by using the stopPropagation method.
* @desc Stop only an event from bubbling by using the stopPropagation method.
*
*
* @example $("form").bind( "submit", function(event) {
* // do something after submit
* }, 1 )
* @desc Executes the function only on the first submit event and removes it afterwards
*
* @name bind
* @name bind
* @type jQuery
* @type jQuery
* @param String type An event type
* @param String type An event type
* @param Function fn A function to bind to the event on each of the set of matched elements
* @param Function fn A function to bind to the event on each of the set of matched elements
* @param Number amount An optional amount of times to execute the bound function
* @cat Events
* @cat Events
*/
*/
bind
:
function
(
type
,
fn
,
amount
)
{
bind
:
function
(
type
,
fn
)
{
if
(
fn
.
constructor
==
String
)
if
(
fn
.
constructor
==
String
)
fn
=
new
Function
(
"e"
,
(
!
fn
.
indexOf
(
"."
)
?
"jQuery(this)"
:
"return "
)
+
fn
);
fn
=
new
Function
(
"e"
,
(
!
fn
.
indexOf
(
"."
)
?
"jQuery(this)"
:
"return "
)
+
fn
);
if
(
amount
>
0
)
{
var
element
=
this
,
handler
=
fn
,
count
=
0
;
fn
=
function
(
e
)
{
if
(
++
count
>=
amount
)
jQuery
(
element
).
unbind
(
type
,
fn
);
handler
.
apply
(
element
,
[
e
]);
};
}
jQuery
.
event
.
add
(
this
,
type
,
fn
);
jQuery
.
event
.
add
(
this
,
type
,
fn
);
},
},
...
...
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