Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

/** 
  * Author                      : Raj Kumar Bharti
  * Creation Date       : 06 Dec 2010
  * Project             : Shop2020
  * Copyright 2010 Evon Technologies
*/


$(document).ready(function(){
        notificationLen = 0;
        screenCount     = 0;
        closeClickCount = 0;
        
        // Count Notification length
        notificationLen = $("#notification .notificationContent").length;
        
        // Count notification screens
        for(var i=1; i<=notificationLen; i += 3){
                screenCount++;
        }
        
        if(notificationLen > 0){
                
                // Show notification
                showNotification();
                        
                // Event for notification close
                $('#notificationClose').click(function(){
                                                                                           
                        closeClickCount++;
                        
                        if(notificationLen <= 3){
                                $('#notification').fadeOut("fast");
                                closeClickCount = 0;
                                
                        }else if(closeClickCount < screenCount){
                                
                                // Reset all notification visible state to hidden
                                $("#notification .notificationContent:eq(0)").hide();
                                $("#notification .notificationContent:gt(0)").hide();                           
                                $("#notification .notificationContent:eq(0) .borderBottom").hide();
                                $("#notification .notificationContent:gt(0) .borderBottom").hide();
                                
                                // Visible current screen notification
                                $("#notification .notificationContent:gt(" + (closeClickCount*3 - 1) + ")").fadeIn("fast");
                                $("#notification .notificationContent:gt(" + (closeClickCount*3 - 1) + ") .borderBottom").fadeIn("fast");
                                $("#notification .notificationContent:eq(" + ((closeClickCount + 1)*3 - 1) + ") .borderBottom").hide();
                                
                                // Hide next screen notification
                                $("#notification .notificationContent:gt(" + ((closeClickCount + 1)*3 - 1) + ")").hide();
                                $("#notification .notificationContent:last .borderBottom").hide();      
                        }else{
                                
                                $('#notification').fadeOut("fast");
                                closeClickCount = 0;
                        }
                });     
        }
        
});

/*
 * Show Notification
*/
function showNotification(){
        if(notificationLen > 0){
                resetNotification();
                
                $("#notification .notificationContent:gt(2)").hide();   // Hide notifications greater than 3
        
                if(notificationLen > 3){
                        // Make 3rd notifictaion of 1st screen bottom border hidden
                        $("#notification .notificationContent:eq(2) .borderBottom").hide();     
                }else{
                        // Make last notifictaion of 1st screen bottom border hidden
                        $("#notification .notificationContent:last .borderBottom").hide();      
                }
                
                // Show notification container
                $('#notification').fadeIn("fast");
                
                closeClickCount = 0;
        }
}

/*
 * Reset Notification
*/
function resetNotification(){
        // Reset all notification and bottom border visible state to visible that were hidden earlier
        
        $("#notification .notificationContent:eq(0)").show();
        $("#notification .notificationContent:gt(0)").show();
        
        $("#notification .notificationContent:eq(0) .borderBottom").show();
        $("#notification .notificationContent:gt(0) .borderBottom").show();
}