﻿/// <reference path="SMSCentral.js" />

SMSCentral.UIBlocker = function(selector) {
    
    //private
    var sel = selector; 
    var blocked = false;
    
    //public
    return {
        block : function() {
            if (blocked === true) {
                return;
            }            
            $(sel).block({ // styles for the overlay 
                overlayCSS: {
                    backgroundColor: '#000',
                    opacity: 0.2
                },
                css: {
                    padding: 0,
                    paddingTop: '18px',
                    margin: 0,
                    width: '250px',
                    height: '60px',
                    textAlign: 'center',
                    color: 'transparent',
                    border: '0px',
                    background: 'url("/Skins/Base/Images/background_loading.gif") transparent no-repeat',
                    cursor: 'wait'
                },
                message: "<img src='/Skins/Base/Images/ajax-loader.gif' alt='" + Lang.AjaxMessages.LoadingProgress + "' />",
                // fadeIn time in millis; set to 0 to disable fadeIn on block 
                fadeIn: 10,
                // fadeOut time in millis; set to 0 to disable fadeOut on unblock 
                fadeOut: 10,
                // z-index for the blocking overlay 
                baseZ: 300
            });
            blocked = true;
        },
    
        unblock : function() {
            if (blocked === false) {
                return;
            }
            $(sel).unblock();
            blocked = false;
        }
    }
};

