/* svn info: $Revision: 847 $ $Date: 2018-06-06 18:37:11 +0800 (Wed, 06 Jun 2018) $ */
var PopView=function(){
    var r,a=0,l=null;

    function p(){
        clearInterval(l);
        var pop_content=  '<div class="AlertPopRect"><div id="PopWaitting"><div id="popalert_circle"><img src="submit.gif" width="48" height="48"><div id="popalert_countdown"></div></div><div id="popalert_wait"><table align="center"><tr align="left"><td id="PopWaitting_desc"></td></tr></table></div></div><div id="PopDiag"><div class="popalert_row" id="popalert_title"></div><div id="popalert_desc"></div><div class="popalert_row"></div><div class="popalert_buttons"><button type="button" id="popalert_cancel" class="styled_button_ss"></button>  <button type="button" id="popalert_ok" class="styled_button_ss"></button></div></div></div>';
        $("#popalert").html(pop_content);
        document.getElementById("popalert_ok").innerHTML =  "OK";
        document.getElementById("popalert_cancel").innerHTML = "Cancel";
        $("#popalert").hide();
    }
    function c(o){
        var e=$("#popalert > .AlertPopRect");
        switch(e.removeClass("dialog countdown confirm waiting warningMSG cleanUI"),o)
        {
            case"dialog":e.addClass("dialog");break;
            case"countdown":e.addClass("countdown");break;
            case"confirm":e.addClass("confirm");break;
            case"warningMSG":e.addClass("warningMSG");break;
            case"cleanUI":e.addClass("cleanUI");break;
            default:e.addClass("waiting");
        }
    }
    return{
        show:function(o){
            p(),c("waiting"),
            $("#PopWaitting_desc").html(o),
            $("#popalert").show()
        },
        showcount:function(o,e){
            p(),a=e,c("countdown"),
            $("#popalert_countdown").html(a),
            $("#PopWaitting_desc").html(o),
            $("#popalert").show()
        },
        showWithCountdown:function(o,e,n){
            return r=$.Deferred(),p(),a=parseInt(e),
                l=setInterval(function(){
                            a--,$("#popalert_countdown").html(a),a<=0&&(clearInterval(l),r.resolve(n))
                        },
                    1e3),
                c("countdown"),
                $("#popalert_countdown").html(a),
                $("#PopWaitting_desc").html(o),
                $("#popalert").show(),
                r.promise()
        },
        showWithPercent:function(o,e,n){
            r=$.Deferred();
            var t=parseInt(e);
            return p(),a=0,
                l=setInterval(function(){
                        var o=Math.ceil(++a/t*100);$("#popalert_countdown").html(o+"%"),100<=o&&(clearInterval(l),r.resolve(n))
                    },
                    1e3),
                c("countdown"),
                $("#popalert_countdown").html(a+"%"),
                $("#PopWaitting_desc").html(o),
                $("#popalert").show(),
                r.promise()
        },
        showDialog:function(o,e){
            return r=$.Deferred(),p(),c("dialog"),
                1==e&&($("#popalert_InformationIMG").show(),
                $("#popalert_desc").addClass("infoText")),
                $("#popalert_desc").html(o),
                $("#popalert_ok").off("click").on("click",function(){
                    r.resolve(),$("#popalert_InformationIMG").hide(),$("#popalert_desc").removeClass("infoText")}
                ),
                $("#popalert_cancel").off("click").on("click",function(){
                    r.reject(),$("#popalert_InformationIMG").hide(),$("#popalert_desc").removeClass("infoText")}
                ),
                $("#popalert").show(),
                r.promise()
        },
        showConfirm:function(o){
            return r=$.Deferred(),p(),c("confirm"),
                $("#popalert_desc").html(o),
                $("#popalert_ok").off("click").on("click",function(){r.resolve()}),
                $("#popalert").show(),
                r.promise()
        },
        hide:p,
        showWarningMSG:function(o,e){
            return r=$.Deferred(),p(),c("warningMSG"),
                o&&($("#popalert_title").show(),
                $("#popalert_title").html(o)),
                $("#popalert_desc").html(e),
                $("#popalert_ok").off("click").on("click",function(){$("#popalert_title").hide(),r.resolve()}),
                $("#popalert").show(),
                r.promise()
        },
        showCleanUI:function(){
            p(),c("cleanUI"),$("#popalert").show()
        }
    }
}();