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