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,
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap = {
|
2012-11-28 02:32:59 +00:00
|
|
|
option: [ 1, "<select multiple='multiple'>" ],
|
|
|
|
legend: [ 1, "<fieldset>" ],
|
|
|
|
area: [ 1, "<map>" ],
|
|
|
|
param: [ 1, "<object>" ],
|
|
|
|
thead: [ 1, "<table>" ],
|
|
|
|
tr: [ 2, "<table><tbody>" ],
|
|
|
|
col: [ 2, "<table><tbody></tbody><colgroup>", "</table>" ],
|
|
|
|
td: [ 3, "<table><tbody><tr>" ],
|
2012-12-19 16:26:49 +00:00
|
|
|
_default: [ 0, "" ]
|
|
|
|
};
|
2009-07-19 15:48:30 +00:00
|
|
|
|
2009-09-07 20:55:36 +00:00
|
|
|
wrapMap.optgroup = wrapMap.option;
|
|
|
|
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
|
|
|
|
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 ) :
|
|
|
|
this.empty().append( ( this[0] && this[0].ownerDocument || document ).createTextNode( value ) );
|
|
|
|
}, null, value, arguments.length );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
wrapAll: function( html ) {
|
2009-07-19 15:29:03 +00:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
2010-01-06 20:08:07 +00:00
|
|
|
return this.each(function(i) {
|
|
|
|
jQuery(this).wrapAll( html.call(this, i) );
|
2009-07-19 15:29:03 +00:00
|
|
|
});
|
2009-07-12 21:08:54 +00:00
|
|
|
}
|
2009-07-21 09:17:33 +00:00
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
if ( this[0] ) {
|
|
|
|
// The elements to wrap the target around
|
2009-12-08 19:21:24 +00:00
|
|
|
var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2009-07-19 15:29:03 +00:00
|
|
|
if ( this[0].parentNode ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
wrap.insertBefore( this[0] );
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
wrap.map(function() {
|
2009-03-18 21:15:38 +00:00
|
|
|
var elem = this;
|
|
|
|
|
2009-07-19 15:29:03 +00:00
|
|
|
while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
elem = elem.firstChild;
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
|
|
|
return elem;
|
2011-04-22 01:51:23 +00:00
|
|
|
}).append( this );
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
wrapInner: function( html ) {
|
2010-01-26 00:16:23 +00:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
2012-12-19 18:33:55 +00:00
|
|
|
return this.each(function( i ) {
|
|
|
|
jQuery( this ).wrapInner( html.call(this, i) );
|
2010-01-26 00:16:23 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.each(function() {
|
2010-11-09 16:09:07 +00:00
|
|
|
var self = jQuery( this ),
|
|
|
|
contents = self.contents();
|
2010-01-11 21:31:31 +00:00
|
|
|
|
|
|
|
if ( contents.length ) {
|
|
|
|
contents.wrapAll( html );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
self.append( html );
|
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
wrap: function( html ) {
|
2012-12-19 18:33:55 +00:00
|
|
|
var isFunc = jQuery.isFunction( html );
|
2011-11-06 21:59:41 +00:00
|
|
|
|
2012-12-19 18:33:55 +00:00
|
|
|
return this.each(function( i ) {
|
|
|
|
jQuery( this ).wrapAll( isFunc ? html.call(this, i) : html );
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2009-09-25 21:41:21 +00:00
|
|
|
unwrap: function() {
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.parent().each(function() {
|
2009-09-25 21:41:21 +00:00
|
|
|
if ( !jQuery.nodeName( this, "body" ) ) {
|
|
|
|
jQuery( this ).replaceWith( this.childNodes );
|
|
|
|
}
|
|
|
|
}).end();
|
|
|
|
},
|
2009-12-10 04:57:19 +00:00
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
append: function() {
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.domManip(arguments, true, function( elem ) {
|
2012-09-07 18:12:24 +00:00
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
this.appendChild( elem );
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
prepend: function() {
|
2009-12-22 00:58:13 +00:00
|
|
|
return this.domManip(arguments, true, function( elem ) {
|
2012-09-07 18:12:24 +00:00
|
|
|
if ( this.nodeType === 1 || this.nodeType === 11 || this.nodeType === 9 ) {
|
2009-03-18 21:15:38 +00:00
|
|
|
this.insertBefore( elem, this.firstChild );
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
before: function() {
|
2012-10-16 20:50:30 +00:00
|
|
|
return this.domManip( arguments, false, 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() {
|
2012-10-16 20:50:30 +00:00
|
|
|
return this.domManip( arguments, false, 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-19 18:33:55 +00:00
|
|
|
var elem, i = 0;
|
2012-07-10 01:38:11 +00:00
|
|
|
|
2012-12-19 18:33:55 +00:00
|
|
|
for ( ; ( elem = this[ i ] ) != null; i++ ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( !selector || jQuery.filter( selector, [ elem ] ).length > 0 ) {
|
2010-01-28 20:25:52 +00:00
|
|
|
if ( !keepData && elem.nodeType === 1 ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.cleanData( getAll( elem ) );
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ( elem.parentNode ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( keepData && jQuery.contains( elem.ownerDocument, elem ) ) {
|
|
|
|
setGlobalEval( getAll( elem, "script" ) );
|
|
|
|
}
|
2011-02-10 02:15:32 +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,
|
|
|
|
i = 0;
|
|
|
|
|
|
|
|
for ( ; (elem = this[i]) != null; i++ ) {
|
2010-01-28 20:25:52 +00:00
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
if ( elem.nodeType === 1 ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.cleanData( getAll( elem, false ) );
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Remove any remaining nodes
|
|
|
|
while ( elem.firstChild ) {
|
|
|
|
elem.removeChild( elem.firstChild );
|
|
|
|
}
|
|
|
|
}
|
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 ) {
|
|
|
|
var elem = this[0] || {},
|
|
|
|
i = 0,
|
|
|
|
l = this.length;
|
|
|
|
|
|
|
|
if ( value === undefined ) {
|
2012-12-19 16:26:49 +00:00
|
|
|
return elem.nodeType === 1 ? elem.innerHTML: undefined;
|
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 ) &&
|
2011-12-06 20:25:38 +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 {
|
|
|
|
for (; i < l; i++ ) {
|
|
|
|
// Remove element nodes and prevent memory leaks
|
|
|
|
elem = this[i] || {};
|
|
|
|
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
|
|
|
|
} catch(e) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( elem ) {
|
|
|
|
this.empty().append( value );
|
|
|
|
}
|
|
|
|
}, null, value, arguments.length );
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
replaceWith: function( value ) {
|
2012-12-08 19:49:42 +00:00
|
|
|
var isFunc = jQuery.isFunction( value );
|
2010-01-11 21:25:01 +00:00
|
|
|
|
2012-10-16 20:50:30 +00:00
|
|
|
// Make sure that the elements are removed from the DOM before they are inserted
|
|
|
|
// this can help fix replacing a parent with child elements
|
|
|
|
if ( !isFunc && typeof value !== "string" ) {
|
2012-12-10 21:12:54 +00:00
|
|
|
value = jQuery( value ).not( this ).detach();
|
2012-10-16 20:50:30 +00:00
|
|
|
}
|
2010-02-02 02:48:05 +00:00
|
|
|
|
2012-12-08 19:49:42 +00:00
|
|
|
return this.domManip( [ value ], true, function( elem ) {
|
2012-12-09 19:45:31 +00:00
|
|
|
var next = this.nextSibling,
|
2012-12-05 02:50:22 +00:00
|
|
|
parent = this.parentNode;
|
2009-12-05 20:30:36 +00:00
|
|
|
|
2012-12-09 19:45:31 +00:00
|
|
|
if ( parent && this.nodeType === 1 || this.nodeType === 11 ) {
|
|
|
|
|
2012-12-05 02:50:22 +00:00
|
|
|
jQuery( this ).remove();
|
|
|
|
|
|
|
|
if ( next ) {
|
|
|
|
next.parentNode.insertBefore( elem, next );
|
|
|
|
} else {
|
|
|
|
parent.appendChild( elem );
|
|
|
|
}
|
2012-10-16 20:50:30 +00:00
|
|
|
}
|
|
|
|
});
|
2009-03-18 21:15:38 +00:00
|
|
|
},
|
|
|
|
|
2009-07-21 15:57:51 +00:00
|
|
|
detach: function( selector ) {
|
|
|
|
return this.remove( selector, true );
|
|
|
|
},
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
domManip: function( args, table, callback ) {
|
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,
|
2010-11-09 16:09:07 +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 ) {
|
2012-12-19 23:52:08 +00:00
|
|
|
args[0] = value.call( this, index, table ? self.html() : undefined );
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
2010-01-25 23:43:33 +00:00
|
|
|
self.domManip( args, table, callback );
|
2009-07-12 20:19:43 +00:00
|
|
|
});
|
2009-07-19 15:48:30 +00:00
|
|
|
}
|
2009-07-11 13:49:46 +00:00
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
if ( this[0] ) {
|
2012-12-07 02:17:27 +00:00
|
|
|
doc = this[0].ownerDocument;
|
|
|
|
fragment = doc.createDocumentFragment();
|
2012-12-10 21:12:54 +00:00
|
|
|
jQuery.clean( args, doc, fragment, undefined, 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 ) {
|
|
|
|
table = table && jQuery.nodeName( first, "tr" );
|
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 ) {
|
|
|
|
jQuery.merge( scripts, getAll( node, "script" ) );
|
|
|
|
}
|
|
|
|
}
|
2012-12-05 02:30:37 +00:00
|
|
|
|
2009-07-11 13:49:46 +00:00
|
|
|
callback.call(
|
2012-04-05 03:00:58 +00:00
|
|
|
table && jQuery.nodeName( this[i], "table" ) ?
|
|
|
|
findOrAppend( this[i], "tbody" ) :
|
2009-07-11 13:49:46 +00:00
|
|
|
this[i],
|
2012-12-05 02:50:22 +00:00
|
|
|
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 || "" ) &&
|
|
|
|
!jQuery._data( node, "globalEval" ) && jQuery.contains( doc, node ) ) {
|
|
|
|
|
|
|
|
if ( node.src ) {
|
|
|
|
// Hope ajax is available...
|
|
|
|
jQuery.ajax({
|
|
|
|
url: node.src,
|
|
|
|
type: "GET",
|
|
|
|
dataType: "script",
|
|
|
|
async: false,
|
|
|
|
global: false,
|
|
|
|
"throws": true
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
jQuery.globalEval( ( node.text || node.textContent || node.innerHTML || "" ).replace( rcleanScript, "" ) );
|
|
|
|
}
|
2012-07-06 13:22:44 +00:00
|
|
|
}
|
2011-12-09 02:27:05 +00:00
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
}
|
2011-12-09 02:27:05 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Fix #11809: Avoid leaking memory
|
|
|
|
fragment = first = null;
|
2009-07-11 13:49:46 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2012-04-05 03:00:58 +00:00
|
|
|
function findOrAppend( elem, tag ) {
|
|
|
|
return elem.getElementsByTagName( tag )[0] || elem.appendChild( elem.ownerDocument.createElement( tag ) );
|
2010-03-02 02:24:49 +00:00
|
|
|
}
|
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Replace/restore the type attribute of script elements for safe DOM manipulation
|
|
|
|
function disableScript( elem ) {
|
|
|
|
var attr = elem.getAttributeNode("type");
|
|
|
|
elem.type = ( attr && attr.specified ) + "/" + 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" ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
function cloneCopyEvent( src, dest ) {
|
2009-12-02 22:15:09 +00:00
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
|
|
|
|
return;
|
|
|
|
}
|
2010-12-22 15:13:28 +00:00
|
|
|
|
2011-09-19 20:13:14 +00:00
|
|
|
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++ ) {
|
2012-01-28 19:58:00 +00:00
|
|
|
jQuery.event.add( dest, type, events[ type ][ i ] );
|
2009-12-22 17:04:17 +00:00
|
|
|
}
|
|
|
|
}
|
2011-01-20 19:25:56 +00:00
|
|
|
}
|
2011-09-19 20:13:14 +00:00
|
|
|
|
|
|
|
// make the cloned public data object a copy from the original
|
|
|
|
if ( curData.data ) {
|
|
|
|
curData.data = jQuery.extend( {}, curData.data );
|
|
|
|
}
|
2009-12-02 22:15:09 +00:00
|
|
|
}
|
|
|
|
|
2012-11-18 22:03:38 +00:00
|
|
|
function fixCloneNodeIssues( src, dest ) {
|
2012-11-18 18:53:24 +00:00
|
|
|
var nodeName, data, e;
|
2011-04-22 01:51:23 +00:00
|
|
|
|
2010-12-13 01:23:22 +00:00
|
|
|
// We do not need to do anything for non-Elements
|
|
|
|
if ( dest.nodeType !== 1 ) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
nodeName = dest.nodeName.toLowerCase();
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
// IE6-8 copies events bound via attachEvent when using cloneNode.
|
|
|
|
if ( !jQuery.support.noCloneEvent && dest[ jQuery.expando ] ) {
|
|
|
|
data = jQuery._data( dest );
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-11-18 18:53:24 +00:00
|
|
|
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 );
|
|
|
|
}
|
2011-04-22 01:51:23 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// 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" ) {
|
2012-07-24 18:34:14 +00:00
|
|
|
if ( dest.parentNode ) {
|
|
|
|
dest.outerHTML = src.outerHTML;
|
|
|
|
}
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2012-03-23 15:31:53 +00:00
|
|
|
// 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
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( jQuery.support.html5Clone && ( src.innerHTML && !jQuery.trim(dest.innerHTML) ) ) {
|
2012-03-23 15:31:53 +00:00
|
|
|
dest.innerHTML = src.innerHTML;
|
|
|
|
}
|
2012-04-11 01:38:11 +00:00
|
|
|
|
2012-11-26 08:20:43 +00:00
|
|
|
} else if ( nodeName === "input" && manipulation_rcheckableType.test( src.type ) ) {
|
2011-01-10 00:38:44 +00:00
|
|
|
// 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
|
2012-07-26 02:23:24 +00:00
|
|
|
|
|
|
|
dest.defaultChecked = dest.checked = src.checked;
|
2011-01-10 00:38:44 +00:00
|
|
|
|
|
|
|
// 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;
|
|
|
|
}
|
2010-12-13 01:23:22 +00:00
|
|
|
|
2010-12-13 02:01:47 +00:00
|
|
|
// IE6-8 fails to return the selected option to the default selected
|
2010-12-13 01:23:22 +00:00
|
|
|
// state when cloning options
|
2010-12-16 07:29:06 +00:00
|
|
|
} else if ( nodeName === "option" ) {
|
2012-12-12 04:05:18 +00:00
|
|
|
dest.defaultSelected = dest.selected = src.defaultSelected;
|
2011-01-10 00:38:44 +00:00
|
|
|
|
|
|
|
// 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;
|
2010-12-13 01:23:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-03-18 21:15:38 +00:00
|
|
|
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,
|
|
|
|
i = 0,
|
|
|
|
ret = [],
|
2010-11-09 16:09:07 +00:00
|
|
|
insert = jQuery( selector ),
|
2012-12-12 22:05:50 +00:00
|
|
|
last = insert.length - 1;
|
|
|
|
|
2012-12-13 17:40:55 +00:00
|
|
|
for ( ; i <= last; i++ ) {
|
|
|
|
elems = i === last ? this : this.clone(true);
|
|
|
|
jQuery( insert[i] )[ original ]( elems );
|
|
|
|
|
|
|
|
// Modern browsers can apply jQuery collections as arrays, but oldIE needs a .get()
|
|
|
|
core_push.apply( ret, elems.get() );
|
|
|
|
}
|
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
|
|
|
};
|
|
|
|
});
|
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
function getAll( context, tag ) {
|
|
|
|
var elems, elem,
|
|
|
|
i = 0,
|
|
|
|
found = typeof context.getElementsByTagName !== "undefined" ? context.getElementsByTagName( tag || "*" ) :
|
|
|
|
typeof context.querySelectorAll !== "undefined" ? 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 ) );
|
|
|
|
}
|
|
|
|
}
|
2011-02-23 18:18:44 +00:00
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
|
|
|
|
return tag === undefined || tag && jQuery.nodeName( context, tag ) ?
|
|
|
|
jQuery.merge( [ context ], found ) :
|
|
|
|
found;
|
2011-02-23 18:18:44 +00:00
|
|
|
}
|
|
|
|
|
2011-04-22 01:51:23 +00:00
|
|
|
// Used in clean, fixes the defaultChecked property
|
|
|
|
function fixDefaultChecked( elem ) {
|
2012-11-26 08:20:43 +00:00
|
|
|
if ( manipulation_rcheckableType.test( elem.type ) ) {
|
2011-04-22 01:51:23 +00:00
|
|
|
elem.defaultChecked = elem.checked;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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-19 16:26:49 +00:00
|
|
|
var destElements, srcElements, node, i,
|
|
|
|
inPage = jQuery.contains( elem.ownerDocument, elem ),
|
2012-08-08 20:31:59 +00:00
|
|
|
clone = elem.cloneNode( true );
|
2012-11-18 22:03:38 +00:00
|
|
|
|
2012-04-17 01:57:41 +00:00
|
|
|
// IE<=8 does not properly clone detached, unknown element nodes
|
2011-02-23 18:18:44 +00:00
|
|
|
if ( (!jQuery.support.noCloneEvent || !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-11-18 18:53:24 +00:00
|
|
|
// Fix all IE cloning issues
|
2012-11-19 14:50:19 +00:00
|
|
|
for ( i = 0; (node = srcElements[i]) != null; ++i ) {
|
2011-06-15 15:14:52 +00:00
|
|
|
// Ensure that the destination node is not null; Fixes #9587
|
|
|
|
if ( destElements[i] ) {
|
2012-11-18 22:03:38 +00:00
|
|
|
fixCloneNodeIssues( node, destElements[i] );
|
2011-06-15 15:14:52 +00:00
|
|
|
}
|
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-11-19 14:50:19 +00:00
|
|
|
for ( i = 0; (node = srcElements[i]) != null; i++ ) {
|
|
|
|
cloneCopyEvent( node, 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" ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
destElements = srcElements = node = null;
|
2011-05-25 19:18:13 +00:00
|
|
|
|
2011-01-20 19:25:56 +00:00
|
|
|
// Return the cloned set
|
|
|
|
return clone;
|
2011-04-02 01:13:01 +00:00
|
|
|
},
|
|
|
|
|
2012-12-10 21:12:54 +00:00
|
|
|
clean: function( elems, context, fragment, scripts, selection ) {
|
2012-12-19 16:34:08 +00:00
|
|
|
var elem, i, j, tmp, tag, wrap,
|
2012-11-19 14:50:19 +00:00
|
|
|
ret = [],
|
2012-12-19 16:26:49 +00:00
|
|
|
container = context === document && fragment;
|
2011-04-12 22:30:21 +00:00
|
|
|
|
2012-04-05 03:00:58 +00:00
|
|
|
// Ensure that context is a document
|
|
|
|
if ( !context || typeof context.createDocumentFragment === "undefined" ) {
|
|
|
|
context = document;
|
2009-07-19 15:29:03 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
2012-08-28 21:00:12 +00:00
|
|
|
for ( i = 0; (elem = elems[i]) != null; i++ ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( elem || elem === 0 ) {
|
|
|
|
// Add nodes directly
|
2012-11-19 22:17:48 +00:00
|
|
|
if ( jQuery.type( elem ) === "object" ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.merge( ret, 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 ) ) {
|
|
|
|
ret.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 {
|
2012-11-19 14:50:19 +00:00
|
|
|
// Ensure a safe container
|
2012-12-19 16:26:49 +00:00
|
|
|
container = container || context.createDocumentFragment();
|
|
|
|
tmp = tmp || container.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-04-05 03:00:58 +00:00
|
|
|
tag = ( rtagName.exec( elem ) || ["", ""] )[1].toLowerCase();
|
|
|
|
wrap = wrapMap[ tag ] || wrapMap._default;
|
2012-11-28 02:32:59 +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
|
|
|
|
j = wrap[0];
|
|
|
|
while ( j-- ) {
|
|
|
|
tmp = tmp.lastChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.merge( ret, tmp.childNodes );
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Fix #12392 for WebKit and IE > 9
|
|
|
|
tmp.textContent = "";
|
2012-10-26 00:41:47 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Remember the top-level container for proper cleanup
|
2012-12-19 16:26:49 +00:00
|
|
|
tmp = container.lastChild;
|
2012-10-26 00:41:47 +00:00
|
|
|
}
|
2012-04-16 02:54:18 +00:00
|
|
|
}
|
|
|
|
}
|
2012-04-05 03:00:58 +00:00
|
|
|
|
2012-12-19 16:26:49 +00:00
|
|
|
// Fix #11356: Clear elements from fragment
|
2012-11-19 14:50:19 +00:00
|
|
|
if ( tmp ) {
|
2012-12-19 16:26:49 +00:00
|
|
|
container.removeChild( tmp );
|
2012-04-16 02:54:18 +00:00
|
|
|
}
|
2009-03-23 01:55:17 +00:00
|
|
|
|
2012-04-05 03:00:58 +00:00
|
|
|
// Reset defaultChecked for any radios and checkboxes
|
2012-04-16 02:54:18 +00:00
|
|
|
// about to be appended to the DOM in IE 6/7 (#8060)
|
|
|
|
if ( !jQuery.support.appendChecked ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
jQuery.grep( getAll( ret, "input" ), fixDefaultChecked );
|
2012-04-16 02:54:18 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
|
|
|
|
if ( fragment ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
for ( i = 0; (elem = ret[i]) != null; i++ ) {
|
2012-12-19 16:26:49 +00:00
|
|
|
container = jQuery.contains( elem.ownerDocument, elem );
|
2012-11-19 14:50:19 +00:00
|
|
|
|
|
|
|
// Append to fragment
|
2012-12-10 21:12:54 +00:00
|
|
|
// #4087 - If origin and destination elements are the same, and this is
|
|
|
|
// that element, do not append to fragment
|
2012-12-13 17:40:55 +00:00
|
|
|
if ( !selection || jQuery.inArray( elem, selection ) === -1 ) {
|
2012-12-10 21:12:54 +00:00
|
|
|
fragment.appendChild( elem );
|
|
|
|
}
|
2012-11-19 14:50:19 +00:00
|
|
|
tmp = getAll( elem, "script" );
|
|
|
|
|
|
|
|
// Preserve script evaluation history
|
2012-12-19 16:26:49 +00:00
|
|
|
if ( container ) {
|
2012-11-19 14:50:19 +00:00
|
|
|
setGlobalEval( tmp );
|
2012-04-05 03:00:58 +00:00
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-11-19 14:50:19 +00:00
|
|
|
// Capture executables
|
|
|
|
if ( scripts ) {
|
|
|
|
for ( j = 0; (elem = tmp[j]) != null; j++ ) {
|
|
|
|
if ( rscriptType.test( elem.type || "" ) ) {
|
|
|
|
scripts.push( elem );
|
|
|
|
}
|
2009-07-19 15:48:30 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
2010-01-24 02:20:19 +00:00
|
|
|
},
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
cleanData: function( elems, /* internal */ acceptData ) {
|
|
|
|
var data, id, elem, type,
|
|
|
|
i = 0,
|
|
|
|
internalKey = jQuery.expando,
|
2011-09-19 20:13:14 +00:00
|
|
|
cache = jQuery.cache,
|
2012-07-06 13:22:44 +00:00
|
|
|
deleteExpando = jQuery.support.deleteExpando,
|
|
|
|
special = jQuery.event.special;
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
for ( ; (elem = elems[i]) != null; i++ ) {
|
2010-03-02 18:56:15 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
if ( acceptData || jQuery.acceptData( elem ) ) {
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
id = elem[ internalKey ];
|
|
|
|
data = id && cache[ id ];
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
if ( data ) {
|
|
|
|
if ( data.events ) {
|
|
|
|
for ( type in data.events ) {
|
|
|
|
if ( special[ type ] ) {
|
|
|
|
jQuery.event.remove( elem, type );
|
2010-02-13 11:10:43 +00:00
|
|
|
|
2012-07-06 13:22:44 +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
|
|
|
}
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
// Remove cache only if it was not already removed by jQuery.event.remove
|
|
|
|
if ( cache[ id ] ) {
|
2010-02-13 11:57:58 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
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 ];
|
2010-12-07 01:36:42 +00:00
|
|
|
|
2012-07-06 13:22:44 +00:00
|
|
|
} else if ( elem.removeAttribute ) {
|
|
|
|
elem.removeAttribute( internalKey );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
elem[ internalKey ] = null;
|
|
|
|
}
|
|
|
|
|
2012-10-21 01:02:01 +00:00
|
|
|
core_deletedIds.push( id );
|
2012-07-06 13:22:44 +00:00
|
|
|
}
|
2012-04-05 01:17:01 +00:00
|
|
|
}
|
2010-01-28 20:25:52 +00:00
|
|
|
}
|
2009-03-18 21:15:38 +00:00
|
|
|
}
|
|
|
|
}
|
2010-01-25 02:37:05 +00:00
|
|
|
});
|