diff options
| author | Jonathan Barronville | 2014-06-07 19:13:28 -0400 | 
|---|---|---|
| committer | Jonathan Barronville | 2014-06-07 19:13:28 -0400 | 
| commit | b56e5c671ce89f1c8ddc67a4ac8d2f59de04ea85 (patch) | |
| tree | 80ce4d67ff46505dc1ec77b72daf7bed59abf8b4 /bower_components/jquery/src/wrap.js | |
| parent | 67ad58c27c4a2704532246d044e1ecbae2a11022 (diff) | |
| download | sellevate-b56e5c671ce89f1c8ddc67a4ac8d2f59de04ea85.tar.bz2 | |
Yo.
Diffstat (limited to 'bower_components/jquery/src/wrap.js')
| -rw-r--r-- | bower_components/jquery/src/wrap.js | 78 | 
1 files changed, 78 insertions, 0 deletions
| diff --git a/bower_components/jquery/src/wrap.js b/bower_components/jquery/src/wrap.js new file mode 100644 index 0000000..b6dce72 --- /dev/null +++ b/bower_components/jquery/src/wrap.js @@ -0,0 +1,78 @@ +define([ +	"./core", +	"./core/init", +	"./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; +}); | 
