Test/popModal.min.js
(完整代码) 11KB/* popModal - 23.05.14 */
(function(a){a.fn.popModal=function(b){function g(){function b(a){var c=Math.max(B,C,D);return(a==q?0<C:a==u?0<B:0<D)?a:0<C&&C==c?q:0<B&&B==c?u:0<deltaBC&&D==c?t:a}var m=f.position().left,h=f.position().top,l=parseInt(f.css("marginLeft"));parseInt(f.css("paddingLeft"));var d=parseInt(f.css("marginTop")),g=f.outerHeight(),p=f.outerWidth(),r=parseInt(c.css("maxWidth")),v=parseInt(c.css("minWidth")),y=c.outerHeight();n?isNaN(r)&&(r=300):(isNaN(v)&&(v=180),r=v);c.css({width:r+"px"});var A,z=f.offset().left,
E=a(window).width()-f.offset().left-p,H=f.offset().top,v=z-10-r,B=p+z-r,I=E-10-r,C=p+E-r,D=Math.min(p/2+E-r/2,p/2+z-r/2),z=H-y/2;/^bottom/.test(k.placement)?A=b(k.placement):/^left/.test(k.placement)?A=0<v?k.placement==s&&0<z?s:w:b(q):/^right/.test(k.placement)&&(A=0<I?k.placement==F&&0<z?F:G:b(u));c.removeAttr("class").addClass(e+" animated "+A);switch(A){case q:c.css({top:h+d+g+10+"px",left:m+l+"px"}).addClass(x+"Bottom");break;case u:c.css({top:h+d+g+10+"px",left:m+l+p-r+"px"}).addClass(x+"Bottom");
break;case t:c.css({top:h+d+g+10+"px",left:m+l+(p-r)/2+"px"}).addClass(x+"Bottom");break;case w:c.css({top:h+d+"px",left:m+l-r-10+"px"}).addClass(x+"Left");break;case G:c.css({top:h+d+"px",left:m+l+p+10+"px"}).addClass(x+"Right");break;case s:c.css({top:h+d+g/2-y/2+"px",left:m+l-r-10+"px"}).addClass(x+"Left");break;case F:c.css({top:h+d+g/2-y/2+"px",left:m+l+p+10+"px"}).addClass(x+"Right")}}function h(){c=a("."+e);d();p||(p=c.css("animationDuration"),p=void 0!=p?1E3*p.replace("s",""):0);setTimeout(function(){a("."+
e+"_source").replaceWith(a("."+e+"_content").children());c.remove();a("html."+e+"Open").off("."+e+"Event").removeClass(e+"Open")},p)}function d(){var a=c.attr("class"),e=a.replace(x,v);c.removeClass(a).addClass(e)}var f=a(this),c,m="",n=!0,l="",e="popModal",k,p,x="fadeIn",v="fadeOut",q="bottomLeft",t="bottomCenter",u="bottomRight",w="leftTop",s="leftCenter",G="rightTop",F="rightCenter",y={init:function(b){k=a.extend({html:"",placement:q,showCloseBut:!0,onDocumentClickClose:!0,onOkBut:function(){return!0},
onCancelBut:function(){},onLoad:function(){},onClose:function(){}},b);if(f.next("div").hasClass(e))h();else{a("html."+e+"Open").off("."+e+"Event").removeClass(e+"Open");a("."+e+"_source").replaceWith(a("."+e+"_content").children());a("."+e).remove();k.showCloseBut&&(l=a('<button type="button" class="close">×</button>'));"fixed"==f.css("position")&&(m="position:fixed;");b=a('<div class="'+e+' animated" style="'+m+'"></div>');var d=a('<div class="'+e+"_content "+e+'_contentOverflow"></div>');
b.append(l,d);a.isFunction(k.html)?(d.append("Please, waiting..."),k.html(function(b){d.empty().append(b);c=a("."+e);n=!0;-1!=d[0].innerHTML.search(/<form/)?c.find("."+e+"_content").removeClass(e+"_contentOverflow"):c.find("."+e+"_content").addClass(e+"_contentOverflow");g()})):("object"==a.type(k.html)&&k.html.after(a('<div class="popModal_source"></div>')),d.append(k.html));f.after(b);c=a("."+e);c.find("."+e+"_footer")&&c.find("."+e+"_content").css({marginBottom:c.find("."+e+"_footer").outerHeight()+
"px"});a.isFunction(k.html)||(-1!=("string"==a.type(k.html)?k.html:k.html[0].outerHTML).search(/<form/)||200>c.find("."+e+"_content").outerHeight())&&c.find("."+e+"_content").removeClass(e+"_contentOverflow");if(k.onLoad&&a.isFunction(k.onLoad))k.onLoad();c.on("destroyed",function(){if(k.onClose&&a.isFunction(k.onClose))k.onClose()});n=!0;("absolute"!=f.parent().css("position")||"fixed"!=f.parent().css("position"))&&270>c.find("."+e+"_content").width()&&60>c.find("."+e+"_content").height()&&(n=!1);
g();if(k.onDocumentClickClose)a("html").on("click."+e+"Event",function(b){a(this).addClass(e+"Open");c.is(":hidden")&&h();var d=a(b.target);d.parents().andSelf().is("."+e)||d.parents().andSelf().is(f)||(b=parseInt(d.parents().filter(function(){return"auto"!==a(this).css("zIndex")}).first().css("zIndex")),isNaN(b)&&(b=0),d=d.css("zIndex"),"auto"==d&&(d=0),b<d&&(b=d),b<=c.css("zIndex")&&h())});a(window).resize(function(){g()});c.find(".close").bind("click",function(){h()});c.find('[data-popModalBut="close"]').bind("click",
function(){h()});c.find('[data-popModalBut="ok"]').bind("click",function(c){var e;k.onOkBut&&a.isFunction(k.onOkBut)&&(e=k.onOkBut(c));!1!==e&&h()});c.find('[data-popModalBut="cancel"]').bind("click",function(){if(k.onCancelBut&&a.isFunction(k.onCancelBut))k.onCancelBut();h()});a("html").on("keydown."+e+"Event",function(a){27==a.keyCode&&h()})}},hide:function(){h()}};if(y[b])return y[b].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof b||!b)return y.init.apply(this,arguments)};
a("* [data-popModalBind]").bind("click",function(){var b=a(this).attr("data-popModalBind"),b={html:a(b)};void 0!=a(this).attr("data-placement")&&(b.placement=a(this).attr("data-placement"));void 0!=a(this).attr("data-showCloseBut")&&(b.showCloseBut=/^true$/i.test(a(this).attr("data-showCloseBut")));void 0!=a(this).attr("data-overflowContent")&&(b.overflowContent=/^true$/i.test(a(this).attr("data-overflowContent")));void 0!=a(this).attr("data-onDocumentClickClose")&&(b.onDocumentClickClose=/^true$/i.test(a(this).attr("data-onDocumentClickClose")));
a(this).popModal(b)});a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}})(jQuery);
(function(a){a.fn.notifyModal=function(b){function g(){var c=a("."+f);setTimeout(function(){c.removeClass("open");setTimeout(function(){c.remove();-1!=m.duration&&clearTimeout(notifDur)},n)},n)}var h=a(this),d,f="notifyModal",c="",m,n,l={init:function(e){m=a.extend({duration:2500,placement:"center",overlay:!0},e);m.overlay&&(c="overlay");a("."+f).remove();e=a('<div class="'+f+" "+m.placement+" "+c+'"></div>');var b=a('<div class="'+f+'_content"></div>'),l=a('<button type="button" class="close">×</button>');
h=void 0==h[0]?h.selector:h[0].innerHTML;b.append(l,h);e.append(b);a("body").append(e);d=a("."+f);n||(n=d.css("transitionDuration"),n=void 0!=n?1E3*n.replace("s",""):0);setTimeout(function(){d.addClass("open")},n);d.click(function(){g()});-1!=m.duration&&(notifDur=setTimeout(g,m.duration))},hide:function(){g()}};a("html").keydown(function(a){27==a.keyCode&&g()});if(l[b])return l[b].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof b||!b)return l.init.apply(this,arguments)};
a("* [data-notifyModalBind]").bind("click",function(){var b=a(this).attr("data-notifyModalBind"),g={};void 0!=a(this).attr("data-duration")&&(g.duration=parseInt(a(this).attr("data-duration")));void 0!=a(this).attr("data-placement")&&(g.placement=a(this).attr("data-placement"));void 0!=a(this).attr("data-onTop")&&(g.onTop=/^true$/i.test(a(this).attr("data-onTop")));a(b).notifyModal(g)})})(jQuery);
(function(a){a.fn.hintModal=function(b){var g=a(".hintModal_container"),h=a(".hintModal"),d;bl="bottomLeft";bc="bottomCenter";br="bottomRight";g.addClass("animated fadeInBottom");var f={init:function(c){h.mouseenter(function(){var c,b,d=h.outerWidth();b=g.outerWidth();var e=h.offset().left,f=a(window).width()-h.offset().left-d;c=d+e-b;var p=d+f-b,d=Math.min(d/2+f-b/2,d/2+e-b/2);b=h.hasClass(bl)?bl:h.hasClass(bc)?bc:h.hasClass(br)?br:bl;void 0==h.data("placement")&&h.data("placement",b);b=h.data("placement");
e=Math.max(c,p,d);c=(b==bl?0<p:b==br?0<c:0<d)?b:0<p&&p==e?bl:0<c&&c==e?br:0<deltaBC&&d==e?bc:b;h.removeAttr("class").addClass("hintModal "+c);c=a(this).find(".hintModal_container");g.css({display:"none"});p=c.attr("class");d=p.replace("fadeOut","fadeIn");c.removeClass(p).addClass(d).css({display:"block"})});h.mouseleave(function(){var a=g.attr("class"),c=a.replace("fadeIn","fadeOut");g.removeClass(a).addClass(c);d||(d=g.css("animationDuration"),d=void 0!=d?1E3*d.replace("s",""):0);setTimeout(function(){g.css({display:"none"})},
d)})}};if(f[b])return f[b].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof b||!b)return f.init.apply(this,arguments)};a(".hintModal").hintModal()})(jQuery);
(function(a){a.fn.dialogModal=function(b){function g(){var b=a("."+c);setTimeout(function(){b.removeClass("open");setTimeout(function(){b.remove();a("body").removeClass(c+"Open");a("html."+c+"Open").off("."+c+"Event").removeClass(c+"Open");b.find("."+m).off("click");b.find("."+n).off("click")},e)},e)}var h=a(this),d,f,c="dialogModal",m="dialogPrev",n="dialogNext",l,e,k={init:function(b){function k(){var b=f.outerHeight();a(window).height()>b+80?f.css({marginTop:(a(window).height()-b)/2+"px"}):f.css({marginTop:"60px"});
a("body").addClass(c+"Open");d.addClass("open");setTimeout(function(){d.addClass("open");f.css({marginTop:parseInt(f.css("marginTop"))-20+"px"})},e);v()}function v(){d.find('[data-dialogModalBut="close"]').bind("click",function(){g()});d.find('[data-dialogModalBut="ok"]').bind("click",function(c){var b;l.onOkBut&&a.isFunction(l.onOkBut)&&(b=l.onOkBut(c));!1!==b&&g()});d.find('[data-dialogModalBut="cancel"]').bind("click",function(){if(l.onCancelBut&&a.isFunction(l.onCancelBut))l.onCancelBut();g()})}
l=a.extend({onOkBut:function(){return!0},onCancelBut:function(){},onLoad:function(){},onClose:function(){}},b);a("html."+c+"Open").off("."+c+"Event").removeClass(c+"Open");a("."+c+" ."+m+", ."+c+" ."+n).off("click");a("."+c).remove();var q=0,t=h.length-1;b=a('<div class="'+c+'"></div>');var u=a('<div class="'+c+'_container"></div>'),w=a('<button type="button" class="close">×</button>'),s=a('<div class="'+c+'_body"></div>');b.append(u);u.append(w,s);s.append(h[q].innerHTML);0<t&&u.prepend(a('<div class="'+
m+' notactive"></div><div class="'+n+'"></div>'));a("body").append(b);d=a("."+c);f=a("."+c+"_container");e||(e=d.css("transitionDuration"),e=void 0!=e?1E3*e.replace("s",""):0);if(l.onLoad&&a.isFunction(l.onLoad))l.onLoad();d.on("destroyed",function(){if(l.onClose&&a.isFunction(l.onClose))l.onClose()});k();d.find("."+m).bind("click",function(){0<q&&(--q,q<t&&d.find("."+n).removeClass("notactive"),0==q&&d.find("."+m).addClass("notactive"),s.empty().append(h[q].innerHTML),k())});d.find("."+n).bind("click",
function(){q<t&&(++q,0<q&&d.find("."+m).removeClass("notactive"),q==t&&d.find("."+n).addClass("notactive"),s.empty().append(h[q].innerHTML),k())});d.find(".close").bind("click",function(){g()});a("html").on("keydown."+c+"Event",function(a){27==a.keyCode?g():37==a.keyCode?d.find("."+m).click():39==a.keyCode&&d.find("."+n).click()})},hide:function(){g()}};if(k[b])return k[b].apply(this,Array.prototype.slice.call(arguments,1));if("object"===typeof b||!b)return k.init.apply(this,arguments)};a("* [data-dialogModalBind]").bind("click",
function(){var b=a(this).attr("data-dialogModalBind");a(b).dialogModal()});a.event.special.destroyed={remove:function(a){a.handler&&a.handler()}}})(jQuery);
(function(a){a.fn.titleModal=function(b){var g={init:function(b){function d(){var a=c.attr("class"),b=a.replace(n,l);c.removeClass(a).addClass(b)}var f,c;b=a("*[data-titleModal]");var g,n="fadeIn",l="fadeOut";b.mouseenter(function(){f=a(this);titleAttr=f.attr("title");f.removeAttr("title");f.attr("data-title",titleAttr);titleModal=a('<div class="titleModal animated"></div>');c=a(".titleModal");placement=f.attr("data-placement");void 0==placement&&(placement="bottom");c&&c.remove();f.after(titleModal.append(titleAttr));
c=a(".titleModal");var b=f.position().left,d=f.position().top,g=f.css("marginLeft"),h=f.css("marginTop"),l=f.css("marginBottom"),m=f.outerHeight(),t=f.outerWidth(),u=c.css("marginTop"),w=c.outerWidth(),s=c.outerHeight();switch(placement){case "bottom":c.css({marginTop:parseInt(u)-parseInt(l)+"px",left:b+parseInt(g)+(t-w)/2+"px"}).addClass(n+"Bottom");break;case "top":c.css({top:d+parseInt(h)-s+"px",left:b+parseInt(g)+(t-w)/2+"px"}).addClass("top "+n+"Top");break;case "left":c.css({top:d+parseInt(h)+
m/2-s/2+"px",left:b+parseInt(g)-w-10+"px"}).addClass("left "+n+"Left");break;case "right":c.css({top:d+parseInt(h)+m/2-s/2+"px",left:b+parseInt(g)+t+10+"px"}).addClass("right "+n+"Right")}});b.mouseleave(function(){f=a(this);titleAttr=f.attr("data-title");f.removeAttr("data-title");f.attr("title",titleAttr);d();g||(g=c.css("animationDuration"),g=void 0!=g?1E3*g.replace("s",""):0);setTimeout(function(){c.remove()},g)})}};if(g[b])return g[b].apply(this,Array.prototype.slice.call(arguments,1));if("object"===
typeof b||!b)return g.init.apply(this,arguments)}()})(jQuery);
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。