首页 > Web开发 > 详细

js公共弹出窗插件

时间:2018-03-02 11:27:53      阅读:158      评论:0      收藏:0      [点我收藏+]
/*错误提示框*/
var wr = function() {
    var wrap = ‘<div class="wrapBox opacity">&nbsp;</div>‘;
    var callback;
    var me = this;
    var htmlBox = ‘<div class="alertBox opacity"></div>‘;
    // 遮罩显示
    me.faIn = function faIn(callback) {
        $(‘body‘).append(wrap);
        $(wrap).fadeIn(150, function() {
            $(‘.bodyBox‘).addClass(‘overAuto‘);
            if (callback) {
                callback();
            }
            ;
        });
    };
    // 遮罩隐藏
    me.faOut = function(callback) {
        $(‘.wrapBox‘).fadeOut(150, function() {
            $(‘.bodyBox‘).removeClass(‘overAuto‘);
            if (callback) {
                callback();
            }
            ;
            $(this).remove();
        });
    };
    // 公共提示框
    me.alert = function(message, callback) {
        if(message){
            var pHtml = ‘<p>‘ + message + ‘</p>‘;
            var inhtml = $(htmlBox).append(pHtml);
            $(‘body‘).append(inhtml);
            $(inhtml).fadeIn(250, function() {
                setTimeout(function() {
                    $(inhtml).fadeOut(150, function() {
                        $(this).html(‘‘);
                        $(this).remove();
                    });
                    if (callback) {
                        callback();
                    }
                }, 2000);
            });
        }

    };

    me.alertHide=function(){
        $(‘body‘).find(‘.alertBox‘).fadeOut(0,function(){
            $(this).html(‘‘);
            $(this).remove();
        });
    };

    // 电话
    me.tel = function(tel, callback) {
        var tel = ‘<p class="telBox"><a href="tel:‘ + tel + ‘">‘ + tel
            + ‘</a></p>‘;
        if (callback) {
            callback();
        }
        $(‘body‘).append(htmlBox);
        $(‘body‘).append(tel);
        $(htmlBox).fadeIn(250);
        $(‘.alertBox‘).click(function() {
            $(‘.telBox‘).fadeOut(150, function() {
                $(this).remove();
            });
            $(this).fadeOut(0, function() {
                $(this).html(‘‘);
                $(this).remove();

            });
        });
    };
};
var wrap = new wr();

 

js公共弹出窗插件

原文:https://www.cnblogs.com/AttackLion/p/8492083.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!