自己写的弹窗JS组件

自己写的弹窗JS组件,依赖JQ,
html代码:




    
    Title
    
    

    
    




我是弹出层1
我是弹出层2
我是弹出层3
我是弹出层4
我是MSG

js代码:

//公共弹出组件;
// 依赖JQ和common.css,请先引用;
//
//
// by walker v2.0;

//弹出层 l_layer(a,b,c,d,e,callback)参数a是宽度,b是高度,c是弹窗定位高度,默认是0,自定义值(0-100);d是按钮配置,默认是0,关闭按钮是1,单按钮是2,双按钮是3;e是内容;callback是回调函数,默认值为0或者不写,只有点击确定按钮后才执行;
function ll_layer(a,b,c,d,e,callback) {
    var layer_Width,layer_Height,layer_Top,layer_close,layer_btn,layer_cont;
    //宽度
    if (a == null || a === undefined || a === 0) {
        layer_Width = 5;
        //console.log('默认宽度500px');
    } else {
        layer_Width = a;
        //console.log('自定义宽度'+a);
    }
//高度
    if (b == null || b === undefined || b === 0) {
        layer_Height = 3;
        //console.log('默认高度300px');
    } else {
        layer_Height = b;
        //console.log('自定义高度'+b);
    }
//弹窗定位高度
    if (c === undefined ||c === 0) {
        layer_Top = '30';

    }else  {
        layer_Top = c;

    }
//弹窗按钮类型
    if (d == null || d === undefined || d === 0) {
        layer_close ='';
        layer_btn = '';

    }
    else if(d===1) {
        layer_close = '
X
'; layer_btn = ''; } else if(d===2) { layer_close =''; layer_btn = '
确定
'; } else if(d===3) { layer_close =''; layer_btn = '
取消
确定
'; } //内容 if (e == null || e === undefined || e === 0) { layer_cont = ''; }else if(e!=='') { layer_cont = e; } var marLeft = layer_Width / 2; var layerTop = "
" + layer_cont +"
" +layer_close + "
"; $('body').append(layerTop); $('.ll-pop').append(layer_btn); $('.ll-mask').click(function () { $('.ll-pop').remove(); $(this).remove(); }); $('.ll-close').click(function () { $('.ll-pop').remove(); $('.ll-mask').remove(); }); $('.ll-btn').click(function () { $('.ll-pop').remove(); $('.ll-mask').remove(); }); $('.ll-submit').click(function () { if (callback == null || callback === undefined || callback === 0) { callback = null; } else if(callback!=null){ callback(); } }); } //弹出信息提示 ll_msg(content,callback);参数content是内容;callback是回调函数,默认值0或不写; function ll_msg(content,callback) { var msgW = 4; var marLeft = msgW / 2; var msgTop = "
" + content + "
"; $('body').append(msgTop); setTimeout(function () { $('.ll-msg').remove(); if (callback == null || callback === undefined || callback === 0) { callback = null; } else if(callback!=null){ callback(); } },2500); }

你可能感兴趣的:(JQ)