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