Sha256: 8234977b590c84348f9210db47ecb48a9bf4472a6cedc5a1b1543c8ea627b123

Contents?: true

Size: 1.42 KB

Versions: 110

Compression:

Stored size: 1.42 KB

Contents

define( [
	"./core",
	"./core/init",
	"./manipulation", // clone
	"./traversing" // parent, contents
], function( jQuery ) {

"use strict";

jQuery.fn.extend( {
	wrapAll: function( html ) {
		var wrap;

		if ( this[ 0 ] ) {
			if ( jQuery.isFunction( html ) ) {
				html = html.call( this[ 0 ] );
			}

			// 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 ] );
			}

			wrap.map( function() {
				var elem = this;

				while ( elem.firstElementChild ) {
					elem = elem.firstElementChild;
				}

				return elem;
			} ).append( this );
		}

		return this;
	},

	wrapInner: function( html ) {
		if ( jQuery.isFunction( html ) ) {
			return this.each( function( i ) {
				jQuery( this ).wrapInner( html.call( this, i ) );
			} );
		}

		return this.each( function() {
			var self = jQuery( this ),
				contents = self.contents();

			if ( contents.length ) {
				contents.wrapAll( html );

			} else {
				self.append( html );
			}
		} );
	},

	wrap: function( html ) {
		var isFunction = jQuery.isFunction( html );

		return this.each( function( i ) {
			jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
		} );
	},

	unwrap: function( selector ) {
		this.parent( selector ).not( "body" ).each( function() {
			jQuery( this ).replaceWith( this.childNodes );
		} );
		return this;
	}
} );

return jQuery;
} );

Version data entries

110 entries across 100 versions & 14 rubygems

Version Path
loco-rails-2.5.3 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.5.2 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-3.0.2 test/dummy/node_modules/jquery/src/wrap.js
trusty-cms-3.1.10 spec/dummy/node_modules/jquery/src/wrap.js
trusty-cms-3.1.9 spec/dummy/node_modules/jquery/src/wrap.js
loco-rails-3.0.1 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.5.1 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.5.0 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.4.0 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.3.0 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-3.0.0 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.2.2 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.2.1 test/dummy/node_modules/jquery/src/wrap.js
loco-rails-2.2.0 test/dummy/node_modules/jquery/src/wrap.js
trusty-cms-3.1.6 app/assets/bower_components/jquery/src/wrap.js
jekyll-theme-mozg-0.1.0 assets/javascript/jquery/src/wrap.js
trusty-cms-3.1.5 app/assets/bower_components/jquery/src/wrap.js
loco-rails-2.1.0 test/dummy/node_modules/jquery/src/wrap.js
jinda_lte-0.0.1 lib/generators/jinda_lte/templates/app/assets/jinda_assets/bower_components/jquery/src/wrap.js
loco-rails-2.0.0 test/dummy/node_modules/jquery/src/wrap.js