2013-10-15 14:40:48 +00:00
|
|
|
define([
|
|
|
|
"./core",
|
|
|
|
"./var/concat",
|
|
|
|
"./var/push",
|
|
|
|
"./core/access",
|
|
|
|
"./manipulation/var/rcheckableType",
|
|
|
|
"./manipulation/support",
|
2014-07-17 17:25:59 +00:00
|
|
|
"./data/var/dataPriv",
|
|
|
|
"./data/var/dataUser",
|
2013-10-15 14:40:48 +00:00
|
|
|
|
|
|
|
"./core/init",
|
|
|
|
"./data/accepts",
|
|
|
|
"./traversing",
|
|
|
|
"./selector",
|
|
|
|
"./event"
|
2014-07-17 17:25:59 +00:00
|
|
|
], function( jQuery, concat, push, access, rcheckableType, support, dataPriv, dataUser ) {
|
2013-09-09 15:26:21 +00:00
|
|
|
|
|
|
|
var
|
2015-01-05 00:02:39 +00:00
|
|
|
rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:-]+)[^>]*)\/>/gi,
|
|
|
|
rtagName = /<([\w:-]+)/,
|
2010-02-06 00:58:08 +00:00
|
|
|
rhtml = /<|&#?\w+;/,
|
2012-04-05 16:12:38 +00:00
|
|
|
rnoInnerhtml = /<(?:script|style|link)/i,
|
2011-01-24 10:18:57 +00:00
|
|
|
// checked="checked" or checked
|
2010-11-09 15:34:32 +00:00
|
|
|
rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
|
2012-11-19 14:50:19 +00:00
|
|
|
rscriptType = /^$|\/(?:java|ecma)script/i,
|
|
|
|
rscriptTypeMasked = /^true\/(.*)/,
|
2012-11-26 08:20:43 +00:00
|
|
|
rcleanScript = /^\s*<!(?:\[CDATA\[|--)|(?:\]\]|--)>\s*$/g,
|
2013-01-13 19:47:29 +00:00
|
|
|
|
|
|
|
// We have to close these tags to support XHTML (#13200)
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap = {
|
2012-12-28 14:56:29 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Support: IE9
|
2013-01-13 17:59:22 +00:00
|
|
|
option: [ 1, "<select multiple='multiple'>", "</select>" ],
|
2012-12-28 16:16:49 +00:00
|
|
|
|
2013-01-16 18:07:53 +00:00
|
|
|
thead: [ 1, "<table>", "</table>" ],
|
2015-01-22 23:34:29 +00:00
|
|
|
|
|
|
|
// Some of the following wrappers are not fully defined, because
|
|
|
|
// their parent elements (except for "table" element) could be omitted
|
|
|
|
// since browser parsers are smart enough to auto-insert them
|
|
|
|
|
|
|
|
// Support: Android 2.3
|
|
|
|
// Android browser doesn't auto-insert colgroup
|
2013-04-24 18:15:41 +00:00
|
|
|
col: [ 2, "<table><colgroup>", "</colgroup></table>" ],
|
2015-01-22 23:34:29 +00:00
|
|
|
|
|
|
|
// Auto-insert "tbody" element
|
|
|
|
tr: [ 2, "<table>", "</table>" ],
|
|
|
|
|
|
|
|
// Auto-insert "tbody" and "tr" elements
|
|
|
|
td: [ 3, "<table>", "</table>" ],
|
2013-01-16 18:07:53 +00:00
|
|
|
|
2013-01-13 17:59:22 +00:00
|
|
|
_default: [ 0, "", "" ]
|
2012-12-19 16:26:49 +00:00
|
|
|
};
|
2009-07-19 15:48:30 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Support: IE9
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
2012-12-28 19:38:30 +00:00
|
|
|
|
2013-04-24 18:15:41 +00:00
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
function manipulationTarget( elem, content ) {
|
2015-01-21 18:47:03 +00:00
|
|
|
if ( jQuery.nodeName( elem, "table" ) &&
|
|
|
|
jQuery.nodeName( content.nodeType !== 11 ? content : content.firstChild, "tr" ) ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2015-01-21 18:47:03 +00:00
|
|
|
return elem.getElementsByTagName( "tbody" )[ 0 ] || elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
return elem;
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
|
|
function disableScript( elem ) {
|
|
|
|
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
|
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
function restoreScript( elem ) {
|
|
|
|
var match = rscriptTypeMasked.exec( elem.type );
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( match ) {
|
|
|
|
elem.type = match[ 1 ];
|
|
|
|
} else {
|
|
|
|
elem.removeAttribute("type");
|
|
|
|
}
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
return elem;
|
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Mark scripts as having already been evaluated
|
|
|
|
function setGlobalEval( elems, refElements ) {
|
2013-11-02 08:38:37 +00:00
|
|
|
var i = 0,
|
|
|
|
l = elems.length;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
2014-07-17 17:25:59 +00:00
|
|
|
dataPriv.set(
|
|
|
|
elems[ i ], "globalEval", !refElements || dataPriv.get( refElements[ i ], "globalEval" )
|
2013-09-09 16:13:41 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
function cloneCopyEvent( src, dest ) {
|
|
|
|
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( dest.nodeType !== 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
2012-12-19 18:42:07 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// 1. Copy private data: events, handlers, etc.
|
2014-07-17 17:25:59 +00:00
|
|
|
if ( dataPriv.hasData( src ) ) {
|
|
|
|
pdataOld = dataPriv.access( src );
|
|
|
|
pdataCur = dataPriv.set( dest, pdataOld );
|
2013-09-09 16:13:41 +00:00
|
|
|
events = pdataOld.events;
|
2010-01-28 20:25:52 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
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 ] );
|
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// 2. Copy user data
|
2014-07-17 17:25:59 +00:00
|
|
|
if ( dataUser.hasData( src ) ) {
|
|
|
|
udataOld = dataUser.access( src );
|
2013-09-09 16:13:41 +00:00
|
|
|
udataCur = jQuery.extend( {}, udataOld );
|
2011-01-28 16:55:39 +00:00
|
|
|
|
2014-07-17 17:25:59 +00:00
|
|
|
dataUser.set( dest, udataCur );
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
function getAll( context, tag ) {
|
2014-06-17 13:48:17 +00:00
|
|
|
// Support: IE9-11+
|
|
|
|
// Use typeof to avoid zero-argument method invocation on host objects (#15151)
|
|
|
|
var ret = typeof context.getElementsByTagName !== "undefined" ?
|
|
|
|
context.getElementsByTagName( tag || "*" ) :
|
|
|
|
typeof context.querySelectorAll !== "undefined" ?
|
|
|
|
context.querySelectorAll( tag || "*" ) :
|
2013-09-09 16:13:41 +00:00
|
|
|
[];
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
|
|
jQuery.merge( [ context ], ret ) :
|
|
|
|
ret;
|
|
|
|
}
|
2009-09-07 20:55:36 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Fix IE bugs, see support tests
|
2013-09-09 16:13:41 +00:00
|
|
|
function fixInput( src, dest ) {
|
|
|
|
var nodeName = dest.nodeName.toLowerCase();
|
2010-01-07 18:33:30 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Fails to persist the checked state of a cloned checkbox or radio button.
|
|
|
|
if ( nodeName === "input" && rcheckableType.test( src.type ) ) {
|
|
|
|
dest.checked = src.checked;
|
2009-09-07 20:55:36 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Fails to return the selected option to the default selected state when cloning options
|
|
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
|
|
dest.defaultValue = src.defaultValue;
|
|
|
|
}
|
|
|
|
}
|
2012-12-20 16:51:22 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
jQuery.extend({
|
|
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
|
|
|
var i, l, srcElements, destElements,
|
|
|
|
clone = elem.cloneNode( true ),
|
|
|
|
inPage = jQuery.contains( elem.ownerDocument, elem );
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Fix IE cloning issues
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( !support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) &&
|
|
|
|
!jQuery.isXMLDoc( elem ) ) {
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
|
|
|
destElements = getAll( clone );
|
|
|
|
srcElements = getAll( elem );
|
2011-12-06 20:25:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
|
|
|
fixInput( srcElements[ i ], destElements[ i ] );
|
2011-12-06 20:25:38 +00:00
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
2010-01-11 21:25:01 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Copy the events from the original to the clone
|
|
|
|
if ( dataAndEvents ) {
|
|
|
|
if ( deepDataAndEvents ) {
|
|
|
|
srcElements = srcElements || getAll( elem );
|
|
|
|
destElements = destElements || getAll( clone );
|
2010-02-02 02:48:05 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
|
|
|
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
|
2013-04-23 01:08:18 +00:00
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
} else {
|
|
|
|
cloneCopyEvent( elem, clone );
|
2013-04-03 17:17:02 +00:00
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
2013-02-07 21:43:25 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Preserve script evaluation history
|
|
|
|
destElements = getAll( clone, "script" );
|
|
|
|
if ( destElements.length > 0 ) {
|
|
|
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Return the cloned set
|
|
|
|
return clone;
|
2009-07-21 15:57:51 +00:00
|
|
|
},
|
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
buildFragment: function( elems, context, scripts, selection, ignored ) {
|
2013-09-09 16:13:41 +00:00
|
|
|
var elem, tmp, tag, wrap, contains, j,
|
|
|
|
fragment = context.createDocumentFragment(),
|
2013-11-02 08:38:37 +00:00
|
|
|
nodes = [],
|
|
|
|
i = 0,
|
|
|
|
l = elems.length;
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2013-01-09 09:23:34 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
elem = elems[ i ];
|
|
|
|
|
|
|
|
if ( elem || elem === 0 ) {
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Add nodes directly
|
2012-11-19 22:17:48 +00:00
|
|
|
if ( jQuery.type( elem ) === "object" ) {
|
2014-10-27 17:36:07 +00:00
|
|
|
// Support: Android<4.1, PhantomJS<2
|
2014-04-25 22:26:36 +00:00
|
|
|
// push.apply(_, arraylike) throws on ancient WebKit
|
2013-01-25 04:45:44 +00:00
|
|
|
jQuery.merge( nodes, elem.nodeType ? [ elem ] : elem );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Convert non-html into a text node
|
|
|
|
} else if ( !rhtml.test( elem ) ) {
|
2013-01-09 15:10:08 +00:00
|
|
|
nodes.push( context.createTextNode( elem ) );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Convert html into DOM nodes
|
2011-04-22 01:51:23 +00:00
|
|
|
} else {
|
2013-01-07 14:38:21 +00:00
|
|
|
tmp = tmp || fragment.appendChild( context.createElement("div") );
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Deserialize a standard representation
|
2013-09-11 01:08:01 +00:00
|
|
|
tag = ( rtagName.exec( elem ) || [ "", "" ] )[ 1 ].toLowerCase();
|
2012-04-05 03:00:58 +00:00
|
|
|
wrap = wrapMap[ tag ] || wrapMap._default;
|
2013-01-13 17:59:22 +00:00
|
|
|
tmp.innerHTML = wrap[ 1 ] + elem.replace( rxhtmlTag, "<$1></$2>" ) + wrap[ 2 ];
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Descend through wrappers to the right content
|
2013-01-07 14:38:21 +00:00
|
|
|
j = wrap[ 0 ];
|
2012-11-19 14:50:19 +00:00
|
|
|
while ( j-- ) {
|
2013-06-02 06:32:48 +00:00
|
|
|
tmp = tmp.lastChild;
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
|
|
|
|
2014-10-27 17:36:07 +00:00
|
|
|
// Support: Android<4.1, PhantomJS<2
|
2014-04-25 22:26:36 +00:00
|
|
|
// push.apply(_, arraylike) throws on ancient WebKit
|
2013-01-25 04:45:44 +00:00
|
|
|
jQuery.merge( nodes, tmp.childNodes );
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Remember the top-level container
|
|
|
|
tmp = fragment.firstChild;
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2014-04-25 22:26:36 +00:00
|
|
|
// Ensure the created nodes are orphaned (#12392)
|
2013-01-07 14:38:21 +00:00
|
|
|
tmp.textContent = "";
|
2012-10-26 00:41:47 +00:00
|
|
|
}
|
2013-01-09 09:23:34 +00:00
|
|
|
}
|
2012-04-16 02:54:18 +00:00
|
|
|
}
|
2012-04-05 03:00:58 +00:00
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Remove wrapper from fragment
|
|
|
|
fragment.textContent = "";
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2013-01-07 21:59:01 +00:00
|
|
|
i = 0;
|
|
|
|
while ( (elem = nodes[ i++ ]) ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
// Skip elements already in the context collection (trac-4087)
|
2014-12-31 23:31:27 +00:00
|
|
|
if ( selection && jQuery.inArray( elem, selection ) > -1 ) {
|
2015-04-13 20:05:48 +00:00
|
|
|
if ( ignored ) {
|
|
|
|
ignored.push( elem );
|
|
|
|
}
|
2013-01-07 14:38:21 +00:00
|
|
|
continue;
|
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
|
2013-01-09 09:23:34 +00:00
|
|
|
contains = jQuery.contains( elem.ownerDocument, elem );
|
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Append to fragment
|
|
|
|
tmp = getAll( fragment.appendChild( elem ), "script" );
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Preserve script evaluation history
|
|
|
|
if ( contains ) {
|
|
|
|
setGlobalEval( tmp );
|
|
|
|
}
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Capture executables
|
|
|
|
if ( scripts ) {
|
2013-01-07 21:59:01 +00:00
|
|
|
j = 0;
|
|
|
|
while ( (elem = tmp[ j++ ]) ) {
|
2013-01-07 14:38:21 +00:00
|
|
|
if ( rscriptType.test( elem.type || "" ) ) {
|
2013-01-09 15:10:08 +00:00
|
|
|
scripts.push( elem );
|
2009-07-19 15:48:30 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
return fragment;
|
2010-01-24 02:20:19 +00:00
|
|
|
},
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2013-04-08 19:35:16 +00:00
|
|
|
cleanData: function( elems ) {
|
2013-11-11 18:13:22 +00:00
|
|
|
var data, elem, type,
|
2013-04-17 16:53:41 +00:00
|
|
|
special = jQuery.event.special,
|
|
|
|
i = 0;
|
2013-01-04 01:39:15 +00:00
|
|
|
|
2013-04-17 16:53:41 +00:00
|
|
|
for ( ; (elem = elems[ i ]) !== undefined; i++ ) {
|
2013-11-11 18:13:22 +00:00
|
|
|
if ( jQuery.acceptData( elem ) && (data = elem[ dataPriv.expando ])) {
|
|
|
|
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 );
|
2010-02-13 11:10:43 +00:00
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2012-04-05 01:17:01 +00:00
|
|
|
}
|
2015-03-09 16:03:43 +00:00
|
|
|
delete elem[ dataPriv.expando ];
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 02:37:05 +00:00
|
|
|
});
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
jQuery.fn.extend({
|
|
|
|
text: function( value ) {
|
|
|
|
return access( this, function( value ) {
|
|
|
|
return value === undefined ?
|
|
|
|
jQuery.text( this ) :
|
2013-10-30 08:16:05 +00:00
|
|
|
this.empty().each(function() {
|
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
|
|
|
this.textContent = value;
|
|
|
|
}
|
|
|
|
});
|
2013-09-09 16:13:41 +00:00
|
|
|
}, null, value, arguments.length );
|
|
|
|
},
|
2013-04-03 17:17:02 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
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 );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
before: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.parentNode ) {
|
|
|
|
this.parentNode.insertBefore( elem, this );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2012-12-20 17:11:13 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
after: function() {
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
if ( this.parentNode ) {
|
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
remove: function( selector, keepData /* Internal Use Only */ ) {
|
|
|
|
var elem,
|
|
|
|
elems = selector ? jQuery.filter( selector, this ) : this,
|
|
|
|
i = 0;
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
|
|
|
if ( !keepData && elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem ) );
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( elem.parentNode ) {
|
|
|
|
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
|
|
setGlobalEval( getAll( elem, "script" ) );
|
|
|
|
}
|
|
|
|
elem.parentNode.removeChild( elem );
|
|
|
|
}
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
return this;
|
|
|
|
},
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
empty: function() {
|
|
|
|
var elem,
|
|
|
|
i = 0;
|
2013-02-03 20:27:55 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
for ( ; (elem = this[i]) != null; i++ ) {
|
|
|
|
if ( elem.nodeType === 1 ) {
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Prevent memory leaks
|
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
|
|
|
|
|
|
// Remove any remaining nodes
|
|
|
|
elem.textContent = "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
clone: function( dataAndEvents, deepDataAndEvents ) {
|
|
|
|
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
|
|
|
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
|
|
|
|
2013-09-11 01:08:01 +00:00
|
|
|
return this.map(function() {
|
2013-09-09 16:13:41 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// See if we can take a shortcut and just use innerHTML
|
|
|
|
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
|
|
|
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
|
|
|
|
|
|
|
|
value = value.replace( rxhtmlTag, "<$1></$2>" );
|
|
|
|
|
|
|
|
try {
|
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
elem = this[ i ] || {};
|
|
|
|
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
|
|
|
elem.innerHTML = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = 0;
|
|
|
|
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
2014-07-17 17:25:59 +00:00
|
|
|
} catch ( e ) {}
|
2013-09-09 16:13:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( elem ) {
|
|
|
|
this.empty().append( value );
|
|
|
|
}
|
|
|
|
}, null, value, arguments.length );
|
|
|
|
},
|
|
|
|
|
|
|
|
replaceWith: function() {
|
2015-04-13 20:05:48 +00:00
|
|
|
var ignored = [];
|
2013-09-09 16:13:41 +00:00
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
// Make the changes, replacing each non-ignored context element with the new content
|
|
|
|
return this.domManip( arguments, function( elem ) {
|
|
|
|
var parent = this.parentNode;
|
2013-09-17 09:24:27 +00:00
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
if ( jQuery.inArray( this, ignored ) < 0 ) {
|
|
|
|
jQuery.cleanData( getAll( this ) );
|
|
|
|
if ( parent ) {
|
|
|
|
parent.replaceChild( elem, this );
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
// Force callback invocation
|
|
|
|
}, ignored );
|
2013-09-09 16:13:41 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
domManip: function( args, callback, ignored ) {
|
2013-09-09 16:13:41 +00:00
|
|
|
|
|
|
|
// Flatten any nested arrays
|
|
|
|
args = concat.apply( [], args );
|
|
|
|
|
|
|
|
var fragment, first, scripts, hasScripts, node, doc,
|
|
|
|
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
|
2013-09-11 14:51:31 +00:00
|
|
|
if ( isFunction ||
|
|
|
|
( l > 1 && typeof value === "string" &&
|
|
|
|
!support.checkClone && rchecked.test( value ) ) ) {
|
2013-09-09 16:13:41 +00:00
|
|
|
return this.each(function( index ) {
|
|
|
|
var self = set.eq( index );
|
|
|
|
if ( isFunction ) {
|
|
|
|
args[ 0 ] = value.call( this, index, self.html() );
|
|
|
|
}
|
2015-04-13 20:05:48 +00:00
|
|
|
self.domManip( args, callback, ignored );
|
2013-09-09 16:13:41 +00:00
|
|
|
});
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( l ) {
|
2015-04-13 20:05:48 +00:00
|
|
|
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, this, ignored );
|
2013-09-09 16:13:41 +00:00
|
|
|
first = fragment.firstChild;
|
2013-02-03 20:27:55 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( fragment.childNodes.length === 1 ) {
|
|
|
|
fragment = first;
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2015-04-13 20:05:48 +00:00
|
|
|
// Require either new content or an interest in ignored elements to invoke the callback
|
|
|
|
if ( first || ignored ) {
|
2013-09-09 16:13:41 +00:00
|
|
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
|
|
hasScripts = scripts.length;
|
2013-02-03 20:27:55 +00:00
|
|
|
|
2014-07-17 17:25:59 +00:00
|
|
|
// Use the original fragment for the last item
|
|
|
|
// instead of the first because it can end up
|
2013-09-09 16:13:41 +00:00
|
|
|
// being emptied incorrectly in certain situations (#8070).
|
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
node = fragment;
|
2012-12-20 17:06:06 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
if ( i !== iNoClone ) {
|
|
|
|
node = jQuery.clone( node, true, true );
|
2012-12-20 17:06:06 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
// Keep references to cloned scripts for later restoration
|
|
|
|
if ( hasScripts ) {
|
2014-10-27 17:36:07 +00:00
|
|
|
// Support: Android<4.1, PhantomJS<2
|
|
|
|
// push.apply(_, arraylike) throws on ancient WebKit
|
2013-09-09 16:13:41 +00:00
|
|
|
jQuery.merge( scripts, getAll( node, "script" ) );
|
|
|
|
}
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
callback.call( this[ i ], node, i );
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-09-09 16:13:41 +00:00
|
|
|
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 || "" ) &&
|
2014-07-17 17:25:59 +00:00
|
|
|
!dataPriv.access( node, "globalEval" ) &&
|
|
|
|
jQuery.contains( doc, node ) ) {
|
2013-09-09 16:13:41 +00:00
|
|
|
|
|
|
|
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.textContent.replace( rcleanScript, "" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
2013-09-09 16:13:41 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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 );
|
|
|
|
|
2014-10-27 17:36:07 +00:00
|
|
|
// Support: Android<4.1, PhantomJS<2
|
|
|
|
// .get() because push.apply(_, arraylike) throws on ancient WebKit
|
2013-09-09 16:13:41 +00:00
|
|
|
push.apply( ret, elems.get() );
|
|
|
|
}
|
|
|
|
|
|
|
|
return this.pushStack( ret );
|
|
|
|
};
|
|
|
|
});
|
2013-09-09 01:25:27 +00:00
|
|
|
|
|
|
|
return jQuery;
|
2013-08-15 18:15:49 +00:00
|
|
|
});
|