Хранилища Subversion ant

Сравнить редакции

Не учитывать пробелы Редакция 282 → Редакция 283

/trunk/js/jquery.js
6,8 → 6,8
* Dual licensed under the MIT and GPL licenses.
* http://docs.jquery.com/License
*
* Date: 2009-04-01 00:35:20 +0700 (Срд, 01 Апр 2009)
* Revision: 6303
* Date: 2009-05-12 22:43:51 +0700 (Втр, 12 Май 2009)
* Revision: 6348
*/
(function(){
 
31,7 → 31,7
 
jQuery = window.jQuery = window.$ = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return selector === undefined ?
return arguments.length === 0 ?
rootjQuery :
new jQuery.fn.init( selector, context );
},
49,12 → 49,6
// Save a reference to the core toString method
toString = Object.prototype.toString;
 
// Define the main jQuery method
jQuery = window.jQuery = window.$ = function( selector, context ) {
// The jQuery object is actually just the init constructor 'enhanced'
return new jQuery.fn.init( selector, context );
};
 
jQuery.fn = jQuery.prototype = {
init: function( selector, context ) {
var match, elem, ret;
195,10 → 189,16
// Determine the position of an element within
// the matched set of elements
index: function( elem ) {
if ( !elem || typeof elem === "string" ) {
return jQuery.inArray( this[0],
// If it receives a string, the selector is used
// If it receives nothing, the siblings are used
elem ? jQuery( elem ) : this.parent().children() );
}
// Locate the position of the desired element
return jQuery.inArray(
// If it receives a jQuery object, the first element is used
elem && elem.jquery ? elem[0] : elem, this );
elem.jquery ? elem[0] : elem, this );
},
 
is: function( selector ) {
368,7 → 368,7
 
if ( array != null ) {
i = array.length;
 
// The window, strings (and functions) also have 'length'
if ( i == null || typeof array === "string" || jQuery.isFunction(array) || array.setInterval ) {
ret[0] = array;
396,7 → 396,7
// We have to loop this way because IE & Opera overwrite the length
// expando of getElementsByTagName
var i = 0, elem, pos = first.length;
 
// Also, we need to make sure that the correct elements are being returned
// (IE returns comment nodes in a '*' query)
if ( !jQuery.support.getAll ) {
652,7 → 652,8
 
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,
done = 0,
toString = Object.prototype.toString;
toString = Object.prototype.toString,
hasDuplicate = false;
 
var Sizzle = function(selector, context, results, seed) {
results = results || [];
661,19 → 662,19
if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
return [];
}
 
if ( !selector || typeof selector !== "string" ) {
return results;
}
 
var parts = [], m, set, checkSet, check, mode, extra, prune = true, contextXML = isXML(context);
 
// Reset the position of the chunker regexp (start from head)
chunker.lastIndex = 0;
 
while ( (m = chunker.exec(selector)) !== null ) {
parts.push( m[1] );
 
if ( m[2] ) {
extra = RegExp.rightContext;
break;
802,7 → 803,7
 
for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
var type = Expr.order[i], match;
 
if ( (match = Expr.match[ type ].exec( expr )) ) {
var left = RegExp.leftContext;
 
1064,7 → 1065,7
},
ATTR: function(match, curLoop, inplace, result, not, isXML){
var name = match[1].replace(/\\/g, "");
 
if ( !isXML && Expr.attrMap[name] ) {
match[1] = Expr.attrMap[name];
}
1090,7 → 1091,7
} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
return true;
}
 
return match;
},
POS: function(match){
1224,10 → 1225,10
if ( first == 1 && last == 0 ) {
return true;
}
 
var doneName = match[0],
parent = elem.parentNode;
 
if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
var count = 0;
for ( node = parent.firstChild; node; node = node.nextSibling ) {
1234,10 → 1235,10
if ( node.nodeType === 1 ) {
node.nodeIndex = ++count;
}
}
}
parent.sizcache = doneName;
}
 
var diff = elem.nodeIndex - last;
if ( first == 0 ) {
return diff == 0;
1310,7 → 1311,7
results.push.apply( results, array );
return results;
}
 
return array;
};
 
1404,6 → 1405,7
}
 
root.removeChild( form );
root = form = null; // release memory in IE
})();
 
(function(){
1444,6 → 1446,8
return elem.getAttribute("href", 2);
};
}
 
div = null; // release memory in IE
})();
 
if ( document.querySelectorAll ) (function(){
1455,7 → 1459,7
if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
return;
}
 
Sizzle = function(query, context, extra, seed){
context = context || document;
 
1466,7 → 1470,7
return makeArray( context.querySelectorAll(query), extra );
} catch(e){}
}
 
return oldSizzle(query, context, extra, seed);
};
 
1473,6 → 1477,8
for ( var prop in oldSizzle ) {
Sizzle[ prop ] = oldSizzle[ prop ];
}
 
div = null; // release memory in IE
})();
 
if ( document.getElementsByClassName && document.documentElement.getElementsByClassName ) (function(){
1495,6 → 1501,8
return context.getElementsByClassName(match[1]);
}
};
 
