2015-08-16 06:59:58 +00:00
|
|
|
define( [
|
2013-08-15 18:15:49 +00:00
|
|
|
"./core",
|
2013-09-10 00:13:01 +00:00
|
|
|
"./core/init",
|
2014-05-30 20:13:00 +00:00
|
|
|
"./manipulation", // clone
|
2013-08-15 18:15:49 +00:00
|
|
|
"./traversing" // parent, contents
|
|
|
|
], function( jQuery ) {
|
2013-09-09 15:26:21 +00:00
|
|
|
|
2016-04-25 18:25:08 +00:00
|
|
|
"use strict";
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
jQuery.fn.extend( {
|
2013-04-05 21:30:48 +00:00
|
|
|
wrapAll: function( html ) {
|
|
|
|
var wrap;
|
|
|
|
|
|
|
|
if ( this[ 0 ] ) {
|
2014-12-08 07:32:57 +00:00
|
|
|
if ( jQuery.isFunction( html ) ) {
|
|
|
|
html = html.call( this[ 0 ] );
|
|
|
|
}
|
2013-04-05 21:30:48 +00:00
|
|
|
|
|
|
|
// The elements to wrap the target around
|
|
|
|
wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
|
|
|
|
|
|
|
|
if ( this[ 0 ].parentNode ) {
|
|
|
|
wrap.insertBefore( this[ 0 ] );
|
|
|
|
}
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
wrap.map( function() {
|
2013-04-05 21:30:48 +00:00
|
|
|
var elem = this;
|
|
|
|
|
|
|
|
while ( elem.firstElementChild ) {
|
|
|
|
elem = elem.firstElementChild;
|
|
|
|
}
|
|
|
|
|
|
|
|
return elem;
|
2015-08-16 06:59:58 +00:00
|
|
|
} ).append( this );
|
2013-04-05 21:30:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
|
|
|
wrapInner: function( html ) {
|
|
|
|
if ( jQuery.isFunction( html ) ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
return this.each( function( i ) {
|
|
|
|
jQuery( this ).wrapInner( html.call( this, i ) );
|
|
|
|
} );
|
2013-04-05 21:30:48 +00:00
|
|
|
}
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
return this.each( function() {
|
2013-04-05 21:30:48 +00:00
|
|
|
var self = jQuery( this ),
|
|
|
|
contents = self.contents();
|
|
|
|
|
|
|
|
if ( contents.length ) {
|
|
|
|
contents.wrapAll( html );
|
|
|
|
|
|
|
|
} else {
|
|
|
|
self.append( html );
|
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-04-05 21:30:48 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
wrap: function( html ) {
|
|
|
|
var isFunction = jQuery.isFunction( html );
|
|
|
|
|
2015-08-16 06:59:58 +00:00
|
|
|
return this.each( function( i ) {
|
|
|
|
jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
|
|
|
|
} );
|
2013-04-05 21:30:48 +00:00
|
|
|
},
|
|
|
|
|
2015-01-12 03:17:41 +00:00
|
|
|
unwrap: function( selector ) {
|
2015-08-16 06:59:58 +00:00
|
|
|
this.parent( selector ).not( "body" ).each( function() {
|
2015-01-12 03:17:41 +00:00
|
|
|
jQuery( this ).replaceWith( this.childNodes );
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2015-01-12 03:17:41 +00:00
|
|
|
return this;
|
2013-04-05 21:30:48 +00:00
|
|
|
}
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|
2013-09-09 01:25:27 +00:00
|
|
|
|
|
|
|
return jQuery;
|
2015-08-16 06:59:58 +00:00
|
|
|
} );
|