1,5 → 1,5 |
/*! |
* jQuery JavaScript Library v1.3.3pre |
* jQuery JavaScript Library v1.4pre |
* http://jquery.com/ |
* |
* Copyright (c) 2009 John Resig |
6,8 → 6,8 |
* Dual licensed under the MIT and GPL licenses. |
* http://docs.jquery.com/License |
* |
* Date: 2009-07-28 03:48:42 +0700 (Втр, 28 Июл 2009) |
* Revision: 6514 |
* Date: 2009-10-12 23:26:01 +0700 (Пнд, 12 Окт 2009) |
* Revision: 6617 |
*/ |
(function(window, undefined){ |
|
44,6 → 44,9 |
// Used for trimming whitespace |
rtrim = /^\s+|\s+$/g, |
|
// Match a standalone tag |
rsingleTag = /^<(\w+)\s*\/?>$/, |
|
// Keep a UserAgent string for use with jQuery.browser |
userAgent = navigator.userAgent.toLowerCase(), |
|
50,14 → 53,12 |
// Save a reference to some core methods |
toString = Object.prototype.toString, |
push = Array.prototype.push, |
slice = Array.prototype.slice; |
slice = Array.prototype.slice, |
indexOf = Array.prototype.indexOf; |
|
// Expose jQuery to the global object |
window.jQuery = window.$ = jQuery; |
|
jQuery.fn = jQuery.prototype = { |
init: function( selector, context ) { |
var match, elem, ret; |
var match, elem, ret, doc; |
|
// Handle $(""), $(null), or $(undefined) |
if ( !selector ) { |
81,8 → 82,20 |
|
// HANDLE: $(html) -> $(array) |
if ( match[1] ) { |
selector = jQuery.clean( [ match[1] ], context ); |
doc = (context ? context.ownerDocument || context : document); |
|
// If a single string is passed in and it's a single tag |
// just do a createElement and skip the rest |
ret = rsingleTag.exec( selector ); |
|
if ( ret ) { |
selector = [ doc.createElement( ret[1] ) ]; |
|
} else { |
ret = buildFragment( [ match[1] ], [ doc ] ); |
selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; |
} |
|
// HANDLE: $("#id") |
} else { |
elem = document.getElementById( match[2] ); |
104,6 → 117,12 |
return this; |
} |
|
// HANDLE: $("TAG") |
} else if ( !context && /^\w+$/.test( selector ) ) { |
this.selector = selector; |
this.context = document; |
selector = document.getElementsByTagName( selector ); |
|
// HANDLE: $(expr, $(...)) |
} else if ( !context || context.jquery ) { |
return (context || rootjQuery).find( selector ); |
120,8 → 139,7 |
return rootjQuery.ready( selector ); |
} |
|
// Make sure that old selector state is passed along |
if ( selector.selector && selector.context ) { |
if (selector.selector !== undefined) { |
this.selector = selector.selector; |
this.context = selector.context; |
} |
135,7 → 153,7 |
selector: "", |
|
// The current version of jQuery being used |
jquery: "1.3.3pre", |
jquery: "1.4pre", |
|
// The default length of a jQuery object is 0 |
length: 0, |
332,7 → 350,8 |
isXMLDoc: function( elem ) { |
// documentElement is verified for cases where it doesn't yet exist |
// (such as loading iframes in IE - #4833) |
return ((elem.ownerDocument || elem).documentElement || 0).nodeName !== "HTML"; |
var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; |
return documentElement ? documentElement.nodeName !== "HTML" : false; |
}, |
|
// Evalulates a script in a global context |
456,25 → 475,6 |
return first; |
}, |
|
unique: function( array ) { |
var ret = [], done = {}, id; |
|
try { |
for ( var i = 0, length = array.length; i < length; i++ ) { |
id = jQuery.data( array[ i ] ); |
|
if ( !done[ id ] ) { |
done[ id ] = true; |
ret.push( array[ i ] ); |
} |
} |
} catch( e ) { |
ret = array; |
} |
|
return ret; |
}, |
|
grep: function( elems, callback, inv ) { |
var ret = []; |
|
517,6 → 517,12 |
} |
}); |
|
if ( indexOf ) { |
jQuery.inArray = function( elem, array ) { |
return indexOf.call( array, elem ); |
}; |
} |
|
// All jQuery objects should point back to these |
rootjQuery = jQuery(document); |
|
536,37 → 542,81 |
} |
} |
|
// Mutifunctional method to get and set values to a collection |
// The value/s can be optionally by executed if its a function |
function access( elems, key, value, exec, fn ) { |
var l = elems.length; |
|
// Setting many attributes |
if ( typeof key === "object" ) { |
for (var k in key) { |
access(elems, k, key[k], exec, fn); |
} |
return elems; |
} |
|
// Setting one attribute |
if (value !== undefined) { |
// Optionally, function values get executed if exec is true |
exec = exec && jQuery.isFunction(value); |
|
for (var i = 0; i < l; i++) { |
var elem = elems[i], |
val = exec ? value.call(elem, i) : value; |
fn(elem, key, val); |
} |
return elems; |
} |
|
// Getting an attribute |
return l ? fn(elems[0], key) : null; |
} |
|
function now() { |
return (new Date).getTime(); |
} |
var expando = "jQuery" + now(), uuid = 0, windowData = {}; |
var emptyObject = {}; |
|
jQuery.extend({ |
cache: {}, |
|
expando:expando, |
|
data: function( elem, name, data ) { |
elem = elem == window ? |
windowData : |
elem; |
|
var id = elem[ expando ], cache = jQuery.cache; |
var id = elem[ expando ], cache = jQuery.cache, thisCache; |
|
// Handle the case where there's no name immediately |
if ( !name && !id ) { |
return null; |
} |
|
// Compute a unique ID for the element |
if(!id) id = elem[ expando ] = ++uuid; |
if ( !id ) { |
id = ++uuid; |
} |
|
// Only generate the data cache if we're |
// trying to access or manipulate it |
if ( name && !cache[ id ] ) |
cache[ id ] = {}; |
// Avoid generating a new cache unless none exists and we |
// want to manipulate it. |
if ( cache[ id ] ) { |
thisCache = cache[ id ]; |
} else if ( typeof data === "undefined" ) { |
thisCache = emptyObject; |
} else { |
thisCache = cache[ id ] = {}; |
} |
|
var thisCache = cache[ id ]; |
|
// Prevent overriding the named cache with undefined values |
if ( data !== undefined ) thisCache[ name ] = data; |
if ( data !== undefined ) { |
elem[ expando ] = id; |
thisCache[ name ] = data; |
} |
|
if(name === true) return thisCache |
else if(name) return thisCache[name] |
else return id |
return name ? thisCache[ name ] : thisCache; |
}, |
|
removeData: function( elem, name ) { |
583,9 → 633,10 |
delete thisCache[ name ]; |
|
// If we've removed all the data, remove the element's cache |
if( jQuery.isEmptyObject(thisCache) ) |
if ( jQuery.isEmptyObject(thisCache) ) { |
jQuery.removeData( elem ); |
} |
} |
|
// Otherwise, we want to remove all of the element's data |
} else { |
595,14 → 646,16 |
} catch(e){ |
// IE has trouble directly removing the expando |
// but it's ok with using removeAttribute |
if ( elem.removeAttribute ) |
if ( elem.removeAttribute ) { |
elem.removeAttribute( expando ); |
} |
} |
|
// Completely remove the data cache |
delete cache[ id ]; |
} |
}, |
|
queue: function( elem, type, data ) { |
if( !elem ) return; |
|
640,7 → 693,9 |
|
jQuery.fn.extend({ |
data: function( key, value ){ |
if(typeof key === "undefined" && this.length) return jQuery.data(this[0], true); |
if ( typeof key === "undefined" && this.length ) { |
return jQuery.data( this[0] ); |
} |
|
var parts = key.split("."); |
parts[1] = parts[1] ? "." + parts[1] : ""; |
689,7 → 744,995 |
clearQueue: function(type){ |
return this.queue( type || "fx", [] ); |
} |
});/*! |
}); |
/* |
* A number of helper functions used for managing events. |
* Many of the ideas behind this code originated from |
* Dean Edwards' addEvent library. |
*/ |
jQuery.event = { |
|
// Bind an event to an element |
// Original by Dean Edwards |
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 && !elem.frameElement ) ) { |
elem = window; |
} |
|
// Make sure that the function being executed has a unique ID |
if ( !handler.guid ) { |
handler.guid = this.guid++; |
} |
|
// if data is passed, bind to handler |
if ( data !== undefined ) { |
// Create temporary function pointer to original handler |
var fn = handler; |
|
// Create unique handler function, wrapped around original handler |
handler = this.proxy( fn ); |
|
// Store data in unique handler |
handler.data = data; |
} |
|
// 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() { |
// 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 ) : |
undefined; |
}); |
// Add elem as a property of the handle function |
// This is to prevent a memory leak with non-native |
// event in IE. |
handle.elem = elem; |
|
// Handle multiple events separated by a space |
// jQuery(...).bind("mouseover mouseout", fn); |
types = types.split( /\s+/ ); |
var type, i=0; |
while ( (type = types[ i++ ]) ) { |
// Namespaced event handlers |
var namespaces = type.split("."); |
type = namespaces.shift(); |
handler.type = namespaces.slice(0).sort().join("."); |
|
// Get the current list of functions bound to this event |
var handlers = events[ type ], |
special = this.special[ type ] || {}; |
|
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 ] = {}; |
|
// Check for a special event handler |
// Only use addEventListener/attachEvent if the special |
// events handler returns 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 ); |
} |
} |
} |
|
// Add the function to the element's handler list |
handlers[ handler.guid ] = handler; |
|
// Keep track of which events have been used, for global triggering |
this.global[ type ] = true; |
} |
|
// Nullify elem to prevent memory leaks in IE |
elem = null; |
}, |
|
guid: 1, |
global: {}, |
|
// Detach an event or set of events from an element |
remove: function( elem, types, handler ) { |
// don't do events on text and comment nodes |
if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
return; |
} |
|
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 ( type in events ) { |
this.remove( elem, type + (types || "") ); |
} |
} else { |
// types is actually an event object here |
if ( types.type ) { |
handler = types.handler; |
types = types.type; |
} |
|
// Handle multiple events seperated by a space |
// jQuery(...).unbind("mouseover mouseout", fn); |
types = types.split(/\s+/); |
var i = 0; |
while ( (type = types[ i++ ]) ) { |
// Namespaced event handlers |
var namespaces = type.split("."); |
type = namespaces.shift(); |
var all = !namespaces.length, |
namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
special = this.special[ type ] || {}; |
|
if ( events[ type ] ) { |
// remove the given handler for the given type |
if ( handler ) { |
delete events[ type ][ handler.guid ]; |
|
// remove all handlers for the given type |
} else { |
for ( var handle in events[ type ] ) { |
// Handle the removal of namespaced events |
if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
delete events[ type ][ handle ]; |
} |
} |
} |
|
if ( special.remove ) { |
special.remove.call( elem, namespaces ); |
} |
|
// remove generic event handler if no more handlers exist |
for ( ret in events[ type ] ) { |
break; |
} |
if ( !ret ) { |
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 ]; |
} |
} |
} |
} |
|
// Remove the expando if it's no longer used |
for ( ret in events ) { |
break; |
} |
if ( !ret ) { |
var handle = jQuery.data( elem, "handle" ); |
if ( handle ) { |
handle.elem = null; |
} |
jQuery.removeData( elem, "events" ); |
jQuery.removeData( elem, "handle" ); |
} |
} |
}, |
|
// bubbling is internal |
trigger: function( event, data, elem /*, bubbling */ ) { |
// Event object or event type |
var type = event.type || event, |
bubbling = arguments[3]; |
|
if ( !bubbling ) { |
event = typeof event === "object" ? |
// jQuery.Event object |
event[expando] ? event : |
// Object literal |
jQuery.extend( jQuery.Event(type), event ) : |
// Just the event type (string) |
jQuery.Event(type); |
|
if ( type.indexOf("!") >= 0 ) { |
event.type = type = type.slice(0, -1); |
event.exclusive = true; |
} |
|
// Handle a global trigger |
if ( !elem ) { |
// 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] ) { |
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 ) { |
return undefined; |
} |
|
// Clean up in case it is reused |
event.result = undefined; |
event.target = elem; |
|
// Clone the incoming data, if any |
data = jQuery.makeArray( data ); |
data.unshift( event ); |
} |
|
event.currentTarget = elem; |
|
// Trigger the event, it is assumed that "handle" is a function |
var handle = jQuery.data( elem, "handle" ); |
if ( handle ) { |
handle.apply( elem, data ); |
} |
|
var nativeFn, nativeHandler; |
try { |
nativeFn = elem[ type ]; |
nativeHandler = elem[ "on" + type ]; |
// prevent IE from throwing an error for some elements with some event types, see #3533 |
} catch (e) {} |
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links) |
if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
event.result = false; |
} |
|
// Trigger the native events (except for clicks on links) |
if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
this.triggered = true; |
try { |
nativeFn(); |
// prevent IE from throwing an error for some hidden elements |
} catch (e) {} |
} |
|
this.triggered = false; |
|
if ( !event.isPropagationStopped() ) { |
var parent = elem.parentNode || elem.ownerDocument; |
if ( parent ) { |
jQuery.event.trigger( event, data, parent, true ); |
} |
} |
}, |
|
handle: function( event ) { |
// returned undefined or false |
var all, handlers; |
|
event = arguments[0] = jQuery.event.fix( event || window.event ); |
event.currentTarget = this; |
|
// Namespaced event handlers |
var namespaces = event.type.split("."); |
event.type = namespaces.shift(); |
|
// Cache this now, all = true means, any handler |
all = !namespaces.length && !event.exclusive; |
|
var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
|
handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
|
for ( var j in handlers ) { |
var handler = handlers[ j ]; |
|
// Filter the functions by class |
if ( all || namespace.test(handler.type) ) { |
// Pass in a reference to the handler function itself |
// So that we can later remove it |
event.handler = handler; |
event.data = handler.data; |
|
var ret = handler.apply( this, arguments ); |
|
if ( ret !== undefined ) { |
event.result = ret; |
if ( ret === false ) { |
event.preventDefault(); |
event.stopPropagation(); |
} |
} |
|
if ( event.isImmediatePropagationStopped() ) { |
break; |
} |
|
} |
} |
}, |
|
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 ] ) { |
return event; |
} |
|
// store a copy of the original event object |
// and "clone" to set read-only properties |
var originalEvent = event; |
event = jQuery.Event( originalEvent ); |
|
for ( var i = this.props.length, prop; i; ) { |
prop = this.props[ --i ]; |
event[ prop ] = originalEvent[ prop ]; |
} |
|
// Fix target property, if necessary |
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 ) { |
event.target = event.target.parentNode; |
} |
|
// Add relatedTarget, if necessary |
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 && 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) ) { |
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 ) { |
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 !== undefined ) { |
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
} |
|
return event; |
}, |
|
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 |
return proxy; |
}, |
|
special: { |
ready: { |
// Make sure the ready event is setup |
setup: bindReady, |
teardown: function() {} |
}, |
|
live: { |
add: function( proxy, data, namespaces ) { |
jQuery.extend( proxy, data || {} ); |
proxy.guid += data.selector + data.live; |
jQuery.event.add( this, data.live, liveHandler, data ); |
}, |
|
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) ) { |
remove++; |
} |
}); |
|
if ( remove < 1 ) { |
jQuery.event.remove( this, namespaces[0], liveHandler ); |
} |
} |
} |
} |
} |
}; |
|
jQuery.Event = function( src ){ |
// Allow instantiation without the 'new' keyword |
if ( !this.preventDefault ) { |
return new jQuery.Event( src ); |
} |
|
// Event object |
if ( src && src.type ) { |
this.originalEvent = src; |
this.type = src.type; |
// Event type |
} else { |
this.type = src; |
} |
|
// timeStamp is buggy for some events on Firefox(#3843) |
// So we won't rely on the native value |
this.timeStamp = now(); |
|
// Mark it as fixed |
this[ expando ] = true; |
}; |
|
function returnFalse() { |
return false; |
} |
function returnTrue() { |
return true; |
} |
|
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
jQuery.Event.prototype = { |
preventDefault: function() { |
this.isDefaultPrevented = returnTrue; |
|
var e = this.originalEvent; |
if ( !e ) { |
return; |
} |
|
// if preventDefault exists run it on the original event |
if ( e.preventDefault ) { |
e.preventDefault(); |
} |
// otherwise set the returnValue property of the original event to false (IE) |
e.returnValue = false; |
}, |
stopPropagation: function() { |
this.isPropagationStopped = returnTrue; |
|
var e = this.originalEvent; |
if ( !e ) { |
return; |
} |
// if stopPropagation exists run it on the original event |
if ( e.stopPropagation ) { |
e.stopPropagation(); |
} |
// otherwise set the cancelBubble property of the original event to true (IE) |
e.cancelBubble = true; |
}, |
stopImmediatePropagation: function(){ |
this.isImmediatePropagationStopped = returnTrue; |
this.stopPropagation(); |
}, |
isDefaultPrevented: returnFalse, |
isPropagationStopped: returnFalse, |
isImmediatePropagationStopped: returnFalse |
}; |
// Checks if an event happened on an element within another element |
// Used in jQuery.event.special.mouseenter and mouseleave handlers |
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 ) { |
// Firefox sometimes assigns relatedTarget a XUL element |
// which we cannot access the parentNode property of |
try { parent = parent.parentNode; } |
// assuming we've left the element since we most likely mousedover a xul element |
catch(e) { break; } |
} |
|
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 |
jQuery.event.handle.apply( this, arguments ); |
} |
}; |
|
// Create mouseenter and mouseleave events |
jQuery.each({ |
mouseover: "mouseenter", |
mouseout: "mouseleave" |
}, function( orig, fix ) { |
jQuery.event.special[ fix ] = { |
setup: function(){ |
jQuery.event.add( this, orig, withinElement, fix ); |
}, |
teardown: function(){ |
jQuery.event.remove( this, orig, withinElement ); |
} |
}; |
}); |
|
(function() { |
|
var event = jQuery.event, |
special = event.special, |
handle = event.handle; |
|
special.submit = { |
setup: function(data, namespaces) { |
if(data.selector) { |
event.add(this, 'click.specialSubmit', function(e, eventData) { |
if(jQuery(e.target).filter(":submit, :image").closest(data.selector).length) { |
e.type = "submit"; |
return handle.call( this, e, eventData ); |
} |
}); |
|
event.add(this, 'keypress.specialSubmit', function( e, eventData ) { |
if(jQuery(e.target).filter(":text, :password").closest(data.selector).length) { |
e.type = "submit"; |
return handle.call( this, e, eventData ); |
} |
}); |
} else { |
return false; |
} |
}, |
|
remove: function(namespaces) { |
event.remove(this, 'click.specialSubmit'); |
event.remove(this, 'keypress.specialSubmit'); |
} |
}; |
|
})(); |
|
// Create "bubbling" focus and blur events |
jQuery.each({ |
focus: "focusin", |
blur: "focusout" |
}, function( orig, fix ){ |
var event = jQuery.event, |
special = event.special, |
handle = event.handle; |
|
function ieHandler() { |
arguments[0].type = orig; |
return handle.apply(this, arguments); |
} |
|
special[orig] = { |
setup:function() { |
if ( this.addEventListener ) |
this.addEventListener( orig, handle, true ); |
else |
jQuery.event.add( this, fix, ieHandler ); |
}, |
teardown:function() { |
if ( this.removeEventListener ) |
this.removeEventListener( orig, handle, true ); |
else |
jQuery.event.remove( this, fix, ieHandler ); |
} |
}; |
}); |
|
jQuery.fn.extend({ |
// TODO: make bind(), unbind() and one() DRY! |
bind: function( type, data, fn, thisObject ) { |
// Handle object literals |
if ( typeof type === "object" ) { |
for ( var key in type ) { |
this.bind(key, data, type[key], fn); |
} |
return this; |
} |
|
if ( jQuery.isFunction( data ) ) { |
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, thisObject ) { |
// Handle object literals |
if ( typeof type === "object" ) { |
for ( var key in type ) { |
this.one(key, data, type[key], fn); |
} |
return this; |
} |
|
if ( jQuery.isFunction( data ) ) { |
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, data ); |
}); |
}, |
|
unbind: function( type, fn ) { |
// Handle object literals |
if ( typeof type === "object" && !type.preventDefault ) { |
for ( var key in type ) { |
this.unbind(key, type[key]); |
} |
return this; |
} |
|
return this.each(function() { |
jQuery.event.remove( this, type, fn ); |
}); |
}, |
|
trigger: function( type, data ) { |
return this.each(function() { |
jQuery.event.trigger( type, data, this ); |
}); |
}, |
|
triggerHandler: function( type, data ) { |
if ( this[0] ) { |
var event = jQuery.Event( type ); |
event.preventDefault(); |
event.stopPropagation(); |
jQuery.event.trigger( event, data, this[0] ); |
return event.result; |
} |
}, |
|
toggle: function( fn ) { |
// Save reference to arguments for access in closure |
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++ ] ); |
} |
|
return this.click( jQuery.event.proxy( fn, function( event ) { |
// Figure out which function to execute |
this.lastToggle = ( this.lastToggle || 0 ) % i; |
|
// Make sure that clicks stop |
event.preventDefault(); |
|
// and execute the function |
return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
})); |
}, |
|
hover: function( fnOver, fnOut ) { |
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
}, |
|
ready: function( fn ) { |
// Attach the listeners |
bindReady(); |
|
// If the DOM is already ready |
if ( jQuery.isReady ) { |
// Execute the function immediately |
fn.call( document, jQuery ); |
|
// Otherwise, remember the function for later |
} else { |
// Add the function to the wait list |
jQuery.readyList.push( fn ); |
} |
|
return this; |
}, |
|
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 ); |
return this; |
} |
}); |
|
function liveHandler( event ) { |
var stop = true, elems = [], args = arguments; |
|
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" ); |
}); |
|
jQuery.each(elems, function() { |
event.currentTarget = this.elem; |
event.data = this.fn.data; |
if ( this.fn.apply( this.elem, args ) === false ) { |
return (stop = false); |
} |
}); |
|
return stop; |
} |
|
function liveConvert( type, selector ) { |
return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
} |
|
jQuery.extend({ |
isReady: false, |
readyList: [], |
// Handle when the DOM is ready |
ready: function() { |
// Make sure that the DOM is not already loaded |
if ( !jQuery.isReady ) { |
// Remember that the DOM is ready |
jQuery.isReady = true; |
|
// If there are functions bound, to execute |
if ( jQuery.readyList ) { |
// Execute all of them |
var fn, i = 0; |
while ( (fn = jQuery.readyList[ i++ ]) ) { |
fn.call( document, jQuery ); |
} |
|
// Reset the list of functions |
jQuery.readyList = null; |
} |
|
// Trigger any bound ready events |
jQuery( document ).triggerHandler( "ready" ); |
} |
} |
}); |
|
var readyBound = false; |
|
function bindReady() { |
if ( readyBound ) return; |
readyBound = true; |
|
// Catch cases where $(document).ready() is called after the |
// browser event has already occurred. |
if ( document.readyState === "complete" ) { |
return jQuery.ready(); |
} |
|
// Mozilla, Opera and webkit nightlies currently support this event |
if ( document.addEventListener ) { |
// Use the handy event callback |
document.addEventListener( "DOMContentLoaded", function() { |
document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
jQuery.ready(); |
}, false ); |
|
// If IE event model is used |
} else if ( document.attachEvent ) { |
// ensure firing before onload, |
// maybe late but safe also for iframes |
document.attachEvent("onreadystatechange", function() { |
if ( document.readyState === "complete" ) { |
document.detachEvent( "onreadystatechange", arguments.callee ); |
jQuery.ready(); |
} |
}); |
|
// If IE and not an iframe |
// continually check to see if the document is ready |
// NOTE: DO NOT CHANGE TO ===, FAILS IN IE. |
if ( document.documentElement.doScroll && window == window.top ) (function() { |
if ( jQuery.isReady ) { |
return; |
} |
|
try { |
// If IE is used, use the trick by Diego Perini |
// http://javascript.nwbox.com/IEContentLoaded/ |
document.documentElement.doScroll("left"); |
} catch( error ) { |
setTimeout( arguments.callee, 0 ); |
return; |
} |
|
// and execute any waiting functions |
jQuery.ready(); |
})(); |
} |
|
// A fallback to window.onload, that will always work |
jQuery.event.add( window, "load", jQuery.ready ); |
} |
|
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 ) { |
|
// Handle event binding |
jQuery.fn[ name ] = function( fn ) { |
return fn ? this.bind( name, fn ) : this.trigger( name ); |
}; |
}); |
|
// Prevent memory leaks in IE |
// Window isn't included so as not to unbind existing unload events |
// More info: |
// - http://isaacschlueter.com/2006/10/msie-memory-leaks/ |
/*@cc_on |
jQuery( window ).bind( 'unload', function() { |
for ( var id in jQuery.cache ) { |
// Skip the window |
if ( id != 1 && jQuery.cache[ id ].handle ) { |
jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
} |
} |
}); |
@*/ |
(function(){ |
|
jQuery.support = {}; |
|
var root = document.documentElement, |
script = document.createElement("script"), |
div = document.createElement("div"), |
id = "script" + (new Date).getTime(); |
|
div.style.display = "none"; |
div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
|
var all = div.getElementsByTagName("*"), |
a = div.getElementsByTagName("a")[0]; |
|
// Can't get basic test support |
if ( !all || !all.length || !a ) { |
return; |
} |
|
jQuery.support = { |
// IE strips leading whitespace when .innerHTML is used |
leadingWhitespace: div.firstChild.nodeType == 3, |
|
// Make sure that tbody elements aren't automatically inserted |
// IE will insert them into empty tables |
tbody: !div.getElementsByTagName("tbody").length, |
|
// Make sure that link elements get serialized correctly by innerHTML |
// This requires a wrapper element in IE |
htmlSerialize: !!div.getElementsByTagName("link").length, |
|
// Get the style information from getAttribute |
// (IE uses .cssText insted) |
style: /red/.test( a.getAttribute("style") ), |
|
// Make sure that URLs aren't manipulated |
// (IE normalizes it by default) |
hrefNormalized: a.getAttribute("href") === "/a", |
|
// Make sure that element opacity exists |
// (IE uses filter instead) |
opacity: a.style.opacity === "0.5", |
|
// Verify style float existence |
// (IE uses styleFloat instead of cssFloat) |
cssFloat: !!a.style.cssFloat, |
|
// Will be defined later |
scriptEval: false, |
noCloneEvent: true, |
boxModel: null |
}; |
|
script.type = "text/javascript"; |
try { |
script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
} catch(e){} |
|
root.insertBefore( script, root.firstChild ); |
|
// Make sure that the execution of code works by injecting a script |
// tag with appendChild/createTextNode |
// (IE doesn't support this, fails, and uses .text instead) |
if ( window[ id ] ) { |
jQuery.support.scriptEval = true; |
delete window[ id ]; |
} |
|
root.removeChild( script ); |
|
if ( div.attachEvent && div.fireEvent ) { |
div.attachEvent("onclick", function click(){ |
// Cloning a node shouldn't copy over any |
// bound event handlers (IE does this) |
jQuery.support.noCloneEvent = false; |
div.detachEvent("onclick", click); |
}); |
div.cloneNode(true).fireEvent("onclick"); |
} |
|
// Figure out if the W3C box model works as expected |
// document.body must exist before we can do this |
jQuery(function(){ |
var div = document.createElement("div"); |
div.style.width = div.style.paddingLeft = "1px"; |
|
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 = { |
"for": "htmlFor", |
"class": "className", |
readonly: "readOnly", |
maxlength: "maxLength", |
cellspacing: "cellSpacing", |
rowspan: "rowSpan", |
colspan: "colSpan", |
tabindex: "tabIndex" |
}; |
/*! |
* Sizzle CSS Selector Engine - v1.0 |
* Copyright 2009, The Dojo Foundation |
* Released under the MIT, BSD, and GPL Licenses. |
835,6 → 1878,8 |
} |
} |
} |
|
return results; |
}; |
|
Sizzle.matches = function(expr, set){ |
1242,7 → 2287,7 |
} else if ( name === "not" ) { |
var not = match[3]; |
|
for ( i = 0, l = not.length; i < l; i++ ) { |
for ( var i = 0, l = not.length; i < l; i++ ) { |
if ( not[i] === elem ) { |
return false; |
} |
1394,6 → 2439,13 |
|
if ( document.documentElement.compareDocumentPosition ) { |
sortOrder = function( a, b ) { |
if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { |
if ( a == b ) { |
hasDuplicate = true; |
} |
return 0; |
} |
|
var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1; |
if ( ret === 0 ) { |
hasDuplicate = true; |
1402,6 → 2454,13 |
}; |
} else if ( "sourceIndex" in document.documentElement ) { |
sortOrder = function( a, b ) { |
if ( !a.sourceIndex || !b.sourceIndex ) { |
if ( a == b ) { |
hasDuplicate = true; |
} |
return 0; |
} |
|
var ret = a.sourceIndex - b.sourceIndex; |
if ( ret === 0 ) { |
hasDuplicate = true; |
1410,6 → 2469,13 |
}; |
} else if ( document.createRange ) { |
sortOrder = function( a, b ) { |
if ( !a.ownerDocument || !b.ownerDocument ) { |
if ( a == b ) { |
hasDuplicate = true; |
} |
return 0; |
} |
|
var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange(); |
aRange.selectNode(a); |
aRange.collapse(true); |
1727,12 → 2793,14 |
return r; |
}; |
|
jQuery.unique = Sizzle.uniqueSort; |
|
return; |
|
window.Sizzle = Sizzle; |
|
})(); |
jQuery.winnow = function( elements, qualifier, keep ) { |
var winnow = function( elements, qualifier, keep ) { |
if(jQuery.isFunction( qualifier )) { |
return jQuery.grep(elements, function(elem, i) { |
return !!qualifier.call( elem, i ) === keep; |
1778,17 → 2846,16 |
}, |
|
not: function( selector ) { |
return this.pushStack( jQuery.winnow(this, selector, false), "not", selector); |
return this.pushStack( winnow(this, selector, false), "not", selector); |
}, |
|
filter: function( selector ) { |
return this.pushStack( jQuery.winnow(this, selector, true), "filter", selector ); |
return this.pushStack( winnow(this, selector, true), "filter", selector ); |
}, |
|
closest: function( selector ) { |
closest: function( selector, context ) { |
var pos = jQuery.expr.match.POS.test( selector ) ? jQuery(selector) : null, |
closer = 0, |
context = this.context; |
closer = 0; |
|
return this.map(function(){ |
var cur = this; |
1804,18 → 2871,30 |
}, |
|
add: function( selector ) { |
return this.pushStack( jQuery.unique( jQuery.merge( |
this.get(), |
typeof selector === "string" ? |
var set = typeof selector === "string" ? |
jQuery( selector ) : |
jQuery.makeArray( selector ) |
))); |
jQuery.makeArray( selector ), |
all = jQuery.merge( this.get(), set ); |
|
return this.pushStack( set[0] && (set[0].setInterval || set[0].nodeType === 9 || (set[0].parentNode && set[0].parentNode.nodeType !== 11)) ? |
jQuery.unique( all ) : |
all ); |
}, |
|
eq: function( i ) { |
return this.slice( i, +i + 1 ); |
return i === -1 ? |
this.slice( i ) : |
this.slice( i, +i + 1 ); |
}, |
|
first: function() { |
return this.eq( 0 ); |
}, |
|
last: function() { |
return this.eq( -1 ); |
}, |
|
slice: function() { |
return this.pushStack( Array.prototype.slice.apply( this, arguments ), |
"slice", Array.prototype.slice.call(arguments).join(",") ); |
1850,47 → 2929,82 |
jQuery.fn[ name ] = function( selector ) { |
var ret = jQuery.map( this, fn ); |
|
if ( selector && typeof selector == "string" ) |
if ( selector && typeof selector === "string" ) { |
ret = jQuery.multiFilter( selector, ret ); |
} |
|
return this.pushStack( jQuery.unique( ret ), name, selector ); |
ret = this.length > 1 ? jQuery.unique( ret ) : ret; |
|
if ( name === "parents" && this.length > 1 ) { |
ret = ret.reverse(); |
} |
|
return this.pushStack( ret, name, selector ); |
}; |
}); |
jQuery.fn.extend({ |
attr: function( name, value ) { |
var elem, options, isFunction = jQuery.isFunction(value); |
return access(this, name, value, true, jQuery.attr); |
}, |
|
if ( typeof name === "string" ) { // A single attribute |
if ( value === undefined ) { // Query it on first element |
return this.length ? |
jQuery.attr( this[0], name ) : |
null; |
} else { // Set it on all elements |
addClass: function( value ) { |
if ( value && typeof value === "string" ) { |
var classNames = (value || "").split(/\s+/); |
|
for ( var i = 0, l = this.length; i < l; i++ ) { |
elem = this[i]; |
if ( isFunction ) |
value = value.call(elem,i); |
jQuery.attr( elem, name, value ); |
var elem = this[i]; |
|
if ( elem.nodeType === 1 ) { |
if ( !elem.className ) { |
elem.className = value; |
} else { |
var className = " " + elem.className + " "; |
for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) { |
elem.className += " " + classNames[c]; |
} |
} |
} else { // Multiple attributes to set on all |
options = name; |
} |
} |
} |
} |
|
return this; |
}, |
|
removeClass: function( value ) { |
if ( (value && typeof value === "string") || value === undefined ) { |
var classNames = (value || "").split(/\s+/); |
|
for ( var i = 0, l = this.length; i < l; i++ ) { |
elem = this[i]; |
for ( name in options ) { |
value = options[name]; |
if ( jQuery.isFunction(value) ) |
value = value.call(elem,i); |
jQuery.attr( elem, name, value ); |
var elem = this[i]; |
|
if ( elem.nodeType === 1 && elem.className ) { |
if ( value ) { |
var className = " " + elem.className + " "; |
for ( var c = 0, cl = classNames.length; c < cl; c++ ) { |
className = className.replace(" " + classNames[c] + " ", " "); |
} |
elem.className = className.substring(1, className.length - 1); |
} else { |
elem.className = ""; |
} |
} |
} |
} |
|
return this; |
}, |
|
hasClass: function( selector ) { |
return !!selector && this.is( "." + selector ); |
var className = " " + selector + " "; |
for ( var i = 0, l = this.length; i < l; i++ ) { |
if ( (" " + this[i].className + " ").indexOf( className ) > -1 ) { |
return true; |
} |
} |
|
return false; |
}, |
|
val: function( value ) { |
1983,14 → 3097,6 |
this.removeAttribute( name ); |
}, |
|
addClass: function( classNames ) { |
jQuery.className.add( this, classNames ); |
}, |
|
removeClass: function( classNames ) { |
jQuery.className.remove( this, classNames ); |
}, |
|
toggleClass: function( classNames, state ) { |
var type = typeof classNames; |
if ( type === "string" ) { |
1999,8 → 3105,8 |
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 ); |
state = isBool ? state : !jQuery(this).hasClass( className ); |
jQuery(this)[ state ? "addClass" : "removeClass" ]( className ); |
} |
} else if ( type === "undefined" || type === "boolean" ) { |
if ( this.className ) { |
2018,36 → 3124,15 |
}); |
|
jQuery.extend({ |
className: { |
// internal only, use addClass("class") |
add: function( elem, classNames ) { |
jQuery.each((classNames || "").split(/\s+/), function(i, className){ |
if ( elem.nodeType == 1 && !jQuery.className.has( elem.className, className ) ) |
elem.className += (elem.className ? " " : "") + className; |
}); |
}, |
|
// internal only, use removeClass("class") |
remove: function( elem, classNames ) { |
if (elem.nodeType == 1) |
elem.className = classNames !== undefined ? |
jQuery.grep(elem.className.split(/\s+/), function(className){ |
return !jQuery.className.has( classNames, className ); |
}).join(" ") : |
""; |
}, |
|
// internal only, use hasClass("class") |
has: function( elem, className ) { |
return elem && jQuery.inArray( className, (elem.className || elem).toString().split(/\s+/) ) > -1; |
} |
}, |
|
attr: function( elem, name, value ) { |
// don't set attributes on text and comment nodes |
if (!elem || elem.nodeType == 3 || elem.nodeType == 8) |
return undefined; |
|
if ( name in jQuery.fn && name !== "attr" ) { |
return jQuery(elem)[name](value); |
} |
|
var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ), |
// Whether we are setting (or getting) |
set = value !== undefined; |
2123,17 → 3208,35 |
}); |
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, |
rleadingWhitespace = /^\s+/, |
rsingleTag = /^<(\w+)\s*\/?>$/, |
rxhtmlTag = /(<(\w+)[^>]*?)\/>/g, |
rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g, |
rselfClosing = /^(?:abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i, |
rinsideTable = /^<(thead|tbody|tfoot|colg|cap)/, |
rtagName = /<([\w:]+)/, |
rtbody = /<tbody/i, |
rhtml = /</, |
fcloseTag = function(all, front, tag){ |
return rselfClosing.test(tag) ? |
all : |
front + "></" + tag + ">"; |
}, |
wrapMap = { |
option: [ 1, "<select multiple='multiple'>", "</select>" ], |
legend: [ 1, "<fieldset>", "</fieldset>" ], |
thead: [ 1, "<table>", "</table>" ], |
tr: [ 2, "<table><tbody>", "</tbody></table>" ], |
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ], |
col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ], |
_default: [ 0, "", "" ] |
}; |
|
wrapMap.optgroup = wrapMap.option; |
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; |
wrapMap.th = wrapMap.td; |
|
// IE can't serialize <link> and <script> tags normally |
if ( !jQuery.support.htmlSerialize ) { |
wrapMap._default = [ 1, "div<div>", "</div>" ]; |
} |
|
jQuery.fn.extend({ |
text: function( text ) { |
if ( typeof text !== "object" && text !== undefined ) |
2195,6 → 3298,14 |
}); |
}, |
|
unwrap: function() { |
return this.parent().each(function(){ |
if ( !jQuery.nodeName( this, "body" ) ) { |
jQuery( this ).replaceWith( this.childNodes ); |
} |
}).end(); |
}, |
|
append: function() { |
return this.domManip(arguments, true, function(elem){ |
if ( this.nodeType === 1 ) { |
2212,15 → 3323,27 |
}, |
|
before: function() { |
if ( this[0] && this[0].parentNode ) { |
return this.domManip(arguments, false, function(elem){ |
this.parentNode.insertBefore( elem, this ); |
}); |
} else if ( arguments.length ) { |
var set = jQuery(arguments[0]); |
set.push.apply( set, this.toArray() ); |
return this.pushStack( set, "before", arguments ); |
} |
}, |
|
after: function() { |
if ( this[0] && this[0].parentNode ) { |
return this.domManip(arguments, false, function(elem){ |
this.parentNode.insertBefore( elem, this.nextSibling ); |
}); |
} else if ( arguments.length ) { |
var set = this.pushStack( this, "after", arguments ); |
set.push.apply( set, jQuery(arguments[0]).toArray() ); |
return set; |
} |
}, |
|
clone: function( events ) { |
2273,15 → 3396,43 |
}, |
|
html: function( value ) { |
return value === undefined ? |
(this[0] ? |
if ( value === undefined ) { |
return this[0] ? |
this[0].innerHTML.replace(rinlinejQuery, "") : |
null) : |
null; |
|
// See if we can take a shortcut and just use innerHTML |
} else if ( typeof value === "string" && !/<script/i.test( value ) && |
(!jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) && |
!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) { |
|
try { |
for ( var i = 0, l = this.length; i < l; i++ ) { |
// Remove element nodes and prevent memory leaks |
if ( this[i].nodeType === 1 ) { |
cleanData( this[i].getElementsByTagName("*") ); |
this[i].innerHTML = value; |
} |
} |
|
// If using innerHTML throws an exception, use the fallback method |
} catch(e) { |
this.empty().append( value ); |
} |
|
} else { |
this.empty().append( value ); |
} |
|
return this; |
}, |
|
replaceWith: function( value ) { |
if ( this[0] && this[0].parentNode ) { |
return this.after( value ).remove(); |
} else { |
return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value ); |
} |
}, |
|
detach: function( selector ) { |
2289,8 → 3440,7 |
}, |
|
domManip: function( args, table, callback ) { |
var fragment, scripts, cacheable, cached, cacheresults, first, |
value = args[0]; |
var results, first, value = args[0], scripts = []; |
|
if ( jQuery.isFunction(value) ) { |
return this.each(function() { |
2300,24 → 3450,15 |
} |
|
if ( this[0] ) { |
if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
cacheable = true; |
cacheresults = jQuery.fragments[ args[0] ]; |
if ( cacheresults ) { |
if ( cacheresults !== 1 ) { |
fragment = cacheresults; |
// If we're in a fragment, just use that instead of building a new one |
if ( args[0] && args[0].parentNode && args[0].parentNode.nodeType === 11 ) { |
results = { fragment: args[0].parentNode }; |
} else { |
results = buildFragment( args, this, scripts ); |
} |
cached = true; |
} |
} |
|
if ( !fragment ) { |
fragment = (this[0].ownerDocument || this[0]).createDocumentFragment(); |
scripts = jQuery.clean( args, (this[0].ownerDocument || this[0]), fragment ); |
} |
first = results.fragment.firstChild; |
|
first = fragment.firstChild; |
|
if ( first ) { |
table = table && jQuery.nodeName( first, "tr" ); |
|
2326,9 → 3467,9 |
table ? |
root(this[i], first) : |
this[i], |
cacheable || this.length > 1 || i > 0 ? |
fragment.cloneNode(true) : |
fragment |
results.cacheable || this.length > 1 || i > 0 ? |
results.fragment.cloneNode(true) : |
results.fragment |
); |
} |
} |
2336,11 → 3477,7 |
if ( scripts ) { |
jQuery.each( scripts, evalScript ); |
} |
|
if ( cacheable ) { |
jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
} |
} |
|
return this; |
|
2353,6 → 3490,33 |
} |
}); |
|
function buildFragment(args, nodes, scripts){ |
var fragment, cacheable, cached, cacheresults, doc; |
|
if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && args[0].indexOf("<option") < 0 ) { |
cacheable = true; |
cacheresults = jQuery.fragments[ args[0] ]; |
if ( cacheresults ) { |
if ( cacheresults !== 1 ) { |
fragment = cacheresults; |
} |
cached = true; |
} |
} |
|
if ( !fragment ) { |
doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document); |
fragment = doc.createDocumentFragment(); |
jQuery.clean( args, doc, fragment, scripts ); |
} |
|
if ( cacheable ) { |
jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1; |
} |
|
return { fragment: fragment, cacheable: cacheable }; |
} |
|
jQuery.fragments = {}; |
|
jQuery.each({ |
2370,8 → 3534,7 |
jQuery.fn[ original ].apply( jQuery(insert[i]), elems ); |
ret = ret.concat( elems ); |
} |
|
return this.pushStack( ret, name, selector ); |
return this.pushStack( ret, name, insert.selector ); |
}; |
}); |
|
2380,7 → 3543,8 |
remove: function( selector, keepData ) { |
if ( !selector || jQuery.multiFilter( selector, [ this ] ).length ) { |
if ( !keepData && this.nodeType === 1 ) { |
cleanData( jQuery("*", this).add(this) ); |
cleanData( this.getElementsByTagName("*") ); |
cleanData( [ this ] ); |
} |
|
if ( this.parentNode ) { |
2392,7 → 3556,7 |
empty: function() { |
// Remove element nodes and prevent memory leaks |
if ( this.nodeType === 1 ) { |
cleanData( jQuery("*", this) ); |
cleanData( this.getElementsByTagName("*") ); |
} |
|
// Remove any remaining nodes |
2407,7 → 3571,7 |
}); |
|
jQuery.extend({ |
clean: function( elems, context, fragment ) { |
clean: function( elems, context, fragment, scripts ) { |
context = context || document; |
|
// !context.createElement fails in IE with an error but returns typeof 'object' |
2415,17 → 3579,8 |
context = context.ownerDocument || context[0] && context[0].ownerDocument || document; |
} |
|
// If a single string is passed in and it's a single tag |
// just do a createElement and skip the rest |
if ( !fragment && elems.length === 1 && typeof elems[0] === "string" ) { |
var match = rsingleTag.exec(elems[0]); |
if ( match ) { |
return [ context.createElement( match[1] ) ]; |
} |
} |
var ret = [], div = context.createElement("div"); |
|
var ret = [], scripts = [], div = context.createElement("div"); |
|
jQuery.each(elems, function(i, elem){ |
if ( typeof elem === "number" ) { |
elem += ''; |
2434,46 → 3589,23 |
if ( !elem ) { return; } |
|
// Convert html string into DOM nodes |
if ( typeof elem === "string" ) { |
if ( typeof elem === "string" && !rhtml.test( elem ) ) { |
elem = context.createTextNode( elem ); |
|
} else if ( typeof elem === "string" ) { |
// Fix "XHTML"-style tags in all browsers |
elem = elem.replace(rxhtmlTag, fcloseTag); |
|
// Trim whitespace, otherwise indexOf won't work as expected |
var tags = elem.replace(rleadingWhitespace, "") |
.substring(0, 10).toLowerCase(); |
var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(), |
wrap = wrapMap[ tag ] || wrapMap._default, |
depth = wrap[0]; |
|
var wrap = |
// option or optgroup |
!tags.indexOf("<opt") && |
[ 1, "<select multiple='multiple'>", "</select>" ] || |
|
!tags.indexOf("<leg") && |
[ 1, "<fieldset>", "</fieldset>" ] || |
|
rinsideTable.test(tags) && |
[ 1, "<table>", "</table>" ] || |
|
!tags.indexOf("<tr") && |
[ 2, "<table><tbody>", "</tbody></table>" ] || |
|
// <thead> matched above |
(!tags.indexOf("<td") || !tags.indexOf("<th")) && |
[ 3, "<table><tbody><tr>", "</tr></tbody></table>" ] || |
|
!tags.indexOf("<col") && |
[ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ] || |
|
// IE can't serialize <link> and <script> tags normally |
!jQuery.support.htmlSerialize && |
[ 1, "div<div>", "</div>" ] || |
|
[ 0, "", "" ]; |
|
// Go to html and back, then peel off extra wrappers |
div.innerHTML = wrap[1] + elem + wrap[2]; |
|
// Move to the right depth |
while ( wrap[0]-- ) { |
while ( depth-- ) { |
div = div.lastChild; |
} |
|
2482,7 → 3614,7 |
|
// String was a <table>, *may* have spurious <tbody> |
var hasBody = rtbody.test(elem), |
tbody = !tags.indexOf("<table") && !hasBody ? |
tbody = tag === "table" && !hasBody ? |
div.firstChild && div.firstChild.childNodes : |
|
// String was a bare <thead> or <tfoot> |
2516,7 → 3648,7 |
|
if ( fragment ) { |
for ( var i = 0; ret[i]; i++ ) { |
if ( jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { |
scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); |
} else { |
if ( ret[i].nodeType === 1 ) { |
2525,8 → 3657,6 |
fragment.appendChild( ret[i] ); |
} |
} |
|
return scripts; |
} |
|
return ret; |
2534,911 → 3664,12 |
}); |
|
function cleanData( elems ) { |
for ( var i = 0, l = elems.length; i < l; i++ ) { |
var id = elems[i][expando]; |
if ( id ) { |
for ( var i = 0, elem, id; (elem = elems[i]) != null; i++ ) { |
if ( (id = elem[expando]) ) { |
delete jQuery.cache[ id ]; |
} |
} |
} |
/* |
* A number of helper functions used for managing events. |
* Many of the ideas behind this code originated from |
* Dean Edwards' addEvent library. |
*/ |
jQuery.event = { |
|
// Bind an event to an element |
// Original by Dean Edwards |
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 && !elem.frameElement ) ) { |
elem = window; |
} |
|
// Make sure that the function being executed has a unique ID |
if ( !handler.guid ) { |
handler.guid = this.guid++; |
} |
|
// if data is passed, bind to handler |
if ( data !== undefined ) { |
// Create temporary function pointer to original handler |
var fn = handler; |
|
// Create unique handler function, wrapped around original handler |
handler = this.proxy( fn ); |
|
// Store data in unique handler |
handler.data = data; |
} |
|
// 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() { |
// 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 ) : |
undefined; |
}); |
// Add elem as a property of the handle function |
// This is to prevent a memory leak with non-native |
// event in IE. |
handle.elem = elem; |
|
// Handle multiple events separated by a space |
// jQuery(...).bind("mouseover mouseout", fn); |
types = types.split( /\s+/ ); |
var type, i=0; |
while ( (type = types[ i++ ]) ) { |
// Namespaced event handlers |
var namespaces = type.split("."); |
type = namespaces.shift(); |
handler.type = namespaces.slice(0).sort().join("."); |
|
// Get the current list of functions bound to this event |
var handlers = events[ type ], |
special = this.special[ type ] || {}; |
|
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 ] = {}; |
|
// Check for a special event handler |
// Only use addEventListener/attachEvent if the special |
// events handler returns 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 ); |
} |
} |
} |
|
// Add the function to the element's handler list |
handlers[ handler.guid ] = handler; |
|
// Keep track of which events have been used, for global triggering |
this.global[ type ] = true; |
} |
|
// Nullify elem to prevent memory leaks in IE |
elem = null; |
}, |
|
guid: 1, |
global: {}, |
|
// Detach an event or set of events from an element |
remove: function( elem, types, handler ) { |
// don't do events on text and comment nodes |
if ( elem.nodeType === 3 || elem.nodeType === 8 ) { |
return; |
} |
|
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 ( type in events ) { |
this.remove( elem, type + (types || "") ); |
} |
} else { |
// types is actually an event object here |
if ( types.type ) { |
handler = types.handler; |
types = types.type; |
} |
|
// Handle multiple events seperated by a space |
// jQuery(...).unbind("mouseover mouseout", fn); |
types = types.split(/\s+/); |
var i = 0; |
while ( (type = types[ i++ ]) ) { |
// Namespaced event handlers |
var namespaces = type.split("."); |
type = namespaces.shift(); |
var all = !namespaces.length, |
namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"), |
special = this.special[ type ] || {}; |
|
if ( events[ type ] ) { |
// remove the given handler for the given type |
if ( handler ) { |
delete events[ type ][ handler.guid ]; |
|
// remove all handlers for the given type |
} else { |
for ( var handle in events[ type ] ) { |
// Handle the removal of namespaced events |
if ( all || namespace.test( events[ type ][ handle ].type ) ) { |
delete events[ type ][ handle ]; |
} |
} |
} |
|
if ( special.remove ) { |
special.remove.call( elem, namespaces ); |
} |
|
// remove generic event handler if no more handlers exist |
for ( ret in events[ type ] ) { |
break; |
} |
if ( !ret ) { |
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 ]; |
} |
} |
} |
} |
|
// Remove the expando if it's no longer used |
for ( ret in events ) { |
break; |
} |
if ( !ret ) { |
var handle = jQuery.data( elem, "handle" ); |
if ( handle ) { |
handle.elem = null; |
} |
jQuery.removeData( elem, "events" ); |
jQuery.removeData( elem, "handle" ); |
} |
} |
}, |
|
// bubbling is internal |
trigger: function( event, data, elem /*, bubbling */ ) { |
// Event object or event type |
var type = event.type || event, |
bubbling = arguments[3]; |
|
if ( !bubbling ) { |
event = typeof event === "object" ? |
// jQuery.Event object |
event[expando] ? event : |
// Object literal |
jQuery.extend( jQuery.Event(type), event ) : |
// Just the event type (string) |
jQuery.Event(type); |
|
if ( type.indexOf("!") >= 0 ) { |
event.type = type = type.slice(0, -1); |
event.exclusive = true; |
} |
|
// Handle a global trigger |
if ( !elem ) { |
// 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] ) { |
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 ) { |
return undefined; |
} |
|
// Clean up in case it is reused |
event.result = undefined; |
event.target = elem; |
|
// Clone the incoming data, if any |
data = jQuery.makeArray( data ); |
data.unshift( event ); |
} |
|
event.currentTarget = elem; |
|
// Trigger the event, it is assumed that "handle" is a function |
var handle = jQuery.data( elem, "handle" ); |
if ( handle ) { |
handle.apply( elem, data ); |
} |
|
var nativeFn, nativeHandler; |
try { |
nativeFn = elem[ type ]; |
nativeHandler = elem[ "on" + type ]; |
// prevent IE from throwing an error for some elements with some event types, see #3533 |
} catch (e) {} |
// Handle triggering native .onfoo handlers (and on links since we don't call .click() for links) |
if ( (!nativeFn || (jQuery.nodeName(elem, 'a') && type === "click")) && nativeHandler && nativeHandler.apply( elem, data ) === false ) { |
event.result = false; |
} |
|
// Trigger the native events (except for clicks on links) |
if ( !bubbling && nativeFn && !event.isDefaultPrevented() && !(jQuery.nodeName(elem, 'a') && type === "click") ) { |
this.triggered = true; |
try { |
nativeFn(); |
// prevent IE from throwing an error for some hidden elements |
} catch (e) {} |
} |
|
this.triggered = false; |
|
if ( !event.isPropagationStopped() ) { |
var parent = elem.parentNode || elem.ownerDocument; |
if ( parent ) { |
jQuery.event.trigger( event, data, parent, true ); |
} |
} |
}, |
|
handle: function( event ) { |
// returned undefined or false |
var all, handlers; |
|
event = arguments[0] = jQuery.event.fix( event || window.event ); |
event.currentTarget = this; |
|
// Namespaced event handlers |
var namespaces = event.type.split("."); |
event.type = namespaces.shift(); |
|
// Cache this now, all = true means, any handler |
all = !namespaces.length && !event.exclusive; |
|
var namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join(".*\\.") + "(\\.|$)"); |
|
handlers = ( jQuery.data(this, "events") || {} )[ event.type ]; |
|
for ( var j in handlers ) { |
var handler = handlers[ j ]; |
|
// Filter the functions by class |
if ( all || namespace.test(handler.type) ) { |
// Pass in a reference to the handler function itself |
// So that we can later remove it |
event.handler = handler; |
event.data = handler.data; |
|
var ret = handler.apply( this, arguments ); |
|
if ( ret !== undefined ) { |
event.result = ret; |
if ( ret === false ) { |
event.preventDefault(); |
event.stopPropagation(); |
} |
} |
|
if ( event.isImmediatePropagationStopped() ) { |
break; |
} |
|
} |
} |
}, |
|
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 ] ) { |
return event; |
} |
|
// store a copy of the original event object |
// and "clone" to set read-only properties |
var originalEvent = event; |
event = jQuery.Event( originalEvent ); |
|
for ( var i = this.props.length, prop; i; ) { |
prop = this.props[ --i ]; |
event[ prop ] = originalEvent[ prop ]; |
} |
|
// Fix target property, if necessary |
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 ) { |
event.target = event.target.parentNode; |
} |
|
// Add relatedTarget, if necessary |
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 && 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) ) { |
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 ) { |
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 !== undefined ) { |
event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); |
} |
|
return event; |
}, |
|
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 |
return proxy; |
}, |
|
special: { |
ready: { |
// Make sure the ready event is setup |
setup: bindReady, |
teardown: function() {} |
}, |
|
live: { |
add: function( proxy, data, namespaces ) { |
jQuery.extend( proxy, data || {} ); |
proxy.guid += data.selector + data.live; |
jQuery.event.add( this, data.live, liveHandler ); |
}, |
|
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) ) { |
remove++; |
} |
}); |
|
if ( remove < 1 ) { |
jQuery.event.remove( this, namespaces[0], liveHandler ); |
} |
} |
} |
} |
} |
}; |
|
jQuery.Event = function( src ){ |
// Allow instantiation without the 'new' keyword |
if ( !this.preventDefault ) { |
return new jQuery.Event( src ); |
} |
|
// Event object |
if ( src && src.type ) { |
this.originalEvent = src; |
this.type = src.type; |
// Event type |
} else { |
this.type = src; |
} |
|
// timeStamp is buggy for some events on Firefox(#3843) |
// So we won't rely on the native value |
this.timeStamp = now(); |
|
// Mark it as fixed |
this[ expando ] = true; |
}; |
|
function returnFalse() { |
return false; |
} |
function returnTrue() { |
return true; |
} |
|
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding |
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html |
jQuery.Event.prototype = { |
preventDefault: function() { |
this.isDefaultPrevented = returnTrue; |
|
var e = this.originalEvent; |
if ( !e ) { |
return; |
} |
// if preventDefault exists run it on the original event |
if ( e.preventDefault ) { |
e.preventDefault(); |
} |
// otherwise set the returnValue property of the original event to false (IE) |
e.returnValue = false; |
}, |
stopPropagation: function() { |
this.isPropagationStopped = returnTrue; |
|
var e = this.originalEvent; |
if ( !e ) { |
return; |
} |
// if stopPropagation exists run it on the original event |
if ( e.stopPropagation ) { |
e.stopPropagation(); |
} |
// otherwise set the cancelBubble property of the original event to true (IE) |
e.cancelBubble = true; |
}, |
stopImmediatePropagation: function(){ |
this.isImmediatePropagationStopped = returnTrue; |
this.stopPropagation(); |
}, |
isDefaultPrevented: returnFalse, |
isPropagationStopped: returnFalse, |
isImmediatePropagationStopped: returnFalse |
}; |
// Checks if an event happened on an element within another element |
// Used in jQuery.event.special.mouseenter and mouseleave handlers |
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 ) { |
// Firefox sometimes assigns relatedTarget a XUL element |
// which we cannot access the parentNode property of |
try { parent = parent.parentNode; } |
// assuming we've left the element since we most likely mousedover a xul element |
catch(e) { break; } |
} |
|
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 |
jQuery.event.handle.apply( this, arguments ); |
} |
}; |
|
jQuery.each({ |
mouseover: 'mouseenter', |
mouseout: 'mouseleave' |
}, function( orig, fix ) { |
jQuery.event.special[ fix ] = { |
setup: function(){ |
jQuery.event.add( this, orig, withinElement, fix ); |
}, |
teardown: function(){ |
jQuery.event.remove( this, orig, withinElement ); |
} |
}; |
}); |
|
jQuery.fn.extend({ |
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, 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, data ); |
}); |
}, |
|
unbind: function( type, fn ) { |
return this.each(function() { |
jQuery.event.remove( this, type, fn ); |
}); |
}, |
|
trigger: function( type, data ) { |
return this.each(function() { |
jQuery.event.trigger( type, data, this ); |
}); |
}, |
|
triggerHandler: function( type, data ) { |
if ( this[0] ) { |
var event = jQuery.Event( type ); |
event.preventDefault(); |
event.stopPropagation(); |
jQuery.event.trigger( event, data, this[0] ); |
return event.result; |
} |
}, |
|
toggle: function( fn ) { |
// Save reference to arguments for access in closure |
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++ ] ); |
} |
|
return this.click( jQuery.event.proxy( fn, function( event ) { |
// Figure out which function to execute |
this.lastToggle = ( this.lastToggle || 0 ) % i; |
|
// Make sure that clicks stop |
event.preventDefault(); |
|
// and execute the function |
return args[ this.lastToggle++ ].apply( this, arguments ) || false; |
})); |
}, |
|
hover: function( fnOver, fnOut ) { |
return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); |
}, |
|
ready: function( fn ) { |
// Attach the listeners |
bindReady(); |
|
// If the DOM is already ready |
if ( jQuery.isReady ) { |
// Execute the function immediately |
fn.call( document, jQuery ); |
|
// Otherwise, remember the function for later |
} else { |
// Add the function to the wait list |
jQuery.readyList.push( fn ); |
} |
|
return this; |
}, |
|
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 ); |
return this; |
} |
}); |
|
function liveHandler( event ) { |
var stop = true, elems = [], args = arguments; |
|
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" ); |
}); |
|
jQuery.each(elems, function() { |
event.currentTarget = this.elem; |
event.data = this.fn.data; |
if ( this.fn.apply( this.elem, args ) === false ) { |
return (stop = false); |
} |
}); |
|
return stop; |
} |
|
function liveConvert( type, selector ) { |
return ["live", type, selector.replace(/\./g, "`").replace(/ /g, "|")].join("."); |
} |
|
jQuery.extend({ |
isReady: false, |
readyList: [], |
// Handle when the DOM is ready |
ready: function() { |
// Make sure that the DOM is not already loaded |
if ( !jQuery.isReady ) { |
// Remember that the DOM is ready |
jQuery.isReady = true; |
|
// If there are functions bound, to execute |
if ( jQuery.readyList ) { |
// Execute all of them |
var fn, i = 0; |
while ( (fn = jQuery.readyList[ i++ ]) ) { |
fn.call( document, jQuery ); |
} |
|
// Reset the list of functions |
jQuery.readyList = null; |
} |
|
// Trigger any bound ready events |
jQuery( document ).triggerHandler( "ready" ); |
} |
} |
}); |
|
var readyBound = false; |
|
function bindReady() { |
if ( readyBound ) return; |
readyBound = true; |
|
// Catch cases where $(document).ready() is called after the |
// browser event has already occurred. |
if ( document.readyState === "complete" ) { |
return jQuery.ready(); |
} |
|
// Mozilla, Opera and webkit nightlies currently support this event |
if ( document.addEventListener ) { |
// Use the handy event callback |
document.addEventListener( "DOMContentLoaded", function() { |
document.removeEventListener( "DOMContentLoaded", arguments.callee, false ); |
jQuery.ready(); |
}, false ); |
|
// If IE event model is used |
} else if ( document.attachEvent ) { |
// ensure firing before onload, |
// maybe late but safe also for iframes |
document.attachEvent("onreadystatechange", function() { |
if ( document.readyState === "complete" ) { |
document.detachEvent( "onreadystatechange", arguments.callee ); |
jQuery.ready(); |
} |
}); |
|
// 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; |
} |
|
try { |
// If IE is used, use the trick by Diego Perini |
// http://javascript.nwbox.com/IEContentLoaded/ |
document.documentElement.doScroll("left"); |
} catch( error ) { |
setTimeout( arguments.callee, 0 ); |
return; |
} |
|
// and execute any waiting functions |
jQuery.ready(); |
})(); |
} |
|
// A fallback to window.onload, that will always work |
jQuery.event.add( window, "load", jQuery.ready ); |
} |
|
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 ) { |
|
// Handle event binding |
jQuery.fn[ name ] = function( fn ) { |
return fn ? this.bind( name, fn ) : this.trigger( name ); |
}; |
}); |
|
// Prevent memory leaks in IE |
// And prevent errors on refresh with events like mouseover in other browsers |
// Window isn't included so as not to unbind existing unload events |
// 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 ) { |
// Skip the window |
if ( id != 1 && jQuery.cache[ id ].handle ) { |
jQuery.event.remove( jQuery.cache[ id ].handle.elem ); |
} |
} |
}); |
(function(){ |
|
jQuery.support = {}; |
|
var root = document.documentElement, |
script = document.createElement("script"), |
div = document.createElement("div"), |
id = "script" + (new Date).getTime(); |
|
div.style.display = "none"; |
div.innerHTML = ' <link/><table></table><a href="/a" style="color:red;float:left;opacity:.5;">a</a><select><option>text</option></select>'; |
|
var all = div.getElementsByTagName("*"), |
a = div.getElementsByTagName("a")[0]; |
|
// Can't get basic test support |
if ( !all || !all.length || !a ) { |
return; |
} |
|
jQuery.support = { |
// IE strips leading whitespace when .innerHTML is used |
leadingWhitespace: div.firstChild.nodeType == 3, |
|
// Make sure that tbody elements aren't automatically inserted |
// IE will insert them into empty tables |
tbody: !div.getElementsByTagName("tbody").length, |
|
// Make sure that link elements get serialized correctly by innerHTML |
// This requires a wrapper element in IE |
htmlSerialize: !!div.getElementsByTagName("link").length, |
|
// Get the style information from getAttribute |
// (IE uses .cssText insted) |
style: /red/.test( a.getAttribute("style") ), |
|
// Make sure that URLs aren't manipulated |
// (IE normalizes it by default) |
hrefNormalized: a.getAttribute("href") === "/a", |
|
// Make sure that element opacity exists |
// (IE uses filter instead) |
opacity: a.style.opacity === "0.5", |
|
// Verify style float existence |
// (IE uses styleFloat instead of cssFloat) |
cssFloat: !!a.style.cssFloat, |
|
// Will be defined later |
scriptEval: false, |
noCloneEvent: true, |
boxModel: null |
}; |
|
script.type = "text/javascript"; |
try { |
script.appendChild( document.createTextNode( "window." + id + "=1;" ) ); |
} catch(e){} |
|
root.insertBefore( script, root.firstChild ); |
|
// Make sure that the execution of code works by injecting a script |
// tag with appendChild/createTextNode |
// (IE doesn't support this, fails, and uses .text instead) |
if ( window[ id ] ) { |
jQuery.support.scriptEval = true; |
delete window[ id ]; |
} |
|
root.removeChild( script ); |
|
if ( div.attachEvent && div.fireEvent ) { |
div.attachEvent("onclick", function click(){ |
// Cloning a node shouldn't copy over any |
// bound event handlers (IE does this) |
jQuery.support.noCloneEvent = false; |
div.detachEvent("onclick", click); |
}); |
div.cloneNode(true).fireEvent("onclick"); |
} |
|
// Figure out if the W3C box model works as expected |
// document.body must exist before we can do this |
jQuery(function(){ |
var div = document.createElement("div"); |
div.style.width = div.style.paddingLeft = "1px"; |
|
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 = { |
"for": "htmlFor", |
"class": "className", |
readonly: "readOnly", |
maxlength: "maxLength", |
cellspacing: "cellSpacing", |
rowspan: "rowSpan", |
colspan: "colSpan", |
tabindex: "tabIndex" |
}; |
// exclude the following css properties to add px |
var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i, |
ralpha = /alpha\([^)]*\)/, |
3458,51 → 3689,17 |
}; |
|
jQuery.fn.css = function( name, value ) { |
var options = name, isFunction = jQuery.isFunction( value ); |
|
if ( typeof name === "string" ) { |
// Are we setting the style? |
return access( this, name, value, true, function( elem, name, value ) { |
if ( value === undefined ) { |
return this.length ? |
jQuery.css( this[0], name ) : |
null; |
|
// Convert name, value params to options hash format |
} else { |
options = {}; |
options[ name ] = value; |
return jQuery.css( elem, name ); |
} |
} |
|
var isFunction = {}; |
|
// For each value, determine whether it's a Function so we don't |
// need to determine it again for each element |
for ( var prop in options ) { |
isFunction[prop] = jQuery.isFunction( options[prop] ); |
if ( typeof value === "number" && !rexclude.test(name) ) { |
value += "px"; |
} |
|
// For each element... |
for ( var i = 0, l = this.length; i < l; i++ ) { |
var elem = this[i]; |
|
// Set all the styles |
for ( var prop in options ) { |
value = options[prop]; |
|
if ( isFunction[prop] ) { |
value = value.call( elem, i ); |
} |
|
if ( typeof value === "number" && !rexclude.test(prop) ) { |
value = value + "px"; |
} |
|
jQuery.style( elem, prop, value ); |
} |
} |
|
return this; |
jQuery.style( elem, name, value ); |
}); |
}; |
|
jQuery.extend({ |
3715,8 → 3912,6 |
} |
} |
|
var self = this; |
|
// Request the remote document |
jQuery.ajax({ |
url: url, |
3723,11 → 3918,12 |
type: type, |
dataType: "html", |
data: params, |
context:this, |
complete: function(res, status){ |
// If successful, inject the HTML into all the matched elements |
if ( status === "success" || status === "notmodified" ) { |
// See if a selector was specified |
self.html( selector ? |
this.html( selector ? |
// Create a dummy div to hold the results |
jQuery("<div/>") |
// inject the contents of the document in, removing the scripts |
3742,7 → 3938,7 |
} |
|
if ( callback ) { |
self.each( callback, [res.responseText, status, res] ); |
this.each( callback, [res.responseText, status, res] ); |
} |
} |
}); |
3786,8 → 3982,9 |
jQuery.extend({ |
|
get: function( url, data, callback, type ) { |
// shift arguments if data argument was ommited |
// shift arguments if data argument was omited |
if ( jQuery.isFunction( data ) ) { |
type = type || callback; |
callback = data; |
data = null; |
} |
3810,7 → 4007,9 |
}, |
|
post: function( url, data, callback, type ) { |
// shift arguments if data argument was omited |
if ( jQuery.isFunction( data ) ) { |
type = type || callback; |
callback = data; |
data = {}; |
} |
3869,6 → 4068,7 |
s = jQuery.extend(true, s, jQuery.extend(true, {}, jQuery.ajaxSettings, s)); |
|
var jsonp, status, data, |
callbackContext = s.context || window, |
type = s.type.toUpperCase(); |
|
// convert data if not already a string |
3949,7 → 4149,7 |
if ( s.dataType === "script" && type === "GET" && parts |
&& ( parts[1] && parts[1] !== location.protocol || parts[2] !== location.host )) { |
|
var head = document.getElementsByTagName("head")[0]; |
var head = document.getElementsByTagName("head")[0] || document.documentElement; |
var script = document.createElement("script"); |
script.src = s.url; |
if ( s.scriptCharset ) { |
4026,7 → 4226,7 |
} catch(e){} |
|
// Allow custom headers/mimetypes and early abort |
if ( s.beforeSend && s.beforeSend(xhr, s) === false ) { |
if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) { |
// Handle the global AJAX counter |
if ( s.global && ! --jQuery.active ) { |
jQuery.event.trigger( "ajaxStop" ); |
4038,13 → 4238,13 |
} |
|
if ( s.global ) { |
jQuery.event.trigger("ajaxSend", [xhr, s]); |
trigger("ajaxSend", [xhr, s]); |
} |
|
// Wait for a response to come back |
var onreadystatechange = function(isTimeout){ |
// The request was aborted, clear the interval and decrement jQuery.active |
if ( xhr.readyState === 0 ) { |
if ( !xhr || xhr.readyState === 0 ) { |
if ( ival ) { |
// clear poll interval |
clearInterval( ival ); |
4138,12 → 4338,12 |
function success(){ |
// If a local callback was specified, fire it and pass it the data |
if ( s.success ) { |
s.success( data, status ); |
s.success.call( callbackContext, data, status ); |
} |
|
// Fire the global callback |
if ( s.global ) { |
jQuery.event.trigger( "ajaxSuccess", [xhr, s] ); |
trigger( "ajaxSuccess", [xhr, s] ); |
} |
} |
|
4150,12 → 4350,12 |
function complete(){ |
// Process result |
if ( s.complete ) { |
s.complete(xhr, status); |
s.complete.call( callbackContext, xhr, status); |
} |
|
// The request was completed |
if ( s.global ) { |
jQuery.event.trigger( "ajaxComplete", [xhr, s] ); |
trigger( "ajaxComplete", [xhr, s] ); |
} |
|
// Handle the global AJAX counter |
4164,6 → 4364,10 |
} |
} |
|
function trigger(type, args){ |
(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args); |
} |
|
// return XMLHttpRequest to allow aborting the request etc. |
return xhr; |
}, |
4171,12 → 4375,12 |
handleError: function( s, xhr, status, e ) { |
// If a local callback was specified, fire it |
if ( s.error ) { |
s.error( xhr, status, e ); |
s.error.call( s.context || window, xhr, status, e ); |
} |
|
// Fire the global callback |
if ( s.global ) { |
jQuery.event.trigger( "ajaxError", [xhr, s, e] ); |
(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] ); |
} |
}, |
|
4198,11 → 4402,11 |
|
// Determines if an XMLHttpRequest returns NotModified |
httpNotModified: function( xhr, url ) { |
var last_modified = xhr.getResponseHeader("Last-Modified"), |
var lastModified = xhr.getResponseHeader("Last-Modified"), |
etag = xhr.getResponseHeader("Etag"); |
|
if ( last_modified ) { |
jQuery.lastModified[url] = last_modified; |
if ( lastModified ) { |
jQuery.lastModified[url] = lastModified; |
} |
|
if ( etag ) { |
4252,35 → 4456,53 |
// Serialize an array of form elements or a set of |
// key/values into a query string |
param: function( a ) { |
var s = []; |
var s = [], |
param_traditional = jQuery.param.traditional; |
|
function add( key, value ){ |
// If value is a function, invoke it and return its value |
value = jQuery.isFunction(value) ? value() : value; |
s[ s.length ] = encodeURIComponent(key) + '=' + encodeURIComponent(value); |
} |
|
// If an array was passed in, assume that it is an array |
// of form elements |
if ( jQuery.isArray(a) || a.jquery ) { |
if ( jQuery.isArray(a) || a.jquery ) |
// Serialize the form elements |
jQuery.each( a, function(){ |
add( this.name, this.value ); |
}); |
|
// Otherwise, assume that it's an object of key/value pairs |
} else { |
// Serialize the key/values |
for ( var j in a ) { |
// If the value is an array then the key names need to be repeated |
if ( jQuery.isArray(a[j]) ) { |
jQuery.each( a[j], function(){ |
add( j, this ); |
else |
// Encode parameters from object, recursively. If |
// jQuery.param.traditional is set, encode the "old" way |
// (the way 1.3.2 or older did it) |
jQuery.each( a, function buildParams( prefix, obj ) { |
|
if ( jQuery.isArray(obj) ) |
jQuery.each( obj, function(i,v){ |
// Due to rails' limited request param syntax, numeric array |
// indices are not supported. To avoid serialization ambiguity |
// issues, serialized arrays can only contain scalar values. php |
// does not have this issue, but we should go with the lowest |
// common denominator |
add( prefix + ( param_traditional ? "" : "[]" ), v ); |
}); |
} else { |
add( j, jQuery.isFunction(a[j]) ? a[j]() : a[j] ); |
} |
} |
} |
|
else if ( typeof obj == "object" ) |
if ( param_traditional ) |
add( prefix, obj ); |
|
else |
jQuery.each( obj, function(k,v){ |
buildParams( prefix ? prefix + "[" + k + "]" : k, v ); |
}); |
|
else |
add( prefix, obj ); |
|
}); |
|
// Return the resulting serialization |
return s.join("&").replace(r20, "+"); |
} |
4307,7 → 4529,7 |
|
jQuery.fn.extend({ |
show: function(speed,callback){ |
if ( speed ) { |
if ( speed !== undefined ) { |
return this.animate( genFx("show", 3), speed, callback); |
} else { |
for ( var i = 0, l = this.length; i < l; i++ ){ |
4347,7 → 4569,7 |
}, |
|
hide: function(speed,callback){ |
if ( speed ) { |
if ( speed !== undefined ) { |
return this.animate( genFx("hide", 3), speed, callback); |
} else { |
for ( var i = 0, l = this.length; i < l; i++ ){ |
4709,9 → 4931,14 |
} |
}); |
if ( "getBoundingClientRect" in document.documentElement ) { |
jQuery.fn.offset = function() { |
jQuery.fn.offset = function( options ) { |
var elem = this[0]; |
if ( !elem || !elem.ownerDocument ) { return null; } |
if ( options ) { |
return this.each(function() { |
jQuery.offset.setOffset( this, options ); |
}); |
} |
if ( elem === elem.ownerDocument.body ) { |
return jQuery.offset.bodyOffset( elem ); |
} |
4723,9 → 4950,14 |
return { top: top, left: left }; |
}; |
} else { |
jQuery.fn.offset = function() { |
jQuery.fn.offset = function( options ) { |
var elem = this[0]; |
if ( !elem || !elem.ownerDocument ) { return null; } |
if ( options ) { |
return this.each(function() { |
jQuery.offset.setOffset( this, options ); |
}); |
} |
if ( elem === elem.ownerDocument.body ) { |
return jQuery.offset.bodyOffset( elem ); |
} |
4821,10 → 5053,31 |
} |
|
return { top: top, left: left }; |
}, |
|
setOffset: function( elem, options ) { |
// set position first, in-case top/left are set even on static elem |
if ( /static/.test( jQuery.curCSS( elem, 'position' ) ) ) { |
elem.style.position = 'relative'; |
} |
var curElem = jQuery( elem ), |
curOffset = curElem.offset(), |
curTop = parseInt( jQuery.curCSS( elem, 'top', true ), 10 ) || 0, |
curLeft = parseInt( jQuery.curCSS( elem, 'left', true ), 10) || 0, |
props = { |
top: (options.top - curOffset.top) + curTop, |
left: (options.left - curOffset.left) + curLeft |
}; |
|
if ( 'using' in options ) { |
options.using.call( elem, props ); |
} else { |
curElem.css( props ); |
} |
} |
}; |
|
|
jQuery.fn.extend({ |
position: function() { |
if ( !this[0] ) { return null; } |
4954,4 → 5207,7 |
}; |
|
}); |
// Expose jQuery to the global object |
window.jQuery = window.$ = jQuery; |
|
})(window); |