scratch – Diff between revs 58 and 125
?pathlinks?
Rev 58 | Rev 125 | |||
---|---|---|---|---|
Line 1... | Line 1... | |||
1 | define( [ |
1 | define([ |
|
2 | "./core", |
2 | "./core", |
|
3 | "./core/init", |
3 | "./core/init", |
|
4 | "./manipulation", // clone |
4 | "./manipulation", // clone |
|
5 | "./traversing" // parent, contents |
5 | "./traversing" // parent, contents |
|
6 | ], function( jQuery ) { |
6 | ], function( jQuery ) { |
|
Line 7... | Line -... | |||
7 | |
- | ||
8 | "use strict"; |
- | ||
9 | |
7 | |
|
10 | jQuery.fn.extend( { |
8 | jQuery.fn.extend({ |
|
11 | wrapAll: function( html ) { |
9 | wrapAll: function( html ) { |
|
Line -... | Line 10... | |||
- | 10 | var wrap; |
||
- | 11 | |
||
- | 12 | if ( jQuery.isFunction( html ) ) { |
||
- | 13 | return this.each(function( i ) { |
||
- | 14 | jQuery( this ).wrapAll( html.call(this, i) ); |
||
- | 15 | }); |
||
12 | var wrap; |
16 | } |
|
13 | |
- | ||
14 | if ( this[ 0 ] ) { |
- | ||
15 | if ( jQuery.isFunction( html ) ) { |
- | ||
Line 16... | Line 17... | |||
16 | html = html.call( this[ 0 ] ); |
17 | |
|
17 | } |
18 | if ( this[ 0 ] ) { |
|
Line 18... | Line 19... | |||
18 | |
19 | |
|
19 | // The elements to wrap the target around |
20 | // The elements to wrap the target around |
|
20 | wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
21 | wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
|
Line 21... | Line 22... | |||
21 | |
22 | |
|
22 | if ( this[ 0 ].parentNode ) { |
23 | if ( this[ 0 ].parentNode ) { |
|
Line 23... | Line 24... | |||
23 | wrap.insertBefore( this[ 0 ] ); |
24 | wrap.insertBefore( this[ 0 ] ); |
|
24 | } |
25 | } |
|
25 | |
26 | |
|
Line 26... | Line 27... | |||
26 | wrap.map( function() { |
27 | wrap.map(function() { |
|
27 | var elem = this; |
28 | var elem = this; |
|
28 | |
29 | |
|
Line 29... | Line 30... | |||
29 | while ( elem.firstElementChild ) { |
30 | while ( elem.firstElementChild ) { |
|
30 | elem = elem.firstElementChild; |
31 | elem = elem.firstElementChild; |
|
Line 31... | Line 32... | |||
31 | } |
32 | } |
|
32 | |
33 | |
|
33 | return elem; |
34 | return elem; |
|
34 | } ).append( this ); |
35 | }).append( this ); |
|
35 | } |
36 | } |
|
36 | |
37 | |
|
Line 37... | Line 38... | |||
37 | return this; |
38 | return this; |
|
38 | }, |
39 | }, |
|
39 | |
40 | |
|
Line 40... | Line 41... | |||
40 | wrapInner: function( html ) { |
41 | wrapInner: function( html ) { |
|
41 | if ( jQuery.isFunction( html ) ) { |
42 | if ( jQuery.isFunction( html ) ) { |
|
Line 42... | Line 43... | |||
42 | return this.each( function( i ) { |
43 | return this.each(function( i ) { |
|
43 | jQuery( this ).wrapInner( html.call( this, i ) ); |
44 | jQuery( this ).wrapInner( html.call(this, i) ); |
|
44 | } ); |
45 | }); |
|
45 | } |
46 | } |
|
46 | |
47 | |
|
Line 47... | Line 48... | |||
47 | return this.each( function() { |
48 | return this.each(function() { |
|
48 | var self = jQuery( this ), |
49 | var self = jQuery( this ), |
|
Line 49... | Line 50... | |||
49 | contents = self.contents(); |
50 | contents = self.contents(); |
|
50 | |
51 | |
|
51 | if ( contents.length ) { |
52 | if ( contents.length ) { |
|
52 | contents.wrapAll( html ); |
53 | contents.wrapAll( html ); |
|
Line 53... | Line 54... | |||
53 | |
54 | |
|
54 | } else { |
55 | } else { |
|
- | 56 | self.append( html ); |
||
55 | self.append( html ); |
57 | } |
|
56 | } |
58 | }); |
|
57 | } ); |
59 | }, |
|
58 | }, |
60 | |
|
59 | |
61 | wrap: function( html ) { |
|
Line 60... | Line 62... | |||
60 | wrap: function( html ) { |
62 | var isFunction = jQuery.isFunction( html ); |
|
61 | var isFunction = jQuery.isFunction( html ); |
63 | |