ÿþ/ *   S t i c k y   T o o l t i p   s c r i p t   ( v 1 . 0 )  
 *   C r e a t e d :   N o v   2 5 t h ,   2 0 0 9 .   T h i s   n o t i c e   m u s t   s t a y   i n t a c t   f o r   u s a g e    
 *   A u t h o r :   D y n a m i c   D r i v e   a t   h t t p : / / w w w . d y n a m i c d r i v e . c o m /  
 *   V i s i t   h t t p : / / w w w . d y n a m i c d r i v e . c o m /   f o r   f u l l   s o u r c e   c o d e  
 * /  
  
  
 v a r   s t i c k y t o o l t i p = {  
 	 t o o l t i p o f f s e t s :   [ 2 0 ,   - 3 0 ] ,   / / a d d i t i o n a l   x   a n d   y   o f f s e t   f r o m   m o u s e   c u r s o r   f o r   t o o l t i p s  
 	 f a d e i n s p e e d :   2 0 0 ,   / / d u r a t i o n   o f   f a d e   e f f e c t   i n   m i l l i s e c o n d s  
 	 r i g h t c l i c k s t i c k :   t r u e ,   / / s t i c k y   t o o l t i p   w h e n   u s e r   r i g h t   c l i c k s   o v e r   t h e   t r i g g e r i n g   e l e m e n t   ( a p a r t   f r o m   p r e s s i n g   " s "   k e y )   ?  
 	 s t i c k y b o r d e r c o l o r s :   [ " b l a c k " ,   " d a r k r e d " ] ,   / / b o r d e r   c o l o r   o f   t o o l t i p   d e p e n d i n g   o n   s t i c k y   s t a t e  
 	 s t i c k y n o t i c e 1 :   [ " 9Ì/  (1" ,   " 4E'" ,   " E('1©" ] ,   / / c u s t o m i z e   t o o l t i p   s t a t u s   m e s s a g e  
 	 s t i c k y n o t i c e 2 :   " C l i c k   o u t s i d e   t h i s   b o x   t o   h i d e   i t " ,   / / c u s t o m i z e   t o o l t i p   s t a t u s   m e s s a g e  
  
 	 / / * * * * *   N O   N E E D   T O   E D I T   B E Y O N D   H E R E  
  
 	 i s d o c k e d :   f a l s e ,  
  
 	 p o s i t i o n t o o l t i p : f u n c t i o n ( $ ,   $ t o o l t i p ,   e ) {  
 	 	 v a r   x = e . p a g e X + t h i s . t o o l t i p o f f s e t s [ 0 ] ,   y = e . p a g e Y + t h i s . t o o l t i p o f f s e t s [ 1 ]  
 	 	 v a r   t i p w = $ t o o l t i p . o u t e r W i d t h ( ) ,   t i p h = $ t o o l t i p . o u t e r H e i g h t ( ) ,    
 	 	 x = ( x + t i p w > $ ( d o c u m e n t ) . s c r o l l L e f t ( ) + $ ( w i n d o w ) . w i d t h ( ) ) ?   x - t i p w - ( s t i c k y t o o l t i p . t o o l t i p o f f s e t s [ 0 ] * 2 )   :   x  
 	 	 y = ( y + t i p h > $ ( d o c u m e n t ) . s c r o l l T o p ( ) + $ ( w i n d o w ) . h e i g h t ( ) ) ?   $ ( d o c u m e n t ) . s c r o l l T o p ( ) + $ ( w i n d o w ) . h e i g h t ( ) - t i p h - 1 0   :   y  
 	 	 $ t o o l t i p . c s s ( { l e f t : x ,   t o p : y } )  
 	 } ,  
 	  
 	 s h o w b o x : f u n c t i o n ( $ ,   $ t o o l t i p ,   e ) {  
 	 	 $ t o o l t i p . f a d e I n ( t h i s . f a d e i n s p e e d )  
 	 	 t h i s . p o s i t i o n t o o l t i p ( $ ,   $ t o o l t i p ,   e )  
 	 } ,  
  
 	 h i d e b o x : f u n c t i o n ( $ ,   $ t o o l t i p ) {  
 	 	 i f   ( ! t h i s . i s d o c k e d ) {  
 	 	 	 $ t o o l t i p . s t o p ( f a l s e ,   t r u e ) . h i d e ( )  
 	 	 	 $ t o o l t i p . c s s ( { b o r d e r C o l o r : ' b l a c k ' } ) . f i n d ( ' . s t i c k y s t a t u s : e q ( 0 ) ' ) . c s s ( { b a c k g r o u n d : t h i s . s t i c k y b o r d e r c o l o r s [ 0 ] } ) . h t m l ( t h i s . s t i c k y n o t i c e 1 )  
 	 	 }  
 	 } ,  
  
 	 d o c k t o o l t i p : f u n c t i o n ( $ ,   $ t o o l t i p ,   e ) {  
 	 	 t h i s . i s d o c k e d = t r u e  
 	 	 $ t o o l t i p . c s s ( { b o r d e r C o l o r : ' d a r k r e d ' } ) . f i n d ( ' . s t i c k y s t a t u s : e q ( 0 ) ' ) . c s s ( { b a c k g r o u n d : t h i s . s t i c k y b o r d e r c o l o r s [ 1 ] } ) . h t m l ( t h i s . s t i c k y n o t i c e 2 )  
 	 } ,  
  
  
 	 i n i t : f u n c t i o n ( t a r g e t s e l e c t o r ,   t i p i d ) {  
 	 	 j Q u e r y ( d o c u m e n t ) . r e a d y ( f u n c t i o n ( $ ) {  
 	 	 	 v a r   $ t a r g e t s = $ ( t a r g e t s e l e c t o r )  
 	 	 	 v a r   $ t o o l t i p = $ ( ' # ' + t i p i d ) . a p p e n d T o ( d o c u m e n t . b o d y )  
 	 	 	 i f   ( $ t a r g e t s . l e n g t h = = 0 )  
 	 	 	 	 r e t u r n  
 	 	 	 v a r   $ a l l t i p s = $ t o o l t i p . f i n d ( ' d i v . a t i p ' )  
 	 	 	 i f   ( ! s t i c k y t o o l t i p . r i g h t c l i c k s t i c k )  
 	 	 	 	 s t i c k y t o o l t i p . s t i c k y n o t i c e 1 [ 1 ] = ' '  
 	 	 	 s t i c k y t o o l t i p . s t i c k y n o t i c e 1 = s t i c k y t o o l t i p . s t i c k y n o t i c e 1 . j o i n ( '   ' )  
 	 	 	 s t i c k y t o o l t i p . h i d e b o x ( $ ,   $ t o o l t i p )  
 	 	 	 $ t a r g e t s . b i n d ( ' m o u s e e n t e r ' ,   f u n c t i o n ( e ) {  
 	 	 	 	 $ a l l t i p s . h i d e ( ) . f i l t e r ( ' # ' + $ ( t h i s ) . a t t r ( ' d a t a - t o o l t i p ' ) ) . s h o w ( )  
 	 	 	 	 s t i c k y t o o l t i p . s h o w b o x ( $ ,   $ t o o l t i p ,   e )  
 	 	 	 } )  
 	 	 	 $ t a r g e t s . b i n d ( ' m o u s e l e a v e ' ,   f u n c t i o n ( e ) {  
 	 	 	 	 s t i c k y t o o l t i p . h i d e b o x ( $ ,   $ t o o l t i p )  
 	 	 	 } )  
 	 	 	 $ t a r g e t s . b i n d ( ' m o u s e m o v e ' ,   f u n c t i o n ( e ) {  
 	 	 	 	 i f   ( ! s t i c k y t o o l t i p . i s d o c k e d ) {  
 	 	 	 	 	 s t i c k y t o o l t i p . p o s i t i o n t o o l t i p ( $ ,   $ t o o l t i p ,   e )  
 	 	 	 	 }  
 	 	 	 } )  
 	 	 	 $ t o o l t i p . b i n d ( " m o u s e e n t e r " ,   f u n c t i o n ( ) {  
 	 	 	 	 s t i c k y t o o l t i p . h i d e b o x ( $ ,   $ t o o l t i p )  
 	 	 	 } )  
 	 	 	 $ t o o l t i p . b i n d ( " c l i c k " ,   f u n c t i o n ( e ) {  
 	 	 	 	 e . s t o p P r o p a g a t i o n ( )  
 	 	 	 } )  
 	 	 	 $ ( t h i s ) . b i n d ( " c l i c k " ,   f u n c t i o n ( e ) {  
 	 	 	 	 i f   ( e . b u t t o n = = 0 ) {  
 	 	 	 	 	 s t i c k y t o o l t i p . i s d o c k e d = f a l s e  
 	 	 	 	 	 s t i c k y t o o l t i p . h i d e b o x ( $ ,   $ t o o l t i p )  
 	 	 	 	 }  
 	 	 	 } )  
 	 	 	 $ ( t h i s ) . b i n d ( " c o n t e x t m e n u " ,   f u n c t i o n ( e ) {  
 	 	 	 	 i f   ( s t i c k y t o o l t i p . r i g h t c l i c k s t i c k   & &   $ ( e . t a r g e t ) . p a r e n t s ( ) . a n d S e l f ( ) . f i l t e r ( t a r g e t s e l e c t o r ) . l e n g t h = = 1 ) {   / / i f   o n c o n t e x t m e n u   o v e r   a   t a r g e t   e l e m e n t  
 	 	 	 	 	 s t i c k y t o o l t i p . d o c k t o o l t i p ( $ ,   $ t o o l t i p ,   e )  
 	 	 	 	 	 r e t u r n   f a l s e  
 	 	 	 	 }  
 	 	 	 } )  
 	 	 	 $ ( t h i s ) . b i n d ( ' k e y p r e s s ' ,   f u n c t i o n ( e ) {  
 	 	 	 	 v a r   k e y u n i c o d e = e . c h a r C o d e   | |   e . k e y C o d e  
 	 	 	 	 i f   ( k e y u n i c o d e = = 1 1 5 ) {   / / i f   " s "   k e y   w a s   p r e s s e d  
 	 	 	 	 	 s t i c k y t o o l t i p . d o c k t o o l t i p ( $ ,   $ t o o l t i p ,   e )  
 	 	 	 	 }  
 	 	 	 } )  
 	 	 } )   / / e n d   d o m   r e a d y  
 	 }  
 }  
  
 / / s t i c k y t o o l t i p . i n i t ( " t a r g e t E l e m e n t S e l e c t o r " ,   " t o o l t i p c o n t a i n e r " )  
 s t i c k y t o o l t i p . i n i t ( " * [ d a t a - t o o l t i p ] " ,   " m y s t i c k y t o o l t i p " ) 
