Blame view

app/bower_components/jquery/src/wrap.js 1.42 KB
87c93a029   Dang YoungWorld   add modal
1
  define( [
f986e111b   TRUONG   add libs
2
3
4
5
6
  	"./core",
  	"./core/init",
  	"./manipulation", // clone
  	"./traversing" // parent, contents
  ], function( jQuery ) {
87c93a029   Dang YoungWorld   add modal
7
8
9
  "use strict";
  
  jQuery.fn.extend( {
f986e111b   TRUONG   add libs
10
  	wrapAll: function( html ) {
87c93a029   Dang YoungWorld   add modal
11
12
13
14
15
16
  		var wrap;
  
  		if ( this[ 0 ] ) {
  			if ( jQuery.isFunction( html ) ) {
  				html = html.call( this[ 0 ] );
  			}
f986e111b   TRUONG   add libs
17

f986e111b   TRUONG   add libs
18
  			// The elements to wrap the target around
87c93a029   Dang YoungWorld   add modal
19
  			wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true );
f986e111b   TRUONG   add libs
20

87c93a029   Dang YoungWorld   add modal
21
22
  			if ( this[ 0 ].parentNode ) {
  				wrap.insertBefore( this[ 0 ] );
f986e111b   TRUONG   add libs
23
  			}
87c93a029   Dang YoungWorld   add modal
24
  			wrap.map( function() {
f986e111b   TRUONG   add libs
25
  				var elem = this;
87c93a029   Dang YoungWorld   add modal
26
27
  				while ( elem.firstElementChild ) {
  					elem = elem.firstElementChild;
f986e111b   TRUONG   add libs
28
29
30
  				}
  
  				return elem;
87c93a029   Dang YoungWorld   add modal
31
  			} ).append( this );
f986e111b   TRUONG   add libs
32
33
34
35
36
37
38
  		}
  
  		return this;
  	},
  
  	wrapInner: function( html ) {
  		if ( jQuery.isFunction( html ) ) {
87c93a029   Dang YoungWorld   add modal
39
40
41
  			return this.each( function( i ) {
  				jQuery( this ).wrapInner( html.call( this, i ) );
  			} );
f986e111b   TRUONG   add libs
42
  		}
87c93a029   Dang YoungWorld   add modal
43
  		return this.each( function() {
f986e111b   TRUONG   add libs
44
45
46
47
48
49
50
51
52
  			var self = jQuery( this ),
  				contents = self.contents();
  
  			if ( contents.length ) {
  				contents.wrapAll( html );
  
  			} else {
  				self.append( html );
  			}
87c93a029   Dang YoungWorld   add modal
53
  		} );
f986e111b   TRUONG   add libs
54
55
56
57
  	},
  
  	wrap: function( html ) {
  		var isFunction = jQuery.isFunction( html );
87c93a029   Dang YoungWorld   add modal
58
59
60
  		return this.each( function( i ) {
  			jQuery( this ).wrapAll( isFunction ? html.call( this, i ) : html );
  		} );
f986e111b   TRUONG   add libs
61
  	},
87c93a029   Dang YoungWorld   add modal
62
63
64
65
66
  	unwrap: function( selector ) {
  		this.parent( selector ).not( "body" ).each( function() {
  			jQuery( this ).replaceWith( this.childNodes );
  		} );
  		return this;
f986e111b   TRUONG   add libs
67
  	}
87c93a029   Dang YoungWorld   add modal
68
  } );
f986e111b   TRUONG   add libs
69
70
  
  return jQuery;
87c93a029   Dang YoungWorld   add modal
71
  } );