2022-05-29 09:24:36 +00:00
|
|
|
!function(A,e,n,D){"use strict";A.isFunction=A.isFunction||function(e){return"function"==typeof e&&"number"!=typeof e.nodeType},e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),A.fn.toast=function(w){var k,e=A(this),T=e.selector||"",x=(new Date).getTime(),I=[],P=w,O="string"==typeof P,M=[].slice.call(arguments,1);return e.each(function(){var o,s,a,i,c,l,r,u,d=A.isPlainObject(w)?A.extend(!0,{},A.fn.toast.settings,w):A.extend({},A.fn.toast.settings),p=d.className,f=d.selector,m=d.error,e=d.namespace,g=d.fields,n="."+e,t=e+"-module",h=A(this),v=d.context?A(d.context):A("body"),b=h.hasClass("toast")||h.hasClass("message")||h.hasClass("card"),C=this,y=b?h.data(t):D;u={initialize:function(){u.verbose("Initializing element"),u.has.container()||u.create.container(),(b||""!==d.message||""!==d.title||""!==u.get.iconClass()||d.showImage||u.has.configActions())&&("string"==typeof d.showProgress&&-1!==[p.top,p.bottom].indexOf(d.showProgress)||(d.showProgress=!1),u.create.toast(),d.closeOnClick&&(d.closeIcon||0<A(s).find(f.input).length||u.has.configActions())&&(d.closeOnClick=!1),d.closeOnClick||o.addClass(p.unclickable),u.bind.events()),u.instantiate(),o&&u.show()},instantiate:function(){u.verbose("Storing instance of toast"),y=u,h.data(t,y)},destroy:function(){o&&(u.debug("Removing toast",o),u.unbind.events(),o.remove(),l=s=o=D,d.onRemove.call(o,C),r=c=i=D),h.removeData(t)},show:function(e){e=e||function(){},u.debug("Showing toast"),!1!==d.onShow.call(o,C)?u.animate.show(e):u.debug("onShow callback returned false, cancelling toast animation")},close:function(e){e=e||function(){},u.remove.visible(),u.unbind.events(),u.animate.close(e)},create:{container:function(){u.verbose("Creating container"),v.append(A("<div/>",{class:d.position+" "+p.container+" "+(d.horizontal?p.horizontal:"")}))},toast:function(){o=A("<div/>",{class:p.box});var e=u.get.iconClass();if(b)s=d.cloneModule?h.clone().removeAttr("id"):h,r=s.find("> i"+u.helpers.toClass(p.close)),d.closeIcon=0<r.length,""!==e&&s.find(f.icon).attr("class",e+" "+p.icon),d.showImage&&s.find(f.image).attr("src",d.showImage),""!==d.title&&s.find(f.title).html(u.helpers.escape(d.title,d.preserveHTML)),""!==d.message&&s.find(f.message).html(u.helpers.escape(d.message,d.preserveHTML));else{u.verbose("Creating toast"),s=A("<div/>");var n=A("<div/>",{class:p.content});""!==e&&s.append(A("<i/>",{class:e+" "+p.icon})),d.showImage&&s.append(A("<img>",{class:p.image+" "+d.classImage,src:d.showImage})),""!==d.title&&n.append(A("<div/>",{class:p.title,text:d.title})),n.append(A("<div/>",{class:p.message,html:u.helpers.escape(d.message,d.preserveHTML)})),s.addClass(d.class+" "+p.toast).append(n),s.css("opacity",d.opacity),d.closeIcon&&((r=A("<i/>",{class:p.close+" "+("string"==typeof d.closeIcon?d.closeIcon:"")})).hasClass(p.left)?s.prepend(r):s.append(r))}if(s.hasClass(p.compact)&&(d.compact=!0),s.hasClass("card")&&(d.compact=!1),a=s.find(".actions"),u.has.configActions()&&(0===a.length&&(a=A("<div/>",{class:p.actions+" "+(d.classActions||"")}).appendTo(s)),s.hasClass("card")&&!a.hasClass(p.attached)&&(a.addClass(p.extraContent),a.hasClass(p.vertical)&&(a.removeClass(p.vertical),u.error(m.verticalCard))),d.actions.forEach(function(e){var n=e[g.icon]?'<i class="'+u.helpers.deQuote(e[g.icon])+' icon"></i>':"",t=u.helpers.escape(e[g.text]||"",d.preserveHTML),o=u.helpers.deQuote(e[g.class]||""),s=e[g.click]&&A.isFunction(e[g.click])?e[g.click]:function(){};a.append(A("<button/>",{html:n+t,class:p.button+" "+o,click:function(){!1!==s.call(C,h)&&u.close()}}))})),a&&a.hasClass(p.vertical)&&s.addClass(p.vertical),0<a.length&&!a.hasClass(p.attached)&&(!a||a.hasClass(p.basic)&&!a.hasClass(p.left)||s.addClass(p.actions)),"auto"===d.displayTime&&(d.displayTime=Math.max(d.minDisplayTime,s.text().split(" ").length/d.wordsPerMinute*6e4)),o.append(s),0<a.length&&a.hasClass(p.attached)&&(a.addClass(p.buttons),a.detach(),s.addClass(p.attached),a.hasClass(p.vertical)?(s.wrap(A("<div/>",{class:p.vertical+" "+p.attached+" "+(d.compact?p.compact:"")})),a.hasClass(p.le
|