码迷,mamicode.com
首页 > 其他好文 > 详细

提示信息 alert

时间:2015-01-06 13:44:37      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:

js代码

function alertbox(option) {

    var thisel = this;
    thisel.mergeJsonObject = function (jsonbject1, jsonbject2) {
        var resultJsonObject = {};
        var attr;
        for (attr in jsonbject1) {
            resultJsonObject[attr] = jsonbject1[attr];
        }
        for (attr in jsonbject2) {
            resultJsonObject[attr] = jsonbject2[attr];
        }

        return resultJsonObject;
    };
    thisel.o = {
        successMsg: 操作成功,
        errMsg: 操作失败,
        autoClose: 1 //是否自动关闭
        //resize: { width: 320, height: 240, quality: 90 }
    };
    //合并配置
    thisel.o = thisel.mergeJsonObject(thisel.o, option);

    thisel.createHtml = function () {
        var htmlbox = $("body");
        htmlbox.append("<div class=\"y-cue\" >" + "</div>");
    };

    function close() {
        //alert(‘dd‘);
        var htmlbox = $("body");
        var box = htmlbox.find(".y-cue");
        box.hide();
    }

    thisel.showsuccess = function () {
        var htmlbox = $("body");
        var box = htmlbox.find(".y-cue");
        box.html(thisel.o.successMsg);
        if (thisel.o.autoClose == 0) {
            box.append("<div><a href=\"javascript:void(0);\" id=\"aalertClose\">关闭</a></div>");
            $("#aalertClose").bind("click", function () {
                close();
            });
            box.show();
        } else {
            box.fadeIn("fast");
            setTimeout(function () {
                box.fadeOut("fast");
            }, 500);
        }
    };

    thisel.showerr = function () {
        var htmlbox = $("body");
        var box = htmlbox.find(".y-cue");
        box.html(thisel.o.errMsg);
        box.fadeIn("fast");
        setTimeout(function () {
            box.fadeOut("fast");
        }, 500);
    };
    thisel.warnerr = function (warnmsg) {
        var htmlbox = $("body");
        var box = htmlbox.find(".y-cue");
        box.html(warnmsg);
        box.fadeIn("fast");
        setTimeout(function () {
            box.fadeOut("fast");
        }, 1000);
    };

    thisel.hide = function () {
        setTimeout(function () {
            var htmlbox = $("body");
            var box = htmlbox.find(".y-cue");
            box.fadeOut("fast");
        }, 500);
    };

    thisel.showandredirct = function (url) {
        var htmlbox = $("body");
        var box = htmlbox.find(".y-cue");
        box.html(thisel.o.successMsg);
        box.fadeIn("fast");
        setTimeout(function () {
            box.fadeOut("fast");
            if (url) {
                window.location = url;
            } else {
                window.location = window.location;
            }
        }, 1000);
    };


    //初始化上传组建
    thisel.create = function () {
        thisel.createHtml();
    };


}

调用时

   var proup = null;
        $(function () {
            proup = new alertbox();
            proup.create();
        }); /// <summary>添加操作</summary>

 

提示信息 alert

标签:

原文地址:http://www.cnblogs.com/llxy/p/4205806.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!