2017-04-03 19:46:56 +02:00
|
|
|
!function(a,b){"use strict";angular.module("toaster",[]).constant("toasterConfig",{limit:0,"tap-to-dismiss":!0,"close-button":!1,"close-html":'<button class="toast-close-button" type="button">×</button>',"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(a){a.put("angularjs-toaster/toast.html",'<div id="toast-container" ng-class="[config.position, config.animation]"><div ng-repeat="toaster in toasters" class="toast" ng-class="toaster.type" ng-click="click($event, toaster)" ng-mouseover="stopTimer(toaster)" ng-mouseout="restartTimer(toaster)"><div ng-if="toaster.showCloseButton" ng-click="click($event, toaster, true)" ng-bind-html="toaster.closeHtml"></div><div ng-class="config.title">{{toaster.title}}</div><div ng-class="config.message" ng-switch on="toaster.bodyOutputType"><div ng-switch-when="trustedHtml" ng-bind-html="toaster.html"></div><div ng-switch-when="template"><div ng-include="toaster.bodyTemplate"></div></div><div ng-switch-when="templateWithData"><div ng-include="toaster.bodyTemplate"></div></div><div ng-switch-when="directive"><div directive-template directive-name="{{toaster.html}}" directive-data="{{toaster.directiveData}}"></div></div><div ng-switch-default >{{toaster.body}}</div></div></div></div>')}]).service("toaster",["$rootScope","toasterConfig",function(a,b){function e(a){return function(b,c,d,e,f,g,h,i,j){return angular.isString(b)?this.pop(a,b,c,d,e,f,g,h,i,j):this.pop(angular.extend(b,{type:a}))}}var c=function(){var a={};return a.newGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(a){var b=16*Math.random()|0,c="x"==a?b:3&b|8;return c.toString(16)})},a}();this.pop=function(b,d,e,f,g,h,i,j,k,l){if(angular.isObject(b)){var m=b;this.toast={type:m.type,title:m.title,body:m.body,timeout:m.timeout,bodyOutputType:m.bodyOutputType,clickHandler:m.clickHandler,showCloseButton:m.showCloseButton,closeHtml:m.closeHtml,toastId:m.toastId,onShowCallback:m.onShowCallback,onHideCallback:m.onHideCallback,directiveData:m.directiveData,tapToDismiss:m.tapToDismiss},i=m.toasterId}else this.toast={type:b,title:d,body:e,timeout:f,bodyOutputType:g,clickHandler:h,showCloseButton:j,toastId:k,onHideCallback:l};return this.toast.toastId&&this.toast.toastId.length||(this.toast.toastId=c.newGuid()),a.$emit("toaster-newToast",i,this.toast.toastId),{toasterId:i,toastId:this.toast.toastId}},this.clear=function(b,c){angular.isObject(b)?a.$emit("toaster-clearToasts",b.toasterId,b.toastId):a.$emit("toaster-clearToasts",b,c)};for(var d in b["icon-classes"])this[d]=e(d)}]).factory("toasterEventRegistry",["$rootScope",function(a){var f,b=null,c=null,d=[],e=[];return f={setup:function(){b||(b=a.$on("toaster-newToast",function(a,b,c){for(var e=0,f=d.length;e<f;e++)d[e](a,b,c)})),c||(c=a.$on("toaster-clearToasts",function(a,b,c){for(var d=0,f=e.length;d<f;d++)e[d](a,b,c)}))},subscribeToNewToastEvent:function(a){d.push(a)},subscribeToClearToastsEvent:function(a){e.push(a)},unsubscribeToNewToastEvent:function(a){var c=d.indexOf(a);c>=0&&d.splice(c,1),0===d.length&&(b(),b=null)},unsubscribeToClearToastsEvent:function(a){var b=e.indexOf(a);b>=0&&e.splice(b,1),0===e.length&&(c(),c=null)}},{setup:f.setup,subscribeToNewToastEvent:f.subscribeToNewToastEvent,subscribeToClearToastsEvent:f.subscribeToClearToastsEvent,unsubscribeToNewToastEvent:f.unsubscribeToNewToastEvent,unsubscribeToClearToastsEvent:f.unsubscribeToClearToastsEvent}}]).directive("directiveTemplate",["$compile","$injector",function(a,b){return{restrict:"A",scope:{directiveName:"@directiveName",directiveData:"@directiveData"},replace:!0,link:function(c,d,e){c.$watch("directiveName",function(f){if(angular.isUndefined(f)||f.length<=0)throw new Error("A valid directive name must be
|