/** 
    @ Name : Careff Javascript Library 
    @ Author : 
    @ Date : 2017-5-1
    @ Email : 
    @ Version : 1.0 
    @ Update : 
    功能： 开始建立自己的JS类库，需要按照功能进行分类；
     */
(function () {
    if (!window.usalert) {
        window.usalert = {};
    };
    window.usalert = {
        NAME: "usalert",
        VERSION: '1.0',
        DATE: '2017-12-16',
        INDEX: 10,
        UsGetLayer:function(){
            var lay =top.layer;
            if(lay==null){
                lay=layer;
            }
            return lay;
        },
        /** 
       @ Name :删除的提示
       @ Update : 
       */
        UsConfirmDelete: function (info, cb) {
            var lay = usalert.UsGetLayer();
            var index = lay.confirm(info, {
                icon: 1,
                title: "操作确认",
                btn: ['确认', '关闭'] //按钮
                , success: function (layero, index) {
                    //第一个按钮获得焦点
                    var f = $(layero).find(".layui-layer-btn a")[0];
                    $(f).attr("href", "#").focus();
                    $(f).focus();
                }
            }, function () {
                //layer.msg('的确很重要', { icon: 1 });
                //alert();
                lay.close(index);
                cb(true);
            }, function () {
                //layer.msg('的确很重要1', { icon: 1 });
                cb(false);
            });
        },
        UsConfirm: function (info, cb) {
            var bisclick = false;
            var lay = usalert.UsGetLayer();
            var index = lay.confirm(info, {
                icon: 1,
                title: "操作确认",
                btn: ['确认', '取消'] //按钮
                 , success: function (layero, index) {
                     //第一个按钮获得焦点
                     var f = $(layero).find(".layui-layer-btn a")[0];
                     $(f).attr("href", "#").focus();
                     $(f).focus();
                 }, end: function () {
                     if (!bisclick) {
                         cb(false);
                     }

                 }
            }, function () {
                //layer.msg('的确很重要', { icon: 1 });
                //alert();
                lay.close(index);
                bisclick = true;
                if (cb != null) {
                    cb(true);
                }

            }, function () {
                bisclick = true;
                //layer.msg('的确很重要1', { icon: 1 });
                if (cb != null) {
                    cb(false);
                }
            });
        },
        UsAlert: function (info, cb) {
            var bisclick = false;
            var lay = usalert.UsGetLayer();
            var index = lay.confirm(info, {
                icon: 1,
                title: "系统提示",
                btn: ['确认', '关闭'] //按钮
                 , success: function (layero, index) {
                     //第一个按钮获得焦点
                     var f = $(layero).find(".layui-layer-btn a")[0];
                     $(f).attr("href", "#").focus();
                     $(f).focus();
                 }, end: function () {
                     if (!bisclick) {
                         cb(false);
                     }

                 }
            }, function () {
                //layer.msg('的确很重要', { icon: 1 });
                //alert();
                lay.close(index);
                bisclick = true;
                if (cb != null) {
                    cb(true);
                }

            }, function () {
                bisclick = true;
                //layer.msg('的确很重要1', { icon: 1 });
                if (cb != null) {
                    cb(false);
                }
            });
        },
        UsConfirmParent: function (info, cb) {
            var bisclick = false;
            var lay = usalert.UsGetLayer();
            var index = lay.confirm(info, {
                icon: 1,
                title: "操作确认",
                btn: ['确认', '取消'] //按钮
                 , success: function (layero, index) {
                     //第一个按钮获得焦点
                     var f = $(layero).find(".layui-layer-btn a")[0];
                     $(f).attr("href", "#").focus();
                     $(f).focus();
                 }, end: function () {
                     if (!bisclick) {
                         cb(false);
                     }

                 }
            }, function () {
                //layer.msg('的确很重要', { icon: 1 });
                //alert();
                lay.close(index);
                bisclick = true;
                if (cb != null) {
                    cb(true);
                }

            }, function () {
                bisclick = true;
                //layer.msg('的确很重要1', { icon: 1 });
                if (cb != null) {
                    cb(false);
                }
            });
        }
    };

})();