Commits

speixoto  committed 9cf09ec

Hides the notification window when clicking outside it

  • Participants
  • Parent commits b0690ce

Comments (0)

Files changed (1)

File app/protected/modules/zurmo/views/HeaderLinksView.php

                                     array('id' => 'notifications-flyout', 'style' => 'display:none;'),
                                     CHtml::image($imageSourceUrl, Yii::t('Default', 'Loading')), 'div');
             Yii::app()->clientScript->registerScript('notificationPopupLinkScript', "
+                //Hides the container on click outside it
+                $(document).mouseup(function (e)
+                {          
+                    var container = $('#notifications-flyout');                    
+                    if (container.has(e.target).length === 0)
+                    {
+                        container.hide();
+                    }
+                });
                 $('#notifications-flyout-link').unbind('click');
                 $('#notifications-flyout-link').bind('click', function()
                 {
                     if ($('#notifications-flyout').css('display') == 'none')
                     {
-                        $('#notifications-flyout').show();
+                        $('#notifications-flyout').show();                       
                         $.ajax({
                             url 	 : '" . $this->notificationsUrl . "',
                             type     : 'GET',
                                 jQuery('#notifications-flyout').html(html);
                             }
                         });
-                    }
-                    else
-                    {
-                        $('#notifications-flyout').hide();
-                    }
-                });
+                    }                    
+                });                
             ", CClientScript::POS_END);
             Yii::app()->clientScript->registerScript('deleteNotificationFromAjaxListViewScript', "
                 function deleteNotificationFromAjaxListView(element, modelId)