wishthis/semantic/dist/components/toast.min.js

11 lines
13 KiB
JavaScript
Raw Normal View History

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