mirror of
https://github.com/jquery/jquery.git
synced 2024-11-23 02:54:22 +00:00
Apply consistent ordering in all modules. -219 bytes. Order modules like functions > jQuery.extend > jQuery.fn.extend.
This commit is contained in:
parent
6bc8059717
commit
49cfcb9f3e
@ -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([
|
|||||||
"./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 ) {
|
||||||
|
460
src/effects.js
vendored
460
src/effects.js
vendored
@ -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,177 +115,6 @@ function createTween( value, prop, animation ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function Animation( elem, properties, options ) {
|
|
||||||
var result,
|
|
||||||
stopped,
|
|
||||||
index = 0,
|
|
||||||
length = animationPrefilters.length,
|
|
||||||
deferred = jQuery.Deferred().always( function() {
|
|
||||||
// don't match elem in the :animated selector
|
|
||||||
delete tick.elem;
|
|
||||||
}),
|
|
||||||
tick = function() {
|
|
||||||
if ( stopped ) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
var currentTime = fxNow || createFxNow(),
|
|
||||||
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
|
||||||
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
|
||||||
temp = remaining / animation.duration || 0,
|
|
||||||
percent = 1 - temp,
|
|
||||||
index = 0,
|
|
||||||
length = animation.tweens.length;
|
|
||||||
|
|
||||||
for ( ; index < length ; index++ ) {
|
|
||||||
animation.tweens[ index ].run( percent );
|
|
||||||
}
|
|
||||||
|
|
||||||
deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
|
||||||
|
|
||||||
if ( percent < 1 && length ) {
|
|
||||||
return remaining;
|
|
||||||
} else {
|
|
||||||
deferred.resolveWith( elem, [ animation ] );
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
animation = deferred.promise({
|
|
||||||
elem: elem,
|
|
||||||
props: jQuery.extend( {}, properties ),
|
|
||||||
opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
|
||||||
originalProperties: properties,
|
|
||||||
originalOptions: options,
|
|
||||||
startTime: fxNow || createFxNow(),
|
|
||||||
duration: options.duration,
|
|
||||||
tweens: [],
|
|
||||||
createTween: function( prop, end ) {
|
|
||||||
var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
|
||||||
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
|
||||||
animation.tweens.push( tween );
|
|
||||||
return tween;
|
|
||||||
},
|
|
||||||
stop: function( gotoEnd ) {
|
|
||||||
var index = 0,
|
|
||||||
// if we are going to the end, we want to run all the tweens
|
|
||||||
// otherwise we skip this part
|
|
||||||
length = gotoEnd ? animation.tweens.length : 0;
|
|
||||||
if ( stopped ) {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
stopped = true;
|
|
||||||
for ( ; index < length ; index++ ) {
|
|
||||||
animation.tweens[ index ].run( 1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
// resolve when we played the last frame
|
|
||||||
// otherwise, reject
|
|
||||||
if ( gotoEnd ) {
|
|
||||||
deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
|
||||||
} else {
|
|
||||||
deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
|
||||||
}
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
props = animation.props;
|
|
||||||
|
|
||||||
propFilter( props, animation.opts.specialEasing );
|
|
||||||
|
|
||||||
for ( ; index < length ; index++ ) {
|
|
||||||
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
|
||||||
if ( result ) {
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.map( props, createTween, animation );
|
|
||||||
|
|
||||||
if ( jQuery.isFunction( animation.opts.start ) ) {
|
|
||||||
animation.opts.start.call( elem, animation );
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.fx.timer(
|
|
||||||
jQuery.extend( tick, {
|
|
||||||
elem: elem,
|
|
||||||
anim: animation,
|
|
||||||
queue: animation.opts.queue
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
// attach callbacks from options
|
|
||||||
return animation.progress( animation.opts.progress )
|
|
||||||
.done( animation.opts.done, animation.opts.complete )
|
|
||||||
.fail( animation.opts.fail )
|
|
||||||
.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, {
|
|
||||||
|
|
||||||
tweener: function( props, callback ) {
|
|
||||||
if ( jQuery.isFunction( props ) ) {
|
|
||||||
callback = props;
|
|
||||||
props = [ "*" ];
|
|
||||||
} else {
|
|
||||||
props = props.split(" ");
|
|
||||||
}
|
|
||||||
|
|
||||||
var prop,
|
|
||||||
index = 0,
|
|
||||||
length = props.length;
|
|
||||||
|
|
||||||
for ( ; index < length ; index++ ) {
|
|
||||||
prop = props[ index ];
|
|
||||||
tweeners[ prop ] = tweeners[ prop ] || [];
|
|
||||||
tweeners[ prop ].unshift( callback );
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
prefilter: function( callback, prepend ) {
|
|
||||||
if ( prepend ) {
|
|
||||||
animationPrefilters.unshift( callback );
|
|
||||||
} else {
|
|
||||||
animationPrefilters.push( callback );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function defaultPrefilter( elem, props, opts ) {
|
function defaultPrefilter( elem, props, opts ) {
|
||||||
/* jshint validthis: true */
|
/* jshint validthis: true */
|
||||||
var prop, value, toggle, tween, hooks, oldfire,
|
var prop, value, toggle, tween, hooks, oldfire,
|
||||||
@ -394,15 +245,208 @@ function defaultPrefilter( elem, props, opts ) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jQuery.each([ "toggle", "show", "hide" ], function( i, name ) {
|
function propFilter( props, specialEasing ) {
|
||||||
var cssFn = jQuery.fn[ name ];
|
var index, name, easing, value, hooks;
|
||||||
jQuery.fn[ name ] = function( speed, easing, callback ) {
|
|
||||||
return speed == null || typeof speed === "boolean" ?
|
// camelCase, specialEasing and expand cssHook pass
|
||||||
cssFn.apply( this, arguments ) :
|
for ( index in props ) {
|
||||||
this.animate( genFx( name, true ), speed, easing, callback );
|
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 ) {
|
||||||
|
var result,
|
||||||
|
stopped,
|
||||||
|
index = 0,
|
||||||
|
length = animationPrefilters.length,
|
||||||
|
deferred = jQuery.Deferred().always( function() {
|
||||||
|
// don't match elem in the :animated selector
|
||||||
|
delete tick.elem;
|
||||||
|
}),
|
||||||
|
tick = function() {
|
||||||
|
if ( stopped ) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
var currentTime = fxNow || createFxNow(),
|
||||||
|
remaining = Math.max( 0, animation.startTime + animation.duration - currentTime ),
|
||||||
|
// archaic crash bug won't allow us to use 1 - ( 0.5 || 0 ) (#12497)
|
||||||
|
temp = remaining / animation.duration || 0,
|
||||||
|
percent = 1 - temp,
|
||||||
|
index = 0,
|
||||||
|
length = animation.tweens.length;
|
||||||
|
|
||||||
|
for ( ; index < length ; index++ ) {
|
||||||
|
animation.tweens[ index ].run( percent );
|
||||||
|
}
|
||||||
|
|
||||||
|
deferred.notifyWith( elem, [ animation, percent, remaining ]);
|
||||||
|
|
||||||
|
if ( percent < 1 && length ) {
|
||||||
|
return remaining;
|
||||||
|
} else {
|
||||||
|
deferred.resolveWith( elem, [ animation ] );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
animation = deferred.promise({
|
||||||
|
elem: elem,
|
||||||
|
props: jQuery.extend( {}, properties ),
|
||||||
|
opts: jQuery.extend( true, { specialEasing: {} }, options ),
|
||||||
|
originalProperties: properties,
|
||||||
|
originalOptions: options,
|
||||||
|
startTime: fxNow || createFxNow(),
|
||||||
|
duration: options.duration,
|
||||||
|
tweens: [],
|
||||||
|
createTween: function( prop, end ) {
|
||||||
|
var tween = jQuery.Tween( elem, animation.opts, prop, end,
|
||||||
|
animation.opts.specialEasing[ prop ] || animation.opts.easing );
|
||||||
|
animation.tweens.push( tween );
|
||||||
|
return tween;
|
||||||
|
},
|
||||||
|
stop: function( gotoEnd ) {
|
||||||
|
var index = 0,
|
||||||
|
// if we are going to the end, we want to run all the tweens
|
||||||
|
// otherwise we skip this part
|
||||||
|
length = gotoEnd ? animation.tweens.length : 0;
|
||||||
|
if ( stopped ) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
stopped = true;
|
||||||
|
for ( ; index < length ; index++ ) {
|
||||||
|
animation.tweens[ index ].run( 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
// resolve when we played the last frame
|
||||||
|
// otherwise, reject
|
||||||
|
if ( gotoEnd ) {
|
||||||
|
deferred.resolveWith( elem, [ animation, gotoEnd ] );
|
||||||
|
} else {
|
||||||
|
deferred.rejectWith( elem, [ animation, gotoEnd ] );
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
props = animation.props;
|
||||||
|
|
||||||
|
propFilter( props, animation.opts.specialEasing );
|
||||||
|
|
||||||
|
for ( ; index < length ; index++ ) {
|
||||||
|
result = animationPrefilters[ index ].call( animation, elem, props, animation.opts );
|
||||||
|
if ( result ) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.map( props, createTween, animation );
|
||||||
|
|
||||||
|
if ( jQuery.isFunction( animation.opts.start ) ) {
|
||||||
|
animation.opts.start.call( elem, animation );
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.fx.timer(
|
||||||
|
jQuery.extend( tick, {
|
||||||
|
elem: elem,
|
||||||
|
anim: animation,
|
||||||
|
queue: animation.opts.queue
|
||||||
|
})
|
||||||
|
);
|
||||||
|
|
||||||
|
// attach callbacks from options
|
||||||
|
return animation.progress( animation.opts.progress )
|
||||||
|
.done( animation.opts.done, animation.opts.complete )
|
||||||
|
.fail( animation.opts.fail )
|
||||||
|
.always( animation.opts.always );
|
||||||
|
}
|
||||||
|
|
||||||
|
jQuery.Animation = jQuery.extend( Animation, {
|
||||||
|
tweener: function( props, callback ) {
|
||||||
|
if ( jQuery.isFunction( props ) ) {
|
||||||
|
callback = props;
|
||||||
|
props = [ "*" ];
|
||||||
|
} else {
|
||||||
|
props = props.split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
var prop,
|
||||||
|
index = 0,
|
||||||
|
length = props.length;
|
||||||
|
|
||||||
|
for ( ; index < length ; index++ ) {
|
||||||
|
prop = props[ index ];
|
||||||
|
tweeners[ prop ] = tweeners[ prop ] || [];
|
||||||
|
tweeners[ prop ].unshift( callback );
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
prefilter: function( callback, prepend ) {
|
||||||
|
if ( prepend ) {
|
||||||
|
animationPrefilters.unshift( callback );
|
||||||
|
} else {
|
||||||
|
animationPrefilters.push( callback );
|
||||||
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
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.fn.extend({
|
jQuery.fn.extend({
|
||||||
fadeTo: function( speed, to, easing, callback ) {
|
fadeTo: function( speed, to, easing, callback ) {
|
||||||
|
|
||||||
@ -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({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
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,6 +71,402 @@ 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;
|
||||||
|
|
||||||
|
|
||||||
|
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 ) ?
|
||||||
|
jQuery.merge( [ context ], found ) :
|
||||||
|
found;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Used in buildFragment, fixes the defaultChecked property
|
||||||
|
function fixDefaultChecked( elem ) {
|
||||||
|
if ( rcheckableType.test( elem.type ) ) {
|
||||||
|
elem.defaultChecked = elem.checked;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Support: IE<8
|
||||||
|
// Manipulating tables requires a tbody
|
||||||
|
function manipulationTarget( elem, content ) {
|
||||||
|
return jQuery.nodeName( elem, "table" ) &&
|
||||||
|
jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
||||||
|
|
||||||
|
elem.getElementsByTagName("tbody")[0] ||
|
||||||
|
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
||||||
|
elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
||||||
|
function disableScript( elem ) {
|
||||||
|
elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
function restoreScript( elem ) {
|
||||||
|
var match = rscriptTypeMasked.exec( elem.type );
|
||||||
|
if ( match ) {
|
||||||
|
elem.type = match[1];
|
||||||
|
} else {
|
||||||
|
elem.removeAttribute("type");
|
||||||
|
}
|
||||||
|
return elem;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark scripts as having already been evaluated
|
||||||
|
function setGlobalEval( elems, refElements ) {
|
||||||
|
var elem,
|
||||||
|
i = 0;
|
||||||
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
||||||
|
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function cloneCopyEvent( src, dest ) {
|
||||||
|
|
||||||
|
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var type, i, l,
|
||||||
|
oldData = jQuery._data( src ),
|
||||||
|
curData = jQuery._data( dest, oldData ),
|
||||||
|
events = oldData.events;
|
||||||
|
|
||||||
|
if ( events ) {
|
||||||
|
delete curData.handle;
|
||||||
|
curData.events = {};
|
||||||
|
|
||||||
|
for ( type in events ) {
|
||||||
|
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
||||||
|
jQuery.event.add( dest, type, events[ type ][ i ] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// make the cloned public data object a copy from the original
|
||||||
|
if ( curData.data ) {
|
||||||
|
curData.data = jQuery.extend( {}, curData.data );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function fixCloneNodeIssues( src, dest ) {
|
||||||
|
var nodeName, e, data;
|
||||||
|
|
||||||
|
// We do not need to do anything for non-Elements
|
||||||
|
if ( dest.nodeType !== 1 ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nodeName = dest.nodeName.toLowerCase();
|
||||||
|
|
||||||
|
// IE6-8 copies events bound via attachEvent when using cloneNode.
|
||||||
|
if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
|
||||||
|
data = jQuery._data( dest );
|
||||||
|
|
||||||
|
for ( e in data.events ) {
|
||||||
|
jQuery.removeEvent( dest, e, data.handle );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Event data gets referenced instead of copied if the expando gets copied too
|
||||||
|
dest.removeAttribute( jQuery.expando );
|
||||||
|
}
|
||||||
|
|
||||||
|
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
||||||
|
if ( nodeName === "script" && dest.text !== src.text ) {
|
||||||
|
disableScript( dest ).text = src.text;
|
||||||
|
restoreScript( dest );
|
||||||
|
|
||||||
|
// IE6-10 improperly clones children of object elements using classid.
|
||||||
|
// IE10 throws NoModificationAllowedError if parent is null, #12132.
|
||||||
|
} else if ( nodeName === "object" ) {
|
||||||
|
if ( dest.parentNode ) {
|
||||||
|
dest.outerHTML = src.outerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This path appears unavoidable for IE9. When cloning an object
|
||||||
|
// element in IE9, the outerHTML strategy above is not sufficient.
|
||||||
|
// If the src has innerHTML and the destination does not,
|
||||||
|
// copy the src.innerHTML into the dest.innerHTML. #10324
|
||||||
|
if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
||||||
|
dest.innerHTML = src.innerHTML;
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
|
||||||
|
// IE6-8 fails to persist the checked state of a cloned checkbox
|
||||||
|
// or radio button. Worse, IE6-7 fail to give the cloned element
|
||||||
|
// a checked appearance if the defaultChecked value isn't also set
|
||||||
|
|
||||||
|
dest.defaultChecked = dest.checked = src.checked;
|
||||||
|
|
||||||
|
// IE6-7 get confused and end up setting the value of a cloned
|
||||||
|
// checkbox/radio button to an empty string instead of "on"
|
||||||
|
if ( 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.extend({
|
||||||
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
||||||
|
var destElements, node, clone, i, srcElements,
|
||||||
|
inPage = jQuery.contains( elem.ownerDocument, elem );
|
||||||
|
|
||||||
|
if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
||||||
|
clone = elem.cloneNode( true );
|
||||||
|
|
||||||
|
// IE<=8 does not properly clone detached, unknown element nodes
|
||||||
|
} else {
|
||||||
|
fragmentDiv.innerHTML = elem.outerHTML;
|
||||||
|
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (!support.noCloneEvent || !support.noCloneChecked) &&
|
||||||
|
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
||||||
|
|
||||||
|
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
||||||
|
destElements = getAll( clone );
|
||||||
|
srcElements = getAll( elem );
|
||||||
|
|
||||||
|
// Fix all IE cloning issues
|
||||||
|
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
||||||
|
// Ensure that the destination node is not null; Fixes #9587
|
||||||
|
if ( destElements[i] ) {
|
||||||
|
fixCloneNodeIssues( node, destElements[i] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy the events from the original to the clone
|
||||||
|
if ( dataAndEvents ) {
|
||||||
|
if ( deepDataAndEvents ) {
|
||||||
|
srcElements = srcElements || getAll( elem );
|
||||||
|
destElements = destElements || getAll( clone );
|
||||||
|
|
||||||
|
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
||||||
|
cloneCopyEvent( node, destElements[i] );
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
cloneCopyEvent( elem, clone );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Preserve script evaluation history
|
||||||
|
destElements = getAll( clone, "script" );
|
||||||
|
if ( destElements.length > 0 ) {
|
||||||
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
destElements = srcElements = node = null;
|
||||||
|
|
||||||
|
// Return the cloned set
|
||||||
|
return clone;
|
||||||
|
},
|
||||||
|
|
||||||
|
buildFragment: function( elems, context, scripts, selection ) {
|
||||||
|
var j, elem, contains,
|
||||||
|
tmp, tag, tbody, wrap,
|
||||||
|
l = elems.length,
|
||||||
|
|
||||||
|
// Ensure a safe fragment
|
||||||
|
safe = createSafeFragment( context ),
|
||||||
|
|
||||||
|
nodes = [],
|
||||||
|
i = 0;
|
||||||
|
|
||||||
|
for ( ; i < l; i++ ) {
|
||||||
|
elem = elems[ i ];
|
||||||
|
|
||||||
|
if ( elem || elem === 0 ) {
|
||||||
|
|
||||||
|
// Add nodes directly
|
||||||
|
if ( jQuery.type( elem ) === "object" ) {
|
||||||
|
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
||||||
|
|
||||||
|
// Convert non-html into a text node
|
||||||
|
} else if ( !rhtml.test( elem ) ) {
|
||||||
|
nodes.push( context.createTextNode( elem ) );
|
||||||
|
|
||||||
|
// Convert html into DOM nodes
|
||||||
|
} else {
|
||||||
|
tmp = tmp || safe.appendChild( context.createElement("div") );
|
||||||
|
|
||||||
|
// Deserialize a standard representation
|
||||||
|
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
||||||
|
wrap = wrapMap[ tag ] || wrapMap._default;
|
||||||
|
|
||||||
|
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
||||||
|
|
||||||
|
// Descend through wrappers to the right content
|
||||||
|
j = wrap[0];
|
||||||
|
while ( j-- ) {
|
||||||
|
tmp = tmp.lastChild;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manually add leading whitespace removed by IE
|
||||||
|
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
||||||
|
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({
|
jQuery.fn.extend({
|
||||||
text: function( value ) {
|
text: function( value ) {
|
||||||
return access( this, function( value ) {
|
return access( this, function( value ) {
|
||||||
@ -331,136 +727,6 @@ jQuery.fn.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Support: IE<8
|
|
||||||
// Manipulating tables requires a tbody
|
|
||||||
function manipulationTarget( elem, content ) {
|
|
||||||
return jQuery.nodeName( elem, "table" ) &&
|
|
||||||
jQuery.nodeName( content.nodeType === 1 ? content : content.firstChild, "tr" ) ?
|
|
||||||
|
|
||||||
elem.getElementsByTagName("tbody")[0] ||
|
|
||||||
elem.appendChild( elem.ownerDocument.createElement("tbody") ) :
|
|
||||||
elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
||||||
function disableScript( elem ) {
|
|
||||||
elem.type = (jQuery.find.attr( elem, "type" ) !== null) + "/" + elem.type;
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
function restoreScript( elem ) {
|
|
||||||
var match = rscriptTypeMasked.exec( elem.type );
|
|
||||||
if ( match ) {
|
|
||||||
elem.type = match[1];
|
|
||||||
} else {
|
|
||||||
elem.removeAttribute("type");
|
|
||||||
}
|
|
||||||
return elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Mark scripts as having already been evaluated
|
|
||||||
function setGlobalEval( elems, refElements ) {
|
|
||||||
var elem,
|
|
||||||
i = 0;
|
|
||||||
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
||||||
jQuery._data( elem, "globalEval", !refElements || jQuery._data( refElements[i], "globalEval" ) );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function cloneCopyEvent( src, dest ) {
|
|
||||||
|
|
||||||
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
var type, i, l,
|
|
||||||
oldData = jQuery._data( src ),
|
|
||||||
curData = jQuery._data( dest, oldData ),
|
|
||||||
events = oldData.events;
|
|
||||||
|
|
||||||
if ( events ) {
|
|
||||||
delete curData.handle;
|
|
||||||
curData.events = {};
|
|
||||||
|
|
||||||
for ( type in events ) {
|
|
||||||
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
||||||
jQuery.event.add( dest, type, events[ type ][ i ] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// make the cloned public data object a copy from the original
|
|
||||||
if ( curData.data ) {
|
|
||||||
curData.data = jQuery.extend( {}, curData.data );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixCloneNodeIssues( src, dest ) {
|
|
||||||
var nodeName, e, data;
|
|
||||||
|
|
||||||
// We do not need to do anything for non-Elements
|
|
||||||
if ( dest.nodeType !== 1 ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
nodeName = dest.nodeName.toLowerCase();
|
|
||||||
|
|
||||||
// IE6-8 copies events bound via attachEvent when using cloneNode.
|
|
||||||
if ( !support.noCloneEvent && dest[ jQuery.expando ] ) {
|
|
||||||
data = jQuery._data( dest );
|
|
||||||
|
|
||||||
for ( e in data.events ) {
|
|
||||||
jQuery.removeEvent( dest, e, data.handle );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Event data gets referenced instead of copied if the expando gets copied too
|
|
||||||
dest.removeAttribute( jQuery.expando );
|
|
||||||
}
|
|
||||||
|
|
||||||
// IE blanks contents when cloning scripts, and tries to evaluate newly-set text
|
|
||||||
if ( nodeName === "script" && dest.text !== src.text ) {
|
|
||||||
disableScript( dest ).text = src.text;
|
|
||||||
restoreScript( dest );
|
|
||||||
|
|
||||||
// IE6-10 improperly clones children of object elements using classid.
|
|
||||||
// IE10 throws NoModificationAllowedError if parent is null, #12132.
|
|
||||||
} else if ( nodeName === "object" ) {
|
|
||||||
if ( dest.parentNode ) {
|
|
||||||
dest.outerHTML = src.outerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This path appears unavoidable for IE9. When cloning an object
|
|
||||||
// element in IE9, the outerHTML strategy above is not sufficient.
|
|
||||||
// If the src has innerHTML and the destination does not,
|
|
||||||
// copy the src.innerHTML into the dest.innerHTML. #10324
|
|
||||||
if ( support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
|
||||||
dest.innerHTML = src.innerHTML;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
|
|
||||||
// IE6-8 fails to persist the checked state of a cloned checkbox
|
|
||||||
// or radio button. Worse, IE6-7 fail to give the cloned element
|
|
||||||
// a checked appearance if the defaultChecked value isn't also set
|
|
||||||
|
|
||||||
dest.defaultChecked = dest.checked = src.checked;
|
|
||||||
|
|
||||||
// IE6-7 get confused and end up setting the value of a cloned
|
|
||||||
// checkbox/radio button to an empty string instead of "on"
|
|
||||||
if ( 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({
|
jQuery.each({
|
||||||
appendTo: "append",
|
appendTo: "append",
|
||||||
prependTo: "prepend",
|
prependTo: "prepend",
|
||||||
@ -487,270 +753,5 @@ jQuery.each({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
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 ) ?
|
|
||||||
jQuery.merge( [ context ], found ) :
|
|
||||||
found;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Used in buildFragment, fixes the defaultChecked property
|
|
||||||
function fixDefaultChecked( elem ) {
|
|
||||||
if ( rcheckableType.test( elem.type ) ) {
|
|
||||||
elem.defaultChecked = elem.checked;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
jQuery.extend({
|
|
||||||
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
|
||||||
var destElements, node, clone, i, srcElements,
|
|
||||||
inPage = jQuery.contains( elem.ownerDocument, elem );
|
|
||||||
|
|
||||||
if ( support.html5Clone || jQuery.isXMLDoc(elem) || !rnoshimcache.test( "<" + elem.nodeName + ">" ) ) {
|
|
||||||
clone = elem.cloneNode( true );
|
|
||||||
|
|
||||||
// IE<=8 does not properly clone detached, unknown element nodes
|
|
||||||
} else {
|
|
||||||
fragmentDiv.innerHTML = elem.outerHTML;
|
|
||||||
fragmentDiv.removeChild( clone = fragmentDiv.firstChild );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( (!support.noCloneEvent || !support.noCloneChecked) &&
|
|
||||||
(elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
|
|
||||||
|
|
||||||
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
|
||||||
destElements = getAll( clone );
|
|
||||||
srcElements = getAll( elem );
|
|
||||||
|
|
||||||
// Fix all IE cloning issues
|
|
||||||
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
|
||||||
// Ensure that the destination node is not null; Fixes #9587
|
|
||||||
if ( destElements[i] ) {
|
|
||||||
fixCloneNodeIssues( node, destElements[i] );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy the events from the original to the clone
|
|
||||||
if ( dataAndEvents ) {
|
|
||||||
if ( deepDataAndEvents ) {
|
|
||||||
srcElements = srcElements || getAll( elem );
|
|
||||||
destElements = destElements || getAll( clone );
|
|
||||||
|
|
||||||
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
|
||||||
cloneCopyEvent( node, destElements[i] );
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cloneCopyEvent( elem, clone );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Preserve script evaluation history
|
|
||||||
destElements = getAll( clone, "script" );
|
|
||||||
if ( destElements.length > 0 ) {
|
|
||||||
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
||||||
}
|
|
||||||
|
|
||||||
destElements = srcElements = node = null;
|
|
||||||
|
|
||||||
// Return the cloned set
|
|
||||||
return clone;
|
|
||||||
},
|
|
||||||
|
|
||||||
buildFragment: function( elems, context, scripts, selection ) {
|
|
||||||
var j, elem, contains,
|
|
||||||
tmp, tag, tbody, wrap,
|
|
||||||
l = elems.length,
|
|
||||||
|
|
||||||
// Ensure a safe fragment
|
|
||||||
safe = createSafeFragment( context ),
|
|
||||||
|
|
||||||
nodes = [],
|
|
||||||
i = 0;
|
|
||||||
|
|
||||||
for ( ; i < l; i++ ) {
|
|
||||||
elem = elems[ i ];
|
|
||||||
|
|
||||||
if ( elem || elem === 0 ) {
|
|
||||||
|
|
||||||
// Add nodes directly
|
|
||||||
if ( jQuery.type( elem ) === "object" ) {
|
|
||||||
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
|
||||||
|
|
||||||
// Convert non-html into a text node
|
|
||||||
} else if ( !rhtml.test( elem ) ) {
|
|
||||||
nodes.push( context.createTextNode( elem ) );
|
|
||||||
|
|
||||||
// Convert html into DOM nodes
|
|
||||||
} else {
|
|
||||||
tmp = tmp || safe.appendChild( context.createElement("div") );
|
|
||||||
|
|
||||||
// Deserialize a standard representation
|
|
||||||
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
|
||||||
wrap = wrapMap[ tag ] || wrapMap._default;
|
|
||||||
|
|
||||||
tmp.innerHTML = wrap[1] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[2];
|
|
||||||
|
|
||||||
// Descend through wrappers to the right content
|
|
||||||
j = wrap[0];
|
|
||||||
while ( j-- ) {
|
|
||||||
tmp = tmp.lastChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manually add leading whitespace removed by IE
|
|
||||||
if ( !support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
|
|
||||||
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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
return jQuery;
|
return jQuery;
|
||||||
});
|
});
|
||||||
|
@ -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 = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
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({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/**
|
|
||||||
* 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 );
|
||||||
|
106
src/serialize.js
106
src/serialize.js
@ -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 ) {
|
|||||||
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() );
|
||||||
|
},
|
||||||
|
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();
|
||||||
|
|
||||||
if ( jQuery.isArray( obj ) ) {
|
return val == null ?
|
||||||
// Serialize array item.
|
null :
|
||||||
jQuery.each( obj, function( i, v ) {
|
jQuery.isArray( val ) ?
|
||||||
if ( traditional || rbracket.test( prefix ) ) {
|
jQuery.map( val, function( val ){
|
||||||
// Treat each array item as a scalar.
|
return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
||||||
add( prefix, v );
|
}) :
|
||||||
|
{ name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
|
||||||
} else {
|
}).get();
|
||||||
// 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 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return jQuery;
|
return jQuery;
|
||||||
});
|
});
|
||||||
|
@ -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({
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
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;
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user