|
define( [ |
|
"./core", |
|
"./var/concat", |
|
"./var/push", |
|
"./core/access", |
|
"./manipulation/var/rcheckableType", |
|
"./manipulation/var/rtagName", |
|
"./manipulation/var/rscriptType", |
|
"./manipulation/wrapMap", |
|
"./manipulation/getAll", |
|
"./manipulation/setGlobalEval", |
|
"./manipulation/buildFragment", |
|
"./manipulation/support", |
|
|
|
"./data/var/dataPriv", |
|
"./data/var/dataUser", |
|
"./data/var/acceptData", |
|
|
|
"./core/init", |
|
"./traversing", |
|
"./selector", |
|
"./event" |
|
], function( jQuery, concat, push, access, |
|
rcheckableType, rtagName, rscriptType, |
|
wrapMap, getAll, setGlobalEval, buildFragment, support, |
|
dataPriv, dataUser, acceptData ) { |
|
|
|
var |
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi, |
|
|
|
|
|
|
|
|
|
rnoInnerhtml = /<script|<style|<link/i, |
|
|
|
|
|
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i, |
|
rscriptTypeMasked = /^true\/(.*)/, |
|
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g; |
|
|
|
|
|
function manipulationTarget( elem, content ) { |
|
return jQuery.nodeName( elem, "table" ) && |
|
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ? |
|
|
|
elem.getElementsByTagName( "tbody" )[ 0 ] || |
|
elem.appendChild( elem.ownerDocument.createElement( "tbody" ) ) : |
|
elem; |
|
} |
|
|
|
|
|
function disableScript( elem ) { |
|
elem.type = ( elem.getAttribute( "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; |
|
} |
|
|
|
function cloneCopyEvent( src, dest ) { |
|
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events; |
|
|
|
if ( dest.nodeType !== 1 ) { |
|
return; |
|
} |
|
|
|
|
|
if ( dataPriv.hasData( src ) ) { |
|
pdataOld = dataPriv.access( src ); |
|
pdataCur = dataPriv.set( dest, pdataOld ); |
|
events = pdataOld.events; |
|
|
|
if ( events ) { |
|
delete pdataCur.handle; |
|
pdataCur.events = {}; |
|
|
|
for ( type in events ) { |
|
for ( i = 0, l = events[ type ].length; i < l; i++ ) { |
|
jQuery.event.add( dest, type, events[ type ][ i ] ); |
|
} |
|
} |
|
} |
|
} |
|
|
|
|
|
if ( dataUser.hasData( src ) ) { |
|
udataOld = dataUser.access( src ); |
|
udataCur = jQuery.extend( {}, udataOld ); |
|
|
|
dataUser.set( dest, udataCur ); |
|
} |
|
} |
|
|
|
|
|
function fixInput( src, dest ) { |
|
var nodeName = dest.nodeName.toLowerCase(); |
|
|
|
|
|
if ( nodeName === "input" && rcheckableType.test( src.type ) ) { |
|
dest.checked = src.checked; |
|
|
|
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) { |
|
dest.defaultValue = src.defaultValue; |
|
} |
|
} |
|
|
|
function domManip( collection, args, callback, ignored ) { |
|
|
|
|
|
args = concat.apply( [], args ); |
|
|
|
var fragment, first, scripts, hasScripts, node, doc, |
|
i = 0, |
|
l = collection.length, |
|
iNoClone = l - 1, |
|
value = args[ 0 ], |
|
isFunction = jQuery.isFunction( value ); |
|
|
|
|
|
if ( isFunction || |
|
( l > 1 && typeof value === "string" && |
|
!support.checkClone && rchecked.test( value ) ) ) { |
|
return collection.each( function( index ) { |
|
var self = collection.eq( index ); |
|
if ( isFunction ) { |
|
args[ 0 ] = value.call( this, index, self.html() ); |
|
} |
|
domManip( self, args, callback, ignored ); |
|
} ); |
|
} |
|
|
|
if ( l ) { |
|
fragment = buildFragment( args, collection[ 0 ].ownerDocument, false, collection, ignored ); |
|
first = fragment.firstChild; |
|
|
|
if ( fragment.childNodes.length === 1 ) { |
|
fragment = first; |
|
} |
|
|
|
|
|
if ( first || ignored ) { |
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript ); |
|
hasScripts = scripts.length; |
|
|
|
|
|
|
|
|
|
for ( ; i < l; i++ ) { |
|
node = fragment; |
|
|
|
if ( i !== iNoClone ) { |
|
node = jQuery.clone( node, true, true ); |
|
|
|
|
|
if ( hasScripts ) { |
|
|
|
|
|
|
|
jQuery.merge( scripts, getAll( node, "script" ) ); |
|
} |
|
} |
|
|
|
callback.call( collection[ i ], node, i ); |
|
} |
|
|
|
if ( hasScripts ) { |
|
doc = scripts[ scripts.length - 1 ].ownerDocument; |
|
|
|
|
|
jQuery.map( scripts, restoreScript ); |
|
|
|
|
|
for ( i = 0; i < hasScripts; i++ ) { |
|
node = scripts[ i ]; |
|
if ( rscriptType.test( node.type || "" ) && |
|
!dataPriv.access( node, "globalEval" ) && |
|
jQuery.contains( doc, node ) ) { |
|
|
|
if ( node.src ) { |
|
|
|
|
|
if ( jQuery._evalUrl ) { |
|
jQuery._evalUrl( node.src ); |
|
} |
|
} else { |
|
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) ); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
return collection; |
|
} |
|
|
|
function remove( elem, selector, keepData ) { |
|
var node, |
|
nodes = selector ? jQuery.filter( selector, elem ) : elem, |
|
i = 0; |
|
|
|
for ( ; ( node = nodes[ i ] ) != null; i++ ) { |
|
if ( !keepData && node.nodeType === 1 ) { |
|
jQuery.cleanData( getAll( node ) ); |
|
} |
|
|
|
if ( node.parentNode ) { |
|
if ( keepData && jQuery.contains( node.ownerDocument, node ) ) { |
|
setGlobalEval( getAll( node, "script" ) ); |
|
} |
|
node.parentNode.removeChild( node ); |
|
} |
|
} |
|
|
|
return elem; |
|
} |
|
|
|
jQuery.extend( { |
|
htmlPrefilter: function( html ) { |
|
return html.replace( rxhtmlTag, "<$1></$2>" ); |
|
}, |
|
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) { |
|
var i, l, srcElements, destElements, |
|
clone = elem.cloneNode( true ), |
|
inPage = jQuery.contains( elem.ownerDocument, elem ); |
|
|
|
|
|
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && |
|
!jQuery.isXMLDoc( elem ) ) { |
|
|
|
|
|
destElements = getAll( clone ); |
|
srcElements = getAll( elem ); |
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
fixInput( srcElements[ i ], destElements[ i ] ); |
|
} |
|
} |
|
|
|
|
|
if ( dataAndEvents ) { |
|
if ( deepDataAndEvents ) { |
|
srcElements = srcElements || getAll( elem ); |
|
destElements = destElements || getAll( clone ); |
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) { |
|
cloneCopyEvent( srcElements[ i ], destElements[ i ] ); |
|
} |
|
} else { |
|
cloneCopyEvent( elem, clone ); |
|
} |
|
} |
|
|
|
|
|
destElements = getAll( clone, "script" ); |
|
if ( destElements.length > 0 ) { |
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) ); |
|
} |
|
|
|
|
|
return clone; |
|
}, |
|
|
|
cleanData: function( elems ) { |
|
var data, elem, type, |
|
special = jQuery.event.special, |
|
i = 0; |
|
|
|
for ( ; ( elem = elems[ i ] ) !== undefined; i++ ) { |
|
if ( acceptData( elem ) ) { |
|
if ( ( data = elem[ dataPriv.expando ] ) ) { |
|
if ( data.events ) { |
|
for ( type in data.events ) { |
|
if ( special[ type ] ) { |
|
jQuery.event.remove( elem, type ); |
|
|
|
|
|
} else { |
|
jQuery.removeEvent( elem, type, data.handle ); |
|
} |
|
} |
|
} |
|
|
|
|
|
|
|
elem[ dataPriv.expando ] = undefined; |
|
} |
|
if ( elem[ dataUser.expando ] ) { |
|
|
|
|
|
|
|
elem[ dataUser.expando ] = undefined; |
|
} |
|
} |
|
} |
|
} |
|
} ); |
|
|
|
jQuery.fn.extend( { |
|
|
|
|
|
domManip: domManip, |
|
|
|
detach: function( selector ) { |
|
return remove( this, selector, true ); |
|
}, |
|
|
|
remove: function( selector ) { |
|
return remove( this, selector ); |
|
}, |
|
|
|
text: function( value ) { |
|
return access( this, function( value ) { |
|
return value === undefined ? |
|
jQuery.text( this ) : |
|
this.empty().each( function() { |
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
this.textContent = value; |
|
} |
|
} ); |
|
}, null, value, arguments.length ); |
|
}, |
|
|
|
append: function() { |
|
return domManip( this, arguments, function( elem ) { |
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) { |
|
var target = manipulationTarget( this, elem ); |
|
target.appendChild( elem ); |
|
} |
|
} ); |
|
}, |
|
|
|
prepend: function() { |
|
return domManip( this, 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 domManip( this, arguments, function( elem ) { |
|
if ( this.parentNode ) { |
|
this.parentNode.insertBefore( elem, this ); |
|
} |
|
} ); |
|
}, |
|
|
|
after: function() { |
|
return domManip( this, arguments, function( elem ) { |
|
if ( this.parentNode ) { |
|
this.parentNode.insertBefore( elem, this.nextSibling ); |
|
} |
|
} ); |
|
}, |
|
|
|
empty: function() { |
|
var elem, |
|
i = 0; |
|
|
|
for ( ; ( elem = this[ i ] ) != null; i++ ) { |
|
if ( elem.nodeType === 1 ) { |
|
|
|
|
|
jQuery.cleanData( getAll( elem, false ) ); |
|
|
|
|
|
elem.textContent = ""; |
|
} |
|
} |
|
|
|
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 && elem.nodeType === 1 ) { |
|
return elem.innerHTML; |
|
} |
|
|
|
|
|
if ( typeof value === "string" && !rnoInnerhtml.test( value ) && |
|
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) { |
|
|
|
value = jQuery.htmlPrefilter( value ); |
|
|
|
try { |
|
for ( ; i < l; i++ ) { |
|
elem = this[ i ] || {}; |
|
|
|
|
|
if ( elem.nodeType === 1 ) { |
|
jQuery.cleanData( getAll( elem, false ) ); |
|
elem.innerHTML = value; |
|
} |
|
} |
|
|
|
elem = 0; |
|
|
|
|
|
} catch ( e ) {} |
|
} |
|
|
|
if ( elem ) { |
|
this.empty().append( value ); |
|
} |
|
}, null, value, arguments.length ); |
|
}, |
|
|
|
replaceWith: function() { |
|
var ignored = []; |
|
|
|
|
|
return domManip( this, arguments, function( elem ) { |
|
var parent = this.parentNode; |
|
|
|
if ( jQuery.inArray( this, ignored ) < 0 ) { |
|
jQuery.cleanData( getAll( this ) ); |
|
if ( parent ) { |
|
parent.replaceChild( elem, this ); |
|
} |
|
} |
|
|
|
|
|
}, ignored ); |
|
} |
|
} ); |
|
|
|
jQuery.each( { |
|
appendTo: "append", |
|
prependTo: "prepend", |
|
insertBefore: "before", |
|
insertAfter: "after", |
|
replaceAll: "replaceWith" |
|
}, function( name, original ) { |
|
jQuery.fn[ name ] = function( selector ) { |
|
var elems, |
|
ret = [], |
|
insert = jQuery( selector ), |
|
last = insert.length - 1, |
|
i = 0; |
|
|
|
for ( ; i <= last; i++ ) { |
|
elems = i === last ? this : this.clone( true ); |
|
jQuery( insert[ i ] )[ original ]( elems ); |
|
|
|
|
|
|
|
push.apply( ret, elems.get() ); |
|
} |
|
|
|
return this.pushStack( ret ); |
|
}; |
|
} ); |
|
|
|
return jQuery; |
|
} ); |
|
|