Commit 49cfcb9f authored by Timmy Willison's avatar Timmy Willison

Apply consistent ordering in all modules. -219 bytes. Order modules like...

Apply consistent ordering in all modules. -219 bytes. Order modules like functions > jQuery.extend > jQuery.fn.extend.
parent 6bc80597
...@@ -2,10 +2,12 @@ define([ ...@@ -2,10 +2,12 @@ define([
"./core", "./core",
"./traversing" "./traversing"
], function( jQuery ) { ], function( jQuery ) {
// The number of elements contained in the matched element set // The number of elements contained in the matched element set
jQuery.fn.size = function() { jQuery.fn.size = function() {
return this.length; return this.length;
}; };
jQuery.fn.andSelf = jQuery.fn.addBack; jQuery.fn.andSelf = jQuery.fn.addBack;
}); });
...@@ -3,6 +3,7 @@ define([ ...@@ -3,6 +3,7 @@ define([
"./core/access", "./core/access",
"./css" "./css"
], function( jQuery, access ) { ], function( jQuery, access ) {
// Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods // Create innerHeight, innerWidth, height, width, outerHeight and outerWidth methods
jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) { jQuery.each( { padding: "inner" + name, content: type, "": "outer" + name }, function( defaultExtra, funcName ) {
......
...@@ -79,6 +79,28 @@ function createFxNow() { ...@@ -79,6 +79,28 @@ function createFxNow() {
return ( fxNow = jQuery.now() ); return ( fxNow = jQuery.now() );
} }
// Generate parameters to create a standard animation
function genFx( type, includeWidth ) {
var which,
attrs = { height: type },
i = 0;
// if we include width, step value is 1 to do all cssExpand values,
// if we don't include width, step value is 2 to skip over Left and Right
includeWidth = includeWidth? 1 : 0;
for( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}
if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}
return attrs;
}
function createTween( value, prop, animation ) { function createTween( value, prop, animation ) {
var tween, var tween,
collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ), collection = ( tweeners[ prop ] || [] ).concat( tweeners[ "*" ] ),
...@@ -93,6 +115,173 @@ function createTween( value, prop, animation ) { ...@@ -93,6 +115,173 @@ function createTween( value, prop, animation ) {
} }
} }
function defaultPrefilter( elem, props, opts ) {
/* jshint validthis: true */
var prop, value, toggle, tween, hooks, oldfire,
anim = this,
orig = {},
style = elem.style,
hidden = elem.nodeType && isHidden( elem ),
dataShow = jQuery._data( elem, "fxshow" );
// handle queue: false promises
if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) {
hooks.unqueued = 0;
oldfire = hooks.empty.fire;
hooks.empty.fire = function() {
if ( !hooks.unqueued ) {
oldfire();
}
};
}
hooks.unqueued++;
anim.always(function() {
// doing this makes sure that the complete handler will be called
// before this completes
anim.always(function() {
hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire();
}
});
});
}
// height/width overflow pass
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE does not
// change the overflow attribute when overflowX and
// overflowY are set to the same value
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated
if ( jQuery.css( elem, "display" ) === "inline" &&
jQuery.css( elem, "float" ) === "none" ) {
// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
style.display = "inline-block";
} else {
style.zoom = 1;
}
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
if ( !support.shrinkWrapBlocks() ) {
anim.always(function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
});
}
}
// show/hide pass
for ( prop in props ) {
value = props[ prop ];
if ( rfxtypes.exec( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) {
hidden = true;
} else {
continue;
}
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
}
if ( !jQuery.isEmptyObject( orig ) ) {
if ( dataShow ) {
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
}
} else {
dataShow = jQuery._data( elem, "fxshow", {} );
}
// store state if its toggle - enables .stop().toggle() to "reverse"
if ( toggle ) {
dataShow.hidden = !hidden;
}
if ( hidden ) {
jQuery( elem ).show();
} else {
anim.done(function() {
jQuery( elem ).hide();
});
}
anim.done(function() {
var prop;
jQuery._removeData( elem, "fxshow" );
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
});
for ( prop in orig ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( !( prop in dataShow ) ) {
dataShow[ prop ] = tween.start;
if ( hidden ) {
tween.end = tween.start;
tween.start = prop === "width" || prop === "height" ? 1 : 0;
}
}
}
}
}
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
name = jQuery.camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( jQuery.isArray( value ) ) {
easing = value[ 1 ];
value = props[ index ] = value[ 0 ];
}
if ( index !== name ) {
props[ name ] = value;
delete props[ index ];
}
hooks = jQuery.cssHooks[ name ];
if ( hooks && "expand" in hooks ) {
value = hooks.expand( value );
delete props[ name ];
// not quite $.extend, this wont overwrite keys already present.
// also - reusing 'index' from above because we have the correct "name"
for ( index in value ) {
if ( !( index in props ) ) {
props[ index ] = value[ index ];
specialEasing[ index ] = easing;
}
}
} else {
specialEasing[ name ] = easing;
}
}
}
function Animation( elem, properties, options ) { function Animation( elem, properties, options ) {
var result, var result,
stopped, stopped,
...@@ -197,45 +386,7 @@ function Animation( elem, properties, options ) { ...@@ -197,45 +386,7 @@ function Animation( elem, properties, options ) {
.always( animation.opts.always ); .always( animation.opts.always );
} }
function propFilter( props, specialEasing ) {
var index, name, easing, value, hooks;
// camelCase, specialEasing and expand cssHook pass
for ( index in props ) {
name = jQuery.camelCase( index );
easing = specialEasing[ name ];
value = props[ index ];
if ( jQuery.isArray( value ) ) {
easing = value[ 1 ];
value = props[ index ] = value[ 0 ];
}
if ( index !== name ) {
props[ name ] = value;
delete props[ index ];
}
hooks = jQuery.cssHooks[ name ];
if ( hooks && "expand" in hooks ) {
value = hooks.expand( value );
delete props[ name ];
// not quite $.extend, this wont overwrite keys already present.
// also - reusing 'index' from above because we have the correct "name"
for ( index in value ) {
if ( !( index in props ) ) {
props[ index ] = value[ index ];
specialEasing[ index ] = easing;
}
}
} else {
specialEasing[ name ] = easing;
}
}
}
jQuery.Animation = jQuery.extend( Animation, { jQuery.Animation = jQuery.extend( Animation, {
tweener: function( props, callback ) { tweener: function( props, callback ) {
if ( jQuery.isFunction( props ) ) { if ( jQuery.isFunction( props ) ) {
callback = props; callback = props;
...@@ -264,144 +415,37 @@ jQuery.Animation = jQuery.extend( Animation, { ...@@ -264,144 +415,37 @@ jQuery.Animation = jQuery.extend( Animation, {
} }
}); });
function defaultPrefilter( elem, props, opts ) { jQuery.speed = function( speed, easing, fn ) {
/* jshint validthis: true */ var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
var prop, value, toggle, tween, hooks, oldfire, complete: fn || !fn && easing ||
anim = this, jQuery.isFunction( speed ) && speed,
orig = {}, duration: speed,
style = elem.style, easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
hidden = elem.nodeType && isHidden( elem ), };
dataShow = jQuery._data( elem, "fxshow" );
// handle queue: false promises
if ( !opts.queue ) {
hooks = jQuery._queueHooks( elem, "fx" );
if ( hooks.unqueued == null ) {
hooks.unqueued = 0;
oldfire = hooks.empty.fire;
hooks.empty.fire = function() {
if ( !hooks.unqueued ) {
oldfire();
}
};
}
hooks.unqueued++;
anim.always(function() {
// doing this makes sure that the complete handler will be called
// before this completes
anim.always(function() {
hooks.unqueued--;
if ( !jQuery.queue( elem, "fx" ).length ) {
hooks.empty.fire();
}
});
});
}
// height/width overflow pass
if ( elem.nodeType === 1 && ( "height" in props || "width" in props ) ) {
// Make sure that nothing sneaks out
// Record all 3 overflow attributes because IE does not
// change the overflow attribute when overflowX and
// overflowY are set to the same value
opts.overflow = [ style.overflow, style.overflowX, style.overflowY ];
// Set display property to inline-block for height/width
// animations on inline elements that are having width/height animated
if ( jQuery.css( elem, "display" ) === "inline" &&
jQuery.css( elem, "float" ) === "none" ) {
// inline-level elements accept inline-block;
// block-level elements need to be inline with layout
if ( !support.inlineBlockNeedsLayout || defaultDisplay( elem.nodeName ) === "inline" ) {
style.display = "inline-block";
} else {
style.zoom = 1;
}
}
}
if ( opts.overflow ) {
style.overflow = "hidden";
if ( !support.shrinkWrapBlocks() ) {
anim.always(function() {
style.overflow = opts.overflow[ 0 ];
style.overflowX = opts.overflow[ 1 ];
style.overflowY = opts.overflow[ 2 ];
});
}
}
// show/hide pass opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
for ( prop in props ) { opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
value = props[ prop ];
if ( rfxtypes.exec( value ) ) {
delete props[ prop ];
toggle = toggle || value === "toggle";
if ( value === ( hidden ? "hide" : "show" ) ) {
// If there is dataShow left over from a stopped hide or show and we are going to proceed with show, we should pretend to be hidden // normalize opt.queue - true/undefined/null -> "fx"
if ( value === "show" && dataShow && dataShow[ prop ] !== undefined ) { if ( opt.queue == null || opt.queue === true ) {
hidden = true; opt.queue = "fx";
} else {
continue;
}
}
orig[ prop ] = dataShow && dataShow[ prop ] || jQuery.style( elem, prop );
}
} }
if ( !jQuery.isEmptyObject( orig ) ) { // Queueing
if ( dataShow ) { opt.old = opt.complete;
if ( "hidden" in dataShow ) {
hidden = dataShow.hidden;
}
} else {
dataShow = jQuery._data( elem, "fxshow", {} );
}
// store state if its toggle - enables .stop().toggle() to "reverse" opt.complete = function() {
if ( toggle ) { if ( jQuery.isFunction( opt.old ) ) {
dataShow.hidden = !hidden; opt.old.call( this );
}
if ( hidden ) {
jQuery( elem ).show();
} else {
anim.done(function() {
jQuery( elem ).hide();
});
} }
anim.done(function() {
var prop;
jQuery._removeData( elem, "fxshow" );
for ( prop in orig ) {
jQuery.style( elem, prop, orig[ prop ] );
}
});
for ( prop in orig ) {
tween = createTween( hidden ? dataShow[ prop ] : 0, prop, anim );
if ( !( prop in dataShow ) ) { if ( opt.queue ) {
dataShow[ prop ] = tween.start; jQuery.dequeue( this, opt.queue );
if ( hidden ) {
tween.end = tween.start;
tween.start = prop === "width" || prop === "height" ? 1 : 0;
}
}
} }
}
}
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
var cssFn = jQuery.fn[ name ];
jQuery.fn[ name ] = function( speed, easing, callback ) {
return speed == null || typeof speed === "boolean" ?
cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback );
}; };
});
return opt;
};
jQuery.fn.extend({ jQuery.fn.extend({
fadeTo: function( speed, to, easing, callback ) { fadeTo: function( speed, to, easing, callback ) {
...@@ -523,26 +567,14 @@ jQuery.fn.extend({ ...@@ -523,26 +567,14 @@ jQuery.fn.extend({
} }
}); });
// Generate parameters to create a standard animation jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
function genFx( type, includeWidth ) { var cssFn = jQuery.fn[ name ];
var which, jQuery.fn[ name ] = function( speed, easing, callback ) {
attrs = { height: type }, return speed == null || typeof speed === "boolean" ?
i = 0; cssFn.apply( this, arguments ) :
this.animate( genFx( name, true ), speed, easing, callback );
// if we include width, step value is 1 to do all cssExpand values, };
// if we don't include width, step value is 2 to skip over Left and Right });
includeWidth = includeWidth? 1 : 0;
for( ; i < 4 ; i += 2 - includeWidth ) {
which = cssExpand[ i ];
attrs[ "margin" + which ] = attrs[ "padding" + which ] = type;
}
if ( includeWidth ) {
attrs.opacity = attrs.width = type;
}
return attrs;
}
// Generate shortcuts for custom animations // Generate shortcuts for custom animations
jQuery.each({ jQuery.each({
...@@ -558,38 +590,6 @@ jQuery.each({ ...@@ -558,38 +590,6 @@ jQuery.each({
}; };
}); });
jQuery.speed = function( speed, easing, fn ) {
var opt = speed && typeof speed === "object" ? jQuery.extend( {}, speed ) : {
complete: fn || !fn && easing ||
jQuery.isFunction( speed ) && speed,
duration: speed,
easing: fn && easing || easing && !jQuery.isFunction( easing ) && easing
};
opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[ opt.duration ] : jQuery.fx.speeds._default;
// normalize opt.queue - true/undefined/null -> "fx"
if ( opt.queue == null || opt.queue === true ) {
opt.queue = "fx";
}
// Queueing
opt.old = opt.complete;
opt.complete = function() {
if ( jQuery.isFunction( opt.old ) ) {
opt.old.call( this );
}
if ( opt.queue ) {
jQuery.dequeue( this, opt.queue );
}
};
return opt;
};
jQuery.timers = []; jQuery.timers = [];
jQuery.fx.tick = function() { jQuery.fx.tick = function() {
var timer, var timer,
......
...@@ -71,265 +71,35 @@ wrapMap.optgroup = wrapMap.option; ...@@ -71,265 +71,35 @@ wrapMap.optgroup = wrapMap.option;
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
wrapMap.th = wrapMap.td; wrapMap.th = wrapMap.td;
jQuery.fn.extend({
text: function( value ) {
return access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
}, null, value, arguments.length );
},
append: function() {
return this.domManip( arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
});
},
prepend: function() {
return this.domManip( arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild );
}
});
},
before: function() {
return this.domManip( arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
});
},
after: function() {
return this.domManip( arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling );
}
});
},
remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
}
if ( elem.parentNode ) {
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
setGlobalEval( getAll( elem, "script" ) );
}
elem.parentNode.removeChild( elem );
}
}
return this;
},
empty: function() {
var elem,
i = 0;
for ( ; (elem = this[i]) != null; i++ ) {
// Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
}
// Remove any remaining nodes
while ( elem.firstChild ) {
elem.removeChild( elem.firstChild );
}
// If this is a select, ensure that it displays empty (#12336)
// Support: IE<9
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
elem.options.length = 0;
}
}
return this;
},
clone: function( dataAndEvents, deepDataAndEvents ) {
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
return this.map( function () {
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
});
},
html: function( value ) {
return access( this, function( value ) {
var elem = this[ 0 ] || {},
i = 0,
l = this.length;
if ( value === undefined ) {
return elem.nodeType === 1 ?
elem.innerHTML.replace( rinlinejQuery, "" ) :
undefined;
}
// See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
value = value.replace( rxhtmlTag, "<$1></$2>" );
try {
for (; i < l; i++ ) {
// Remove element nodes and prevent memory leaks
elem = this[i] || {};
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value;
}
}
elem = 0;
// If using innerHTML throws an exception, use the fallback method
} catch(e) {}
}
if ( elem ) { function getAll( context, tag ) {
this.empty().append( value ); var elems, elem,
} i = 0,
}, null, value, arguments.length ); found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
}, typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
undefined;
replaceWith: function() {
var
// Snapshot the DOM in case .domManip sweeps something relevant into its fragment
args = jQuery.map( this, function( elem ) {
return [ elem.nextSibling, elem.parentNode ];
}),
i = 0;
// Make the changes, replacing each context element with the new content
this.domManip( arguments, function( elem ) {
var next = args[ i++ ],
parent = args[ i++ ];
if ( parent ) { if ( !found ) {
// Don't use the snapshot next if it has moved (#13810) for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
if ( next && next.parentNode !== parent ) { if ( !tag || jQuery.nodeName( elem, tag ) ) {
next = this.nextSibling; found.push( elem );
} } else {
jQuery( this ).remove(); jQuery.merge( found, getAll( elem, tag ) );
parent.insertBefore( elem, next );
} }
// Allow new content to include elements from the context set
}, true );
// Force removal if there was no new content (e.g., from empty arguments)
return i ? this : this.remove();
},
detach: function( selector ) {
return this.remove( selector, true );
},
domManip: function( args, callback, allowIntersection ) {
// Flatten any nested arrays
args = concat.apply( [], args );
var first, node, hasScripts,
scripts, doc, fragment,
i = 0,
l = this.length,
set = this,
iNoClone = l - 1,
value = args[0],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction || !( l <= 1 || typeof value !== "string" || support.checkClone || !rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
args[0] = value.call( this, index, self.html() );
}
self.domManip( args, callback, allowIntersection );
});
} }
}
if ( l ) { return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this ); jQuery.merge( [ context ], found ) :
first = fragment.firstChild; found;
}
if ( fragment.childNodes.length === 1 ) {
fragment = first;
}
if ( first ) {
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
// Use the original fragment for the last item instead of the first because it can end up
// being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( i !== iNoClone ) {
node = jQuery.clone( node, true, true );
// Keep references to cloned scripts for later restoration
if ( hasScripts ) {
jQuery.merge( scripts, getAll( node, "script" ) );
}
}
callback.call( this[i], node, i );
}
if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// Reenable scripts
jQuery.map( scripts, restoreScript );
// Evaluate executable scripts on first document insertion
for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
if ( node.src ) {
// Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
}
}
}
}
// Fix #11809: Avoid leaking memory
fragment = first = null;
}
}
return this; // Used in buildFragment, fixes the defaultChecked property
function fixDefaultChecked( elem ) {
if ( rcheckableType.test( elem.type ) ) {
elem.defaultChecked = elem.checked;
} }
}); }
// Support: IE<8 // Support: IE<8
// Manipulating tables requires a tbody // Manipulating tables requires a tbody
...@@ -441,78 +211,23 @@ function fixCloneNodeIssues( src, dest ) { ...@@ -441,78 +211,23 @@ function fixCloneNodeIssues( src, dest ) {
// or radio button. Worse, IE6-7 fail to give the cloned element // or radio button. Worse, IE6-7 fail to give the cloned element
// a checked appearance if the defaultChecked value isn't also set // a checked appearance if the defaultChecked value isn't also set
dest.defaultChecked = dest.checked = src.checked; dest.defaultChecked = dest.checked = src.checked;
// IE6-7 get confused and end up setting the value of a cloned // IE6-7 get confused and end up setting the value of a cloned
// checkbox/radio button to an empty string instead of "on" // checkbox/radio button to an empty string instead of "on"
if ( dest.value !== src.value ) { if ( dest.value !== src.value ) {
dest.value = src.value; dest.value = src.value;
}
// IE6-8 fails to return the selected option to the default selected
// state when cloning options
} else if ( nodeName === "option" ) {
dest.defaultSelected = dest.selected = src.defaultSelected;
// IE6-8 fails to set the defaultValue to the correct value when
// cloning other types of input fields
} else if ( nodeName === "input" || nodeName === "textarea" ) {
dest.defaultValue = src.defaultValue;
}
}
jQuery.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var elems,
i = 0,
ret = [],
insert = jQuery( selector ),
last = insert.length - 1;
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone(true);
jQuery( insert[i] )[ original ]( elems );
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
push.apply( ret, elems.get() );
}
return this.pushStack( ret );
};
});
function getAll( context, tag ) {
var elems, elem,
i = 0,
found = typeof context.getElementsByTagName !== strundefined ? context.getElementsByTagName( tag || "*" ) :
typeof context.querySelectorAll !== strundefined ? context.querySelectorAll( tag || "*" ) :
undefined;
if ( !found ) {
for ( found = [], elems = context.childNodes || context; (elem = elems[i]) != null; i++ ) {
if ( !tag || jQuery.nodeName( elem, tag ) ) {
found.push( elem );
} else {
jQuery.merge( found, getAll( elem, tag ) );
}
} }
}
return tag === undefined || tag && jQuery.nodeName( context, tag ) ? // IE6-8 fails to return the selected option to the default selected
jQuery.merge( [ context ], found ) : // state when cloning options
found; } else if ( nodeName === "option" ) {
} dest.defaultSelected = dest.selected = src.defaultSelected;
// Used in buildFragment, fixes the defaultChecked property // IE6-8 fails to set the defaultValue to the correct value when
function fixDefaultChecked( elem ) { // cloning other types of input fields
if ( rcheckableType.test( elem.type ) ) { } else if ( nodeName === "input" || nodeName === "textarea" ) {
elem.defaultChecked = elem.checked; dest.defaultValue = src.defaultValue;
} }
} }
...@@ -612,145 +327,431 @@ jQuery.extend({ ...@@ -612,145 +327,431 @@ jQuery.extend({
tmp = tmp.lastChild; tmp = tmp.lastChild;
} }
// Manually add leading whitespace removed by IE // Manually add leading whitespace removed by IE
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) { if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) ); nodes.push( context.createTextNode( rleadingWhitespace.exec( elem )[0] ) );
} }
// Remove IE's autoinserted <tbody> from table fragments
if ( !support.tbody ) {
// String was a <table>, *may* have spurious <tbody>
elem = tag === "table" && !rtbody.test( elem ) ?
tmp.firstChild :
// String was a bare <thead> or <tfoot>
wrap[1] === "<table>" && !rtbody.test( elem ) ?
tmp :
0;
j = elem && elem.childNodes.length;
while ( j-- ) {
if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) {
elem.removeChild( tbody );
}
}
}
jQuery.merge( nodes, tmp.childNodes );
// Fix #12392 for WebKit and IE > 9
tmp.textContent = "";
// Fix #12392 for oldIE
while ( tmp.firstChild ) {
tmp.removeChild( tmp.firstChild );
}
// Remember the top-level container for proper cleanup
tmp = safe.lastChild;
}
}
}
// Fix #11356: Clear elements from fragment
if ( tmp ) {
safe.removeChild( tmp );
}
// Reset defaultChecked for any radios and checkboxes
// about to be appended to the DOM in IE 6/7 (#8060)
if ( !support.appendChecked ) {
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked );
}
i = 0;
while ( (elem = nodes[ i++ ]) ) {
// #4087 - If origin and destination elements are the same, and this is
// that element, do not do anything
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) {
continue;
}
contains = jQuery.contains( elem.ownerDocument, elem );
// Append to fragment
tmp = getAll( safe.appendChild( elem ), "script" );
// Preserve script evaluation history
if ( contains ) {
setGlobalEval( tmp );
}
// Capture executables
if ( scripts ) {
j = 0;
while ( (elem = tmp[ j++ ]) ) {
if ( rscriptType.test( elem.type || "" ) ) {
scripts.push( elem );
}
}
}
}
tmp = null;
return safe;
},
cleanData: function( elems, /* internal */ acceptData ) {
var elem, type, id, data,
i = 0,
internalKey = jQuery.expando,
cache = jQuery.cache,
deleteExpando = support.deleteExpando,
special = jQuery.event.special;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( acceptData || jQuery.acceptData( elem ) ) {
id = elem[ internalKey ];
data = id && cache[ id ];
if ( data ) {
if ( data.events ) {
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead
} else {
jQuery.removeEvent( elem, type, data.handle );
}
}
}
// Remove cache only if it was not already removed by jQuery.event.remove
if ( cache[ id ] ) {
delete cache[ id ];
// IE does not allow us to delete expando properties from nodes,
// nor does it have a removeAttribute function on Document nodes;
// we must handle all of these cases
if ( deleteExpando ) {
delete elem[ internalKey ];
} else if ( typeof elem.removeAttribute !== strundefined ) {
elem.removeAttribute( internalKey );
} else {
elem[ internalKey ] = null;
}
deletedIds.push( id );
}
}
}
}
}
});
jQuery.fn.extend({
text: function( value ) {
return access( this, function( value ) {
return value === undefined ?
jQuery.text( this ) :
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
}, null, value, arguments.length );
},
append: function() {
return this.domManip( arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.appendChild( elem );
}
});
},
prepend: function() {
return this.domManip( arguments, function( elem ) {
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
var target = manipulationTarget( this, elem );
target.insertBefore( elem, target.firstChild );
}
});
},
before: function() {
return this.domManip( arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this );
}
});
},
after: function() {
return this.domManip( arguments, function( elem ) {
if ( this.parentNode ) {
this.parentNode.insertBefore( elem, this.nextSibling );
}
});
},
remove: function( selector, keepData /* Internal Use Only */ ) {
var elem,
elems = selector ? jQuery.filter( selector, this ) : this,
i = 0;
for ( ; (elem = elems[i]) != null; i++ ) {
if ( !keepData && elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem ) );
}
if ( elem.parentNode ) {
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
setGlobalEval( getAll( elem, "script" ) );
}
elem.parentNode.removeChild( elem );
}
}
return this;
},
empty: function() {
var elem,
i = 0;
for ( ; (elem = this[i]) != null; i++ ) {
// Remove element nodes and prevent memory leaks
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
}
// Remove any remaining nodes
while ( elem.firstChild ) {
elem.removeChild( elem.firstChild );
}
// If this is a select, ensure that it displays empty (#12336)
// Support: IE<9
if ( elem.options && jQuery.nodeName( elem, "select" ) ) {
elem.options.length = 0;
}
}
return this;
},
// Remove IE's autoinserted <tbody> from table fragments clone: function( dataAndEvents, deepDataAndEvents ) {
if ( !support.tbody ) { dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
// String was a <table>, *may* have spurious <tbody> return this.map( function () {
elem = tag === "table" && !rtbody.test( elem ) ? return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
tmp.firstChild : });
},
// String was a bare <thead> or <tfoot> html: function( value ) {
wrap[1] === "<table>" && !rtbody.test( elem ) ? return access( this, function( value ) {
tmp : var elem = this[ 0 ] || {},
0; i = 0,
l = this.length;
j = elem && elem.childNodes.length; if ( value === undefined ) {
while ( j-- ) { return elem.nodeType === 1 ?
if ( jQuery.nodeName( (tbody = elem.childNodes[j]), "tbody" ) && !tbody.childNodes.length ) { elem.innerHTML.replace( rinlinejQuery, "" ) :
elem.removeChild( tbody ); undefined;
} }
}
}
jQuery.merge( nodes, tmp.childNodes ); // See if we can take a shortcut and just use innerHTML
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
( support.htmlSerialize || !rnoshimcache.test( value ) ) &&
( support.leadingWhitespace || !rleadingWhitespace.test( value ) ) &&
!wrapMap[ ( rtagName.exec( value ) || ["", ""] )[1].toLowerCase() ] ) {
// Fix #12392 for WebKit and IE > 9 value = value.replace( rxhtmlTag, "<$1></$2>" );
tmp.textContent = "";
// Fix #12392 for oldIE try {
while ( tmp.firstChild ) { for (; i < l; i++ ) {
tmp.removeChild( tmp.firstChild ); // Remove element nodes and prevent memory leaks
elem = this[i] || {};
if ( elem.nodeType === 1 ) {
jQuery.cleanData( getAll( elem, false ) );
elem.innerHTML = value;
}
} }
// Remember the top-level container for proper cleanup elem = 0;
tmp = safe.lastChild;
} // If using innerHTML throws an exception, use the fallback method
} catch(e) {}
} }
}
// Fix #11356: Clear elements from fragment if ( elem ) {
if ( tmp ) { this.empty().append( value );
safe.removeChild( tmp ); }
} }, null, value, arguments.length );
},
// Reset defaultChecked for any radios and checkboxes replaceWith: function() {
// about to be appended to the DOM in IE 6/7 (#8060) var
if ( !support.appendChecked ) { // Snapshot the DOM in case .domManip sweeps something relevant into its fragment
jQuery.grep( getAll( nodes, "input" ), fixDefaultChecked ); args = jQuery.map( this, function( elem ) {
} return [ elem.nextSibling, elem.parentNode ];
}),
i = 0;
i = 0; // Make the changes, replacing each context element with the new content
while ( (elem = nodes[ i++ ]) ) { this.domManip( arguments, function( elem ) {
var next = args[ i++ ],
parent = args[ i++ ];
// #4087 - If origin and destination elements are the same, and this is if ( parent ) {
// that element, do not do anything // Don't use the snapshot next if it has moved (#13810)
if ( selection && jQuery.inArray( elem, selection ) !== -1 ) { if ( next && next.parentNode !== parent ) {
continue; next = this.nextSibling;
}
jQuery( this ).remove();
parent.insertBefore( elem, next );
} }
// Allow new content to include elements from the context set
}, true );
contains = jQuery.contains( elem.ownerDocument, elem ); // Force removal if there was no new content (e.g., from empty arguments)
return i ? this : this.remove();
},
// Append to fragment detach: function( selector ) {
tmp = getAll( safe.appendChild( elem ), "script" ); return this.remove( selector, true );
},
// Preserve script evaluation history domManip: function( args, callback, allowIntersection ) {
if ( contains ) {
setGlobalEval( tmp );
}
// Capture executables // Flatten any nested arrays
if ( scripts ) { args = concat.apply( [], args );
j = 0;
while ( (elem = tmp[ j++ ]) ) { var first, node, hasScripts,
if ( rscriptType.test( elem.type || "" ) ) { scripts, doc, fragment,
scripts.push( elem ); i = 0,
} l = this.length,
set = this,
iNoClone = l - 1,
value = args[0],
isFunction = jQuery.isFunction( value );
// We can't cloneNode fragments that contain checked, in WebKit
if ( isFunction || !( l <= 1 || typeof value !== "string" || support.checkClone || !rchecked.test( value ) ) ) {
return this.each(function( index ) {
var self = set.eq( index );
if ( isFunction ) {
args[0] = value.call( this, index, self.html() );
} }
} self.domManip( args, callback, allowIntersection );
});
} }
tmp = null; if ( l ) {
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
return safe; first = fragment.firstChild;
},
cleanData: function( elems, /* internal */ acceptData ) { if ( fragment.childNodes.length === 1 ) {
var elem, type, id, data, fragment = first;
i = 0, }
internalKey = jQuery.expando,
cache = jQuery.cache,
deleteExpando = support.deleteExpando,
special = jQuery.event.special;
for ( ; (elem = elems[i]) != null; i++ ) { if ( first ) {
if ( acceptData || jQuery.acceptData( elem ) ) { scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
hasScripts = scripts.length;
id = elem[ internalKey ]; // Use the original fragment for the last item instead of the first because it can end up
data = id && cache[ id ]; // being emptied incorrectly in certain situations (#8070).
for ( ; i < l; i++ ) {
node = fragment;
if ( data ) { if ( i !== iNoClone ) {
if ( data.events ) { node = jQuery.clone( node, true, true );
for ( type in data.events ) {
if ( special[ type ] ) {
jQuery.event.remove( elem, type );
// This is a shortcut to avoid jQuery.event.remove's overhead // Keep references to cloned scripts for later restoration
} else { if ( hasScripts ) {
jQuery.removeEvent( elem, type, data.handle ); jQuery.merge( scripts, getAll( node, "script" ) );
}
} }
} }
// Remove cache only if it was not already removed by jQuery.event.remove callback.call( this[i], node, i );
if ( cache[ id ] ) { }
delete cache[ id ]; if ( hasScripts ) {
doc = scripts[ scripts.length - 1 ].ownerDocument;
// IE does not allow us to delete expando properties from nodes, // Reenable scripts
// nor does it have a removeAttribute function on Document nodes; jQuery.map( scripts, restoreScript );
// we must handle all of these cases
if ( deleteExpando ) {
delete elem[ internalKey ];
} else if ( typeof elem.removeAttribute !== strundefined ) { // Evaluate executable scripts on first document insertion
elem.removeAttribute( internalKey ); for ( i = 0; i < hasScripts; i++ ) {
node = scripts[ i ];
if ( rscriptType.test( node.type || "" ) &&
!jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
} else { if ( node.src ) {
elem[ internalKey ] = null; // Optional AJAX dependency, but won't run scripts if not present
if ( jQuery._evalUrl ) {
jQuery._evalUrl( node.src );
}
} else {
jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
}
} }
deletedIds.push( id );
} }
} }
// Fix #11809: Avoid leaking memory
fragment = first = null;
} }
} }
return this;
} }
}); });
jQuery.each({
appendTo: "append",
prependTo: "prepend",
insertBefore: "before",
insertAfter: "after",
replaceAll: "replaceWith"
}, function( name, original ) {
jQuery.fn[ name ] = function( selector ) {
var elems,
i = 0,
ret = [],
insert = jQuery( selector ),
last = insert.length - 1;
for ( ; i <= last; i++ ) {
elems = i === last ? this : this.clone(true);
jQuery( insert[i] )[ original ]( elems );
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
push.apply( ret, elems.get() );
}
return this.pushStack( ret );
};
});
return jQuery; return jQuery;
}); });
...@@ -8,45 +8,18 @@ define([ ...@@ -8,45 +8,18 @@ define([
var docElem = window.document.documentElement; var docElem = window.document.documentElement;
jQuery.fn.offset = function( options ) { /**
if ( arguments.length ) { * Gets a window from an element
return options === undefined ? */
this : function getWindow( elem ) {
this.each(function( i ) { return jQuery.isWindow( elem ) ?
jQuery.offset.setOffset( this, options, i ); elem :
}); elem.nodeType === 9 ?
} elem.defaultView || elem.parentWindow :
false;
var docElem, win, }
box = { top: 0, left: 0 },
elem = this[ 0 ],
doc = elem && elem.ownerDocument;
if ( !doc ) {
return;
}
docElem = doc.documentElement;
// Make sure it's not a disconnected DOM node
if ( !jQuery.contains( docElem, elem ) ) {
return box;
}
// If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
if ( typeof elem.getBoundingClientRect !== strundefined ) {
box = elem.getBoundingClientRect();
}
win = getWindow( doc );
return {
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
};
};
jQuery.offset = { jQuery.offset = {
setOffset: function( elem, options, i ) { setOffset: function( elem, options, i ) {
var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition, var curPosition, curLeft, curCSSTop, curTop, curOffset, curCSSLeft, calculatePosition,
position = jQuery.css( elem, "position" ), position = jQuery.css( elem, "position" ),
...@@ -93,8 +66,43 @@ jQuery.offset = { ...@@ -93,8 +66,43 @@ jQuery.offset = {
} }
}; };
jQuery.fn.extend({ jQuery.fn.extend({
offset: function( options ) {
if ( arguments.length ) {
return options === undefined ?
this :
this.each(function( i ) {
jQuery.offset.setOffset( this, options, i );
});
}
var docElem, win,
box = { top: 0, left: 0 },
elem = this[ 0 ],
doc = elem && elem.ownerDocument;
if ( !doc ) {
return;
}
docElem = doc.documentElement;
// Make sure it's not a disconnected DOM node
if ( !jQuery.contains( docElem, elem ) ) {
return box;
}
// If we don't have gBCR, just use 0,0 rather than error
// BlackBerry 5, iOS 3 (original iPhone)
if ( typeof elem.getBoundingClientRect !== strundefined ) {
box = elem.getBoundingClientRect();
}
win = getWindow( doc );
return {
top: box.top + ( win.pageYOffset || docElem.scrollTop ) - ( docElem.clientTop || 0 ),
left: box.left + ( win.pageXOffset || docElem.scrollLeft ) - ( docElem.clientLeft || 0 )
};
},
position: function() { position: function() {
if ( !this[ 0 ] ) { if ( !this[ 0 ] ) {
...@@ -145,17 +153,6 @@ jQuery.fn.extend({ ...@@ -145,17 +153,6 @@ jQuery.fn.extend({
} }
}); });
/**
* Gets a window from an element
*/
function getWindow( elem ) {
return jQuery.isWindow( elem ) ?
elem :
elem.nodeType === 9 ?
elem.defaultView || elem.parentWindow :
false;
}
// Create scrollLeft and scrollTop methods // Create scrollLeft and scrollTop methods
jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) { jQuery.each( {scrollLeft: "pageXOffset", scrollTop: "pageYOffset"}, function( method, prop ) {
var top = /Y/.test( prop ); var top = /Y/.test( prop );
......
...@@ -11,36 +11,33 @@ var r20 = /%20/g, ...@@ -11,36 +11,33 @@ var r20 = /%20/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i, rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
rsubmittable = /^(?:input|select|textarea|keygen)/i; rsubmittable = /^(?:input|select|textarea|keygen)/i;
jQuery.fn.extend({ function buildParams( prefix, obj, traditional, add ) {
serialize: function() { var name;
return jQuery.param( this.serializeArray() );
},
serializeArray: function() {
return this.map(function(){
// Can add propHook for "elements" to filter or add form elements
var elements = jQuery.prop( this, "elements" );
return elements ? jQuery.makeArray( elements ) : this;
})
.filter(function(){
var type = this.type;
// Use .is(":disabled") so that fieldset[disabled] works
return this.name && !jQuery( this ).is( ":disabled" ) &&
rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
})
.map(function( i, elem ){
var val = jQuery( this ).val();
return val == null ? if ( jQuery.isArray( obj ) ) {
null : // Serialize array item.
jQuery.isArray( val ) ? jQuery.each( obj, function( i, v ) {
jQuery.map( val, function( val ){ if ( traditional || rbracket.test( prefix ) ) {
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) }; // Treat each array item as a scalar.
}) : add( prefix, v );
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}).get(); } else {
// Item is non-scalar (array or object), encode its numeric index.
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add );
}
});
} else if ( !traditional && jQuery.type( obj ) === "object" ) {
// Serialize object item.
for ( name in obj ) {
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else {
// Serialize scalar item.
add( prefix, obj );
} }
}); }
// Serialize an array of form elements or a set of // Serialize an array of form elements or a set of
// key/values into a query string // key/values into a query string
...@@ -77,33 +74,36 @@ jQuery.param = function( a, traditional ) { ...@@ -77,33 +74,36 @@ jQuery.param = function( a, traditional ) {
return s.join( "&" ).replace( r20, "+" ); return s.join( "&" ).replace( r20, "+" );
}; };
function buildParams( prefix, obj, traditional, add ) { jQuery.fn.extend({
var name; serialize: function() {
return jQuery.param( this.serializeArray() );
if ( jQuery.isArray( obj ) ) { },
// Serialize array item. serializeArray: function() {
jQuery.each( obj, function( i, v ) { return this.map(function(){
if ( traditional || rbracket.test( prefix ) ) { // Can add propHook for "elements" to filter or add form elements
// Treat each array item as a scalar. var elements = jQuery.prop( this, "elements" );
add( prefix, v ); return elements ? jQuery.makeArray( elements ) : this;
})
} else { .filter(function(){
// Item is non-scalar (array or object), encode its numeric index. var type = this.type;
buildParams( prefix + "[" + ( typeof v === "object" ? i : "" ) + "]", v, traditional, add ); // Use .is(":disabled") so that fieldset[disabled] works
} return this.name && !jQuery( this ).is( ":disabled" ) &&
}); rsubmittable.test( this.nodeName ) && !rsubmitterTypes.test( type ) &&
( this.checked || !rcheckableType.test( type ) );
} else if ( !traditional && jQuery.type( obj ) === "object" ) { })
// Serialize object item. .map(function( i, elem ){
for ( name in obj ) { var val = jQuery( this ).val();
buildParams( prefix + "[" + name + "]", obj[ name ], traditional, add );
}
} else { return val == null ?
// Serialize scalar item. null :
add( prefix, obj ); jQuery.isArray( val ) ?
jQuery.map( val, function( val ){
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}) :
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
}).get();
} }
} });
return jQuery; return jQuery;
}); });
...@@ -14,6 +14,77 @@ var isSimple = /^.[^:#\[\.,]*$/, ...@@ -14,6 +14,77 @@ var isSimple = /^.[^:#\[\.,]*$/,
prev: true prev: true
}; };
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not;
});
}
if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not;
});
}
if ( typeof qualifier === "string" ) {
if ( isSimple.test( qualifier ) ) {
return jQuery.filter( qualifier, elements, not );
}
qualifier = jQuery.filter( qualifier, elements );
}
return jQuery.grep( elements, function( elem ) {
return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
});
}
jQuery.extend({
filter: function( expr, elems, not ) {
var elem = elems[ 0 ];
if ( not ) {
expr = ":not(" + expr + ")";
}
return elems.length === 1 && elem.nodeType === 1 ?
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1;
}));
},
dir: function( elem, dir, until ) {
var matched = [],
cur = elem[ dir ];
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
if ( cur.nodeType === 1 ) {
matched.push( cur );
}
cur = cur[dir];
}
return matched;
},
sibling: function( n, elem ) {
var r = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
r.push( n );
}
}
return r;
}
});
jQuery.fn.extend({ jQuery.fn.extend({
find: function( selector ) { find: function( selector ) {
var i, var i,
...@@ -216,76 +287,5 @@ jQuery.each({ ...@@ -216,76 +287,5 @@ jQuery.each({
}; };
}); });
jQuery.extend({
filter: function( expr, elems, not ) {
var elem = elems[ 0 ];
if ( not ) {
expr = ":not(" + expr + ")";
}
return elems.length === 1 && elem.nodeType === 1 ?
jQuery.find.matchesSelector( elem, expr ) ? [ elem ] : [] :
jQuery.find.matches( expr, jQuery.grep( elems, function( elem ) {
return elem.nodeType === 1;
}));
},
dir: function( elem, dir, until ) {
var matched = [],
cur = elem[ dir ];
while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
if ( cur.nodeType === 1 ) {
matched.push( cur );
}
cur = cur[dir];
}
return matched;
},
sibling: function( n, elem ) {
var r = [];
for ( ; n; n = n.nextSibling ) {
if ( n.nodeType === 1 && n !== elem ) {
r.push( n );
}
}
return r;
}
});
// Implement the identical functionality for filter and not
function winnow( elements, qualifier, not ) {
if ( jQuery.isFunction( qualifier ) ) {
return jQuery.grep( elements, function( elem, i ) {
/* jshint -W018 */
return !!qualifier.call( elem, i, elem ) !== not;
});
}
if ( qualifier.nodeType ) {
return jQuery.grep( elements, function( elem ) {
return ( elem === qualifier ) !== not;
});
}
if ( typeof qualifier === "string" ) {
if ( isSimple.test( qualifier ) ) {
return jQuery.filter( qualifier, elements, not );
}
qualifier = jQuery.filter( qualifier, elements );
}
return jQuery.grep( elements, function( elem ) {
return ( jQuery.inArray( elem, qualifier ) >= 0 ) !== not;
});
}
return jQuery; return jQuery;
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment