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