/*! * zeroModal.js * http://git.oschina.net/cylansad/zeroModal * * Copyright 2016, Sad */ (function(a){if(typeof module!=="undefined"&&typeof exports==="object"&&define.cmd){module.exports=a}else{if(typeof define==="function"&&define.amd){define(function(){return a})}else{window.zeroModal=a}}}((function(e,f){var u={};var r={unique:"",title:"",content:"",url:false,iframe:false,width:"500px",height:"300px",transition:false,opacity:0.2,overlay:true,overlayClose:false,max:false,resize:false,resizeAfterFn:f,ok:false,okTitle:"确定",okFn:false,cancel:false,cancelTitle:"关闭",cancelFn:true,buttonTopLine:true,buttons:[],esc:false,onOpen:false,onLoad:false,onComplete:false,onCleanup:false,onClosed:false};var d=false;var q=1000;var k={};u.show=function(v){var w=m(v);h(w);d=true;e(window).resize(function(){if(d){g(w)}});return w.unique};u.close=function(v){a({unique:v});d=false;delete k[v]};u.closeAll=function(){e('[role="zeromodal-loading"]').remove();e(".zeromodal-overlay").remove();e(".zeromodal-container").each(function(){var x=e(this);var w=x.attr("zero-unique-container");if(w!==f&&k[w]!==f){var v=k[w];if(typeof v.onCleanup==="function"){v.onCleanup()}x.remove();if(typeof v.onClosed==="function"){v.onClosed()}delete k[w]}});d=false};u.loading=function(y){var B=m();t(B);q++;var A=e(window).scrollTop()+Math.ceil(e(window).height()/3);if(y===f){y=1}if(y===1||y===2){var z="zeromodal-loading"+y;e("body").append('
')}else{if(i([3,4,5,6],y)){var v={};switch(y){case 3:v.className="pacman";v.containerCount=5;break;case 4:v.className="line-scale-pulse-out";v.containerCount=5;break;case 5:v.className="line-spin-fade-loader";v.containerCount=8;break;case 6:v.className="square-spin";v.containerCount=1;break}var w='
';for(var x=0;x
"}w+=" ";e("body").append(w)}}return B.unique};u.progress=function(B,v){var y=m();t(y);q++;if(B===f){B=3}var D=e(window).scrollTop()+Math.ceil(e(window).height()/3);var C={};switch(B){case 3:C.className="pacman";C.containerCount=5;break;case 4:C.className="line-scale-pulse-out";C.containerCount=5;break;case 5:C.className="line-spin-fade-loader";C.containerCount=8;break;case 6:C.className="square-spin";C.containerCount=1;break}var w='
';for(var A=0;A
"}w+=" ";w+='
';w+="";e("body").append(w);var z=0;var x=setInterval(function(){e.ajax({url:v.getProgressUrl+"?_="+new Date().getTime(),dataType:"json",type:"get",success:function(E){e("#progess_content_"+y.unique).html(E.progress);if(E.progress==="finish"){clearInterval(x);e.get(v.clearProgressUrl);u.close(y.unique)}}});z++;if(z>=500){clearInterval(x)}},500);return y.unique};u.progress_old=function(x){var A=m();t(A);q++;var D=e(window).scrollTop()+Math.ceil(e(window).height()/3);var E=e(window).width()/2-200;var B=1;if(x!==f&&x>B&&x<10){B=x}var w='
';w+='
';w+='
 0%
';w+="
";w+="
";e("body").append(w);var v=0;var C=e('[zeromodal-progress-bar="'+A.unique+'"]');var z=e('[zeromodal-progress-val="'+A.unique+'"]');var y=setInterval(function(){v+=1;C.css("width",v+"%");z.html((v>9?v:" "+v)+"%");if(v>=100){z.html('');clearInterval(y)}},B*100);return A.unique};u.alert=function(w){var v={iconClass:"show-zero2 zeromodal-icon-info",iconText:"!"};var x={};e.extend(x,v);if(typeof w==="object"){e.extend(x,w)}else{x.content=w}o(x)};u.error=function(v){var w={iconDisplay:'
'};if(typeof v==="object"){e.extend(w,v)}else{w.content=v}o(w)};u.success=function(v){var w={iconDisplay:'
'};if(typeof v==="object"){e.extend(w,v)}else{w.content=v}o(w)};u.confirm=function(x,w){var v={iconClass:"show-zero2 zeromodal-icon-question",iconText:"?",};var y={};e.extend(y,v);if(typeof w==="function"){y.okFn=w}y.cancel=true;if(typeof x==="object"){e.extend(y,x)}else{y.content=x}o(y)};function m(v){var w={};e.extend(w,r);e.extend(w,v);if(typeof w.unique==="undefined"||w.unique===""){w.unique=b()}k[w.unique]=w;return w}function h(v){if(typeof v.onOpen==="function"){v.onOpen()}t(v);l(v)}function a(v){if(typeof v==="object"){if(typeof v.onCleanup==="function"){v.onCleanup()}e('[zero-unique-overlay="'+v.unique+'"]').remove();e('[zero-unique-container="'+v.unique+'"]').remove();e('[zero-unique-loading="'+v.unique+'"]').remove();if(typeof v.onClosed==="function"){v.onClosed()}}}function t(y){q++;var w=e(document).width();var x=e(document).height();if(y.overlay){var v=e('
');e("body").append(v);if(y.overlayClose){v.css("cursor","pointer");v.click(function(){a(y)})}else{v.click(function(){s(e('[zero-unique-container="'+y.unique+'"]'))})}}}function l(w){q++;var A=w.width.replace("px","");var C=w.height.replace("px","");var v=e(window).width();var B=e(window).height();if(A.indexOf("%")!==-1){A=(v*parseInt(A.replace("%",""))/100)}if(C.indexOf("%")!==-1){C=(B*parseInt(C.replace("%",""))/100)}if(typeof A==="string"){A=parseInt(A)}if(typeof C==="string"){C=parseInt(C)}var G=(v-A)/2;var F=e(window).scrollTop()+Math.ceil((e(window).height()-C)/3);var z=e('
');var y='
';y+='
×
';if(w.max){y+='
'}y+=' '+w.title+"";y+="
";var E=e(y);z.append(E);e("body").append(z);e('[zero-close-unique="'+w.unique+'"]').click(function(){a(k[e(this).attr("zero-close-unique")])});e('[zero-max-unique="'+w.unique+'"]').click(function(){if(e(this).attr("max")!=="1"){g(k[e(this).attr("zero-max-unique")],"90%","85%");e(this).attr("max","1")}else{g(k[e(this).attr("zero-max-unique")]);e(this).attr("max","0")}n(w)});if(w.transition){e(".zeromodal-container").animate({top:F},300)}var x=e('
');z.append(x);n(w);if(w.resize){z.append('
');j(w.unique,w)}if(typeof w.onLoad==="function"){w.onLoad()}if(!w.url){e('[zero-unique-body="'+w.unique+'"]').addClass("zeromodal-overflow-y");x.html(w.content);if(typeof w.onComplete==="function"){w.onComplete()}}else{x.html('
');if(w.iframe){var D=e('');x.append(D);D.load(function(){e(".zeromodal-loading1").remove();if(typeof w.onComplete==="function"){w.onComplete()}})}else{e('[zero-unique-body="'+w.unique+'"]').addClass("zeromodal-overflow-y");e.ajax({url:w.url,dataType:"html",type:"get",success:function(H){x.append(H);e(".zeromodal-loading1").remove();if(typeof w.onComplete==="function"){w.onComplete()}}})}}c(w,z);if(w.esc){e("body").one("keyup",function(H){if(H.keyCode===27){a(w)}})}}function c(z,x){if(z.ok||z.cancel||(z.buttons!==f&&z.buttons.length>0)){var w='";x.append(w);if(z.buttons!==f&&z.buttons.length>0){var A="";for(var y=0;y"+v.name+""}e('[zeromodal-btn-container="'+z.unique+'"]').append(A)}else{if(z.ok){var B=e('");e('[zeromodal-btn-container="'+z.unique+'"]').append(B);B.click(function(){if(typeof z.okFn==="function"){var D=z.okFn();if(typeof D==="undefined"||D){a(z)}}else{a(z)}})}if(z.cancel){var C=e('");e('[zeromodal-btn-container="'+z.unique+'"]').append(C);C.click(function(){if(typeof z.cancelFn==="function"){var D=z.cancelFn();if(typeof D==="undefined"||D){a(z)}}else{a(z)}})}}}}function o(x){if(typeof x==="undefined"||typeof x.cancelTitle==="undefined"){x.cancelTitle="取消"}var A=m(x);A.width="360px";A.height="300px";A.esc=true;A.ok=true;A.buttonTopLine=false;if(typeof _okFn!=="undefined"){A.okFn=_okFn}if(typeof cancelFn!=="undefined"){A.cancelFn=cancelFn}var w=A.content||"";var v=A.contentDetail||"";A.content="";h(A);var y;if(typeof A.iconDisplay!=="undefined"){y=e(A.iconDisplay)}else{y=e('
'+A.iconText+"
")}var z=e('
'+w+'
'+v+"
");e('[zero-unique-body="'+A.unique+'"]').append(y);e('[zero-unique-body="'+A.unique+'"]').append(z);e('[zero-unique-body="'+A.unique+'"]').removeClass("zeromodal-overflow-y");e('[zeromodal-btn-ok="'+A.unique+'"]').focus();d=true;e(window).resize(function(){if(d){g(A)}})}function g(x,w,B){e('[zero-unique-overlay="'+x.unique+'"]').css("width",e(document).width()+"px").css("height",e(document).height()+"px");var v=e(window).width();var z=e(window).height();var y=w!==f?w.replace("px",""):x.width.replace("px","");var A=B!==f?B.replace("px",""):x.height.replace("px","");if(y.indexOf("%")!==-1){y=(v*parseInt(y.replace("%",""))/100)}if(A.indexOf("%")!==-1){A=(z*parseInt(A.replace("%",""))/100)}if(typeof y==="string"){y=parseInt(y)}if(typeof A==="string"){A=parseInt(A)}var D=(v-y)/2;var C=e(window).scrollTop()+Math.ceil((e(window).height()-A)/3);e('[zero-unique-container="'+x.unique+'"]').css("width",y+"px").css("height",A+"px").css("left",D+"px").css("top",C+"px")}function p(z){var w=e(window).width();var x=e(window).height();var v=parseInt(e('[zero-unique-container="'+z.unique+'"]').css("width").replace("px",""));var y=parseInt(e('[zero-unique-container="'+z.unique+'"]').css("height").replace("px",""));var A=(w-v)/2;var B=e(window).scrollTop()+Math.ceil((e(window).height()-y)/3);e('[zero-unique-container="'+z.unique+'"]').css("left",A+"px").css("top",B+"px")}function n(x){var w=e('[zeromodal-unqiue-header="'+x.unique+'"]').height();var y=(x.ok||x.cancel||(x.buttons!==f&&x.buttons.length>0))?60:0;var v=e('[zero-unique-container="'+x.unique+'"]').height()-w-10-y;e('[zero-unique-body="'+x.unique+'"]').css("height",v)}function s(x){if(x.length===0){return}var w=x.position().left;for(var v=0;v<2;v++){x.animate({left:w-2},50);x.animate({left:w},50);x.animate({left:w+2},50)}x.animate({left:w},50)}function i(v,x){for(var w=0;w