/* * @license * AngularJS Toaster * Version: 3.0.0 * * Copyright 2013-2019 Jiri Kavulak, Stabzs. * All Rights Reserved. * Use, reproduction, distribution, and modification of this code is subject to the terms and * conditions of the MIT license, available at http://www.opensource.org/licenses/mit-license.php * * Authors: Jiri Kavulak, Stabzs * Related to project of John Papa, Hans Fjällemark and Nguyễn Thiện Hùng (thienhung1989) */ !function(t,e){"use strict";angular.module("toaster",[]).constant("toasterConfig",{limit:0,"tap-to-dismiss":!0,"close-button":!1,"close-html":'',"newest-on-top":!0,"time-out":5e3,"icon-classes":{error:"toast-error",info:"toast-info",wait:"toast-wait",success:"toast-success",warning:"toast-warning"},"body-output-type":"","body-template":"toasterBodyTmpl.html","icon-class":"toast-info","position-class":"toast-top-right","title-class":"toast-title","message-class":"toast-message","prevent-duplicates":!1,"mouseover-timer-stop":!0}).run(["$templateCache",function(t){t.put("angularjs-toaster/toast.html",'
{{toaster.title}}
{{toaster.body}}
')}]).service("toaster",["$rootScope","toasterConfig",function(d,t){var m={newGuid:function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)})}};for(var e in this.pop=function(t,e,o,s,a,i,n,r,c,l){if(angular.isObject(t)){var u=t;this.toast={type:u.type,title:u.title,body:u.body,timeout:u.timeout,bodyOutputType:u.bodyOutputType,clickHandler:u.clickHandler,showCloseButton:u.showCloseButton,closeHtml:u.closeHtml,toastId:u.toastId,onShowCallback:u.onShowCallback,onHideCallback:u.onHideCallback,directiveData:u.directiveData,tapToDismiss:u.tapToDismiss},n=u.toasterId}else this.toast={type:t,title:e,body:o,timeout:s,bodyOutputType:a,clickHandler:i,showCloseButton:r,toastId:c,onHideCallback:l};return this.toast.toastId&&this.toast.toastId.length||(this.toast.toastId=m.newGuid()),d.$emit("toaster-newToast",n,this.toast.toastId),{toasterId:n,toastId:this.toast.toastId}},this.clear=function(t,e){angular.isObject(t)?d.$emit("toaster-clearToasts",t.toasterId,t.toastId):d.$emit("toaster-clearToasts",t,e)},t["icon-classes"])this[e]=o(e);function o(l){return function(t,e,o,s,a,i,n,r,c){return angular.isString(t)?this.pop(l,t,e,o,s,a,i,n,r,c):this.pop(angular.extend(t,{type:l}))}}}]).factory("toasterEventRegistry",["$rootScope",function(t){var e,o=null,s=null,i=[],n=[];return{setup:(e={setup:function(){o||(o=t.$on("toaster-newToast",function(t,e,o){for(var s=0,a=i.length;s")(a);i.append(s)})}}}]).directive("toasterContainer",["$parse","$rootScope","$interval","$sce","toasterConfig","toaster","toasterEventRegistry",function(d,t,i,m,o,a,n){return{replace:!0,restrict:"EA",scope:!0,link:function(c,t,e){var l;function u(t){var e=c.toasters[t];e.timeoutPromise&&i.cancel(e.timeoutPromise),c.toasters.splice(t,1),angular.isFunction(e.onHideCallback)&&e.onHideCallback(e)}function s(t){return angular.isUndefined(t)||null===t}l=angular.extend({},o,c.$eval(e.toasterOptions)),c.config={toasterId:l["toaster-id"],position:l["position-class"],title:l["title-class"],message:l["message-class"],tap:l["tap-to-dismiss"],closeButton:l["close-button"],closeHtml:l["close-html"],animation:l["animation-class"],mouseoverTimer:l["mouseover-timer-stop"]},c.$on("$destroy",function(){n.unsubscribeToNewToastEvent(c._onNewToast),n.unsubscribeToClearToastsEvent(c._onClearToasts)}),c.configureTimer=function(t){var e,o,s=angular.isNumber(t.timeout)?t.timeout:l["time-out"];"object"==typeof s&&(s=s[t.type]),0l.limit&&u(c.toasters.length-1)):(c.toasters.push(t),0l.limit&&u(0)),angular.isFunction(t.onShowCallback)&&t.onShowCallback(t)}(a.toast,o)},c._onClearToasts=function(t,e,o){("*"==e||s(c.config.toasterId)&&s(e)||!s(c.config.toasterId)&&!s(e)&&c.config.toasterId==e)&&function(t){for(var e=c.toasters.length-1;0<=e;e--)s(t)?u(e):c.toasters[e].toastId==t&&u(e)}(o)},n.setup(),n.subscribeToNewToastEvent(c._onNewToast),n.subscribeToClearToastsEvent(c._onClearToasts)},controller:["$scope","$element","$attrs",function(a,t,e){a.stopTimer=function(t){!0===a.config.mouseoverTimer&&t.timeoutPromise&&(i.cancel(t.timeoutPromise),t.timeoutPromise=null)},a.restartTimer=function(t){!0===a.config.mouseoverTimer?t.timeoutPromise||a.configureTimer(t):null===t.timeoutPromise&&a.removeToast(t.toastId)},a.click=function(t,e,o){if(t.stopPropagation(),!0===("boolean"==typeof e.tapToDismiss?e.tapToDismiss:a.config.tap)||!0===e.showCloseButton&&!0===o){var s=!0;e.clickHandler&&(angular.isFunction(e.clickHandler)?s=e.clickHandler(e,o):angular.isFunction(a.$parent.$eval(e.clickHandler))?s=a.$parent.$eval(e.clickHandler)(e,o):console.log("TOAST-NOTE: Your click handler is not inside a parent scope of toaster-container.")),s&&a.removeToast(e.toastId)}}}],templateUrl:"angularjs-toaster/toast.html"}}])}(window,document);