Newer
Older
ubFramework / Portal / docroot / assets / js / plugins / angular-notify / angular-notify.min.js
@Christopher W. Olsen Christopher W. Olsen on 10 Dec 2017 2 KB Cleaning Up Making It A Sub Module
angular.module("cgNotify",[]).factory("notify",["$timeout","$http","$compile","$templateCache","$rootScope",function(a,b,c,d,e){var f=10,g=15,h=1e4,i="angular-notify.html",j="center",k=document.body,l=[],m=function(m){"object"!=typeof m&&(m={message:m}),m.templateUrl=m.templateUrl?m.templateUrl:i,m.position=m.position?m.position:j,m.container=m.container?m.container:k,m.classes=m.classes?m.classes:"";var n=m.scope?m.scope.$new():e.$new();n.$message=m.message,n.$classes=m.classes,n.$messageTemplate=m.messageTemplate,b.get(m.templateUrl,{cache:d}).success(function(b){var d=c(b)(n);if(d.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",function(a){("opacity"===a.propertyName||a.originalEvent&&"opacity"===a.originalEvent.propertyName)&&(d.remove(),l.splice(l.indexOf(d),1),j())}),m.messageTemplate){for(var e,i=0;i<d.children().length;i++)if(angular.element(d.children()[i]).hasClass("cg-notify-message-template")){e=angular.element(d.children()[i]);break}if(!e)throw new Error("cgNotify could not find the .cg-notify-message-template element in "+m.templateUrl+".");e.append(c(m.messageTemplate)(n))}angular.element(m.container).append(d),l.push(d),"center"===m.position&&a(function(){d.css("margin-left","-"+d[0].offsetWidth/2+"px")}),n.$close=function(){d.css("opacity",0).attr("data-closing","true"),j()};var j=function(){for(var a=0,b=f,c=l.length-1;c>=0;c--){var d=10,e=l[c],h=e[0].offsetHeight,i=b+h+d;e.attr("data-closing")?i+=20:b+=h+g,e.css("top",i+"px").css("margin-top","-"+(h+d)+"px").css("visibility","visible"),a++}};a(function(){j()}),h>0&&a(function(){n.$close()},h)}).error(function(a){throw new Error("Template specified for cgNotify ("+m.templateUrl+") could not be loaded. "+a)});var o={};return o.close=function(){n.$close&&n.$close()},Object.defineProperty(o,"message",{get:function(){return n.$message},set:function(a){n.$message=a}}),o};return m.config=function(a){f=angular.isUndefined(a.startTop)?f:a.startTop,g=angular.isUndefined(a.verticalSpacing)?g:a.verticalSpacing,h=angular.isUndefined(a.duration)?h:a.duration,i=a.templateUrl?a.templateUrl:i,j=angular.isUndefined(a.position)?j:a.position,k=a.container?a.container:k},m.closeAll=function(){for(var a=l.length-1;a>=0;a--){var b=l[a];b.css("opacity",0)}},m}]),angular.module("cgNotify").run(["$templateCache",function(a){"use strict";a.put("angular-notify.html",'<div class="cg-notify-message" ng-class="$classes">\n\n    <div ng-show="!$messageTemplate">\n        {{$message}}\n    </div>\n\n    <div ng-show="$messageTemplate" class="cg-notify-message-template">\n        \n    </div>\n\n    <button type="button" class="cg-notify-close" ng-click="$close()">\n        <span aria-hidden="true">&times;</span>\n        <span class="cg-notify-sr-only">Close</span>\n    </button>\n\n</div>')}]);