forked from marcorinck/angular-growl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular-growl.min.js
6 lines (6 loc) · 2.29 KB
/
angular-growl.min.js
1
2
3
4
5
6
/**
* angular-growl - v0.3.4 - 2014-01-07
* https://github.com/mattduffield/angular-growl
* Copyright (c) 2014 Matt Duffield; Licensed MIT
*/
angular.module("angular-growl",[]),angular.module("angular-growl").directive("growl",["$rootScope",function(a){"use strict";return{restrict:"A",template:'<div class="growl"> <div class="growl-item alert" ng-repeat="message in messages" ng-class="computeClasses(message)"> <button type="button" class="close" ng-click="deleteMessage(message)">×</button> {{ message.text}} </div></div>',replace:!1,scope:!0,controller:["$scope","$timeout",function(b,c){b.messages=[],a.$on("growlMessage",function(a,d){b.messages.push(d),d.ttl&&-1!==d.ttl&&c(function(){b.deleteMessage(d)},d.ttl)}),b.deleteMessage=function(a){var c=b.messages.indexOf(a);c>-1&&b.messages.splice(c,1),"function"==typeof a.callback&&a.callback()},b.computeClasses=function(a){return{"alert-success":a.isSuccess,"alert-error":a.isError,"alert-danger":a.isError,"alert-info":a.isInfo,"alert-warning":a.isWarn}}}]}}]),angular.module("angular-growl").provider("growl",function(){"use strict";var a=null,b="messages",c="text",d="severity";this.globalTimeToLive=function(b){a=b},this.messagesKey=function(a){b=a},this.messageTextKey=function(a){c=a},this.messageSeverityKey=function(a){d=a},this.serverMessagesInterceptor=["$q","growl",function(a,c){function d(a){a.data[b]&&a.data[b].length>0&&c.addServerMessages(a.data[b])}function e(a){return d(a),a}function f(b){return d(b),a.reject(b)}return function(a){return a.then(e,f)}}],this.$get=["$rootScope","$filter",function(b,e){function f(a){m&&(a.text=m(a.text)),b.$broadcast("growlMessage",a)}function g(b,c,d,e){var g,h=c||{};g={text:b,isWarn:d.isWarn,isError:d.isError,isInfo:d.isInfo,isSuccess:d.isSuccess,ttl:h.ttl||a,callback:e},f(g)}function h(a,b,c){g(a,b,{isWarn:!0},c)}function i(a,b,c){g(a,b,{isError:!0},c)}function j(a,b,c){g(a,b,{isInfo:!0},c)}function k(a,b,c){g(a,b,{isSuccess:!0},c)}function l(a){var b,e,f,h;for(h=a.length,b=0;h>b;b++)if(e=a[b],e[c]&&e[d]){switch(e[d]){case"warn":f={isWarn:!0};break;case"success":f={isSuccess:!0};break;case"info":f={isInfo:!0};break;case"error":f={isError:!0}}g(e[c],void 0,f)}}var m;try{m=e("translate")}catch(n){}return{addWarnMessage:h,addErrorMessage:i,addInfoMessage:j,addSuccessMessage:k,addServerMessages:l}}]});