当前访客身份:游客 [ 登录 | 加入开源中国 ]

代码分享

当前位置:
代码分享 » JavaScript  » Web编程
分享到: 
收藏 +0
0
依赖jquery,兼容所有主流浏览器,目前有队列ajax、信息提示、字符串拼接、加载提示等
标签: <无>

代码片段(1) [全屏查看所有代码]

1. [代码][JavaScript]代码     跳至 [1] [全屏预览]

(function(a,b){String.prototype.jsclass_Format=function(d){var c=this;if(arguments.length<1){return c}var g=arguments;if(arguments.length==1&&typeof(d)=="object"){g=d}for(var e in g){var f=g[e];if(undefined!=f){c=c.replace("{"+e+"}",f)}}return c};a.jsclass=b()}(this,function(){var c=0;var a={loading:function(){return{parent:function(){var d=$("<div></div>");d.attr("class","loading");d.css({"position":"fixed","width":"100%","height":"100%","background":"rgba(207, 207, 207, 0.35)","left":"0","top":"0","z-index":"999999","display":"none"});return d},mask:function(){var d=$("<div></div>");d.css({"background":"#ffffff","margin":"0 auto","width":"66px","height":"66px","border-radius":"10px","position":"absolute","left":"50%","top":"50%","margin-left":"-33px","margin-top":"-33px"});return d},img:function(){var d=$("<img/>");d.css({"margin":"0 auto","margin-top":"15px","display":"block"});d.attr({"src":" data:image/gif;base64,R0lGODlhJQAlAJECAL3L2AYrTv///wAAACH/C05FVFNDQVBFMi4wAwEAAAAh+QQFCgACACwAAAAAJQAlAAACi5SPqcvtDyGYIFpF690i8xUw3qJBwUlSadmcLqYmGQu6KDIeM13beGzYWWy3DlB4IYaMk+Dso2RWkFCfLPcRvFbZxFLUDTt21BW56TyjRep1e20+i+eYMR145W2eefj+6VFmgTQi+ECVY8iGxcg35phGo/iDFwlTyXWphwlm1imGRdcnuqhHeop6UAAAIfkEBQoAAgAsEAACAAQACwAAAgWMj6nLXAAh+QQFCgACACwVAAUACgALAAACFZQvgRi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwXABEADAADAAACBYyPqcsFACH5BAUKAAIALBUAFQAKAAsAAAITlGKZwWoMHYxqtmplxlNT7ixGAQAh+QQFCgACACwQABgABAALAAACBYyPqctcACH5BAUKAAIALAUAFQAKAAsAAAIVlC+BGL3Z3IlxUmUuhtR2LzHhsiEFACH5BAUKAAIALAEAEQAMAAMAAAIFjI+pywUAIfkEBQoAAgAsBQAFAAoACwAAAhOUYJnAagwdjGq2amXGU1PuLEYBACH5BAUKAAIALBAAAgAEAAsAAAIFhI+py1wAIfkEBQoAAgAsFQAFAAoACwAAAhWUL4AIvdnciXFSZS6G1HYvMeGyIQUAIfkEBQoAAgAsFwARAAwAAwAAAgWEj6nLBQAh+QQFCgACACwVABUACgALAAACE5RgmcBqDB2MarZqZcZTU+4sRgEAIfkEBQoAAgAsEAAYAAQACwAAAgWEj6nLXAAh+QQFCgACACwFABUACgALAAACFZQvgAi92dyJcVJlLobUdi8x4bIhBQAh+QQFCgACACwBABEADAADAAACBYSPqcsFADs="});return d}}}(),Layer:function(f){var e="<style>.alert_box{display:none;position:fixed;width:100%;height:100%;background:rgba(0,0,0,0.33);z-index:99999;left:0;top:0}.alert_body{display:none;width:400px;position:fixed;background:#fff;z-index:999999;left:50%;margin-left:-200px;border-radius:0 0 10px 10px}.alert_body div{height:35px;line-height:35px}.alert_body h2{display:block;padding:15px;text-align:center}.alert_foot_left{background:#eaeaea;width:50%;float:left;border-radius:0 0 0 10px;text-align:center;cursor:pointer;font-weight:bold}.alert_foot_left:hover{opacity:.4}.alert_foot_right:hover{opacity:.6}.alert_foot_right{background:#e8b3ff;width:50%;float:left;border-radius:0 0 10px 0;text-align:center;color:#fff;font-weight:bold;cursor:pointer}</style>";var d=$('<div class="alert_box"><div class="alert_body"><h2><strong>{0}</strong></h2><div><div class="alert_foot_left">取消</div><div class="alert_foot_right">确定</div></div></div></div>'.jsclass_Format({0:f}));d.append(e);$("body").append(d);$(".alert_box").fadeToggle(500);$(".alert_body").css({"top":"-"+$(".alert_body").height()+"px"}).show().animate({top:0},300);$(".alert_box").click(function(g){if(g.target==this){$(this).remove()}});return d}};var b={Ajax_Func:function(g){var e=$.type(g);if(e=="array"){for(var d=0;d<g.length;d++){(function(h){var j=$.extend({load:true,url:null,type:"post",data:null,success:null,async:true,contentType:"application/json;charset=utf-8"},g[h]);if(b.layer.Loading.obj().length==0&&j.load){b.layer.Loading.open();c=g.length}$.ajax({type:j.type,url:j.url,data:j.data,contentType:j.contentType,async:j.async}).done(function(i){if(typeof j.success==="function"){j.success(i)}--c;if(c==0&&b.layer.Loading.obj().length>0){b.layer.Loading.close();c=0}})}(d))}}else{if(e=="object"){var f=$.extend({load:true,url:null,type:"post",data:null,success:null,async:true,contentType:"application/json;charset=utf-8"},g);if(b.layer.Loading.obj().length==0&&f.load){b.layer.Loading.open()}$.ajax({type:f.type,url:f.url,data:f.data,contentType:f.contentType,async:f.async}).done(function(h){if(typeof f.success==="function"){f.success(h)}if(b.layer.Loading.obj().length>0){b.layer.Loading.close()}})}}},layer:{alert:function(d){a.Layer(d);$(".alert_foot_left,.alert_foot_right").parent().hide()},confirm:function(e){var d=a.Layer(e.text);d.find(".alert_foot_left").click(function(){b.layer.close();typeof e.no==="function"?e.no():undefined});d.find(".alert_foot_right").click(function(){b.layer.close();typeof e.ok==="function"?e.ok():undefined});$(".alert_foot_left,.alert_foot_right").parent().show()},Loading:{open:function(){$("body").append(a.loading.parent().append(a.loading.mask().append(a.loading.img())));$(".loading").show()},close:function(){$(".loading").remove()},obj:function(){return $(".loading")}},close:function(){$(".alert_box").remove()}}};return b}));


开源中国-程序员在线工具:Git代码托管 API文档大全(120+) JS在线编辑演示 二维码 更多»

发表评论 回到顶部 网友评论(2)

  • 1楼:肖锦和 发表于 2016-08-12 20:54 回复此评论
    如何使用????
  • 2楼:sam6666 发表于 2016-08-23 09:29 回复此评论

    引用来自“肖锦和”的评论

    如何使用????
    相关文档正在整理当中。。稍后发上来
开源从代码分享开始 分享代码
sam6666的其它代码 全部(1)...