1 |
- "use strict";!function(){$.Toast=function(t,s,o,e){function a(){window.csdn.userLogin.Toast.remove(n)}var i={appendTo:"body",stack:!1,position_class:"toast-bottom-right",fullscreen:!1,width:250,spacing:20,timeout:4e3,has_close_btn:!0,has_icon:!0,sticky:!1,border_radius:6,has_progress:!1,rtl:!1},n=null,r=$.extend(!0,{},i,e),p=r.spacing,d={position:"body"==r.appendTo?"fixed":"absolute","min-width":r.width,display:"none","border-radius":r.border_radius,"z-index":99999};if(n=$('<div class="toast-item-wrapper '+o+" "+r.position_class+'"></div>'),$('<p class="toast-title">'+t+"</p>").appendTo(n),$('<p class="toast-message">'+s+"</p>").appendTo(n),r.fullscreen&&n.addClass("fullscreen"),r.rtl&&n.addClass("rtl"),r.has_close_btn&&($('<span class="toast-close">×</span>').appendTo(n),r.rtl?d["padding-left"]=20:d["padding-right"]=20),r.has_icon&&($('<i class="toast-icon toast-icon-'+o+'"></i>').appendTo(n),r.rtl?d["padding-right"]=50:d["padding-left"]=50),r.has_progress&&r.timeout>0&&$('<div class="toast-progress"></div>').appendTo(n),r.sticky)switch(r.spacing=0,p=0,r.position_class){case"toast-top-left":case"toast-top-right":d.top=0,d.left=0;break;case"toast-top-center":d.top=0,d.left=d.right=0,d.width="100%";break;case"toast-bottom-left":d.bottom=0,d.left=0;break;case"toast-bottom-right":d.bottom=0,d.right=0;break;case"toast-bottom-center":d.bottom=0,d.left=d.right=0,d.width="100%"}return r.stack&&(-1!==r.position_class.indexOf("toast-top")?$(r.appendTo).find(".toast-item-wrapper").each(function(){d.top=parseInt($(this).css("top"))+this.offsetHeight+p}):-1!==r.position_class.indexOf("toast-bottom")&&$(r.appendTo).find(".toast-item-wrapper").each(function(){d.bottom=parseInt($(this).css("bottom"))+this.offsetHeight+p})),n.css(d),n.appendTo(r.appendTo),n.fadeIn?n.fadeIn():$alert.css({display:"block",opacity:1}),r.timeout>0&&(setTimeout(a,r.timeout),r.has_progress&&$(".toast-progress",n).animate({width:"100%"},r.timeout)),$(".toast-close",n).click(a),n},window.csdn.userLogin=window.csdn.userLogin||{},window.csdn.userLogin.Toast=$.Toast,$.Toast.remove=function(t){t.fadeOut?t.fadeOut(function(){return t.remove()}):t.remove()},window.csdn.userLogin.Toast.remove=$.Toast.remove}();
|