2012-12-19 16:27:42 +00:00
|
|
|
var rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,
|
2009-10-12 16:26:01 +00:00
|
|
|
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,
|
2012-11-26 08:20:43 +00:00
|
|
|
manipulation_rcheckableType = /^(?:checkbox|radio)$/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
|
|
|
|
|
|
|
// Support: IE 9
|
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>" ],
|
|
|
|
tr: [ 2, "<table><tbody>", "</tbody></table>" ],
|
|
|
|
td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
|
|
|
|
|
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
|
|
|
|
2012-12-28 14:56:29 +00:00
|
|
|
// Support: IE 9
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
2012-12-28 19:38:30 +00:00
|
|
|
|
2013-01-16 18:07:53 +00:00
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.col = wrapMap.thead;
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.th = wrapMap.td;
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
jQuery.fn.extend({
|
2011-12-06 20:25:38 +00:00
|
|
|
text: function( value ) {
|
|
|
|
return jQuery.access( this, function( value ) {
|
|
|
|
return value === undefined ?
|
|
|
|
jQuery.text( this ) :
|
2013-01-07 11:48:44 +00:00
|
|
|
this.empty().append( ( this[ 0 ] && this[ 0 ].ownerDocument || document ).createTextNode( value ) );
|
2011-12-06 20:25:38 +00:00
|
|
|
}, null, value, arguments.length );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
append: function() {
|
2013-04-03 17:17:02 +00:00
|
|
|
return this.domManip( arguments, function( elem ) {
|
2012-09-07 18:12:24 +00:00
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
2013-04-03 17:17:02 +00:00
|
|
|
var target = manipulationTarget( this, elem );
|
|
|
|
target.appendChild( elem );
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
2013-04-03 17:17:02 +00:00
|
|
|
return this.domManip( arguments, function( elem ) {
|
2012-09-07 18:12:24 +00:00
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
2013-04-03 17:17:02 +00:00
|
|
|
var target = manipulationTarget( this, elem );
|
|
|
|
target.insertBefore( elem, target.firstChild );
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
before: function() {
|
2013-04-03 17:17:02 +00:00
|
|
|
return this.domManip( arguments, function( elem ) {
|
2012-12-09 19:45:31 +00:00
|
|
|
if ( this.parentNode ) {
|
2009-09-14 22:09:42 +00:00
|
|
|
this.parentNode.insertBefore( elem, this );
|
2012-10-16 20:50:30 +00:00
|
|
|
}
|
|
|
|
});
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
after: function() {
|
2013-04-03 17:17:02 +00:00
|
|
|
return this.domManip( arguments, function( elem ) {
|
2012-12-09 19:45:31 +00:00
|
|
|
if ( this.parentNode ) {
|
2009-09-14 22:09:42 +00:00
|
|
|
this.parentNode.insertBefore( elem, this.nextSibling );
|
2012-10-16 20:50:30 +00:00
|
|
|
}
|
|
|
|
});
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2010-01-28 20:25:52 +00:00
|
|
|
// keepData is for internal use only--do not document
|
|
|
|
remove: function( selector, keepData ) {
|
2012-12-20 17:11:13 +00:00
|
|
|
var elem,
|
2013-04-05 12:57:01 +00:00
|
|
|
elems = selector ? jQuery.filter( selector, this ) : this,
|
2013-04-17 02:37:48 +00:00
|
|
|
i = 0;
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-04-17 02:37:48 +00:00
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
2013-04-05 12:57:01 +00:00
|
|
|
if ( !keepData && elem.nodeType === 1 ) {
|
|
|
|
jQuery.cleanData( getAll( elem ) );
|
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
|
2013-04-05 12:57:01 +00:00
|
|
|
if ( elem.parentNode ) {
|
|
|
|
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
|
|
setGlobalEval( getAll( elem, "script" ) );
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2013-04-05 12:57:01 +00:00
|
|
|
elem.parentNode.removeChild( elem );
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2010-01-28 20:25:52 +00:00
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
empty: function() {
|
2012-07-10 01:38:11 +00:00
|
|
|
var elem,
|
2013-04-17 02:37:48 +00:00
|
|
|
i = 0;
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2013-04-17 02:37:48 +00:00
|
|
|
for ( ; (elem = this[i]) != null; i++ ) {
|
2010-01-28 20:25:52 +00:00
|
|
|
if ( elem.nodeType === 1 ) {
|
2012-12-19 18:42:07 +00:00
|
|
|
|
2012-12-20 16:51:22 +00:00
|
|
|
// Prevent memory leaks
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
2010-01-28 20:25:52 +00:00
|
|
|
|
2012-12-19 18:42:07 +00:00
|
|
|
// Remove any remaining nodes
|
|
|
|
elem.textContent = "";
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2010-01-28 20:25:52 +00:00
|
|
|
return this;
|
|
|
|
},
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2011-01-20 20:25:04 +00:00
|
|
|
clone: function( dataAndEvents, deepDataAndEvents ) {
|
2011-02-01 13:57:18 +00:00
|
|
|
dataAndEvents = dataAndEvents == null ? false : dataAndEvents;
|
2011-01-20 20:25:04 +00:00
|
|
|
deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
|
2011-01-28 16:55:39 +00:00
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
return this.map( function () {
|
2011-01-20 20:25:04 +00:00
|
|
|
return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
html: function( value ) {
|
2011-12-06 20:25:38 +00:00
|
|
|
return jQuery.access( this, function( value ) {
|
2013-01-07 11:48:44 +00:00
|
|
|
var elem = this[ 0 ] || {},
|
2011-12-06 20:25:38 +00:00
|
|
|
i = 0,
|
|
|
|
l = this.length;
|
|
|
|
|
2012-12-19 23:16:02 +00:00
|
|
|
if ( value === undefined && elem.nodeType === 1 ) {
|
|
|
|
return elem.innerHTML;
|
2009-09-07 20:55:36 +00:00
|
|
|
}
|
|
|
|
|
2012-04-05 16:12:38 +00:00
|
|
|
// See if we can take a shortcut and just use innerHTML
|
2012-03-30 15:56:11 +00:00
|
|
|
if ( typeof value === "string" && !rnoInnerhtml.test( value ) &&
|
2012-12-20 17:11:13 +00:00
|
|
|
!wrapMap[ ( rtagName.exec( value ) || [ "", "" ] )[ 1 ].toLowerCase() ] ) {
|
2010-01-07 18:33:30 +00:00
|
|
|
|
2011-12-06 20:25:38 +00:00
|
|
|
value = value.replace( rxhtmlTag, "<$1></$2>" );
|
2009-09-07 20:55:36 +00:00
|
|
|
|
2011-12-06 20:25:38 +00:00
|
|
|
try {
|
2012-12-20 17:11:13 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
2012-12-19 18:59:16 +00:00
|
|
|
elem = this[ i ] || {};
|
2012-12-20 16:51:22 +00:00
|
|
|
|
|
|
|
// Remove element nodes and prevent memory leaks
|
2011-12-06 20:25:38 +00:00
|
|
|
if ( elem.nodeType === 1 ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
2011-12-06 20:25:38 +00:00
|
|
|
elem.innerHTML = value;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
elem = 0;
|
|
|
|
|
|
|
|
// If using innerHTML throws an exception, use the fallback method
|
2012-12-19 19:35:25 +00:00
|
|
|
} catch( e ) {}
|
2011-12-06 20:25:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( elem ) {
|
|
|
|
this.empty().append( value );
|
|
|
|
}
|
|
|
|
}, null, value, arguments.length );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
replaceWith: function() {
|
|
|
|
var
|
|
|
|
// Snapshot the DOM in case .domManip sweeps something relevant into its fragment
|
|
|
|
args = jQuery.map( this, function( elem ) {
|
|
|
|
return [ elem.nextSibling, elem.parentNode ];
|
|
|
|
}),
|
|
|
|
i = 0;
|
2010-01-11 21:25:01 +00:00
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
// Make the changes, replacing each context element with the new content
|
|
|
|
this.domManip( arguments, function( elem ) {
|
|
|
|
var next = args[ i++ ],
|
|
|
|
parent = args[ i++ ];
|
2010-02-02 02:48:05 +00:00
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
if ( parent ) {
|
|
|
|
jQuery( this ).remove();
|
|
|
|
parent.insertBefore( elem, next );
|
|
|
|
}
|
|
|
|
// Allow new content to include elements from the context set
|
|
|
|
}, true );
|
2013-02-07 21:43:25 +00:00
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
// Force removal if there was no new content (e.g., from empty arguments)
|
|
|
|
return i ? this : this.remove();
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
2009-07-21 15:57:51 +00:00
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
domManip: function( args, callback, allowIntersection ) {
|
2012-06-16 02:17:05 +00:00
|
|
|
|
|
|
|
// Flatten any nested arrays
|
2012-11-19 14:50:19 +00:00
|
|
|
args = core_concat.apply( [], args );
|
2012-06-16 02:17:05 +00:00
|
|
|
|
2012-12-13 17:40:55 +00:00
|
|
|
var fragment, first, scripts, hasScripts, node, doc,
|
2012-04-05 03:00:58 +00:00
|
|
|
i = 0,
|
2012-11-19 14:50:19 +00:00
|
|
|
l = this.length,
|
2012-12-19 23:52:08 +00:00
|
|
|
set = this,
|
2012-12-13 17:40:55 +00:00
|
|
|
iNoClone = l - 1,
|
2013-01-07 14:38:21 +00:00
|
|
|
value = args[ 0 ],
|
2012-11-19 14:50:19 +00:00
|
|
|
isFunction = jQuery.isFunction( value );
|
2009-07-12 20:19:43 +00:00
|
|
|
|
2010-01-25 23:43:33 +00:00
|
|
|
// We can't cloneNode fragments that contain checked, in WebKit
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( isFunction || !( l <= 1 || typeof value !== "string" || jQuery.support.checkClone || !rchecked.test( value ) ) ) {
|
2012-12-19 23:52:08 +00:00
|
|
|
return this.each(function( index ) {
|
|
|
|
var self = set.eq( index );
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( isFunction ) {
|
2013-04-03 17:17:02 +00:00
|
|
|
args[ 0 ] = value.call( this, index, self.html() );
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
2013-04-03 17:17:02 +00:00
|
|
|
self.domManip( args, callback, allowIntersection );
|
2009-07-12 20:19:43 +00:00
|
|
|
});
|
2009-07-19 15:48:30 +00:00
|
|
|
}
|
2009-07-11 13:49:46 +00:00
|
|
|
|
2012-12-23 16:52:46 +00:00
|
|
|
if ( l ) {
|
2013-04-03 17:17:02 +00:00
|
|
|
fragment = jQuery.buildFragment( args, this[ 0 ].ownerDocument, false, !allowIntersection && this );
|
2012-04-16 02:54:18 +00:00
|
|
|
first = fragment.firstChild;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-04-05 03:00:58 +00:00
|
|
|
if ( fragment.childNodes.length === 1 ) {
|
|
|
|
fragment = first;
|
2010-01-28 22:18:27 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2009-07-11 13:49:46 +00:00
|
|
|
if ( first ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
scripts = jQuery.map( getAll( fragment, "script" ), disableScript );
|
|
|
|
hasScripts = scripts.length;
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2012-04-05 03:00:58 +00:00
|
|
|
// Use the original fragment for the last item instead of the first because it can end up
|
|
|
|
// being emptied incorrectly in certain situations (#8070).
|
2012-12-13 17:40:55 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
node = fragment;
|
2012-12-05 02:30:37 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( i !== iNoClone ) {
|
|
|
|
node = jQuery.clone( node, true, true );
|
|
|
|
|
|
|
|
// Keep references to cloned scripts for later restoration
|
|
|
|
if ( hasScripts ) {
|
2013-01-25 04:45:44 +00:00
|
|
|
// Support: QtWebKit
|
|
|
|
// jQuery.merge because core_push.apply(_, arraylike) throws
|
|
|
|
jQuery.merge( scripts, getAll( node, "script" ) );
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
|
|
|
}
|
2012-12-05 02:30:37 +00:00
|
|
|
|
2013-04-03 17:17:02 +00:00
|
|
|
callback.call( this[ i ], node, i );
|
2009-07-11 13:49:46 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 14:50:19 +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 || "" ) &&
|
2013-02-03 20:27:55 +00:00
|
|
|
!data_priv.access( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
|
|
|
|
if ( node.src ) {
|
|
|
|
// Hope ajax is available...
|
2012-12-02 05:14:25 +00:00
|
|
|
jQuery._evalUrl( node.src );
|
2012-11-19 14:50:19 +00:00
|
|
|
} else {
|
2012-12-19 22:35:52 +00:00
|
|
|
jQuery.globalEval( node.textContent.replace( rcleanScript, "" ) );
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
2012-07-06 13:22:44 +00:00
|
|
|
}
|
2011-12-09 02:27:05 +00:00
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
2009-07-11 13:49:46 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.each({
|
|
|
|
appendTo: "append",
|
|
|
|
prependTo: "prepend",
|
|
|
|
insertBefore: "before",
|
|
|
|
insertAfter: "after",
|
|
|
|
replaceAll: "replaceWith"
|
2009-12-22 00:58:13 +00:00
|
|
|
}, function( name, original ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
jQuery.fn[ name ] = function( selector ) {
|
2012-07-10 01:38:11 +00:00
|
|
|
var elems,
|
|
|
|
ret = [],
|
2010-11-09 16:09:07 +00:00
|
|
|
insert = jQuery( selector ),
|
2012-12-23 22:51:09 +00:00
|
|
|
last = insert.length - 1,
|
|
|
|
i = 0;
|
2012-12-12 22:05:50 +00:00
|
|
|
|
2012-12-13 17:40:55 +00:00
|
|
|
for ( ; i <= last; i++ ) {
|
2012-12-19 21:08:24 +00:00
|
|
|
elems = i === last ? this : this.clone( true );
|
2012-12-19 18:59:16 +00:00
|
|
|
jQuery( insert[ i ] )[ original ]( elems );
|
2012-12-13 17:40:55 +00:00
|
|
|
|
2013-01-25 04:45:44 +00:00
|
|
|
// Support: QtWebKit
|
|
|
|
// .get() because core_push.apply(_, arraylike) throws
|
|
|
|
core_push.apply( ret, elems.get() );
|
2012-12-13 17:40:55 +00:00
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-12-13 17:40:55 +00:00
|
|
|
return this.pushStack( ret );
|
2009-03-18 21:15:38 +00:00
|
|
|
};
|
|
|
|
});
|
|
|
|
|
|
|
|
jQuery.extend({
|
2011-01-20 20:25:04 +00:00
|
|
|
clone: function( elem, dataAndEvents, deepDataAndEvents ) {
|
2012-12-23 22:51:09 +00:00
|
|
|
var i, l, srcElements, destElements,
|
|
|
|
clone = elem.cloneNode( true ),
|
|
|
|
inPage = jQuery.contains( elem.ownerDocument, elem );
|
2012-11-18 22:03:38 +00:00
|
|
|
|
2013-04-04 20:04:39 +00:00
|
|
|
// Support: IE >= 9
|
2012-12-23 17:10:59 +00:00
|
|
|
// Fix Cloning issues
|
2012-12-19 20:52:39 +00:00
|
|
|
if ( !jQuery.support.noCloneChecked && ( elem.nodeType === 1 || elem.nodeType === 11 ) && !jQuery.isXMLDoc( elem ) ) {
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// We eschew Sizzle here for performance reasons: http://jsperf.com/getall-vs-sizzle/2
|
2011-02-23 18:18:44 +00:00
|
|
|
destElements = getAll( clone );
|
2012-11-19 14:50:19 +00:00
|
|
|
srcElements = getAll( elem );
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-12-23 21:54:53 +00:00
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
2012-12-28 19:38:30 +00:00
|
|
|
fixInput( srcElements[ i ], destElements[ i ] );
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Copy the events from the original to the clone
|
2011-01-20 20:25:04 +00:00
|
|
|
if ( dataAndEvents ) {
|
2011-02-23 18:18:44 +00:00
|
|
|
if ( deepDataAndEvents ) {
|
2012-11-18 18:53:24 +00:00
|
|
|
srcElements = srcElements || getAll( elem );
|
|
|
|
destElements = destElements || getAll( clone );
|
2011-01-20 19:25:56 +00:00
|
|
|
|
2012-12-23 21:54:53 +00:00
|
|
|
for ( i = 0, l = srcElements.length; i < l; i++ ) {
|
|
|
|
cloneCopyEvent( srcElements[ i ], destElements[ i ] );
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
} else {
|
|
|
|
cloneCopyEvent( elem, clone );
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
|
|
|
}
|
2011-02-23 18:18:44 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Preserve script evaluation history
|
|
|
|
destElements = getAll( clone, "script" );
|
|
|
|
if ( destElements.length > 0 ) {
|
|
|
|
setGlobalEval( destElements, !inPage && getAll( elem, "script" ) );
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
// Return the cloned set
|
|
|
|
return clone;
|
2011-04-02 01:13:01 +00:00
|
|
|
},
|
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
buildFragment: function( elems, context, scripts, selection ) {
|
2013-01-07 21:59:01 +00:00
|
|
|
var elem, tmp, tag, wrap, contains, j,
|
2012-12-23 22:51:09 +00:00
|
|
|
i = 0,
|
2013-01-09 09:23:34 +00:00
|
|
|
l = elems.length,
|
2013-01-07 21:59:01 +00:00
|
|
|
fragment = context.createDocumentFragment(),
|
2013-01-07 14:38:21 +00:00
|
|
|
nodes = [];
|
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" ) {
|
2013-01-25 04:45:44 +00:00
|
|
|
// Support: QtWebKit
|
|
|
|
// jQuery.merge because core_push.apply(_, arraylike) throws
|
|
|
|
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
|
2012-12-19 18:59:16 +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-01-07 14:38:21 +00:00
|
|
|
tmp = tmp.firstChild;
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
|
|
|
|
2013-01-25 04:45:44 +00:00
|
|
|
// Support: QtWebKit
|
|
|
|
// jQuery.merge because core_push.apply(_, arraylike) throws
|
|
|
|
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
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// Fixes #12346
|
|
|
|
// Support: Webkit, IE
|
|
|
|
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
|
|
|
|
2013-01-07 14:38:21 +00:00
|
|
|
// #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;
|
|
|
|
}
|
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-02-03 20:27:55 +00:00
|
|
|
var data, elem, type,
|
2012-12-23 21:54:53 +00:00
|
|
|
l = elems.length,
|
2012-12-23 22:51:09 +00:00
|
|
|
i = 0,
|
2012-07-06 13:22:44 +00:00
|
|
|
special = jQuery.event.special;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-12-23 21:54:53 +00:00
|
|
|
for ( ; i < l; i++ ) {
|
|
|
|
elem = elems[ i ];
|
2010-03-02 18:56:15 +00:00
|
|
|
|
2013-04-08 19:35:16 +00:00
|
|
|
if ( jQuery.acceptData( elem ) ) {
|
2013-01-04 01:39:15 +00:00
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
data = data_priv.access( elem );
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
if ( data ) {
|
2012-12-19 22:27:45 +00:00
|
|
|
for ( type in data.events ) {
|
|
|
|
if ( special[ type ] ) {
|
|
|
|
jQuery.event.remove( elem, type );
|
2010-02-13 11:10:43 +00:00
|
|
|
|
2012-12-19 22:27:45 +00:00
|
|
|
// 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
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2013-02-03 20:27:55 +00:00
|
|
|
// Discard any remaining `private` and `user` data
|
2013-04-08 19:35:16 +00:00
|
|
|
// One day we'll replace the dual arrays with a WeakMap and this won't be an issue.
|
|
|
|
// (Splices the data objects out of the internal cache arrays)
|
|
|
|
data_user.discard( elem );
|
|
|
|
data_priv.discard( elem );
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
2012-12-02 05:14:25 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_evalUrl: function( url ) {
|
|
|
|
return jQuery.ajax({
|
|
|
|
url: url,
|
|
|
|
type: "GET",
|
|
|
|
dataType: "text",
|
|
|
|
async: false,
|
|
|
|
global: false,
|
|
|
|
success: jQuery.globalEval
|
|
|
|
});
|
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-04-03 17:17:02 +00:00
|
|
|
// Support: 1.x compatibility
|
|
|
|
// 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;
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
|
|
function disableScript( elem ) {
|
2013-04-18 17:43:51 +00:00
|
|
|
elem.type = (elem.getAttribute("type") !== null) + "/" + elem.type;
|
2012-12-19 21:13:54 +00:00
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
function restoreScript( elem ) {
|
|
|
|
var match = rscriptTypeMasked.exec( elem.type );
|
2012-12-23 21:54:53 +00:00
|
|
|
|
2012-12-19 21:13:54 +00:00
|
|
|
if ( match ) {
|
|
|
|
elem.type = match[ 1 ];
|
|
|
|
} else {
|
|
|
|
elem.removeAttribute("type");
|
|
|
|
}
|
2012-12-20 17:11:13 +00:00
|
|
|
|
2012-12-19 21:13:54 +00:00
|
|
|
return elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Mark scripts as having already been evaluated
|
|
|
|
function setGlobalEval( elems, refElements ) {
|
2012-12-23 22:51:09 +00:00
|
|
|
var l = elems.length,
|
|
|
|
i = 0;
|
2012-12-23 21:54:53 +00:00
|
|
|
|
|
|
|
for ( ; i < l; i++ ) {
|
2013-02-03 20:27:55 +00:00
|
|
|
data_priv.set(
|
|
|
|
elems[ i ], "globalEval", !refElements || data_priv.get( refElements[ i ], "globalEval" )
|
|
|
|
);
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function cloneCopyEvent( src, dest ) {
|
2013-02-03 20:27:55 +00:00
|
|
|
var i, l, type, pdataOld, pdataCur, udataOld, udataCur, events;
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
if ( dest.nodeType !== 1 ) {
|
2012-12-19 21:13:54 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
// 1. Copy private data: events, handlers, etc.
|
|
|
|
if ( data_priv.hasData( src ) ) {
|
|
|
|
pdataOld = data_priv.access( src );
|
|
|
|
pdataCur = jQuery.extend( {}, pdataOld );
|
|
|
|
events = pdataOld.events;
|
|
|
|
|
|
|
|
data_priv.set( dest, pdataCur );
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
if ( events ) {
|
|
|
|
delete pdataCur.handle;
|
|
|
|
pdataCur.events = {};
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
for ( type in events ) {
|
|
|
|
for ( i = 0, l = events[ type ].length; i < l; i++ ) {
|
|
|
|
jQuery.event.add( dest, type, events[ type ][ i ] );
|
|
|
|
}
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
// 2. Copy user data
|
|
|
|
if ( data_user.hasData( src ) ) {
|
|
|
|
udataOld = data_user.access( src );
|
|
|
|
udataCur = jQuery.extend( {}, udataOld );
|
|
|
|
|
|
|
|
data_user.set( dest, udataCur );
|
2012-12-19 21:13:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-02-03 20:27:55 +00:00
|
|
|
|
2012-12-20 17:06:06 +00:00
|
|
|
function getAll( context, tag ) {
|
2012-12-24 00:29:41 +00:00
|
|
|
var ret = context.getElementsByTagName ? context.getElementsByTagName( tag || "*" ) :
|
|
|
|
context.querySelectorAll ? context.querySelectorAll( tag || "*" ) :
|
|
|
|
[];
|
2012-12-20 17:06:06 +00:00
|
|
|
|
|
|
|
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
|
|
jQuery.merge( [ context ], ret ) :
|
|
|
|
ret;
|
|
|
|
}
|
|
|
|
|
2012-12-28 19:38:30 +00:00
|
|
|
// Support: IE >= 9
|
|
|
|
function fixInput( src, dest ) {
|
2012-12-24 00:28:52 +00:00
|
|
|
var nodeName = dest.nodeName.toLowerCase();
|
2012-12-19 21:13:54 +00:00
|
|
|
|
2012-12-23 17:10:59 +00:00
|
|
|
// Fails to persist the checked state of a cloned checkbox or radio button.
|
2012-12-24 00:16:17 +00:00
|
|
|
if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
|
2012-12-19 21:13:54 +00:00
|
|
|
dest.checked = src.checked;
|
|
|
|
|
2012-12-23 17:10:59 +00:00
|
|
|
// Fails to return the selected option to the default selected state when cloning options
|
2012-12-19 21:13:54 +00:00
|
|
|
} else if ( nodeName === "input" || nodeName === "textarea" ) {
|
|
|
|
dest.defaultValue = src.defaultValue;
|
|
|
|
}
|
|
|
|
}
|