!function(i){"function"==typeof define&&define.amd?define(["jquery"],i):i("undefined"!=typeof module&&module.exports?require("jquery"):jquery)}(function(i){var t=".j_dialogclose",e={id:"",title:"title",isfixed:!0,hideheader:!1,hideclose:!1,content:null,callback:null,withnopadding:!1,withnominwidth:!1,bghide:!0,eschide:!0},o={windows:i(window),lightbox:".dialog-background",section:".dialog-section",imagetag:".dialog-imageitem",imagedata:{},width:0,height:0,left:0,top:0,paddingwidth:0,paddingheight:0,resizeparams:[".dialog-section"]},n={},a={show:function(t){n=i.extend({},e,t||{}),t.content?a.dialog(t):a.lightbox(t),"function"==typeof n.oninit&&n.oninit(),o.windows.on("resize",function(){a.settings.apply(window,o.resizeparams)})},hide:function(t){var e=i(o.lightbox),a=i(o.section);n.isfixed?a.animate({margintop:-(o.top-150),opacity:0}):a.animate({top:o.top+150,opacity:0}),e.fadeout(function(){e.remove(),a.remove(),t&&t()})},dialog:function(i){a.install(i),o.resizeparams=[o.section,!0,!0],a.settings.apply(window,o.resizeparams)},lightbox:function(i){var t=i.clickobj.attr("data-src")||i.clickobj.attr("data-image");o.now=0,a.getimages_src(n.imagelist),a.loadimage(t,!0,a.settings),a.getnow(t)},install:function(t){var e=i("body"),a='
'+n.title+"
",s='
',c="",d=e.find(o.lightbox);if(n.content)l=n.content;else var l='
<>';n.hideheader&&(a=""),n.hideclose&&(s=''),n.id&&(c=' id="'+n.id+'"');var g='
',r='
"+a+'
'+l+"
"+s+"
";d.length?(d.stop().fadein(),e.find(o.section).remove()):e.append(g),e.append(r),i(o.lightbox).fadein(),i(o.section).show();var f=i(o.section).outerwidth()-i(o.section).width(),h=i(o.section).outerheight()-i(o.section).height();o.paddingwidth=f,o.paddingheight=h,n.callback&&n.callback()},getnow:function(i){for(var t=0,e=o.images.length;to.images.length-1&&(o.now=0);var e=o.images[o.now];a.loadimage(e,t,a.settings)},setbtnsate:function(){o.images.length<2&&i(".dialog-btnprev, .dialog-btnnext").hide()},settings:function(t,e,s){var t="string"==typeof t?i(t):t,c=i(window).height();if(n.content)t.css({left:"0px"}),o.width=t.width(),o.height=t.height();else{var d=o.imagedata.width,l=o.imagedata.height;o.width=d,o.height=l,116+o.height>c&&(o.height=c-116-50,o.height=o.height<500?500:o.height,o.width=math.round(o.width*(o.height/l)))}var g=o.width+o.paddingwidth,r=o.height+o.paddingheight+i(".dialog-header").outerheight();if("object"==typeof e&&e.hide().attr("src",o.imagedata.src).css({width:o.width,height:o.height}).fadein(),n.isfixed)o.left=math.floor(g/2),o.top=math.floor(r/2),t.css({position:"fixed",left:"50%"}),s?t.css({marginleft:-o.left,margintop:-o.top}):t.animate({marginleft:-o.left,margintop:-o.top},{queue:!1});else{var f=o.windows.scrollleft(),h=o.windows.scrolltop(),m=i(o.lightbox).width();o.left=math.floor((m-g)/2)+f,o.top=math.floor((c-r)/2)+h,t.css({position:"absolute",marginleft:0,margintop:0}),s?t.css({left:o.left,top:o.top}):t.animate({left:o.left,top:o.top},{queue:!1})}e&&a.move(t,s)},move:function(i,t){n.isfixed&&t?i.css({margintop:-(o.top-150)}).animate({margintop:-o.top,opacity:1},function(){i.css("overflow","visible")}):t&&i.css({top:o.top+150}).animate({top:o.top,opacity:1},function(){i.css("overflow","visible")}),i.animate({width:o.width},{queue:!1})},canceldefault:function(i){i.preventdefault(),i.stoppropagation()}};i.extend({sendsuccesstotop:function(t,e,o){var n='
'+t+"
";i("body").append(n);var a=i(".dialog-success-top"),s=a.width();a.css({"margin-left":-s/2,"margin-top":20,opacity:0}),a.animate({opacity:1,"margin-top":0},400,function(){cleartimeout(window.cc_timersendsuccesstotop),window.cc_timersendsuccesstotop=settimeout(function(){a.fadeout(function(){a.remove(),"function"==typeof o&&o()})},e||3e3)})},sendwarningtotop:function(t,e,o){var n='
'+t+"
";i("body").append(n);var a=i(".dialog-warning-top"),s=a.width();a.css({"margin-left":-s/2,"margin-top":20,opacity:0}),a.animate({opacity:1,"margin-top":0},400,function(){cleartimeout(window.cc_timersendwarningtotop),window.cc_timersendwarningtotop=settimeout(function(){a.fadeout(function(){a.remove(),"function"==typeof o&&o()})},e||3e3)})},sendmsg:function(e,o,n,s){i.isfunction(o)&&(n=o,o=void 0);var c={id:"dialogtipbox",title:" ",hideheader:!0,hideclose:!1,content:'
'+(s||"")+e+"
",callback:!1===o?null:function(){cleartimeout(window.timerdialoghide),window.timerdialoghide=settimeout(function(){i(t).trigger("click")},o||3e3)},onclose:function(){"function"==typeof n&&n()}};a.show(c)},sendsuccess:function(t,e,o){i.sendmsg(t,e,o,'')},sendwarning:function(t,e,o){i.sendmsg(t,e,o,'')},senderror:function(t,e,o){i.sendmsg(t,e,o,'')},sendconfirm:function(e){var o=(e=i.extend(!0,{id:"dialogconfirmbox",title:"提示框",hideheader:!1,hideclose:!1,withcenter:!1,withicon:!1,autoclose:!1,timeout:3e3,width:null,noconfirm:!1,msg:"",desc:"",content:"",button:{confirm:"确认",cancel:"取消",cancelfirst:!1}},e)).button.confirm,n=e.button.cancel,s="",c="",d="",l="",g="";e.button&&(o||n)&&(s=o?'"+(o.text||o)+"":"",c=n?''+(n.text||n)+"":"",d='
'+(e.button.cancelfirst?c+s:s+c)+"
"),e.withcenter&&(l+=" withcenter"),e.withicon&&(l+=" "+("string"==typeof e.withicon?e.withicon:"withicon")),null!==e.width&&(g=' style="width:'+e.width+("string"==typeof e.width?"":"px")+';"');var r='
"+(""===e.msg?"":'
'+e.msg+"
")+(""===e.desc?"":'
'+e.desc+"
")+(""===e.content?"":'
'+e.content+"
")+d+"
";if(e.content=r,e.autoclose){var f=e.callback||i.noop;e.callback=function(){f(),cleartimeout(window.timerdialoghide),window.timerdialoghide=settimeout(function(){i(t).trigger("click")},e.timeout)}}a.show(e)}}),function(){var e=i(document);e.on("click",t,function(){var t,e=i(this);"function"==typeof n.onbeforeclose&&(t=n.onbeforeclose(e)),!1!==t&&(cleartimeout(window.timerdialoghide),a.hide(function(){"function"==typeof n.onclose&&n.onclose(e,t)}))}),e.on("click",".j_dialogconfirm",function(){var t,e=i(this);void 0===e.attr("noconfirm")&&("function"==typeof n.onbeforeconfirm&&(t=n.onbeforeconfirm(e)),!1!==t&&(cleartimeout(window.timerdialoghide),a.hide(function(){"function"==typeof n.onconfirm&&n.onconfirm(e,t)})))}),e.on("click",".j_dialogcancel",function(){var t,e=i(this);"function"==typeof n.onbeforecancel&&(t=n.onbeforecancel(e)),!1!==t&&(cleartimeout(window.timerdialoghide),a.hide(function(){"function"==typeof n.oncancel&&n.oncancel(e,t)}))}),e.on("click",".j_bghide",function(){i(t).trigger("click")}),e.on("keyup",function(e){27==e.keycode&&i(".j_eschide").length&&i(t).trigger("click").removeclass("j_dialogclose")})}(),i.dialog=a.show,i.dialogclose=a.hide});