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
abstracted-0.4.17 vendor/assets/components/jquery/src/wrap.js
abstracted-0.4.16 vendor/assets/components/jquery/src/wrap.js
abstracted-0.4.15 vendor/assets/components/jquery/src/wrap.js
abstracted-0.4.14 vendor/assets/components/jquery/src/wrap.js
middleman-core-4.2.1 fixtures/import-app/bower_components/jquery/src/wrap.js
trusty-festivity-extension-2.6.3 vendor/assets/components/jquery/src/wrap.js
trusty-festivity-extension-2.6.2 vendor/assets/components/jquery/src/wrap.js
unpoly-rails-0.32.0 spec_app/vendor/assets/bower_components/jquery/src/wrap.js
middleman-core-4.2.0 fixtures/import-app/bower_components/jquery/src/wrap.js
trusty-festivity-extension-2.6.1 vendor/assets/components/jquery/src/wrap.js
middleman-core-4.1.14 fixtures/import-app/bower_components/jquery/src/wrap.js
middleman-core-4.1.13 fixtures/import-app/bower_components/jquery/src/wrap.js
trusty-festivity-extension-2.6 vendor/assets/components/jquery/src/wrap.js
active_record_survey_api-0.0.19 spec/test_app/vendor/assets/bower_components/jquery/src/wrap.js
active_record_survey_api-0.0.18 spec/test_app/vendor/assets/bower_components/jquery/src/wrap.js
middleman-core-4.1.12 fixtures/import-app/bower_components/jquery/src/wrap.js
active_record_survey_api-0.0.17 spec/test_app/vendor/assets/bower_components/jquery/src/wrap.js
active_record_survey_api-0.0.14 spec/test_app/vendor/assets/bower_components/jquery/src/wrap.js
abstracted-0.4.13 vendor/assets/components/jquery/src/wrap.js
unpoly-rails-0.31.2 spec_app/vendor/assets/bower_components/jquery/src/wrap.js