StocksNew/public/vendor/flasher/flasher-toastr.min.js
Sampanna Rimal 53c0140f58 first commit
2024-08-27 17:48:06 +05:45

2 lines
6.4 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("@flasher/flasher"),require("jquery")):"function"==typeof define&&define.amd?define(["@flasher/flasher","jquery"],t):((e="undefined"!=typeof globalThis?globalThis:e||self).flasher=e.flasher||{},e.flasher.toastr=t(e.flasher,e.jQuery))}(this,(function(e,t){"use strict";var o=function(){return o=Object.assign||function(e){for(var t,o=1,n=arguments.length;o<n;o++)for(var s in t=arguments[o])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},o.apply(this,arguments)};function n(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var s={exports:{}};!function(e){var o;o=function(e){return function(){var t,o,n,s=0,i="error",a="info",r="success",l="warning",c={clear:function(o,n){var s=h();t||u(s),d(o,s,n)||function(o){for(var n=t.children(),s=n.length-1;s>=0;s--)d(e(n[s]),o)}(s)},remove:function(o){var n=h();t||u(n),o&&0===e(":focus",o).length?g(o):t.children().length&&t.remove()},error:function(e,t,o){return f({type:i,iconClass:h().iconClasses.error,message:e,optionsOverride:o,title:t})},getContainer:u,info:function(e,t,o){return f({type:a,iconClass:h().iconClasses.info,message:e,optionsOverride:o,title:t})},options:{},subscribe:function(e){o=e},success:function(e,t,o){return f({type:r,iconClass:h().iconClasses.success,message:e,optionsOverride:o,title:t})},version:"2.1.4",warning:function(e,t,o){return f({type:l,iconClass:h().iconClasses.warning,message:e,optionsOverride:o,title:t})}};return c;function u(o,n){return o||(o=h()),(t=e("#"+o.containerId)).length||n&&(t=function(o){return(t=e("<div/>").attr("id",o.containerId).addClass(o.positionClass)).appendTo(e(o.target)),t}(o)),t}function d(t,o,n){var s=!(!n||!n.force)&&n.force;return!(!t||!s&&0!==e(":focus",t).length||(t[o.hideMethod]({duration:o.hideDuration,easing:o.hideEasing,complete:function(){g(t)}}),0))}function p(e){o&&o(e)}function f(o){var i=h(),a=o.iconClass||i.iconClass;if(void 0!==o.optionsOverride&&(i=e.extend(i,o.optionsOverride),a=o.optionsOverride.iconClass||a),!function(e,t){if(e.preventDuplicates){if(t.message===n)return!0;n=t.message}return!1}(i,o)){s++,t=u(i,!0);var r=null,l=e("<div/>"),c=e("<div/>"),d=e("<div/>"),f=e("<div/>"),m=e(i.closeHtml),v={intervalId:null,hideEta:null,maxHideTime:null},C={toastId:s,state:"visible",startTime:new Date,options:i,map:o};return o.iconClass&&l.addClass(i.toastClass).addClass(a),function(){if(o.title){var e=o.title;i.escapeHtml&&(e=w(o.title)),c.append(e).addClass(i.titleClass),l.append(c)}}(),function(){if(o.message){var e=o.message;i.escapeHtml&&(e=w(o.message)),d.append(e).addClass(i.messageClass),l.append(d)}}(),i.closeButton&&(m.addClass(i.closeClass).attr("role","button"),l.prepend(m)),i.progressBar&&(f.addClass(i.progressClass),l.prepend(f)),i.rtl&&l.addClass("rtl"),i.newestOnTop?t.prepend(l):t.append(l),function(){var e="";switch(o.iconClass){case"toast-success":case"toast-info":e="polite";break;default:e="assertive"}l.attr("aria-live",e)}(),l.hide(),l[i.showMethod]({duration:i.showDuration,easing:i.showEasing,complete:i.onShown}),i.timeOut>0&&(r=setTimeout(y,i.timeOut),v.maxHideTime=parseFloat(i.timeOut),v.hideEta=(new Date).getTime()+v.maxHideTime,i.progressBar&&(v.intervalId=setInterval(T,10))),i.closeOnHover&&l.hover(b,O),!i.onclick&&i.tapToDismiss&&l.click(y),i.closeButton&&m&&m.click((function(e){e.stopPropagation?e.stopPropagation():void 0!==e.cancelBubble&&!0!==e.cancelBubble&&(e.cancelBubble=!0),i.onCloseClick&&i.onCloseClick(e),y(!0)})),i.onclick&&l.click((function(e){i.onclick(e),y()})),p(C),i.debug&&console&&console.log(C),l}function w(e){return null==e&&(e=""),e.replace(/&/g,"&amp;").replace(/"/g,"&quot;").replace(/'/g,"&#39;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function y(t){var o=t&&!1!==i.closeMethod?i.closeMethod:i.hideMethod,n=t&&!1!==i.closeDuration?i.closeDuration:i.hideDuration,s=t&&!1!==i.closeEasing?i.closeEasing:i.hideEasing;if(!e(":focus",l).length||t)return clearTimeout(v.intervalId),l[o]({duration:n,easing:s,complete:function(){g(l),clearTimeout(r),i.onHidden&&"hidden"!==C.state&&i.onHidden(),C.state="hidden",C.endTime=new Date,p(C)}})}function O(){(i.timeOut>0||i.extendedTimeOut>0)&&(r=setTimeout(y,i.extendedTimeOut),v.maxHideTime=parseFloat(i.extendedTimeOut),v.hideEta=(new Date).getTime()+v.maxHideTime)}function b(){clearTimeout(r),v.hideEta=0,l.stop(!0,!0)[i.showMethod]({duration:i.showDuration,easing:i.showEasing})}function T(){var e=(v.hideEta-(new Date).getTime())/v.maxHideTime*100;f.width(e+"%")}}function h(){return e.extend({},{tapToDismiss:!0,toastClass:"toast",containerId:"toast-container",debug:!1,showMethod:"fadeIn",showDuration:300,showEasing:"swing",onShown:void 0,hideMethod:"fadeOut",hideDuration:1e3,hideEasing:"swing",onHidden:void 0,closeMethod:!1,closeDuration:!1,closeEasing:!1,closeOnHover:!0,extendedTimeOut:1e3,iconClasses:{error:"toast-error",info:"toast-info",success:"toast-success",warning:"toast-warning"},iconClass:"toast-info",positionClass:"toast-top-right",timeOut:5e3,titleClass:"toast-title",messageClass:"toast-message",escapeHtml:!1,target:"body",closeHtml:'<button type="button">&times;</button>',closeClass:"toast-close-button",newestOnTop:!0,preventDuplicates:!1,progressBar:!1,progressClass:"toast-progress",rtl:!1},c.options)}function g(e){t||(t=u()),e.is(":visible")||(e.remove(),e=null,0===t.children().length&&(t.remove(),n=void 0))}}()},e.exports?e.exports=o(t):window.toastr=o(window.jQuery)}(s);var i=n(s.exports),a=new(function(){function e(){}return e.prototype.success=function(e,t,o){this.flash("success",e,t,o)},e.prototype.info=function(e,t,o){this.flash("info",e,t,o)},e.prototype.warning=function(e,t,o){this.flash("warning",e,t,o)},e.prototype.error=function(e,t,o){this.flash("error",e,t,o)},e.prototype.flash=function(e,t,o,n){var s=this.createNotification(e,t,o,n);this.renderOptions({}),this.render({notification:s})},e.prototype.createNotification=function(e,t,o,n){if("object"==typeof e?(e=(n=e).type,t=n.message,o=n.title):"object"==typeof t?(t=(n=t).message,o=n.title):"object"==typeof o&&(o=(n=o).title),void 0===t)throw new Error("message option is required");return{type:e||"info",message:t,title:o,options:n}},e.prototype.render=function(e){var t=e.notification,o=t.message,n=t.title,s=t.options,a=t.type||"info",r=i[a](o,n,s);r.parent().attr("data-turbo-cache","false"),r.parent().addClass("fl-no-cache")},e.prototype.renderOptions=function(e){i.options=o({timeOut:e.timeOut||5e3,progressBar:e.progressBar||5e3},e)},e}());return e.addFactory("toastr",a),a}));