1. 程式人生 > >js公共彈出窗插件

js公共彈出窗插件

class over add pre lba pac his ide cit

/*錯誤提示框*/
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公共彈出窗插件