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
0ae7198b
Commit
0ae7198b
authored
Jan 02, 2007
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cleaned up a bunch of the event code, removed .oneEvent() and .unEvent().
parent
07612d92
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
39 deletions
+26
-39
event.js
src/event/event.js
+26
-39
No files found.
src/event/event.js
View file @
0ae7198b
...
@@ -93,7 +93,8 @@ jQuery.event = {
...
@@ -93,7 +93,8 @@ jQuery.event = {
handle
:
function
(
event
)
{
handle
:
function
(
event
)
{
if
(
typeof
jQuery
==
"undefined"
)
return
false
;
if
(
typeof
jQuery
==
"undefined"
)
return
false
;
event
=
jQuery
.
event
.
fix
(
event
||
window
.
event
||
{}
);
// Empty object is for triggered events with no data
// Empty object is for triggered events with no data
event
=
jQuery
.
event
.
fix
(
event
||
window
.
event
||
{}
);
// returned undefined or false
// returned undefined or false
var
returnValue
;
var
returnValue
;
...
@@ -136,14 +137,16 @@ jQuery.event = {
...
@@ -136,14 +137,16 @@ jQuery.event = {
// check if target is a textnode (safari)
// check if target is a textnode (safari)
if
(
event
.
target
.
nodeType
==
3
)
{
if
(
event
.
target
.
nodeType
==
3
)
{
// store a copy of the original event object and clone because target is read only
// store a copy of the original event object
// and clone because target is read only
var
originalEvent
=
event
;
var
originalEvent
=
event
;
event
=
jQuery
.
extend
({},
originalEvent
);
event
=
jQuery
.
extend
({},
originalEvent
);
// get parentnode from textnode
// get parentnode from textnode
event
.
target
=
originalEvent
.
target
.
parentNode
;
event
.
target
=
originalEvent
.
target
.
parentNode
;
// add preventDefault and stopPropagation since they will not work on the clone
// add preventDefault and stopPropagation since
// they will not work on the clone
event
.
preventDefault
=
function
()
{
event
.
preventDefault
=
function
()
{
return
originalEvent
.
preventDefault
();
return
originalEvent
.
preventDefault
();
};
};
...
@@ -153,17 +156,15 @@ jQuery.event = {
...
@@ -153,17 +156,15 @@ jQuery.event = {
}
}
// fix preventDefault and stopPropagation
// fix preventDefault and stopPropagation
if
(
!
event
.
preventDefault
)
{
if
(
!
event
.
preventDefault
)
event
.
preventDefault
=
function
()
{
event
.
preventDefault
=
function
()
{
this
.
returnValue
=
false
;
this
.
returnValue
=
false
;
};
};
}
if
(
!
event
.
stopPropagation
)
{
if
(
!
event
.
stopPropagation
)
event
.
stopPropagation
=
function
()
{
event
.
stopPropagation
=
function
()
{
this
.
cancelBubble
=
true
;
this
.
cancelBubble
=
true
;
};
};
}
return
event
;
return
event
;
}
}
...
@@ -1032,35 +1033,16 @@ new function(){
...
@@ -1032,35 +1033,16 @@ new function(){
return
f
?
this
.
bind
(
o
,
f
)
:
this
.
trigger
(
o
);
return
f
?
this
.
bind
(
o
,
f
)
:
this
.
trigger
(
o
);
};
};
// Handle event unbinding
// TODO remove
jQuery
.
fn
[
"un"
+
o
]
=
function
(
f
){
return
this
.
unbind
(
o
,
f
);
};
// Finally, handle events that only fire once
// TODO remove
jQuery
.
fn
[
"one"
+
o
]
=
function
(
f
){
// save cloned reference to this
var
element
=
jQuery
(
this
);
var
handler
=
function
()
{
// unbind itself when executed
element
.
unbind
(
o
,
handler
);
element
=
null
;
// apply original handler with the same arguments
return
f
.
apply
(
this
,
arguments
);
};
return
this
.
bind
(
o
,
handler
);
};
};
};
// If Mozilla is used
// If Mozilla is used
if
(
jQuery
.
browser
.
mozilla
||
jQuery
.
browser
.
opera
)
{
if
(
jQuery
.
browser
.
mozilla
||
jQuery
.
browser
.
opera
)
// Use the handy event callback
// Use the handy event callback
document
.
addEventListener
(
"DOMContentLoaded"
,
jQuery
.
ready
,
false
);
document
.
addEventListener
(
"DOMContentLoaded"
,
jQuery
.
ready
,
false
);
// If IE is used, use the excellent hack by Matthias Miller
// If IE is used, use the excellent hack by Matthias Miller
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
}
else
if
(
jQuery
.
browser
.
msie
)
{
else
if
(
jQuery
.
browser
.
msie
)
{
// Only works if you document.write() it
// Only works if you document.write() it
document
.
write
(
"<scr"
+
"ipt id=__ie_init defer=true "
+
document
.
write
(
"<scr"
+
"ipt id=__ie_init defer=true "
+
...
@@ -1068,7 +1050,9 @@ new function(){
...
@@ -1068,7 +1050,9 @@ new function(){
// Use the defer script hack
// Use the defer script hack
var
script
=
document
.
getElementById
(
"__ie_init"
);
var
script
=
document
.
getElementById
(
"__ie_init"
);
if
(
script
)
// script does not exist if jQuery is loaded dynamically
// script does not exist if jQuery is loaded dynamically
if
(
script
)
script
.
onreadystatechange
=
function
()
{
script
.
onreadystatechange
=
function
()
{
if
(
this
.
readyState
!=
"complete"
)
return
;
if
(
this
.
readyState
!=
"complete"
)
return
;
this
.
parentNode
.
removeChild
(
this
);
this
.
parentNode
.
removeChild
(
this
);
...
@@ -1079,7 +1063,7 @@ new function(){
...
@@ -1079,7 +1063,7 @@ new function(){
script
=
null
;
script
=
null
;
// If Safari is used
// If Safari is used
}
else
if
(
jQuery
.
browser
.
safari
)
{
}
else
if
(
jQuery
.
browser
.
safari
)
// Continually check to see if the document.readyState is valid
// Continually check to see if the document.readyState is valid
jQuery
.
safariTimer
=
setInterval
(
function
(){
jQuery
.
safariTimer
=
setInterval
(
function
(){
// loaded and complete are both valid states
// loaded and complete are both valid states
...
@@ -1094,7 +1078,6 @@ new function(){
...
@@ -1094,7 +1078,6 @@ new function(){
jQuery
.
ready
();
jQuery
.
ready
();
}
}
},
10
);
},
10
);
}
// A fallback to window.onload, that will always work
// A fallback to window.onload, that will always work
jQuery
.
event
.
add
(
window
,
"load"
,
jQuery
.
ready
);
jQuery
.
event
.
add
(
window
,
"load"
,
jQuery
.
ready
);
...
@@ -1102,10 +1085,14 @@ new function(){
...
@@ -1102,10 +1085,14 @@ new function(){
};
};
// Clean up after IE to avoid memory leaks
// Clean up after IE to avoid memory leaks
if
(
jQuery
.
browser
.
msie
)
jQuery
(
window
).
unload
(
function
()
{
if
(
jQuery
.
browser
.
msie
)
var
event
=
jQuery
.
event
,
global
=
event
.
global
;
jQuery
(
window
).
bind
(
"unload"
,
function
()
{
for
(
var
type
in
global
)
{
var
global
=
jQuery
.
event
.
global
;
for
(
var
type
in
global
)
{
var
els
=
global
[
type
],
i
=
els
.
length
;
var
els
=
global
[
type
],
i
=
els
.
length
;
if
(
i
>
0
)
do
if
(
type
!=
'unload'
)
event
.
remove
(
els
[
i
-
1
],
type
);
while
(
--
i
);
if
(
i
&&
type
!=
'unload'
)
do
jQuery
.
event
.
remove
(
els
[
i
-
1
],
type
);
while
(
--
i
);
}
}
});
});
\ No newline at end of file
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