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