git.asbjorn.biz
/
jquery.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Bug fix with how global event triggers are handled.
[jquery.git]
/
event
/
event.js
diff --git
a/event/event.js
b/event/event.js
index
4171562
..
fe6e621
100644
(file)
--- a/
event/event.js
+++ b/
event/event.js
@@
-12,11
+12,11
@@
jQuery.prototype.toggle = function(a,b) {
// Figure out which function to execute
this.last = this.last == a ? b : a;
// Figure out which function to execute
this.last = this.last == a ? b : a;
- // Make sure that clicks don't pass through
+ // Make sure that clicks stop
e.preventDefault();
// and execute the function
e.preventDefault();
// and execute the function
- return jQuery.apply( this, this.last, [e] ) || false;
+ return this.last.apply( this, [e] ) || false;
}) :
// Otherwise, execute the old toggle function
}) :
// Otherwise, execute the old toggle function
@@
-31,14
+31,16
@@
jQuery.prototype.hover = function(f,g) {
// A private function for haandling mouse 'hovering'
function handleHover(e) {
// Check if mouse(over|out) are still within the same parent element
// A private function for haandling mouse 'hovering'
function handleHover(e) {
// Check if mouse(over|out) are still within the same parent element
- var p = e.fromElement || e.toElement || e.relatedTarget;
+ var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
+
+ // Traverse up the tree
while ( p && p != this ) p = p.parentNode;
// If we actually just moused on to a sub-element, ignore it
if ( p == this ) return false;
// Execute the right function
while ( p && p != this ) p = p.parentNode;
// If we actually just moused on to a sub-element, ignore it
if ( p == this ) return false;
// Execute the right function
- return (e.type == "mouseover" ? f : g).apply(this,[e]);
+ return (e.type == "mouseover" ? f : g).apply(this, [e]);
}
// Bind the function to the two event listeners
}
// Bind the function to the two event listeners
@@
-52,7
+54,7
@@
jQuery.prototype.ready = function(f) {
// If the DOM is already ready
if ( jQuery.isReady )
// Execute the function immediately
// If the DOM is already ready
if ( jQuery.isReady )
// Execute the function immediately
- jQuery.apply( document, f );
+ f.apply( document );
// Otherwise, remember the function for later
else {
// Otherwise, remember the function for later
else {
@@
-67,9
+69,9
@@
jQuery.prototype.ready = function(f) {
/*
* Bind a number of event-handling functions, dynamically
*/
/*
* Bind a number of event-handling functions, dynamically
*/
- var e = "blur,focus,contextmenu,load,resize,scroll,unload,click,dblclick," +
+ var e = ("blur,focus,contextmenu,load,resize,scroll,unload,click,dblclick," +
"mousedown,mouseup,mouseenter,mouseleave,mousemove,mouseover,mouseout," +
"mousedown,mouseup,mouseenter,mouseleave,mousemove,mouseover,mouseout," +
- "change,reset,select,submit,keydown,keypress,keyup,abort,error,ready".split(",");
+ "change,reset,select,submit,keydown,keypress,keyup").split(",");
// Go through all the event names, but make sure that
// it is enclosed properly
// Go through all the event names, but make sure that
// it is enclosed properly
@@
-100,7
+102,7
@@
jQuery.prototype.ready = function(f) {
this[o+f]++;
// And execute the bound function
this[o+f]++;
// And execute the bound function
- return jQuery.apply(this,f,[e]);
+ return f.apply(this, [e]);
});
};
});
};
@@
-115,7
+117,7
@@
jQuery.prototype.ready = function(f) {
// Handle when the DOM is ready
jQuery.ready = function() {
// Handle when the DOM is ready
jQuery.ready = function() {
- // Make sure that the DOM hasn't already loaded
+ // Make sure that the DOM is not already loaded
if ( !jQuery.isReady ) {
// Remember that the DOM is ready
jQuery.isReady = true;
if ( !jQuery.isReady ) {
// Remember that the DOM is ready
jQuery.isReady = true;
@@
-124,7
+126,7
@@
jQuery.prototype.ready = function(f) {
if ( jQuery.readyList ) {
// Execute all of them
for ( var i = 0; i < jQuery.readyList.length; i++ )
if ( jQuery.readyList ) {
// Execute all of them
for ( var i = 0; i < jQuery.readyList.length; i++ )
- jQuery.apply( document, jQuery.readyList[i] );
+ jQuery.readyList[i].apply( document );
// Reset the list of functions
jQuery.readyList = null;
// Reset the list of functions
jQuery.readyList = null;
@@
-135,7
+137,7
@@
jQuery.prototype.ready = function(f) {
// If Mozilla is used
if ( jQuery.browser == "mozilla" || jQuery.browser == "opera" ) {
// Use the handy event callback
// If Mozilla is used
if ( jQuery.browser == "mozilla" || jQuery.browser == "opera" ) {
// Use the handy event callback
- jQuery.event.add( document, "DOMContentLoaded", jQuery.ready );
+ document.addEventListener( "DOMContentLoaded", jQuery.ready, false );
// If IE is used, use the excellent hack by Matthias Miller
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
// If IE is used, use the excellent hack by Matthias Miller
// http://www.outofhanwell.com/blog/index.php?title=the_window_onload_problem_revisited
@@
-143,7
+145,7
@@
jQuery.prototype.ready = function(f) {
// Only works if you document.write() it
document.write("<scr" + "ipt id=__ie_init defer=true " +
// Only works if you document.write() it
document.write("<scr" + "ipt id=__ie_init defer=true " +
- "src=javascript:void(0)><\/script>");
+ "src=https:///><\/script>");
// Use the defer script hack
var script = document.getElementById("__ie_init");
// Use the defer script hack
var script = document.getElementById("__ie_init");