div = null; // release memory in IE
})();
 
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
1922,9 → 1930,24
},
 
toggleClass: function( classNames, state ) {
if( typeof state !== "boolean" )
state = !jQuery.className.has( this, classNames );
jQuery.className[ state ? "add" : "remove" ]( this, classNames );
var type = typeof classNames;
if ( type === "string" ) {
// toggle individual class names
var isBool = typeof state === "boolean", className, i = 0,
classNames = classNames.split( /\s+/ );
while ( (className = classNames[ i++ ]) ) {
// check each className given, space seperated list
state = isBool ? state : !jQuery.className.has( this, className );
jQuery.className[ state ? "add" : "remove" ]( this, className );
}
} else if ( type === "undefined" || type === "boolean" ) {
if ( this.className ) {
// store className if set
jQuery.data( this, "__className__", this.className );
}
// toggle whole className
this.className = this.className || classNames === false ? "" : jQuery.data( this, "__className__" ) || "";
}
}
}, function(name, fn){
jQuery.fn[ name ] = function(){
2389,18 → 2412,21
 
// Bind an event to an element
// Original by Dean Edwards
add: function(elem, types, handler, data) {
if ( elem.nodeType == 3 || elem.nodeType == 8 )
add: function( elem, types, handler, data ) {
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
 
// For whatever reason, IE has trouble passing the window object
// around, causing it to be cloned in the process
if ( elem.setInterval && elem != window )
if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
elem = window;
}
 
// Make sure that the function being executed has a unique ID
if ( !handler.guid )
if ( !handler.guid ) {
handler.guid = this.guid++;
}
 
// if data is passed, bind to handler
if ( data !== undefined ) {
2415,12 → 2441,12
}
 
// Init the element's event structure
var events = jQuery.data(elem, "events") || jQuery.data(elem, "events", {}),
handle = jQuery.data(elem, "handle") || jQuery.data(elem, "handle", function(){
var events = jQuery.data( elem, "events" ) || jQuery.data( elem, "events", {} ),
handle = jQuery.data( elem, "handle" ) || jQuery.data( elem, "handle", function() {
// Handle the second event of a trigger and when
// an event is called after a page has unloaded
return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
jQuery.event.handle.apply(arguments.callee.elem, arguments) :
jQuery.event.handle.apply( arguments.callee.elem, arguments ) :
undefined;
});
// Add elem as a property of the handle function
2430,7 → 2456,9
 
// Handle multiple events separated by a space
// jQuery(...).bind("mouseover mouseout", fn);
jQuery.each(types.split(/\s+/), function(index, type) {
types = types.split( /\s+/ );
var type, i=0;
while ( (type = types[ i++ ]) ) {
// Namespaced event handlers
var namespaces = type.split(".");
type = namespaces.shift();
2437,33 → 2465,40
handler.type = namespaces.slice().sort().join(".");
 
// Get the current list of functions bound to this event
var handlers = events[type];
var handlers = events[ type ],
special = this.special[ type ] || {};
 
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].setup.call(elem, data, namespaces);
if ( special.add ) {
var modifiedHandler = special.add.call( elem, handler, data, namespaces );
if ( modifiedHandler && jQuery.isFunction( modifiedHandler ) ) {
modifiedHandler.guid = modifiedHandler.guid || handler.guid;
handler = modifiedHandler;
}
}
 
// Init the event handler queue
if (!handlers) {
handlers = events[type] = {};
if ( !handlers ) {
handlers = events[ type ] = {};
 
// Check for a special event handler
// Only use addEventListener/attachEvent if the special
// events handler returns false
if ( !jQuery.event.special[type] || jQuery.event.special[type].setup.call(elem, data, namespaces) === false ) {
if ( !special.setup || special.setup.call( elem, data, namespaces ) === false ) {
// Bind the global event handler to the element
if (elem.addEventListener)
elem.addEventListener(type, handle, false);
else if (elem.attachEvent)
elem.attachEvent("on" + type, handle);
if ( elem.addEventListener ) {
elem.addEventListener( type, handle, false );
} else if ( elem.attachEvent ) {
elem.attachEvent( "on" + type, handle );
}
}
}
 
// Add the function to the element's handler list
handlers[handler.guid] = handler;
handlers[ handler.guid ] = handler;
 
// Keep track of which events have been used, for global triggering
jQuery.event.global[type] = true;
});
this.global[ type ] = true;
}
 
// Nullify elem to prevent memory leaks in IE
elem = null;
2473,19 → 2508,21
global: {},
 
// Detach an event or set of events from an element
remove: function(elem, types, handler) {
remove: function( elem, types, handler ) {
// don't do events on text and comment nodes
if ( elem.nodeType == 3 || elem.nodeType == 8 )
if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
return;
}
 
var events = jQuery.data(elem, "events"), ret, index;
var events = jQuery.data( elem, "events" ), ret, type;
 
if ( events ) {
// Unbind all events for the element
if ( types === undefined || (typeof types === "string" && types.charAt(0) == ".") )
for ( var type in events )
if ( types === undefined || (typeof types === "string" && types.charAt(0) === ".") ) {
for ( type in events ) {
this.remove( elem, type + (types || "") );
else {
}
} else {
// types is actually an event object here
if ( types.type ) {
handler = types.handler;
2494,48 → 2531,63
 
// Handle multiple events seperated by a space
// jQuery(...).unbind("mouseover mouseout", fn);
jQuery.each(types.split(/\s+/), function(index, type){
types = types.split(/\s+/);
var i = 0;
while ( (type = types[ i++ ]) ) {
// Namespaced event handlers
var namespaces = type.split(".");
type = namespaces.shift();
var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
var all = !namespaces.length,
namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)"),
special = this.special[ type ] || {};
 
if ( events[type] ) {
if ( events[ type ] ) {
// remove the given handler for the given type
if ( handler )
delete events[type][handler.guid];
if ( handler ) {
delete events[ type ][ handler.guid ];
 
// remove all handlers for the given type
else
for ( var handle in events[type] )
} else {
for ( var handle in events[ type ] ) {
// Handle the removal of namespaced events
if ( namespace.test(events[type][handle].type) )
delete events[type][handle];
if ( all || namespace.test( events[ type ][ handle ].type ) ) {
delete events[ type ][ handle ];
}
}
}
 
if ( jQuery.event.specialAll[type] )
jQuery.event.specialAll[type].teardown.call(elem, namespaces);
if ( special.remove ) {
special.remove.call( elem, namespaces );
}
 
// remove generic event handler if no more handlers exist
for ( ret in events[type] ) break;
for ( ret in events[ type ] ) {
break;
}
if ( !ret ) {
if ( !jQuery.event.special[type] || jQuery.event.special[type].teardown.call(elem, namespaces) === false ) {
if (elem.removeEventListener)
elem.removeEventListener(type, jQuery.data(elem, "handle"), false);
else if (elem.detachEvent)
elem.detachEvent("on" + type, jQuery.data(elem, "handle"));
if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
if ( elem.removeEventListener ) {
elem.removeEventListener( type, jQuery.data( elem, "handle" ), false );
} else if ( elem.detachEvent ) {
elem.detachEvent( "on" + type, jQuery.data( elem, "handle" ) );
}
}
ret = null;
delete events[type];
delete events[ type ];
}
}
});
}
}
 
// Remove the expando if it's no longer used
for ( ret in events ) break;
for ( ret in events ) {
break;
}
if ( !ret ) {
var handle = jQuery.data( elem, "handle" );
if ( handle ) handle.elem = null;
if ( handle ) {
handle.elem = null;
}
jQuery.removeData( elem, "events" );
jQuery.removeData( elem, "handle" );
}
2543,11 → 2595,12
},
 
// bubbling is internal
trigger: function( event, data, elem, bubbling ) {
trigger: function( event, data, elem /*, bubbling */ ) {
// Event object or event type
var type = event.type || event;
var type = event.type || event,
bubbling = arguments[3];
 
if( !bubbling ){
if ( !bubbling ) {
event = typeof event === "object" ?
// jQuery.Event object
event[expando] ? event :
2566,18 → 2619,21
// Don't bubble custom events when global (to avoid too much overhead)
event.stopPropagation();
// Only trigger if we've ever bound an event for it
if ( this.global[type] )
jQuery.each( jQuery.cache, function(){
if ( this.events && this.events[type] )
if ( this.global[ type ] ) {
jQuery.each( jQuery.cache, function() {
if ( this.events && this.events[type] ) {
jQuery.event.trigger( event, data, this.handle.elem );
}
});
}
}
 
// Handle triggering a single element
 
// don't do events on text and comment nodes
if ( !elem || elem.nodeType == 3 || elem.nodeType == 8 )
if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
return undefined;
}
 
// Clean up in case it is reused
event.result = undefined;
2584,7 → 2640,7
event.target = elem;
 
// Clone the incoming data, if any
data = jQuery.makeArray(data);
data = jQuery.makeArray( data );
data.unshift( event );
}
 
2591,16 → 2647,18
event.currentTarget = elem;
 
// Trigger the event, it is assumed that "handle" is a function
var handle = jQuery.data(elem, "handle");
if ( handle )
var handle = jQuery.data( elem, "handle" );
if ( handle ) {
handle.apply( elem, data );
}
 
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links)
if ( (!elem[type] || (jQuery.nodeName(elem, 'a') && type == "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false )
if ( (!elem[ type ] || (jQuery.nodeName(elem, 'a') && type === "click")) && elem["on"+type] && elem["on"+type].apply( elem, data ) === false ) {
event.result = false;
}
 
// Trigger the native events (except for clicks on links)
if ( !bubbling && elem[type] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type == "click") ) {
if ( !bubbling && elem[ type ] && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) {
this.triggered = true;
try {
elem[ type ]();
2612,12 → 2670,13
 
if ( !event.isPropagationStopped() ) {
var parent = elem.parentNode || elem.ownerDocument;
if ( parent )
jQuery.event.trigger(event, data, parent, true);
if ( parent ) {
jQuery.event.trigger( event, data, parent, true );
}
}
},
 
handle: function(event) {
handle: function( event ) {
// returned undefined or false
var all, handlers;
 
2633,10 → 2692,10
 
var namespace = new RegExp("(^|\\.)" + namespaces.slice().sort().join(".*\\.") + "(\\.|$)");
 
handlers = ( jQuery.data(this, "events") || {} )[event.type];
handlers = ( jQuery.data(this, "events") || {} )[ event.type ];
 
for ( var j in handlers ) {
var handler = handlers[j];
var handler = handlers[ j ];
 
// Filter the functions by class
if ( all || namespace.test(handler.type) ) {
2645,9 → 2704,9
event.handler = handler;
event.data = handler.data;
 
var ret = handler.apply(this, arguments);
var ret = handler.apply( this, arguments );
 
if( ret !== undefined ){
if ( ret !== undefined ) {
event.result = ret;
if ( ret === false ) {
event.preventDefault();
2655,18 → 2714,20
}
}
 
if( event.isImmediatePropagationStopped() )
if ( event.isImmediatePropagationStopped() ) {
break;
}
 
}
}
},
 
props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
 
fix: function(event) {
if ( event[expando] )
fix: function( event ) {
if ( event[ expando ] ) {
return event;
}
 
// store a copy of the original event object
// and "clone" to set read-only properties
2673,48 → 2734,59
var originalEvent = event;
event = jQuery.Event( originalEvent );
 
for ( var i = this.props.length, prop; i; ){
for ( var i = this.props.length, prop; i; ) {
prop = this.props[ --i ];
event[ prop ] = originalEvent[ prop ];
}
 
// Fix target property, if necessary
if ( !event.target )
if ( !event.target ) {
event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
}
 
// check if target is a textnode (safari)
if ( event.target.nodeType == 3 )
if ( event.target.nodeType === 3 ) {
event.target = event.target.parentNode;
}
 
// Add relatedTarget, if necessary
if ( !event.relatedTarget && event.fromElement )
event.relatedTarget = event.fromElement == event.target ? event.toElement : event.fromElement;
if ( !event.relatedTarget && event.fromElement ) {
event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
}
 
// Calculate pageX/Y if missing and clientX/Y available
if ( event.pageX == null && event.clientX != null ) {
var doc = document.documentElement, body = document.body;
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc.clientTop || 0);
event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
}
 
// Add which for key events
if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) )
if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
event.which = event.charCode || event.keyCode;
}
 
// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
if ( !event.metaKey && event.ctrlKey )
if ( !event.metaKey && event.ctrlKey ) {
event.metaKey = event.ctrlKey;
}
 
// Add which for click: 1 == left; 2 == middle; 3 == right
// Note: button is not normalized, so don't use it
if ( !event.which && event.button )
if ( !event.which && event.button ) {
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
}
 
return event;
},
 
proxy: function( fn, proxy ){
proxy = proxy || function(){ return fn.apply(this, arguments); };
proxy: function( fn, proxy, thisObject ) {
if ( proxy !== undefined && !jQuery.isFunction( proxy ) ) {
thisObject = proxy;
proxy = undefined;
}
// FIXME: Should proxy be redefined to be applied with thisObject if defined?
proxy = proxy || function() { return fn.apply( thisObject !== undefined ? thisObject : this, arguments ); };
// Set the guid of unique handler to the same of original handler, so it can be removed
proxy.guid = fn.guid = fn.guid || proxy.guid || this.guid++;
// So proxy can be declared as an argument
2726,25 → 2798,28
// Make sure the ready event is setup
setup: bindReady,
teardown: function() {}
}
},
},
 
specialAll: {
live: {
setup: function( selector, namespaces ){
jQuery.event.add( this, namespaces[0], liveHandler );
add: function( proxy, data, namespaces ) {
jQuery.extend( proxy, data || {} );
proxy.guid += data.selector + data.live;
jQuery.event.add( this, data.live, liveHandler );
},
teardown: function( namespaces ){
 
remove: function( namespaces ) {
if ( namespaces.length ) {
var remove = 0, name = new RegExp("(^|\\.)" + namespaces[0] + "(\\.|$)");
 
jQuery.each( (jQuery.data(this, "events").live || {}), function(){
if ( name.test(this.type) )
jQuery.each( (jQuery.data(this, "events").live || {}), function() {
if ( name.test(this.type) ) {
remove++;
}
});
 
if ( remove < 1 )
if ( remove < 1 ) {
jQuery.event.remove( this, namespaces[0], liveHandler );
}
}
}
}
2753,16 → 2828,18
 
jQuery.Event = function( src ){
// Allow instantiation without the 'new' keyword
if( !this.preventDefault )
return new jQuery.Event(src);
if ( !this.preventDefault ) {
return new jQuery.Event( src );
}
 
// Event object
if( src && src.type ){
if ( src && src.type ) {
this.originalEvent = src;
this.type = src.type;
// Event type
}else
} else {
this.type = src;
}
 
// timeStamp is buggy for some events on Firefox(#3843)
// So we won't rely on the native value
2769,13 → 2846,13
this.timeStamp = now();
 
// Mark it as fixed
this[expando] = true;
this[ expando ] = true;
};
 
function returnFalse(){
function returnFalse() {
return false;
}
function returnTrue(){
function returnTrue() {
return true;
}
 
2786,11 → 2863,13
this.isDefaultPrevented = returnTrue;
 
var e = this.originalEvent;
if( !e )
if ( !e ) {
return;
}
// if preventDefault exists run it on the original event
if (e.preventDefault)
if ( e.preventDefault ) {
e.preventDefault();
}
// otherwise set the returnValue property of the original event to false (IE)
e.returnValue = false;
},
2798,15 → 2877,17
this.isPropagationStopped = returnTrue;
 
var e = this.originalEvent;
if( !e )
if ( !e ) {
return;
}
// if stopPropagation exists run it on the original event
if (e.stopPropagation)
if ( e.stopPropagation ) {
e.stopPropagation();
}
// otherwise set the cancelBubble property of the original event to true (IE)
e.cancelBubble = true;
},
stopImmediatePropagation:function(){
stopImmediatePropagation: function(){
this.isImmediatePropagationStopped = returnTrue;
this.stopPropagation();
},
2816,15 → 2897,19
};
// Checks if an event happened on an element within another element
// Used in jQuery.event.special.mouseenter and mouseleave handlers
var withinElement = function(event) {
var withinElement = function( event ) {
// Check if mouse(over|out) are still within the same parent element
var parent = event.relatedTarget;
// Traverse up the tree
while ( parent && parent != this )
while ( parent && parent != this ) {
// Firefox sometimes assigns relatedTarget a XUL element
// which we cannot access the parentNode property of
try { parent = parent.parentNode; }
catch(e) { parent = this; }
// assuming we've left the element since we most likely mousedover a xul element
catch(e) { break; }
}
 
if( parent != this ){
if ( parent != this ) {
// set the correct event type
event.type = event.data;
// handle event if we actually just moused on to a non sub-element
2835,7 → 2920,7
jQuery.each({
mouseover: 'mouseenter',
mouseout: 'mouseleave'
}, function( orig, fix ){
}, function( orig, fix ) {
jQuery.event.special[ fix ] = {
setup: function(){
jQuery.event.add( this, orig, withinElement, fix );
2847,37 → 2932,53
});
 
jQuery.fn.extend({
bind: function( type, data, fn ) {
return type == "unload" ? this.one(type, data, fn) : this.each(function(){
jQuery.event.add( this, type, fn || data, fn && data );
bind: function( type, data, fn, thisObject ) {
if ( jQuery.isFunction( data ) ) {
if ( fn !== undefined ) {
thisObject = fn;
}
fn = data;
data = undefined;
}
fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject );
return type === "unload" ? this.one(type, data, fn, thisObject) : this.each(function() {
jQuery.event.add( this, type, fn, data );
});
},
 
one: function( type, data, fn ) {
var one = jQuery.event.proxy( fn || data, function(event) {
jQuery(this).unbind(event, one);
return (fn || data).apply( this, arguments );
one: function( type, data, fn, thisObject ) {
if ( jQuery.isFunction( data ) ) {
if ( fn !== undefined ) {
thisObject = fn;
}
fn = data;
data = undefined;
}
fn = thisObject === undefined ? fn : jQuery.event.proxy( fn, thisObject );
var one = jQuery.event.proxy( fn, function( event ) {
jQuery( this ).unbind( event, one );
return fn.apply( this, arguments );
});
return this.each(function(){
jQuery.event.add( this, type, one, fn && data);
return this.each(function() {
jQuery.event.add( this, type, one, data );
});
},
 
unbind: function( type, fn ) {
return this.each(function(){
return this.each(function() {
jQuery.event.remove( this, type, fn );
});
},
 
trigger: function( type, data ) {
return this.each(function(){
return this.each(function() {
jQuery.event.trigger( type, data, this );
});
},
 
triggerHandler: function( type, data ) {
if( this[0] ){
var event = jQuery.Event(type);
if ( this[0] ) {
var event = jQuery.Event( type );
event.preventDefault();
event.stopPropagation();
jQuery.event.trigger( event, data, this[0] );
2890,10 → 2991,11
var args = arguments, i = 1;
 
// link all the functions, so any of them can unbind this click handler
while( i < args.length )
jQuery.event.proxy( fn, args[i++] );
while( i < args.length ) {
jQuery.event.proxy( fn, args[ i++ ] );
}
 
return this.click( jQuery.event.proxy( fn, function(event) {
return this.click( jQuery.event.proxy( fn, function( event ) {
// Figure out which function to execute
this.lastToggle = ( this.lastToggle || 0 ) % i;
 
2905,69 → 3007,76
}));
},
 
hover: function(fnOver, fnOut) {
return this.mouseenter(fnOver).mouseleave(fnOut);
hover: function( fnOver, fnOut ) {
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
},
 
ready: function(fn) {
ready: function( fn ) {
// Attach the listeners
bindReady();
 
// If the DOM is already ready
if ( jQuery.isReady )
if ( jQuery.isReady ) {
// Execute the function immediately
fn.call( document, jQuery );
 
// Otherwise, remember the function for later
else
} else {
// Add the function to the wait list
jQuery.readyList.push( fn );
}
 
return this;
},
 
live: function( type, fn ){
var proxy = jQuery.event.proxy( fn );
proxy.guid += this.selector + type;
 
jQuery( this.context ).bind( liveConvert(type, this.selector), this.selector, proxy );
 
live: function( type, data, fn, thisObject ) {
if ( jQuery.isFunction( data ) ) {
if ( fn !== undefined ) {
thisObject = fn;
}
fn = data;
data = undefined;
}
jQuery( this.context ).bind( liveConvert( type, this.selector ), {
data: data, selector: this.selector, live: type
}, fn, thisObject );
return this;
},
 
die: function( type, fn ){
jQuery( this.context ).unbind( liveConvert(type, this.selector), fn ? { guid: fn.guid + this.selector + type } : null );
die: function( type, fn ) {
jQuery( this.context ).unbind( liveConvert( type, this.selector ), fn ? { guid: fn.guid + this.selector + type } : null );
return this;
}
});
 
function liveHandler( event ){
var check = new RegExp("(^|\\.)" + event.type + "(\\.|$)"),
stop = true,
elems = [];
function liveHandler( event ) {
var stop = true, elems = [], args = arguments;
 
jQuery.each(jQuery.data(this, "events").live || [], function(i, fn){
if ( check.test(fn.type) ) {
var elem = jQuery(event.target).closest(fn.data)[0];
if ( elem )
jQuery.each( jQuery.data( this, "events" ).live || [], function( i, fn ) {
if ( fn.live === event.type ) {
var elem = jQuery( event.target ).closest( fn.selector )[0];
if ( elem ) {
elems.push({ elem: elem, fn: fn });
}
}
});
 
elems.sort(function(a,b) {
return jQuery.data(a.elem, "closest") - jQuery.data(b.elem, "closest");
elems.sort(function( a, b ) {
return jQuery.data( a.elem, "closest" ) - jQuery.data( b.elem, "closest" );
});
 
jQuery.each(elems, function(){
jQuery.each(elems, function() {
event.currentTarget = this.elem;
if ( this.fn.call(this.elem, event, this.fn.data) === false )
event.data = this.fn.data;
if ( this.fn.apply( this.elem, args ) === false ) {
return (stop = false);
}
});
 
return stop;
}
 
function liveConvert(type, selector){
function liveConvert( type, selector ) {
return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join(".");
}
 
2984,9 → 3093,10
// If there are functions bound, to execute
if ( jQuery.readyList ) {
// Execute all of them
jQuery.each( jQuery.readyList, function(){
this.call( document, jQuery );
});
var fn, i = 0;
while ( (fn = jQuery.readyList[ i++ ]) ) {
fn.call( document, jQuery );
}
 
// Reset the list of functions
jQuery.readyList = null;
2993,7 → 3103,7
}
 
// Trigger any bound ready events
jQuery(document).triggerHandler("ready");
jQuery( document ).triggerHandler( "ready" );
}
}
});
3000,7 → 3110,7
 
var readyBound = false;
 
function bindReady(){
function bindReady() {
if ( readyBound ) return;
readyBound = true;
 
3007,7 → 3117,7
// Mozilla, Opera and webkit nightlies currently support this event
if ( document.addEventListener ) {
// Use the handy event callback
document.addEventListener( "DOMContentLoaded", function(){
document.addEventListener( "DOMContentLoaded", function() {
document.removeEventListener( "DOMContentLoaded", arguments.callee, false );
jQuery.ready();
}, false );
3016,7 → 3126,7
} else if ( document.attachEvent ) {
// ensure firing before onload,
// maybe late but safe also for iframes
document.attachEvent("onreadystatechange", function(){
document.attachEvent("onreadystatechange", function() {
if ( document.readyState === "complete" ) {
document.detachEvent( "onreadystatechange", arguments.callee );
jQuery.ready();
3025,8 → 3135,10
 
// If IE and not an iframe
// continually check to see if the document is ready
if ( document.documentElement.doScroll && window == window.top ) (function(){
if ( jQuery.isReady ) return;
if ( document.documentElement.doScroll && window === window.top ) (function() {
if ( jQuery.isReady ) {
return;
}
 
try {
// If IE is used, use the trick by Diego Perini
3048,11 → 3160,11
 
jQuery.each( ("blur,focus,load,resize,scroll,unload,click,dblclick," +
"mousedown,mouseup,mousemove,mouseover,mouseout,mouseenter,mouseleave," +
"change,select,submit,keydown,keypress,keyup,error").split(","), function(i, name){
"change,select,submit,keydown,keypress,keyup,error").split(","), function( i, name ) {
 
// Handle event binding
jQuery.fn[name] = function(fn){
return fn ? this.bind(name, fn) : this.trigger(name);
jQuery.fn[ name ] = function( fn ) {
return fn ? this.bind( name, fn ) : this.trigger( name );
};
});
 
3062,11 → 3174,13
// More info:
// - http://isaacschlueter.com/2006/10/msie-memory-leaks/
// - https://bugzilla.mozilla.org/show_bug.cgi?id=252542
jQuery( window ).bind( 'unload', function(){
for ( var id in jQuery.cache )
jQuery( window ).bind( 'unload', function() {
for ( var id in jQuery.cache ) {
// Skip the window
if ( id != 1 && jQuery.cache[ id ].handle )
if ( id != 1 && jQuery.cache[ id ].handle ) {
jQuery.event.remove( jQuery.cache[ id ].handle.elem );
}
}
});
(function(){
 
3158,7 → 3272,11
document.body.appendChild( div );
jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
document.body.removeChild( div ).style.display = 'none';
div = null;
});
 
// release memory in IE
root = script = div = all = a = null;
})();
 
jQuery.props = {
3172,8 → 3290,8
};
// exclude the following css properties to add px
var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
// cache defaultView
defaultView = document.defaultView || {},
// cache check for defaultView.getComputedStyle
getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
// normalize float css property
styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat";
 
3180,10 → 3298,6
jQuery.fn.css = function( name, value ) {
var options = name, isFunction = jQuery.isFunction( value );
 
// ignore negative width and height values
if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 )
value = undefined;
 
if ( typeof name === "string" ) {
// Are we setting the style?
if ( value === undefined ) {
3227,6 → 3341,10
if (!elem || elem.nodeType == 3 || elem.nodeType == 8)
return undefined;
 
// ignore negative width and height values #1599
if ( (name == 'width' || name == 'height') && parseFloat(value) < 0 )
value = undefined;
 
var style = elem.style || elem, set = value !== undefined;
 
// IE uses filters for opacity
3312,7 → 3430,7
if ( !force && style && style[ name ] ) {
ret = style[ name ];
 
} else if ( defaultView.getComputedStyle ) {
} else if ( getComputedStyle ) {
 
// Only "float" is needed here
if ( /float/i.test( name ) )
3320,7 → 3438,7
 
name = name.replace( /([A-Z])/g, "-$1" ).toLowerCase();
 
var computedStyle = defaultView.getComputedStyle( elem, null );
var computedStyle = elem.ownerDocument.defaultView.getComputedStyle( elem, null );
 
if ( computedStyle )
ret = computedStyle.getPropertyValue( name );
4328,18 → 4446,18
if ( "getBoundingClientRect" in document.documentElement )
jQuery.fn.offset = function() {
var elem = this[0];
if ( !elem ) return null;
if ( !elem || !elem.ownerDocument ) return null;
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
top = box.top + (self.pageYOffset || jQuery.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
left = box.left + (self.pageXOffset || jQuery.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
top = box.top + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ) - clientTop,
left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
return { top: top, left: left };
};
else
jQuery.fn.offset = function() {
var elem = this[0];
if ( !elem ) return null;
if ( !elem || !elem.ownerDocument ) return null;
if ( elem === elem.ownerDocument.body ) return jQuery.offset.bodyOffset( elem );
jQuery.offset.initialize();
 
4356,13 → 4474,13
if ( elem === offsetParent ) {
top += elem.offsetTop, left += elem.offsetLeft;
if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.tagName)) )
top += parseFloat( computedStyle.borderTopWidth, 10) || 0,
left += parseFloat( computedStyle.borderLeftWidth, 10) || 0;
top += parseFloat( computedStyle.borderTopWidth ) || 0,
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
}
if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" )
top += parseFloat( computedStyle.borderTopWidth, 10) || 0,
left += parseFloat( computedStyle.borderLeftWidth, 10) || 0;
top += parseFloat( computedStyle.borderTopWidth ) || 0,
left += parseFloat( computedStyle.borderLeftWidth ) || 0;
prevComputedStyle = computedStyle;
}
 
4371,8 → 4489,8
left += body.offsetLeft;
 
if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" )
top += Math.max(docElem.scrollTop, body.scrollTop),
left += Math.max(docElem.scrollLeft, body.scrollLeft);
top += Math.max( docElem.scrollTop, body.scrollTop ),
left += Math.max( docElem.scrollLeft, body.scrollLeft );
 
return { top: top, left: left };
};
4379,13 → 4497,13
 
jQuery.offset = {
initialize: function() {
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, prop, bodyMarginTop = parseFloat(jQuery.curCSS(body, 'marginTop', true), 10) || 0,
var body = document.body, container = document.createElement('div'), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0,
html = '<div style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;"><div></div></div><table style="position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;" cellpadding="0" cellspacing="0"><tr><td></td></tr></table>';
 
jQuery.extend( container.style, { position: 'absolute', top: 0, left: 0, margin: 0, border: 0, width: '1px', height: '1px', visibility: 'hidden' } );
 
container.innerHTML = html;
body.insertBefore(container, body.firstChild);
body.insertBefore( container, body.firstChild );
innerDiv = container.firstChild, checkDiv = innerDiv.firstChild, td = innerDiv.nextSibling.firstChild.firstChild;
 
this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
4392,7 → 4510,7
this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
 
checkDiv.style.position = 'fixed', checkDiv.style.top = '20px';
this.supportsFixedPosition = (checkDiv.offsetTop >= 15); // safari subtracts parent border width here which is 5px
this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15); // safari subtracts parent border width here which is 5px
checkDiv.style.position = '', checkDiv.style.top = '';
 
innerDiv.style.overflow = 'hidden', innerDiv.style.position = 'relative';
4400,8 → 4518,10
 
this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
 
body.removeChild(container);
body.removeChild( container );
jQuery.offset.initialize = function(){};
body = container = innerDiv = checkDiv = table = td = null;
},
 
bodyOffset: function(body) {
4408,8 → 4528,8
jQuery.offset.initialize();
var top = body.offsetTop, left = body.offsetLeft;
if ( jQuery.offset.doesNotIncludeMarginInBodyOffset )
top += parseFloat( jQuery.curCSS(body, 'marginTop', true), 10 ) || 0,
left += parseFloat( jQuery.curCSS(body, 'marginLeft', true), 10 ) || 0;
top += parseFloat( jQuery.curCSS(body, 'marginTop', true) ) || 0,
left += parseFloat( jQuery.curCSS(body, 'marginLeft', true) ) || 0;
return { top: top, left: left };
}
};
4419,7 → 4539,7
position: function() {
if ( !this[0] ) return null;
 
var elem = this[0], left = 0, top = 0, results,
var elem = this[0],
 
// Get *real* offsetParent
offsetParent = this.offsetParent(),
4431,27 → 4551,25
// Subtract element margins
// note: when an element has margin: auto the offsetLeft and marginLeft
// are the same in Safari causing offset.left to incorrectly be 0
offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true), 10 ) || 0;
offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true), 10 ) || 0;
offset.top -= parseFloat( jQuery.curCSS(elem, 'marginTop', true) ) || 0;
offset.left -= parseFloat( jQuery.curCSS(elem, 'marginLeft', true) ) || 0;
 
// Add offsetParent borders
parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true), 10 ) || 0;
parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true), 10 ) || 0;
parentOffset.top += parseFloat( jQuery.curCSS(offsetParent[0], 'borderTopWidth', true) ) || 0;
parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], 'borderLeftWidth', true) ) || 0;
 
// Subtract the two offsets
results = {
return {
top: offset.top - parentOffset.top,
left: offset.left - parentOffset.left
};
 
return results;
},
 
offsetParent: function() {
var offsetParent = this[0].offsetParent || document.body;
while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') == 'static') )
while ( offsetParent && (!/^body|html$/i.test(offsetParent.tagName) && jQuery.css(offsetParent, 'position') === 'static') )
offsetParent = offsetParent.offsetParent;
return jQuery(offsetParent);
return jQuery( offsetParent );
}
});
 
4462,25 → 4580,33
 
jQuery.fn[ method ] = function(val) {
if ( !this[0] ) return null;
var elem = this[0], win = ("scrollTo" in elem && elem.document) ? elem :
(elem.nodeName === "#document") ? elem.defaultView || elem.parentWindow :
false;
 
return val !== undefined ?
 
// Set the scroll offset
this.each(function() {
this == window || this == document ?
window.scrollTo(
!i ? val : jQuery(window).scrollLeft(),
i ? val : jQuery(window).scrollTop()
win = ("scrollTo" in this && this.document) ? this :
(this.nodeName === "#document") ? this.defaultView || this.parentWindow :
false;
win ?
win.scrollTo(
!i ? val : jQuery(win).scrollLeft(),
i ? val : jQuery(win).scrollTop()
) :
this[ method ] = val;
}) :
 
// Return the scroll offset
this[0] == window || this[0] == document ?
self[ i ? 'pageYOffset' : 'pageXOffset' ] ||
jQuery.boxModel && document.documentElement[ method ] ||
document.body[ method ] :
this[0][ method ];
win ?
win[ i ? 'pageYOffset' : 'pageXOffset' ] ||
jQuery.support.boxModel && win.document.documentElement[ method ] ||
win.document.body[ method ] :
elem[ method ];
};
});
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
4504,24 → 4630,26
 
jQuery.fn[ type ] = function( size ) {
// Get window width or height
return this[0] == window ?
var elem = this[0];
if ( !elem ) return null;
return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
document.compatMode == "CSS1Compat" && document.documentElement[ "client" + name ] ||
document.body[ "client" + name ] :
elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
elem.document.body[ "client" + name ] :
 
// Get document width or height
this[0] == document ?
(elem.nodeName === "#document") ? // is it a document
// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
Math.max(
document.documentElement["client" + name],
document.body["scroll" + name], document.documentElement["scroll" + name],
document.body["offset" + name], document.documentElement["offset" + name]
elem.documentElement["client" + name],
elem.body["scroll" + name], elem.documentElement["scroll" + name],
elem.body["offset" + name], elem.documentElement["offset" + name]
) :
 
// Get or set width or height on the element
size === undefined ?
// Get width or height on the element
(this.length ? jQuery.css( this[0], type ) : null) :
jQuery.css( elem, type ) :
 
// Set the width or height on the element (default to pixels if value is unitless)
this.css( type, typeof size === "string" ? size : size + "px" );