diff options
author | Morgan <morgan.bohn@unistra.fr> | 2015-09-15 13:42:08 +0200 |
---|---|---|
committer | Morgan <morgan.bohn@unistra.fr> | 2015-09-15 13:42:08 +0200 |
commit | e2c33fc218dd3677a7f8366815a6b4de1ff7cde3 (patch) | |
tree | 3a326f34cd6e8608eab2d42faf364b0b9d77128e /bower_components/jquery/src/wrap.js | |
parent | examples from eiro.github.com (diff) | |
download | spore.github.io-e2c33fc218dd3677a7f8366815a6b4de1ff7cde3.tar.gz |
initial commit
Diffstat (limited to '')
-rw-r--r-- | bower_components/jquery/src/wrap.js | 79 |
1 files changed, 79 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..4958251 --- /dev/null +++ b/bower_components/jquery/src/wrap.js @@ -0,0 +1,79 @@ +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; +}); |