scratch – Blame information for rev 125
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
125 | office | 1 | define([ |
58 | office | 2 | "./core", |
3 | "./core/init", |
||
4 | "./manipulation", // clone |
||
5 | "./traversing" // parent, contents |
||
6 | ], function( jQuery ) { |
||
7 | |||
125 | office | 8 | jQuery.fn.extend({ |
58 | office | 9 | wrapAll: function( html ) { |
10 | var wrap; |
||
11 | |||
125 | office | 12 | if ( jQuery.isFunction( html ) ) { |
13 | return this.each(function( i ) { |
||
14 | jQuery( this ).wrapAll( html.call(this, i) ); |
||
15 | }); |
||
16 | } |
||
17 | |||
58 | office | 18 | if ( this[ 0 ] ) { |
19 | |||
20 | // The elements to wrap the target around |
||
21 | wrap = jQuery( html, this[ 0 ].ownerDocument ).eq( 0 ).clone( true ); |
||
22 | |||
23 | if ( this[ 0 ].parentNode ) { |
||
24 | wrap.insertBefore( this[ 0 ] ); |
||
25 | } |
||
26 | |||
125 | office | 27 | wrap.map(function() { |
58 | office | 28 | var elem = this; |
29 | |||
30 | while ( elem.firstElementChild ) { |
||
31 | elem = elem.firstElementChild; |
||
32 | } |
||
33 | |||
34 | return elem; |
||
125 | office | 35 | }).append( this ); |
58 | office | 36 | } |
37 | |||
38 | return this; |
||
39 | }, |
||
40 | |||
41 | wrapInner: function( html ) { |
||
42 | if ( jQuery.isFunction( html ) ) { |
||
125 | office | 43 | return this.each(function( i ) { |
44 | jQuery( this ).wrapInner( html.call(this, i) ); |
||
45 | }); |
||
58 | office | 46 | } |
47 | |||
125 | office | 48 | return this.each(function() { |
58 | office | 49 | var self = jQuery( this ), |
50 | contents = self.contents(); |
||
51 | |||
52 | if ( contents.length ) { |
||
53 | contents.wrapAll( html ); |
||
54 | |||
55 | } else { |
||
56 | self.append( html ); |
||
57 | } |
||
125 | office | 58 | }); |
58 | office | 59 | }, |
60 | |||
61 | wrap: function( html ) { |
||
62 | var isFunction = jQuery.isFunction( html ); |
||
63 | |||
125 | office | 64 | return this.each(function( i ) { |
65 | jQuery( this ).wrapAll( isFunction ? html.call(this, i) : html ); |
||
66 | }); |
||
58 | office | 67 | }, |
68 | |||
125 | office | 69 | unwrap: function() { |
70 | return this.parent().each(function() { |
||
71 | if ( !jQuery.nodeName( this, "body" ) ) { |
||
72 | jQuery( this ).replaceWith( this.childNodes ); |
||
73 | } |
||
74 | }).end(); |
||
58 | office | 75 | } |
125 | office | 76 | }); |
58 | office | 77 | |
78 | return jQuery; |
||
125 | office | 79 | }); |