ÿþ/ *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 e x p a n d A l l   v . 1 . 3 . 2 
 h t t p : / / a d i p a l a z . a w a r d s p a c e . c o m / e x p e r i m e n t s / j q u e r y / e x p a n d . h t m l 
 R e q u i r e s :   j Q u e r y   v 1 . 3 + 
 C o p y r i g h t   ( c )   2 0 0 9   A d r i a n a   P a l a z o v a 
 D u a l   l i c e n s e d   u n d e r   t h e   M I T   ( h t t p : / / a d i p a l a z . a w a r d s p a c e . c o m / d o c s / m i t - l i c e n s e . t x t )   a n d   G P L   ( h t t p : / / a d i p a l a z . a w a r d s p a c e . c o m / d o c s / g p l - l i c e n s e . t x t )   l i c e n s e s . 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   * / 
 ( f u n c t i o n ( $ )   { 
 $ . f n . e x p a n d A l l   =   f u n c t i o n ( o p t i o n s )   { 
         v a r   d e f a u l t s   =   { 
                   e x p T x t   :   ' [ G o s t e r ] ' , 
                   c l l p s T x t   :   ' [ G i z l e ] ' , 
                   c l l p s E l   :   ' . c o l l a p s e ' ,   / /   t h e   c o l l a p s i b l e   e l e m e n t 
                   t r i g g e r   :   ' . e x p a n d ' ,   / /   t h e   e l e m e n t s   t h a t   c o n t a i n   t h e   t r i g g e r   o f   t h e   t o g g l e   e f f e c t   o n   t h e   i n d i v i d u a l   c o l l a p s i b l e   s e c t i o n s 
                   r e f   :   ' . e x p a n d ' ,   / /   t h e   s w i t c h   ' E x p a n d   A l l / C o l l a p s e   A l l '   i s   i n s e r t e d   b e f o r e   t h e   ' r e f ' 
                   s h o w M e t h o d   :   ' s h o w ' , 
                   h i d e M e t h o d   :   ' h i d e ' , 
                   s t a t e   :   ' h i d d e n ' ,   / /   t h e   c o l l a p s i b l e   e l e m e n t s   a r e   h i d d e n   b y   d e f a u l t 
                   s p e e d   :   0 
         } ; 
         v a r   o   =   $ . e x t e n d ( { } ,   d e f a u l t s ,   o p t i o n s ) ;       
         
         v a r   t o g g l e T x t   =   o . e x p T x t ; 
         i f   ( o . s t a t e   = =   ' h i d d e n ' )   { $ ( t h i s ) . f i n d ( o . c l l p s E l ) . h i d e ( ) ; }   e l s e   { t o g g l e T x t   =   o . c l l p s T x t ; } 
         
         r e t u r n   t h i s . e a c h ( f u n c t i o n ( i n d e x )   { 
                 v a r   c o n t a i n e r ; 
                 i f   ( t h i s . i d . l e n g t h )   { 
                     c o n t a i n e r   =   ' # '   +   t h i s . i d ; 
                 }   e l s e   i f   ( t h i s . c l a s s N a m e . l e n g t h ) { 
                     c o n t a i n e r   =   t h i s . t a g N a m e . t o L o w e r C a s e ( )   +   ' . '   +   t h i s . c l a s s N a m e . s p l i t ( '   ' ) . j o i n ( ' . ' ) ; 
                 }   e l s e   { c o n t a i n e r   =   t h i s . t a g N a m e . t o L o w e r C a s e ( ) ; } 
                 
                 $ ( t h i s ) . f i n d ( o . r e f   +   ' : f i r s t ' ) . b e f o r e ( ' < p   c l a s s = " s w i t c h " > < a   h r e f = " # " > '   +   t o g g l e T x t   +   ' < / a > < / p > ' ) ; 
                 $ ( t h i s ) . f i n d ( ' p . s w i t c h   a ' ) . c l i c k ( f u n c t i o n ( )   { 
                 v a r   $ c l l p s   =   $ ( t h i s ) . c l o s e s t ( c o n t a i n e r ) . f i n d ( o . c l l p s E l ) , 
                         $ t r   =   $ ( t h i s ) . c l o s e s t ( c o n t a i n e r ) . f i n d ( o . t r i g g e r   +   '   >   a ' ) ; 
                 i f   ( $ ( t h i s ) . t e x t ( )   = =   o . e x p T x t )   { 
                     $ ( t h i s ) . t e x t ( o . c l l p s T x t ) ; 
                     $ t r . a d d C l a s s ( ' o p e n ' ) ; 
                     $ c l l p s [ o . s h o w M e t h o d ] ( o . s p e e d ) ; 
                 }   e l s e   { 
                     $ ( t h i s ) . t e x t ( o . e x p T x t ) ; 
                     $ t r . r e m o v e C l a s s ( ' o p e n ' ) ; 
                     $ c l l p s [ o . h i d e M e t h o d ] ( o . s p e e d ) ; 
                 } 
                 r e t u r n   f a l s e ; 
         } ) ; 
 } ) ; } ; 
 / *   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 T o g g l e r 
 h t t p : / / a d i p a l a z . a w a r d s p a c e . c o m / e x p e r i m e n t s / j q u e r y / e x p a n d . h t m l 
 W h e n   u s i n g   t h i s   s c r i p t ,   p l e a s e   k e e p   t h e   a b o v e   u r l   i n t a c t . 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   * / 
 $ . f n . t o g g l e r   =   f u n c t i o n ( o p t i o n s )   { 
         v a r   d e f a u l t s   =   { 
                   c l l p s E l   :   ' d i v . c o l l a p s e ' , 
                   m e t h o d   :   ' s l i d e T o g g l e ' , 
                   s p e e d   :   ' s l o w ' , 
                   c o n t a i n e r   :   ' ' ,   / / t h e   c o m m o n   c o n t a i n e r   o f   a l l   g r o u p s   w i t h   c o l l a p s i b l e   c o n t e n t   ( o p t i o n a l ) 
                   i n i t S h o w   :   ' . s h o w n '   / / t h e   i n i t i a l l y   e x p a n d e d   s e c t i o n s   ( o p t i o n a l ) 
         } ; 
         v a r   o   =   $ . e x t e n d ( { } ,   d e f a u l t s ,   o p t i o n s ) ; 
         
         $ ( t h i s ) . w r a p I n n e r ( ' < a   s t y l e = " d i s p l a y : b l o c k "   h r e f = " # "   t i t l e = " E x p a n d / C o l l a p s e "   / > ' ) ; 
         r e t u r n   t h i s . e a c h ( f u n c t i o n ( )   { 
             v a r   c o n t a i n e r ; 
             ( o . c o n t a i n e r )   ?   c o n t a i n e r   =   o . c o n t a i n e r   :   c o n t a i n e r   =   ' d i v ' ; 
             i f   ( o . i n i t S h o w )   { 
                 $ ( t h i s ) . c l o s e s t ( c o n t a i n e r ) . f i n d ( o . i n i t S h o w ) . s h o w ( ) . p r e v ( ) . f i n d ( ' a ' ) . a d d C l a s s ( ' o p e n ' ) ; 
             } 
             $ ( t h i s ) . c l i c k ( f u n c t i o n ( )   { 
                     $ ( t h i s ) . f i n d ( ' a ' ) . t o g g l e C l a s s ( ' o p e n ' ) . e n d ( ) 
                     . n e x t ( o . c l l p s E l ) [ o . m e t h o d ] ( o . s p e e d ) ; 
                     r e t u r n   f a l s e ; 
         } ) ; 
 } ) ; } ; 
 $ . f n . t o g g l e H e i g h t   =   f u n c t i o n ( s p e e d ,   e a s i n g ,   c a l l b a c k )   { 
         r e t u r n   t h i s . a n i m a t e ( { h e i g h t :   ' t o g g l e ' } ,   s p e e d ,   e a s i n g ,   c a l l b a c k ) ; 
 } ; 
 / / h t t p : / / w w w . l e a r n i n g j q u e r y . c o m / 2 0 0 8 / 0 2 / s i m p l e - e f f e c t s - p l u g i n s : 
 $ . f n . f a d e T o g g l e   =   f u n c t i o n ( s p e e d ,   e a s i n g ,   c a l l b a c k )   { 
         r e t u r n   t h i s . a n i m a t e ( { o p a c i t y :   ' t o g g l e ' } ,   s p e e d ,   e a s i n g ,   c a l l b a c k ) ; 
 } ; 
 $ . f n . s l i d e F a d e T o g g l e   =   f u n c t i o n ( s p e e d ,   e a s i n g ,   c a l l b a c k )   { 
         r e t u r n   t h i s . a n i m a t e ( { o p a c i t y :   ' t o g g l e ' ,   h e i g h t :   ' t o g g l e ' } ,   s p e e d ,   e a s i n g ,   c a l l b a c k ) ; 
 } ; 
 } ) ( j Q u e r y ) ; 
 / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
 / *   - - - 
 S a m p l e   u s a g e : 
 $ ( f u n c t i o n ( )   { 
         $ ( " # c o n t a i n e r " ) . e x p a n d A l l ( { s h o w M e t h o d :   " s l i d e D o w n " ,   h i d e M e t h o d :   " s l i d e U p " ,   s p e e d :   4 0 0 } ) ; 
         / / C a l l   t o g g l e r ( )   w i t h   t h e   d e f a u l t   o p t i o n s .   I f   w e   a d d   c l a s s = " s h o w n "   t o   s o m e   o f   t h e   c o l l a p s i b l e   e l e m e n t s ,   t h e y   w i l l   b e   e x p a n d e d   o n   p a g e   l o a d : 
         $ ( " # c o n t a i n e r     h 4 . e x p a n d " ) . t o g g l e r ( ) ; 
 } ) ; 
 S a m p l e   m a r k u p : 
 < d i v   i d = " c o n t a i n e r > 
     < h 4   c l a s s = " e x p a n d " > T i t l e   1 < / h 4 > 
     < d i v   c l a s s = " c o l l a p s e   s h o w n " > . . . < / d i v > 
     < h 4   c l a s s = " e x p a n d " > T i t l e   2 < / h 4 > 
     < d i v   c l a s s = " c o l l a p s e " > . . . < / d i v > 
 < / d i v > 
 
 - - -   * / 
 
