Sha256: 95cb7c61096355173e427cccedd30322b190d3cec3c17b2b298d8906077f337a

Contents?: true

Size: 1.46 KB

Versions: 417

Compression:

Stored size: 1.46 KB

Contents

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

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

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

		if ( 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() {
		return this.parent().each(function() {
			if ( !jQuery.nodeName( this, "body" ) ) {
				jQuery( this ).replaceWith( this.childNodes );
			}
		}).end();
	}
});

return jQuery;
});

Version data entries

417 entries across 417 versions & 30 rubygems

Version Path
radius-rails-3.1.4 app/assets/components/jquery/src/wrap.js
middleman-core-4.5.1 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.5.0 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.4.3 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.4.2 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.4.0 fixtures/import-app/bower_components/jquery/src/wrap.js
epuber-0.6.0 lib/epuber/third_party/bower/bower_components/jquery/src/wrap.js
middleman-core-4.3.11 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.3.10 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.3.8 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.3.7 fixtures/import-app/bower_components/jquery/src/wrap.js
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/middleman-core-4.3.3/fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.3.6 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.3.5 fixtures/import-app/bower_components/jquery/src/wrap.js
iqvoc-4.12.1 vendor/assets/bower_components/jquery/src/wrap.js
middleman-core-4.3.4 fixtures/import-app/bower_components/jquery/src/wrap.js
epuber-0.5.7 lib/epuber/third_party/bower/bower_components/jquery/src/wrap.js
card-1.97.0 mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/src/wrap.js
middleman-core-4.3.3 fixtures/import-app/bower_components/jquery/src/wrap.js
card-1.96.8 mod/bootstrap/vendor/bootswatch/docs/3/bower_components/jquery/src/wrap.js