js 提示窗

來源:互聯網
上載者:User

標籤:

/** * @Co.,Ltd.    北京酷伴科技鄭州分公司 * @authors     小石頭([email protected]) * @date        2014-12-22 * @version     4.0 */ var jAlert=(function(){     this.myalertin=function(text,color,time,fn){        var text=text||‘‘;        var color=color||‘default‘;        var time=time||3000;        var timer=500;        var fn=fn||function(){};        var cover=addJcover();        cover.prepend(‘<div class="jbox ‘+color+‘"><div class="jtop"><span class="jtit">\u6d88\u606f\u63d0\u793a</span><span class="jclose">&times;</span></div><div class="jtxt">‘+text+‘</div></div>‘);        var box = $(‘#jcover .jbox‘)        box.delay(time).fadeOut(timer,function(){            //終止動畫隊列            $(this).dequeue();            jRemoveBox($(this),fn);        });        box.on(‘mouseover‘,function(){            //清除動畫隊列            $(this).clearQueue();        });        box.on(‘mouseout‘,function(){            $(this).delay(time).fadeOut(timer,function(){                jRemoveBox($(this),fn);            })        });        box.find(‘.jtop,.jtxt‘).delegate($(this),‘click‘,function(){            jRemoveBox($(this).closest(‘.jbox‘),fn);        });    };    this.myconfirm=function(text,fn){        var text=text||‘‘;        var fn=fn||function(){};        var timer=300;        var cover=addJcover();        cover.append(‘<div class="jconfirm"><div class="confirm-text">‘+text+‘</div><div class="confirm-btns"><div class="confirm-btn ensure"><div class="default">\u53d6\u6d88</div></div><div class="confirm-btn sure"><div class="error">\u786e\u5b9a</div></div></div></div>‘);        $(‘.confirm-btn‘).delegate($(this),‘click‘,function(){            var _this=$(this);            $(this).closest(‘.jconfirm‘).fadeOut(timer,function(){                jRemoveBox($(this),fn);                if (_this.hasClass(‘sure‘)) {                    if(fn)fn(true);                };            })        });    };    this.myalert=function(_data,_refresh,_fn,_show){        var data,refresh=false,show=‘show‘,fn=function(){};        $.each(arguments, function(index, val) {            if (typeof val ==‘boolean‘) {                refresh=val;            }else if (typeof val==‘function‘) {                fn=val;            }else if (typeof val==‘object‘) {                data=val;            }else if (typeof val==‘string‘) {                show=val;            };        });        if (data.status==1) {            if (show==‘hide‘) {                fn();                location.href=data.url;            }else{                mysuccess(data.info,function(){                    fn();                    if (refresh&&data.url!=‘‘) {                        location.href=data.url;                    }                })            }        }else if (data.status==0){            myerror(data.info,function(){                fn();            })        }else{            myerror(‘\u64cd\u4f5c\u5931\u8d25‘,function(){                fn();            });        }    };    this.jaja=function(_btn,_data,_fn,_type,_url){        var btn,data,fn=function(){},type=‘POST‘,url=‘‘;        if (arguments[0].length==0||arguments.length<2) {            return false;        }        btn=arguments[0];        url=btn.data(‘action‘);                $.each(arguments, function(index, val) {            if (val instanceof jQuery) {                btn=val;                data=btn.closest(‘form‘).serialize();                url=btn.data(‘action‘);            }else if ((typeof val==‘object‘) && !(val instanceof jQuery)) {                data=val;            }else if (typeof val==‘function‘) {                fn=val;            }else if ((typeof val==‘string‘) && (val==‘GET‘||val==‘POST‘)){                type=val;            }else if ((typeof val==‘string‘) && (/\//g.test(val.toString())) ) {                url=val;            };        });        if(type==‘GET‘ && btn.closest(‘form‘).length==0){            data=‘‘;        }        var html=btn.html();        btn.prop(‘disabled‘, true).html(‘\u8bf7\u7a0d\u7b49\u002e\u002e\u002e‘);        $.ajax({            url:url,            type: type,            data:data,            error:function(e){                btn.prop(‘disabled‘, false).html(html);                e.info=‘\u64cd\u4f5c\u5931\u8d25‘;                fn(e);            },            success:function(data){                btn.prop(‘disabled‘, false).html(html);                fn(data);            }        });    };    this.mysuccess=function(t,f){myalertin(t,‘success‘,2000,f)};    this.myerror=function(t,f){myalertin(t,‘error‘,2000,f)};    this.mywarning=function(t,f){myalertin(t,‘warning‘,2000,f)};    this.myinfo=function(t,f){myalertin(t,‘info‘,2000,f)};    this.myprimary=function(t,f){myalertin(t,‘primary‘,2000,f)};    this.mydefault=function(t,f){myalertin(t,‘‘,2000,f)};    this.jStyle={        error:‘#DA2F2F‘,    };    this.addJcover=function(){         $(‘#jcover‘).length==0?$(‘body‘).append(‘<div id="jcover"></div>‘):0;         return $(‘#jcover‘);     };     this.jRemoveBox=function(box,fn){        box.remove();        if (!$(‘#jcover‘).children().length) {            $(‘#jcover‘).remove();        }        if(fn)fn();    };    this.alertStyle=(function(){        $(‘head‘).append(‘<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"><meta name="renderer" content="webkit"><style type="text/css">#jcover{position:fixed;z-index:9999;top:25%;left:50%;margin-left:-180px;width:360px;font-family:"Microsoft yahei";word-wrap:break-word;}#jcover .jbox,#jcover .jconfirm{border-radius:2px;width:100%;background:#e4e4e4;margin:0 auto 5px auto;color:#555}#jcover .jtop{height:40px;line-height:50px;width:100%;padding-bottom:10px}#jcover .jtit{font-size:12px;height:40px;display:inline-block;line-height:40px;padding-left:20px;}#jcover .jclose{border-radius:2px;font-size:30px;position:absolute;right:0;right:0;top:0;background-color:rgba(0,0,0,0.1);cursor:pointer;height:40px;width:40px;line-height:40px;text-align:center;font-family:Simsun}@media (max-width:361px){#jcover {width:100%;left:0;margin-left:0}}#jcover .jtxt{font-size:16px;line-height:24px;padding:10px 20px 20px 20px;}#jcover .success,#jcover .error,#jcover .warning,#jcover .info,#jcover .primary{color:#fff}#jcover .success{background:#5CB85C}#jcover .error{background:#c00}#jcover .warning{background:#FFA028}#jcover .info{background:#5BC0DE}#jcover .primary{background:#428BCA}#jcover .default{background:#fff}#jcover .confirm-text{font-size:16px;padding:20px 10px;color:#c00}.confirm-btns{padding:20px 10px;}#jcover .confirm-btn{text-align:center;width:48%;display:inline-block;}#jcover .confirm-btn div{border-radius:3px;padding:10px;cursor:pointer;}#jcover .confirm-btn.sure{float:right;}</style>‘);    })();    return this;})(jAlert);window.jAlert=jAlert;

js 提示窗

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.