From ceff116a3a8b1edd228c2b5254f22615ce210247 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Mon, 12 Dec 2016 22:15:29 +0300 Subject: [PATCH 1/9] fixed bug on cordova accessing template via $http on local file:// + fixed bug on cordova accessing template via $http on local file:// +updated dependencies --- bower.json | 6 +++--- demo/angular-ui-notification.min.css | 2 +- demo/angular-ui-notification.min.js | 4 ++-- dist/angular-ui-notification.css | 2 +- dist/angular-ui-notification.js | 30 ++++++++++++++++++++++------ dist/angular-ui-notification.min.css | 2 +- dist/angular-ui-notification.min.js | 4 ++-- package.json | 2 +- src/angular-ui-notification.js | 28 +++++++++++++++++++++----- 9 files changed, 58 insertions(+), 22 deletions(-) diff --git a/bower.json b/bower.json index 8839ff9..4a8763c 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.0", + "version": "0.3.1", "homepage": "https://github.com/alexcrack/angular-ui-notification", "repository": { "type": "git", @@ -31,9 +31,9 @@ "build" ], "dependencies": { - "angular": "~1.2.23" + "angular": "~1.5.0" }, "devDependencies": { - "bootstrap": "~3.3.2" + "bootstrap": "~3.3.7" } } diff --git a/demo/angular-ui-notification.min.css b/demo/angular-ui-notification.min.css index 6e0b18b..82e48d3 100644 --- a/demo/angular-ui-notification.min.css +++ b/demo/angular-ui-notification.min.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index a4d3c67..8dfb661 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,f=c.horizontalSpacing,m=c.delay,g=[],h=!1,C=function(s,C){var y=l.defer();return"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?m:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,t.get(s.template,{cache:i}).success(function(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){m.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(f+m);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-m/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},m=n(t)(o);m._positionY=s.positionY,m._positionX=s.positionX,m.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(m)),m.remove(),g.splice(g.indexOf(m),1),o.$destroy(),l())};s.closeOnClick&&(m.addClass("clickable"),m.bind("click",C)),m.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){m.addClass("killed")},s.delay),i("none"),angular.element(document.querySelector(s.container)).append(m);var v=-(parseInt(m[0].offsetHeight)+50);if(m.css(m._positionY,v+"px"),g.push(m),"center"==s.positionX){var k=parseInt(m[0].offsetWidth);m.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=m,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),y.resolve(o)}).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),y.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,"angular-ui-notification.html"!=s.template)t.get(s.template,{cache:i}).success(y(loadedTemplate)).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+s.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.css b/dist/angular-ui-notification.css index 652462f..33b4a7c 100644 --- a/dist/angular-ui-notification.css +++ b/dist/angular-ui-notification.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index 91ca0ce..5eb267c 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ @@ -60,7 +60,27 @@ angular.module('ui-notification').provider('Notification', function() { args.closeOnClick = (args.closeOnClick !== null && args.closeOnClick !== undefined) ? args.closeOnClick : options.closeOnClick; args.container = args.container ? args.container : options.container; - $http.get(args.template,{cache: $templateCache}).success(function(template) { + if(args.template!='angular-ui-notification.html'){ + // load it via $http only if it isn't default template + $http.get(args.template,{cache: $templateCache}) + .success(processNotificationTemplate(loadedTemplate)) + .error(function(data){ + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + }); + }else{ + // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova + var template=$templateCache.get('angular-ui-notification.html'); + if(template){ + processNotificationTemplate(template); + }else{ + // means something really broken if we are unable to load default template + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + } + + } + + + function processNotificationTemplate(template) { var scope = args.scope.$new(); scope.message = $sce.trustAsHtml(args.message); @@ -145,7 +165,7 @@ angular.module('ui-notification').provider('Notification', function() { setCssTransitions('none'); - angular.element(document.querySelector(args.container)).append(templateElement); + angular.element(document.getElementsByTagName('body')).append(templateElement); var offset = -(parseInt(templateElement[0].offsetHeight) + 50); templateElement.css(templateElement._positionY, offset + "px"); messageElements.push(templateElement); @@ -193,9 +213,7 @@ angular.module('ui-notification').provider('Notification', function() { deferred.resolve(scope); - }).error(function(data){ - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); + } return deferred.promise; }; diff --git a/dist/angular-ui-notification.min.css b/dist/angular-ui-notification.min.css index 6e0b18b..82e48d3 100644 --- a/dist/angular-ui-notification.min.css +++ b/dist/angular-ui-notification.min.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index a4d3c67..8dfb661 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.2.0 + * @version v0.3.1 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,f=c.horizontalSpacing,m=c.delay,g=[],h=!1,C=function(s,C){var y=l.defer();return"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?m:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,t.get(s.template,{cache:i}).success(function(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){m.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(f+m);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-m/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},m=n(t)(o);m._positionY=s.positionY,m._positionX=s.positionX,m.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(m)),m.remove(),g.splice(g.indexOf(m),1),o.$destroy(),l())};s.closeOnClick&&(m.addClass("clickable"),m.bind("click",C)),m.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){m.addClass("killed")},s.delay),i("none"),angular.element(document.querySelector(s.container)).append(m);var v=-(parseInt(m[0].offsetHeight)+50);if(m.css(m._positionY,v+"px"),g.push(m),"center"==s.positionX){var k=parseInt(m[0].offsetWidth);m.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=m,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),y.resolve(o)}).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),y.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,"angular-ui-notification.html"!=s.template)t.get(s.template,{cache:i}).success(y(loadedTemplate)).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+s.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/package.json b/package.json index 1ab0a75..8fcd16f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.2.0", + "version": "0.3.1", "description": "Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating", "main": "index.js", "scripts": { diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index 4b4c394..164d06e 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -53,7 +53,27 @@ angular.module('ui-notification').provider('Notification', function() { args.closeOnClick = (args.closeOnClick !== null && args.closeOnClick !== undefined) ? args.closeOnClick : options.closeOnClick; args.container = args.container ? args.container : options.container; - $http.get(args.template,{cache: $templateCache}).success(function(template) { + if(args.template!='angular-ui-notification.html'){ + // load it via $http only if it isn't default template + $http.get(args.template,{cache: $templateCache}) + .success(processNotificationTemplate(loadedTemplate)) + .error(function(data){ + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + }); + }else{ + // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova + var template=$templateCache.get('angular-ui-notification.html'); + if(template){ + processNotificationTemplate(template); + }else{ + // means something really broken if we are unable to load default template + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + } + + } + + + function processNotificationTemplate(template) { var scope = args.scope.$new(); scope.message = $sce.trustAsHtml(args.message); @@ -138,7 +158,7 @@ angular.module('ui-notification').provider('Notification', function() { setCssTransitions('none'); - angular.element(document.querySelector(args.container)).append(templateElement); + angular.element(document.getElementsByTagName('body')).append(templateElement); var offset = -(parseInt(templateElement[0].offsetHeight) + 50); templateElement.css(templateElement._positionY, offset + "px"); messageElements.push(templateElement); @@ -186,9 +206,7 @@ angular.module('ui-notification').provider('Notification', function() { deferred.resolve(scope); - }).error(function(data){ - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); + } return deferred.promise; }; From d80bd30ed58f0334aa95d089b636394aa0b747e5 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Mon, 12 Dec 2016 22:23:19 +0300 Subject: [PATCH 2/9] fixed old success\error $http synthax substituted with proper .then with callbacks --- demo/angular-ui-notification.min.js | 2 +- dist/angular-ui-notification.js | 5 ++--- dist/angular-ui-notification.min.js | 2 +- src/angular-ui-notification.js | 5 ++--- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index 8dfb661..b440c44 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,"angular-ui-notification.html"!=s.template)t.get(s.template,{cache:i}).success(y(loadedTemplate)).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+s.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index 5eb267c..fdd2929 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -62,9 +62,8 @@ angular.module('ui-notification').provider('Notification', function() { if(args.template!='angular-ui-notification.html'){ // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}) - .success(processNotificationTemplate(loadedTemplate)) - .error(function(data){ + $http.get(args.template,{cache: $templateCache}).then(processNotificationTemplate(loadedTemplate), + function(data){ throw new Error('Template ('+args.template+') could not be loaded. ' + data); }); }else{ diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index 8dfb661..b440c44 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container,"angular-ui-notification.html"!=s.template)t.get(s.template,{cache:i}).success(y(loadedTemplate)).error(function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+s.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index 164d06e..c5ad096 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -55,9 +55,8 @@ angular.module('ui-notification').provider('Notification', function() { if(args.template!='angular-ui-notification.html'){ // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}) - .success(processNotificationTemplate(loadedTemplate)) - .error(function(data){ + $http.get(args.template,{cache: $templateCache}).then(processNotificationTemplate(loadedTemplate), + function(data){ throw new Error('Template ('+args.template+') could not be loaded. ' + data); }); }else{ From 0a7c0c94aa9e552c0a16e4ee8913b917af186ea6 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Tue, 13 Dec 2016 14:14:34 +0300 Subject: [PATCH 3/9] fixed type of notification passed in as object member Now we can call Notification({message:'message here!',type:'success'}), along with old synthax Notification('message here!','success'); --- demo/angular-ui-notification.min.js | 2 +- dist/angular-ui-notification.js | 2 +- dist/angular-ui-notification.min.js | 2 +- src/angular-ui-notification.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index b440c44..c657134 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index fdd2929..5235612 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -52,7 +52,7 @@ angular.module('ui-notification').provider('Notification', function() { args.scope = args.scope ? args.scope : $rootScope; args.template = args.templateUrl ? args.templateUrl : options.templateUrl; args.delay = !angular.isUndefined(args.delay) ? args.delay : delay; - args.type = t || options.type || ''; + args.type = t || args.type || options.type || ''; args.positionY = args.positionY ? args.positionY : options.positionY; args.positionX = args.positionX ? args.positionX : options.positionX; args.replaceMessage = args.replaceMessage ? args.replaceMessage : options.replaceMessage; diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index b440c44..c657134 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index c5ad096..87fe07e 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -45,7 +45,7 @@ angular.module('ui-notification').provider('Notification', function() { args.scope = args.scope ? args.scope : $rootScope; args.template = args.templateUrl ? args.templateUrl : options.templateUrl; args.delay = !angular.isUndefined(args.delay) ? args.delay : delay; - args.type = t || options.type || ''; + args.type = t || args.type || options.type || ''; args.positionY = args.positionY ? args.positionY : options.positionY; args.positionX = args.positionX ? args.positionX : options.positionX; args.replaceMessage = args.replaceMessage ? args.replaceMessage : options.replaceMessage; From 06591882569e2a150131c9d57693366bbcc034cd Mon Sep 17 00:00:00 2001 From: Piotr Pradzynski Date: Thu, 15 Dec 2016 08:29:18 +0100 Subject: [PATCH 4/9] fixing custom template loading --- bower.json | 2 +- demo/angular-ui-notification.min.js | 4 ++-- dist/angular-ui-notification.js | 11 ++++++----- dist/angular-ui-notification.min.js | 4 ++-- package.json | 2 +- src/angular-ui-notification.js | 9 +++++---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/bower.json b/bower.json index 4a8763c..1fee28f 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.1", + "version": "0.3.2", "homepage": "https://github.com/alexcrack/angular-ui-notification", "repository": { "type": "git", diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index c657134..3a3a1fb 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.2 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y)["catch"](function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index 5235612..c5d08d7 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.2 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ @@ -62,10 +62,11 @@ angular.module('ui-notification').provider('Notification', function() { if(args.template!='angular-ui-notification.html'){ // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}).then(processNotificationTemplate(loadedTemplate), - function(data){ - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); + $http.get(args.template,{cache: $templateCache}) + .then(processNotificationTemplate) + .catch(function(data){ + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + }); }else{ // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova var template=$templateCache.get('angular-ui-notification.html'); diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index c657134..3a3a1fb 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.2 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y(loadedTemplate),function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y)["catch"](function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/package.json b/package.json index 8fcd16f..3e21cd9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.1", + "version": "0.3.2", "description": "Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating", "main": "index.js", "scripts": { diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index 87fe07e..cc5211e 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -55,10 +55,11 @@ angular.module('ui-notification').provider('Notification', function() { if(args.template!='angular-ui-notification.html'){ // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}).then(processNotificationTemplate(loadedTemplate), - function(data){ - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); + $http.get(args.template,{cache: $templateCache}) + .then(processNotificationTemplate) + .catch(function(data){ + throw new Error('Template ('+args.template+') could not be loaded. ' + data); + }); }else{ // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova var template=$templateCache.get('angular-ui-notification.html'); From 1c982f24ee8ab461aed7743755cd872778952400 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Fri, 16 Dec 2016 17:38:34 +0300 Subject: [PATCH 5/9] updated angular dependency to 1.5.9 in bower.json --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 1fee28f..48690d5 100644 --- a/bower.json +++ b/bower.json @@ -31,7 +31,7 @@ "build" ], "dependencies": { - "angular": "~1.5.0" + "angular": "~1.5.9" }, "devDependencies": { "bootstrap": "~3.3.7" From eac34c292ac38eedd17011041438aaf509552d3d Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Fri, 16 Dec 2016 17:51:10 +0300 Subject: [PATCH 6/9] updated version to 0.3.3 done to have same tag for 0.3.3 version with angular 1.5.9 or above dependency. --- bower.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bower.json b/bower.json index 48690d5..fe49600 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.2", + "version": "0.3.3", "homepage": "https://github.com/alexcrack/angular-ui-notification", "repository": { "type": "git", diff --git a/package.json b/package.json index 3e21cd9..97e09f9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.2", + "version": "0.3.3", "description": "Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating", "main": "index.js", "scripts": { From 4fa8267efa21247d5c261ee1dede351aea4c697e Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Fri, 16 Dec 2016 18:01:43 +0300 Subject: [PATCH 7/9] semver updates for bower --- bower.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bower.json b/bower.json index fe49600..519c3fc 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.3", + "version": "0.3.4", "homepage": "https://github.com/alexcrack/angular-ui-notification", "repository": { "type": "git", @@ -31,9 +31,9 @@ "build" ], "dependencies": { - "angular": "~1.5.9" + "angular": "^1.5.x" }, "devDependencies": { - "bootstrap": "~3.3.7" + "bootstrap": "^3.3.x" } } From 6ab4ea88054a9fc80baab4aee2c5b7eed07a9f07 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Fri, 23 Dec 2016 14:17:38 +0300 Subject: [PATCH 8/9] fixed own templateurls getting from templateCache --- bower.json | 2 +- demo/angular-ui-notification.min.css | 2 +- demo/angular-ui-notification.min.js | 4 ++-- dist/angular-ui-notification.css | 2 +- dist/angular-ui-notification.js | 25 ++++++++++--------------- dist/angular-ui-notification.min.css | 2 +- dist/angular-ui-notification.min.js | 4 ++-- package.json | 2 +- src/angular-ui-notification.js | 23 +++++++++-------------- 9 files changed, 28 insertions(+), 38 deletions(-) diff --git a/bower.json b/bower.json index 519c3fc..e980ed2 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.4", + "version": "0.3.5", "homepage": "https://github.com/alexcrack/angular-ui-notification", "repository": { "type": "git", diff --git a/demo/angular-ui-notification.min.css b/demo/angular-ui-notification.min.css index 82e48d3..a055ef4 100644 --- a/demo/angular-ui-notification.min.css +++ b/demo/angular-ui-notification.min.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index 3a3a1fb..322e714 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.2 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y)["catch"](function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var k=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.css b/dist/angular-ui-notification.css index 33b4a7c..98451ea 100644 --- a/dist/angular-ui-notification.css +++ b/dist/angular-ui-notification.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index c5d08d7..a9c477a 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.2 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ @@ -59,24 +59,19 @@ angular.module('ui-notification').provider('Notification', function() { args.onClose = args.onClose ? args.onClose : options.onClose; args.closeOnClick = (args.closeOnClick !== null && args.closeOnClick !== undefined) ? args.closeOnClick : options.closeOnClick; args.container = args.container ? args.container : options.container; + + var template=$templateCache.get(args.template); - if(args.template!='angular-ui-notification.html'){ - // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}) + if(template){ + processNotificationTemplate(template); + }else{ + // load it via $http only if it isn't default template and template isn't exist in template cache + // cache:true means cache it for later access. + $http.get(args.template,{cache: true}) .then(processNotificationTemplate) .catch(function(data){ throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); - }else{ - // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova - var template=$templateCache.get('angular-ui-notification.html'); - if(template){ - processNotificationTemplate(template); - }else{ - // means something really broken if we are unable to load default template - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - } - + }); } diff --git a/dist/angular-ui-notification.min.css b/dist/angular-ui-notification.min.css index 82e48d3..a055ef4 100644 --- a/dist/angular-ui-notification.min.css +++ b/dist/angular-ui-notification.min.css @@ -1,7 +1,7 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.1 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index 3a3a1fb..322e714 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -1,8 +1,8 @@ /** * angular-ui-notification - Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating * @author Alex_Crack - * @version v0.3.2 + * @version v0.3.5 * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,a,s,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(a,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=a.scope.$new();o.message=s.trustAsHtml(a.message),o.title=s.trustAsHtml(a.title),o.t=a.type.substr(0,1),o.delay=a.delay,o.onClose=a.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],s=g.length-1;s>=0;s--){var l=g[s];if(a.replaceMessage&&swindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===s&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=a.positionY,f._positionX=a.positionX,f.addClass(a.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};a.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(a.delay)&&e(function(){f.addClass("killed")},a.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==a.positionX){var w=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-w/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();if("object"!=typeof a&&(a={message:a}),a.scope=a.scope?a.scope:o,a.template=a.templateUrl?a.templateUrl:c.templateUrl,a.delay=angular.isUndefined(a.delay)?f:a.delay,a.type=C||a.type||c.type||"",a.positionY=a.positionY?a.positionY:c.positionY,a.positionX=a.positionX?a.positionX:c.positionX,a.replaceMessage=a.replaceMessage?a.replaceMessage:c.replaceMessage,a.onClose=a.onClose?a.onClose:c.onClose,a.closeOnClick=null!==a.closeOnClick&&void 0!==a.closeOnClick?a.closeOnClick:c.closeOnClick,a.container=a.container?a.container:c.container,"angular-ui-notification.html"!=a.template)t.get(a.template,{cache:i}).then(y)["catch"](function(e){throw new Error("Template ("+a.template+") could not be loaded. "+e)});else{var w=i.get("angular-ui-notification.html");if(!w)throw new Error("Template ("+a.template+") could not be loaded. "+data);y(w)}return v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var k=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/package.json b/package.json index 97e09f9..44d67a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-ui-notification", - "version": "0.3.3", + "version": "0.3.5", "description": "Angular.js service providing simple notifications using Bootstrap 3 styles with css transitions for animating", "main": "index.js", "scripts": { diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index cc5211e..3967e10 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -52,24 +52,19 @@ angular.module('ui-notification').provider('Notification', function() { args.onClose = args.onClose ? args.onClose : options.onClose; args.closeOnClick = (args.closeOnClick !== null && args.closeOnClick !== undefined) ? args.closeOnClick : options.closeOnClick; args.container = args.container ? args.container : options.container; + + var template=$templateCache.get(args.template); - if(args.template!='angular-ui-notification.html'){ - // load it via $http only if it isn't default template - $http.get(args.template,{cache: $templateCache}) + if(template){ + processNotificationTemplate(template); + }else{ + // load it via $http only if it isn't default template and template isn't exist in template cache + // cache:true means cache it for later access. + $http.get(args.template,{cache: true}) .then(processNotificationTemplate) .catch(function(data){ throw new Error('Template ('+args.template+') could not be loaded. ' + data); - }); - }else{ - // load directly form $templateCache! to make it working on pages loaded like file:// specifically for cordova - var template=$templateCache.get('angular-ui-notification.html'); - if(template){ - processNotificationTemplate(template); - }else{ - // means something really broken if we are unable to load default template - throw new Error('Template ('+args.template+') could not be loaded. ' + data); - } - + }); } From 8e225f2ff209df2af7ce00e427014908e86cc596 Mon Sep 17 00:00:00 2001 From: Mikhail Durnev Date: Thu, 29 Dec 2016 16:09:07 +0300 Subject: [PATCH 9/9] fixed body only appending --- demo/angular-ui-notification.min.js | 2 +- dist/angular-ui-notification.js | 2 +- dist/angular-ui-notification.min.js | 2 +- src/angular-ui-notification.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/angular-ui-notification.min.js b/demo/angular-ui-notification.min.js index 322e714..4a1181e 100644 --- a/demo/angular-ui-notification.min.js +++ b/demo/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var k=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,f=c.horizontalSpacing,m=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){m.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(f+m);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-m/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},m=n(t)(o);m._positionY=s.positionY,m._positionX=s.positionX,m.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(m)),m.remove(),g.splice(g.indexOf(m),1),o.$destroy(),l())};s.closeOnClick&&(m.addClass("clickable"),m.bind("click",C)),m.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){m.addClass("killed")},s.delay),i("none"),angular.element(document.querySelector(s.container)).append(m);var y=-(parseInt(m[0].offsetHeight)+50);if(m.css(m._positionY,y+"px"),g.push(m),"center"==s.positionX){var k=parseInt(m[0].offsetWidth);m.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=m,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?m:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/dist/angular-ui-notification.js b/dist/angular-ui-notification.js index a9c477a..0950c6f 100644 --- a/dist/angular-ui-notification.js +++ b/dist/angular-ui-notification.js @@ -160,7 +160,7 @@ angular.module('ui-notification').provider('Notification', function() { setCssTransitions('none'); - angular.element(document.getElementsByTagName('body')).append(templateElement); + angular.element(document.querySelector(args.container)).append(templateElement); var offset = -(parseInt(templateElement[0].offsetHeight) + 50); templateElement.css(templateElement._positionY, offset + "px"); messageElements.push(templateElement); diff --git a/dist/angular-ui-notification.min.js b/dist/angular-ui-notification.min.js index 322e714..4a1181e 100644 --- a/dist/angular-ui-notification.min.js +++ b/dist/angular-ui-notification.min.js @@ -5,4 +5,4 @@ * @link https://github.com/alexcrack/angular-ui-notification * @license MIT */ -angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,m=c.horizontalSpacing,f=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){f.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(m+f);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-f/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},f=n(t)(o);f._positionY=s.positionY,f._positionX=s.positionX,f.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(f)),f.remove(),g.splice(g.indexOf(f),1),o.$destroy(),l())};s.closeOnClick&&(f.addClass("clickable"),f.bind("click",C)),f.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){f.addClass("killed")},s.delay),i("none"),angular.element(document.getElementsByTagName("body")).append(f);var y=-(parseInt(f[0].offsetHeight)+50);if(f.css(f._positionY,y+"px"),g.push(f),"center"==s.positionX){var k=parseInt(f[0].offsetWidth);f.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=f,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?f:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file +angular.module("ui-notification",[]),angular.module("ui-notification").provider("Notification",function(){this.options={delay:5e3,startTop:10,startRight:10,verticalSpacing:10,horizontalSpacing:10,positionX:"right",positionY:"top",replaceMessage:!1,templateUrl:"angular-ui-notification.html",onClose:void 0,closeOnClick:!0,maxCount:0,container:"body"},this.setOptions=function(e){if(!angular.isObject(e))throw new Error("Options should be an object!");this.options=angular.extend({},this.options,e)},this.$get=["$timeout","$http","$compile","$templateCache","$rootScope","$injector","$sce","$q","$window",function(e,t,n,i,o,s,a,l,r){var c=this.options,p=c.startTop,d=c.startRight,u=c.verticalSpacing,f=c.horizontalSpacing,m=c.delay,g=[],h=!1,C=function(s,C){function y(t){function i(e){["-webkit-transition","-o-transition","transition"].forEach(function(t){m.css(t,e)})}var o=s.scope.$new();o.message=a.trustAsHtml(s.message),o.title=a.trustAsHtml(s.title),o.t=s.type.substr(0,1),o.delay=s.delay,o.onClose=s.onClose;var l=function(){for(var e=0,t=0,n=p,i=d,o=[],a=g.length-1;a>=0;a--){var l=g[a];if(s.replaceMessage&&awindow.innerHeight&&(h=p,t++,e=0);var C=n=h?0===e?h:h+u:p,y=i+t*(f+m);l.css(l._positionY,C+"px"),"center"==l._positionX?l.css("left",parseInt(window.innerWidth/2-m/2)+"px"):l.css(l._positionX,y+"px"),o[l._positionY+l._positionX]=C+r,c.maxCount>0&&g.length>c.maxCount&&0===a&&l.scope().kill(!0),e++}}},m=n(t)(o);m._positionY=s.positionY,m._positionX=s.positionX,m.addClass(s.type);var C=function(e){e=e.originalEvent||e,("click"===e.type||"opacity"===e.propertyName&&e.elapsedTime>=1)&&(o.onClose&&o.$apply(o.onClose(m)),m.remove(),g.splice(g.indexOf(m),1),o.$destroy(),l())};s.closeOnClick&&(m.addClass("clickable"),m.bind("click",C)),m.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",C),angular.isNumber(s.delay)&&e(function(){m.addClass("killed")},s.delay),i("none"),angular.element(document.querySelector(s.container)).append(m);var y=-(parseInt(m[0].offsetHeight)+50);if(m.css(m._positionY,y+"px"),g.push(m),"center"==s.positionX){var k=parseInt(m[0].offsetWidth);m.css("left",parseInt(window.innerWidth/2-k/2)+"px")}e(function(){i("")}),o._templateElement=m,o.kill=function(t){t?(o.onClose&&o.$apply(o.onClose(o._templateElement)),g.splice(g.indexOf(o._templateElement),1),o._templateElement.remove(),o.$destroy(),e(l)):o._templateElement.addClass("killed")},e(l),h||(angular.element(r).bind("resize",function(t){e(l)}),h=!0),v.resolve(o)}var v=l.defer();"object"!=typeof s&&(s={message:s}),s.scope=s.scope?s.scope:o,s.template=s.templateUrl?s.templateUrl:c.templateUrl,s.delay=angular.isUndefined(s.delay)?m:s.delay,s.type=C||s.type||c.type||"",s.positionY=s.positionY?s.positionY:c.positionY,s.positionX=s.positionX?s.positionX:c.positionX,s.replaceMessage=s.replaceMessage?s.replaceMessage:c.replaceMessage,s.onClose=s.onClose?s.onClose:c.onClose,s.closeOnClick=null!==s.closeOnClick&&void 0!==s.closeOnClick?s.closeOnClick:c.closeOnClick,s.container=s.container?s.container:c.container;var k=i.get(s.template);return k?y(k):t.get(s.template,{cache:!0}).then(y)["catch"](function(e){throw new Error("Template ("+s.template+") could not be loaded. "+e)}),v.promise};return C.primary=function(e){return this(e,"primary")},C.error=function(e){return this(e,"error")},C.success=function(e){return this(e,"success")},C.info=function(e){return this(e,"info")},C.warning=function(e){return this(e,"warning")},C.clearAll=function(){angular.forEach(g,function(e){e.addClass("killed")})},C}]}),angular.module("ui-notification").run(["$templateCache",function(e){e.put("angular-ui-notification.html",'

')}]); \ No newline at end of file diff --git a/src/angular-ui-notification.js b/src/angular-ui-notification.js index 3967e10..a16d76d 100644 --- a/src/angular-ui-notification.js +++ b/src/angular-ui-notification.js @@ -153,7 +153,7 @@ angular.module('ui-notification').provider('Notification', function() { setCssTransitions('none'); - angular.element(document.getElementsByTagName('body')).append(templateElement); + angular.element(document.querySelector(args.container)).append(templateElement); var offset = -(parseInt(templateElement[0].offsetHeight) + 50); templateElement.css(templateElement._positionY, offset + "px"); messageElements.push(templateElement);