ÿþ/ /   j Q u e r y   A l e r t   D i a l o g s   P l u g i n  
 / /  
 / /   V e r s i o n   1 . 1  
 / /  
 / /   C o r y   S . N .   L a V i s k a  
 / /   A   B e a u t i f u l   S i t e   ( h t t p : / / a b e a u t i f u l s i t e . n e t / )  
 / /   1 4   M a y   2 0 0 9  
 / /  
 / /   V i s i t   h t t p : / / a b e a u t i f u l s i t e . n e t / n o t e b o o k / 8 7   f o r   m o r e   i n f o r m a t i o n  
 / /  
 / /   U s a g e :  
 / / 	 	 j A l e r t (   m e s s a g e ,   [ t i t l e ,   c a l l b a c k ]   )  
 / / 	 	 j C o n f i r m (   m e s s a g e ,   [ t i t l e ,   c a l l b a c k ]   )  
 / / 	 	 j P r o m p t (   m e s s a g e ,   [ v a l u e ,   t i t l e ,   c a l l b a c k ]   )  
 / /    
 / /   H i s t o r y :  
 / /  
 / / 	 	 1 . 0 0   -   R e l e a s e d   ( 2 9   D e c e m b e r   2 0 0 8 )  
 / /  
 / / 	 	 1 . 0 1   -   F i x e d   b u g   w h e r e   u n b i n d i n g   w o u l d   d e s t r o y   a l l   r e s i z e   e v e n t s  
 / /  
 / /   L i c e n s e :  
 / /    
 / /   T h i s   p l u g i n   i s   d u a l - l i c e n s e d   u n d e r   t h e   G N U   G e n e r a l   P u b l i c   L i c e n s e   a n d   t h e   M I T   L i c e n s e   a n d  
 / /   i s   c o p y r i g h t   2 0 0 8   A   B e a u t i f u l   S i t e ,   L L C .    
 / /  
 ( f u n c t i o n ( $ )   {  
  
         $ . a l e r t s   =   {  
  
                 / /   T h e s e   p r o p e r t i e s   c a n   b e   r e a d / w r i t t e n   b y   a c c e s s i n g   $ . a l e r t s . p r o p e r t y N a m e   f r o m   y o u r   s c r i p t s   a t   a n y   t i m e  
  
                 v e r t i c a l O f f s e t :   - 7 5 ,                                 / /   v e r t i c a l   o f f s e t   o f   t h e   d i a l o g   f r o m   c e n t e r   s c r e e n ,   i n   p i x e l s  
                 h o r i z o n t a l O f f s e t :   0 ,                                 / /   h o r i z o n t a l   o f f s e t   o f   t h e   d i a l o g   f r o m   c e n t e r   s c r e e n ,   i n   p i x e l s /  
                 r e p o s i t i o n O n R e s i z e :   t r u e ,                       / /   r e - c e n t e r s   t h e   d i a l o g   o n   w i n d o w   r e s i z e  
                 o v e r l a y O p a c i t y :   . 8 ,                                 / /   t r a n s p a r e n c y   l e v e l   o f   o v e r l a y  
                 o v e r l a y C o l o r :   ' # f f f ' ,                               / /   b a s e   c o l o r   o f   o v e r l a y  
                 d r a g g a b l e :   t r u e ,                                         / /   m a k e   t h e   d i a l o g s   d r a g g a b l e   ( r e q u i r e s   U I   D r a g g a b l e s   p l u g i n )  
                 o k B u t t o n :   ' & n b s p ; Ón g   ý & n b s p ; ' ,                   / /   t e x t   f o r   t h e   O K   b u t t o n  
                 c a n c e l B u t t o n :   ' & n b s p ; ó n g   l ¡i & n b s p ; ' ,   / /   t e x t   f o r   t h e   C a n c e l   b u t t o n  
                 d i a l o g C l a s s :   n u l l ,                                     / /   i f   s p e c i f i e d ,   t h i s   c l a s s   w i l l   b e   a p p l i e d   t o   a l l   d i a l o g s  
                 i n p u t w i d t h :   5 0 0 ,  
                 / /   P u b l i c   m e t h o d s  
  
                 a l e r t :   f u n c t i o n ( m e s s a g e ,   t i t l e ,   x w i d t h ,   c a l l b a c k )   {  
                         i f   ( t i t l e   = =   n u l l )   t i t l e   =   ' A l e r t ' ;  
                         i f   ( x w i d t h   ! =   n u l l )   $ . a l e r t s . i n p u t w i d t h   =   x w i d t h ;  
                         $ . a l e r t s . _ s h o w ( t i t l e ,   m e s s a g e ,   n u l l ,   ' a l e r t ' ,   f u n c t i o n ( r e s u l t )   {  
                                 i f   ( c a l l b a c k )   c a l l b a c k ( r e s u l t ) ;  
                         } ) ;  
                 } ,  
  
                 c o n f i r m :   f u n c t i o n ( m e s s a g e ,   t i t l e ,   c a l l b a c k )   {  
                         i f   ( t i t l e   = =   n u l l )   t i t l e   =   ' C o n f i r m ' ;  
                         $ . a l e r t s . _ s h o w ( t i t l e ,   m e s s a g e ,   n u l l ,   ' c o n f i r m ' ,   f u n c t i o n ( r e s u l t )   {  
                                 i f   ( c a l l b a c k )   c a l l b a c k ( r e s u l t ) ;  
                         } ) ;  
                 } ,  
  
                 p r o m p t :   f u n c t i o n ( m e s s a g e ,   v a l u e ,   t i t l e ,   c a l l b a c k )   {  
                         i f   ( t i t l e   = =   n u l l )   t i t l e   =   ' P r o m p t ' ;  
                         $ . a l e r t s . _ s h o w ( t i t l e ,   m e s s a g e ,   v a l u e ,   ' p r o m p t ' ,   f u n c t i o n ( r e s u l t )   {  
                                 i f   ( c a l l b a c k )   c a l l b a c k ( r e s u l t ) ;  
                         } ) ;  
                 } ,  
  
                 / /   P r i v a t e   m e t h o d s  
  
                 _ s h o w :   f u n c t i o n ( t i t l e ,   m s g ,   v a l u e ,   t y p e ,   c a l l b a c k )   {  
  
                         $ . a l e r t s . _ h i d e ( ) ;  
                         $ . a l e r t s . _ o v e r l a y ( ' s h o w ' ) ;  
  
                         $ ( " B O D Y " ) . a p p e n d (  
 	 	 	     ' < d i v   i d = " p o p u p _ c o n t a i n e r " > '   +  
 	 	 	         ' < d i v   c l a s s = " u i - d i a l o g - t i t l e b a r " > '   +  
 	 	 	         ' < h 1   i d = " p o p u p _ t i t l e " > < / h 1 > < a   h r e f = " j a v a s c r i p t : v o i d ( 0 ) "   o n c l i c k = " $ . a l e r t s . _ h i d e ( ) ; "   c l a s s = " u i - d i a l o g - t i t l e b a r - c l o s e   u i - c o r n e r - a l l "   r o l e = " b u t t o n "   u n s e l e c t a b l e = " o n "   s t y l e = " - m o z - u s e r - s e l e c t :   n o n e ; " > < s p a n   c l a s s = " u i - i c o n   u i - i c o n - c l o s e t h i c k "   u n s e l e c t a b l e = " o n "   s t y l e = " - m o z - u s e r - s e l e c t :   n o n e ; " > c l o s e < / s p a n > < / a > < / d i v > '   +  
 	 	 	         ' < d i v   i d = " p o p u p _ c o n t e n t " > '   +  
 	 	 	             ' < d i v   i d = " p o p u p _ m e s s a g e " > < / d i v > '   +  
 	 	 	 	 ' < / d i v > '   +  
 	 	 	     ' < / d i v > ' ) ;  
  
                         i f   ( $ . a l e r t s . d i a l o g C l a s s )   $ ( " # p o p u p _ c o n t a i n e r " ) . a d d C l a s s ( $ . a l e r t s . d i a l o g C l a s s ) ;  
  
                         / /   I E 6   F i x  
                         v a r   p o s   =   ( $ . b r o w s e r . m s i e   & &   p a r s e I n t ( $ . b r o w s e r . v e r s i o n )   < =   6 )   ?   ' a b s o l u t e '   :   ' f i x e d ' ;  
  
                         $ ( " # p o p u p _ c o n t a i n e r " ) . c s s ( {  
                                 p o s i t i o n :   p o s ,  
                                 z I n d e x :   9 9 9 9 9 ,  
                                 p a d d i n g :   0 ,  
                                 m a r g i n :   0  
                         } ) ;  
  
                         $ ( " # p o p u p _ t i t l e " ) . t e x t ( t i t l e ) ;  
                         $ ( " # p o p u p _ c o n t e n t " ) . a d d C l a s s ( t y p e ) ;  
                         $ ( " # p o p u p _ m e s s a g e " ) . t e x t ( m s g ) ;  
                         $ ( " # p o p u p _ m e s s a g e " ) . h t m l ( $ ( " # p o p u p _ m e s s a g e " ) . t e x t ( ) . r e p l a c e ( / \ n / g ,   ' < b r   / > ' ) ) ;  
  
                         / / 	 	 	 $ ( " # p o p u p _ c o n t a i n e r " ) . c s s ( {  
                         / / 	 	 	 	 m i n W i d t h :   $ ( " # p o p u p _ c o n t a i n e r " ) . o u t e r W i d t h ( ) ,  
                         / / 	 	 	 	 m a x W i d t h :   $ ( " # p o p u p _ c o n t a i n e r " ) . o u t e r W i d t h ( )  
                         / / 	 	 	 } ) ;  
  
  
                         $ . a l e r t s . _ r e p o s i t i o n ( ) ;  
                         $ . a l e r t s . _ m a i n t a i n P o s i t i o n ( t r u e ) ;  
  
                         s w i t c h   ( t y p e )   {  
                                 c a s e   ' a l e r t ' :  
  
                                         $ ( " # p o p u p _ m e s s a g e " ) . a f t e r ( ' < d i v   i d = " p o p u p _ p a n e l " > < b u t t o n   c l a s s = " u i - b t - f "   t y p e = " b u t t o n "     v a l u e = " '   +   $ . a l e r t s . o k B u t t o n   +   ' "   i d = " p o p u p _ o k " > < d i v   i d = " u i - b t - f 0 " > < d i v   c l a s s = " u i - b t - b g - f   u i - b t - c e n t e r - b g - f   u i - b t - c e n t e r - b g - g r a y " > < s p a n > ó n g < / s p a n > < / d i v > < / d i v > < / b u t t o n > < / d i v > ' ) ;  
                                         $ ( " # p o p u p _ o k " ) . c l i c k ( f u n c t i o n ( )   {  
                                                 $ . a l e r t s . _ h i d e ( ) ;  
                                                 c a l l b a c k ( t r u e ) ;  
                                         } ) ;  
                                         $ ( " # p o p u p _ o k " ) . f o c u s ( ) . k e y p r e s s ( f u n c t i o n ( e )   {  
                                                 i f   ( e . k e y C o d e   = =   1 3   | |   e . k e y C o d e   = =   2 7 )   $ ( " # p o p u p _ o k " ) . t r i g g e r ( ' c l i c k ' ) ;  
                                         } ) ;  
                                         b r e a k ;  
                                 c a s e   ' c o n f i r m ' :  
                                         $ ( " # p o p u p _ m e s s a g e " ) . a f t e r ( ' < d i v   i d = " p o p u p _ p a n e l " > < b u t t o n   c l a s s = " u i - b t - f "   t y p e = " b u t t o n "     v a l u e = " '   +   $ . a l e r t s . c a n c e l B u t t o n   +   ' "   i d = " p o p u p _ c a n c e l " > < d i v   i d = " u i - b t - f 0 " > < d i v   c l a s s = " u i - b t - b g - f   u i - b t - c e n t e r - b g - f   u i - b t - c e n t e r - b g - g r a y " > < s p a n > B Ï  q u a < / s p a n > < / d i v > < / d i v > < / b u t t o n > < b u t t o n   c l a s s = " u i - b t - f "   t y p e = " b u t t o n "   v a l u e = " '   +   $ . a l e r t s . o k B u t t o n   +   ' "   i d = " p o p u p _ o k " > < d i v   i d = " u i - b t - f 1 " > < d i v   c l a s s = " u i - b t - b g - f   u i - b t - c e n t e r - b g - f " > < s p a n > Ón g   ý < / s p a n > < / d i v > < / d i v > < / b u t t o n > < / d i v > ' ) ;  
                                         $ ( " # p o p u p _ o k " ) . c l i c k ( f u n c t i o n ( )   {  
                                                 $ . a l e r t s . _ h i d e ( ) ;  
                                                 i f   ( c a l l b a c k )   c a l l b a c k ( t r u e ) ;  
                                         } ) ;  
                                         $ ( " # p o p u p _ c a n c e l " ) . c l i c k ( f u n c t i o n ( )   {  
                                                 $ . a l e r t s . _ h i d e ( ) ;  
                                                 i f   ( c a l l b a c k )   c a l l b a c k ( f a l s e ) ;  
                                         } ) ;  
                                         $ ( " # p o p u p _ o k " ) . f o c u s ( ) ;  
                                         $ ( " # p o p u p _ o k ,   # p o p u p _ c a n c e l " ) . k e y p r e s s ( f u n c t i o n ( e )   {  
                                                 i f   ( e . k e y C o d e   = =   1 3 )   $ ( " # p o p u p _ o k " ) . t r i g g e r ( ' c l i c k ' ) ;  
                                                 i f   ( e . k e y C o d e   = =   2 7 )   $ ( " # p o p u p _ c a n c e l " ) . t r i g g e r ( ' c l i c k ' ) ;  
                                         } ) ;  
                                         b r e a k ;  
                                 c a s e   ' p r o m p t ' :  
                                         $ ( " # p o p u p _ m e s s a g e " ) . a p p e n d ( ' < b r   / > < i n p u t   t y p e = " t e x t "   s i z e = " 3 0 "   i d = " p o p u p _ p r o m p t "   / > ' ) . a f t e r ( ' < d i v   i d = " p o p u p _ p a n e l " > < b u t t o n   c l a s s = " u i - b t - f "   t y p e = " b u t t o n "     v a l u e = " '   +   $ . a l e r t s . c a n c e l B u t t o n   +   ' "   i d = " p o p u p _ c a n c e l " > < d i v   i d = " u i - b t - f 0 " > < d i v   c l a s s = " u i - b t - b g - f   u i - b t - c e n t e r - b g - f   u i - b t - c e n t e r - b g - g r a y " > < s p a n > B Ï  q u a < / s p a n > < / d i v > < / d i v > < / b u t t o n > < b u t t o n   c l a s s = " u i - b t - f "   t y p e = " b u t t o n "   v a l u e = " '   +   $ . a l e r t s . o k B u t t o n   +   ' "   i d = " p o p u p _ o k " > < d i v   i d = " u i - b t - f 1 " > < d i v   c l a s s = " u i - b t - b g - f   u i - b t - c e n t e r - b g - f " > < s p a n > Ón g   ý < / s p a n > < / d i v > < / d i v > < / b u t t o n > < / d i v > ' ) ;  
                                         $ ( " # p o p u p _ p r o m p t " ) . w i d t h ( $ ( " # p o p u p _ m e s s a g e " ) . w i d t h ( ) ) ;  
                                         $ ( " # p o p u p _ o k " ) . c l i c k ( f u n c t i o n ( )   {  
                                                 v a r   v a l   =   $ ( " # p o p u p _ p r o m p t " ) . v a l ( ) ;  
                                                 $ . a l e r t s . _ h i d e ( ) ;  
                                                 i f   ( c a l l b a c k )   c a l l b a c k ( v a l ) ;  
                                         } ) ;  
                                         $ ( " # p o p u p _ c a n c e l " ) . c l i c k ( f u n c t i o n ( )   {  
                                                 $ . a l e r t s . _ h i d e ( ) ;  
                                                 i f   ( c a l l b a c k )   c a l l b a c k ( n u l l ) ;  
                                         } ) ;  
                                         $ ( " # p o p u p _ p r o m p t ,   # p o p u p _ o k ,   # p o p u p _ c a n c e l " ) . k e y p r e s s ( f u n c t i o n ( e )   {  
                                                 i f   ( e . k e y C o d e   = =   1 3 )   $ ( " # p o p u p _ o k " ) . t r i g g e r ( ' c l i c k ' ) ;  
                                                 i f   ( e . k e y C o d e   = =   2 7 )   $ ( " # p o p u p _ c a n c e l " ) . t r i g g e r ( ' c l i c k ' ) ;  
                                         } ) ;  
                                         i f   ( v a l u e )   $ ( " # p o p u p _ p r o m p t " ) . v a l ( v a l u e ) ;  
                                         $ ( " # p o p u p _ p r o m p t " ) . f o c u s ( ) . s e l e c t ( ) ;  
                                         b r e a k ;  
                         }  
  
                         / /   M a k e   d r a g g a b l e  
                         i f   ( $ . a l e r t s . d r a g g a b l e )   {  
                                 t r y   {  
                                         $ ( " # p o p u p _ c o n t a i n e r " ) . d r a g g a b l e ( {   h a n d l e :   $ ( " # p o p u p _ t i t l e " )   } ) ;  
                                         $ ( " # p o p u p _ t i t l e " ) . c s s ( {   c u r s o r :   ' m o v e '   } ) ;  
                                 }   c a t c h   ( e )   {   / *   r e q u i r e s   j Q u e r y   U I   d r a g g a b l e s   * /   }  
                         }  
                 } ,  
  
                 _ h i d e :   f u n c t i o n ( )   {  
                         $ ( " # p o p u p _ c o n t a i n e r " ) . r e m o v e ( ) ;  
                         $ . a l e r t s . _ o v e r l a y ( ' h i d e ' ) ;  
                         $ . a l e r t s . _ m a i n t a i n P o s i t i o n ( f a l s e ) ;  
                 } ,  
  
                 _ o v e r l a y :   f u n c t i o n ( s t a t u s )   {  
                         s w i t c h   ( s t a t u s )   {  
                                 c a s e   ' s h o w ' :  
                                         $ . a l e r t s . _ o v e r l a y ( ' h i d e ' ) ;  
                                         $ ( " B O D Y " ) . a p p e n d ( ' < d i v   i d = " p o p u p _ o v e r l a y " > < / d i v > ' ) ;  
                                         $ ( " # p o p u p _ o v e r l a y " ) . c s s ( {  
                                                 p o s i t i o n :   ' a b s o l u t e ' ,  
                                                 z I n d e x :   9 9 9 9 8 ,  
                                                 t o p :   ' 0 p x ' ,  
                                                 l e f t :   ' 0 p x ' ,  
                                                 w i d t h :   ' 1 0 0 % ' ,  
                                                 h e i g h t :   $ ( d o c u m e n t ) . h e i g h t ( ) ,  
                                                 b a c k g r o u n d :   $ . a l e r t s . o v e r l a y C o l o r ,  
                                                 o p a c i t y :   $ . a l e r t s . o v e r l a y O p a c i t y  
                                         } ) ;  
                                         b r e a k ;  
                                 c a s e   ' h i d e ' :  
                                         $ ( " # p o p u p _ o v e r l a y " ) . r e m o v e ( ) ;  
                                         b r e a k ;  
                         }  
                 } ,  
  
                 _ r e p o s i t i o n :   f u n c t i o n ( )   {  
                         v a r   t o p   =   ( ( $ ( w i n d o w ) . h e i g h t ( )   /   2 )   -   ( $ ( " # p o p u p _ c o n t a i n e r " ) . o u t e r H e i g h t ( )   /   2 ) )   +   $ . a l e r t s . v e r t i c a l O f f s e t ;  
                         / / v a r   l e f t   =   ( ( $ ( w i n d o w ) . w i d t h ( )   /   2 )   -   ( $ ( " # p o p u p _ c o n t a i n e r " ) . o u t e r W i d t h ( )   /   2 ) )   +   $ . a l e r t s . h o r i z o n t a l O f f s e t ;  
                         v a r   l e f t   =   ( ( $ ( w i n d o w ) . w i d t h ( )   -   $ . a l e r t s . i n p u t w i d t h )   /   2 ) ;  
                         i f   ( t o p   <   0 )   t o p   =   0 ;  
                         i f   ( l e f t   <   0 )   l e f t   =   0 ;  
  
                         / /   I E 6   f i x  
                         i f   ( $ . b r o w s e r . m s i e   & &   p a r s e I n t ( $ . b r o w s e r . v e r s i o n )   < =   6 )   t o p   =   t o p   +   $ ( w i n d o w ) . s c r o l l T o p ( ) ;  
  
                         $ ( " # p o p u p _ c o n t a i n e r " ) . c s s ( {  
                                 t o p :   t o p   +   ' p x ' ,  
                                 l e f t :   l e f t   +   ' p x '  
                         } ) ;  
                         $ ( " # p o p u p _ o v e r l a y " ) . h e i g h t ( ' 1 8 0 0 p x ' ) ;  
                 } ,  
  
                 _ m a i n t a i n P o s i t i o n :   f u n c t i o n ( s t a t u s )   {  
                         i f   ( $ . a l e r t s . r e p o s i t i o n O n R e s i z e )   {  
                                 s w i t c h   ( s t a t u s )   {  
                                         c a s e   t r u e :  
                                                 $ ( w i n d o w ) . b i n d ( ' r e s i z e ' ,   $ . a l e r t s . _ r e p o s i t i o n ) ;  
                                                 b r e a k ;  
                                         c a s e   f a l s e :  
                                                 $ ( w i n d o w ) . u n b i n d ( ' r e s i z e ' ,   $ . a l e r t s . _ r e p o s i t i o n ) ;  
                                                 b r e a k ;  
                                 }  
                         }  
                 }  
  
         }  
  
         / /   S h o r t u c t   f u n c t i o n s  
         j A l e r t   =   f u n c t i o n ( m e s s a g e ,   t i t l e ,   x w i d t h ,   c a l l b a c k )   {  
                 $ . a l e r t s . a l e r t ( m e s s a g e ,   t i t l e ,   x w i d t h ,   c a l l b a c k ) ;  
         }  
  
         j C o n f i r m   =   f u n c t i o n ( m e s s a g e ,   t i t l e ,   c a l l b a c k )   {  
                 $ . a l e r t s . c o n f i r m ( m e s s a g e ,   t i t l e ,   c a l l b a c k ) ;  
         } ;  
  
         j P r o m p t   =   f u n c t i o n ( m e s s a g e ,   v a l u e ,   t i t l e ,   c a l l b a c k )   {  
                 $ . a l e r t s . p r o m p t ( m e s s a g e ,   v a l u e ,   t i t l e ,   c a l l b a c k ) ;  
         } ;  
  
 } ) ( j Q u e r y ) ; 
