diff --git a/README.md b/README.md index 097d939..11cecb5 100755 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ The `notify` function can either be passed a string or an object. When passing * `position` - Optional. `center`, `left` and `right` are the only acceptable values. * `container` - Optional. Element that contains each notification. Defaults to `document.body`. -This function will return an object with a `close()` method and a `message` property. +This function will return an object with a `close()` method, `message` and `classes` properties. ### notify.config(Object) diff --git a/angular-notify.js b/angular-notify.js index 7fbdf6e..7fc673c 100755 --- a/angular-notify.js +++ b/angular-notify.js @@ -128,6 +128,16 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' } }); + Object.defineProperty(retVal,'classes',{ + get: function(){ + return scope.$classes; + + }, + set: function(val){ + scope.$classes = val; + } + }); + openNotificationsScope.push(scope); return retVal; diff --git a/dist/angular-notify.js b/dist/angular-notify.js index b23e7bb..afe0baf 100644 --- a/dist/angular-notify.js +++ b/dist/angular-notify.js @@ -128,6 +128,16 @@ angular.module('cgNotify', []).factory('notify',['$timeout','$http','$compile',' } }); + Object.defineProperty(retVal,'classes',{ + get: function(){ + return scope.$classes; + + }, + set: function(val){ + scope.$classes = val; + } + }); + openNotificationsScope.push(scope); return retVal; diff --git a/dist/angular-notify.min.css b/dist/angular-notify.min.css index f6420d5..0a64d29 100644 --- a/dist/angular-notify.min.css +++ b/dist/angular-notify.min.css @@ -1 +1 @@ -.cg-notify-message{position:fixed;top:0;z-index:9999;max-width:400px;text-align:center;background-color:#d9edf7;color:#31708f;padding:15px;border:1px solid #bce8f1;border-radius:4px;-webkit-transition:top .5s ease-out,opacity .2s ease-out;-moz-transition:top .5s ease-out,opacity .2s ease-out;-o-transition:top .5s ease-out,opacity .2s ease-out;transition:top .5s ease-out,opacity .2s ease-out;visibility:hidden;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.cg-notify-message-center{left:50%}.cg-notify-message-left{left:15px}.cg-notify-message-right{right:15px}.cg-notify-message a{font-weight:700;color:inherit}.cg-notify-message a:hover{color:inherit}.cg-notify-close{-webkit-appearance:none;padding:0;cursor:pointer;background:0 0;border:0;font-size:21px;font-weight:700;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2;position:absolute;top:0;right:3px;line-height:15px}.cg-notify-close:focus,.cg-notify-close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}.cg-notify-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);border:0} \ No newline at end of file +.cg-notify-message{position:fixed;top:0;z-index:9999;max-width:400px;text-align:center;background-color:#d9edf7;color:#31708f;padding:15px;border:1px solid #bce8f1;border-radius:4px;-webkit-transition:top .5s ease-out,opacity .2s ease-out;-moz-transition:top .5s ease-out,opacity .2s ease-out;-o-transition:top .5s ease-out,opacity .2s ease-out;transition:top .5s ease-out,opacity .2s ease-out;visibility:hidden;-webkit-box-shadow:0 6px 12px rgba(0,0,0,.175);box-shadow:0 6px 12px rgba(0,0,0,.175)}.cg-notify-close,.cg-notify-sr-only{position:absolute;padding:0;border:0}.cg-notify-message-center{left:50%}.cg-notify-message-left{left:15px}.cg-notify-message-right{right:15px}.cg-notify-message a{font-weight:700;color:inherit}.cg-notify-message a:hover{color:inherit}.cg-notify-close{-webkit-appearance:none;cursor:pointer;background:0 0;font-size:21px;font-weight:700;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2;top:0;right:3px;line-height:15px}.cg-notify-close:focus,.cg-notify-close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}.cg-notify-sr-only{width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0)} \ No newline at end of file diff --git a/dist/angular-notify.min.js b/dist/angular-notify.min.js index 8607d9f..df8b9d7 100644 --- a/dist/angular-notify.min.js +++ b/dist/angular-notify.min.js @@ -1 +1 @@ -angular.module("cgNotify",[]).factory("notify",["$timeout","$http","$compile","$templateCache","$rootScope",function(a,b,c,d,e){var f=10,g=15,h=1e4,i="angular-notify.html",j="center",k=document.body,l=0,m=[],n=[],o=function(o){"object"!=typeof o&&(o={message:o}),o.duration=o.duration?o.duration:h,o.templateUrl=o.templateUrl?o.templateUrl:i,o.container=o.container?o.container:k,o.classes=o.classes?o.classes:"";var p=o.scope?o.scope.$new():e.$new();if(p.$position=o.position?o.position:j,p.$message=o.message,p.$classes=o.classes,p.$messageTemplate=o.messageTemplate,l>0)for(var q=n.length+1-l,r=0;q>r;r++)n[r].$close();b.get(o.templateUrl,{cache:d}).success(function(b){var d=c(b)(p);if(d.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",function(a){("opacity"===a.propertyName||0===a.currentTarget.style.opacity||a.originalEvent&&"opacity"===a.originalEvent.propertyName)&&(d.remove(),m.splice(m.indexOf(d),1),n.splice(n.indexOf(p),1),i())}),o.messageTemplate){for(var e,h=0;h=0;c--){var d=10,e=m[c],h=e[0].offsetHeight,i=b+h+d;e.attr("data-closing")?i+=20:b+=h+g,e.css("top",i+"px").css("margin-top","-"+(h+d)+"px").css("visibility","visible"),a++}};a(function(){i()}),o.duration>0&&a(function(){p.$close()},o.duration)}).error(function(a){throw new Error("Template specified for cgNotify ("+o.templateUrl+") could not be loaded. "+a)});var s={};return s.close=function(){p.$close&&p.$close()},Object.defineProperty(s,"message",{get:function(){return p.$message},set:function(a){p.$message=a}}),n.push(p),s};return o.config=function(a){f=angular.isUndefined(a.startTop)?f:a.startTop,g=angular.isUndefined(a.verticalSpacing)?g:a.verticalSpacing,h=angular.isUndefined(a.duration)?h:a.duration,i=a.templateUrl?a.templateUrl:i,j=angular.isUndefined(a.position)?j:a.position,k=a.container?a.container:k,l=a.maximumOpen?a.maximumOpen:l},o.closeAll=function(){for(var a=m.length-1;a>=0;a--){var b=m[a];b.css("opacity",0)}},o}]),angular.module("cgNotify").run(["$templateCache",function(a){"use strict";a.put("angular-notify.html","
\n\n
\n {{$message}}\n
\n\n"+'
\n \n
\n\n \n\n
')}]); \ No newline at end of file +angular.module("cgNotify",[]).factory("notify",["$timeout","$http","$compile","$templateCache","$rootScope",function(a,b,c,d,e){var f=10,g=15,h=1e4,i="angular-notify.html",j="center",k=document.body,l=0,m=[],n=[],o=function(o){"object"!=typeof o&&(o={message:o}),o.duration=o.duration?o.duration:h,o.templateUrl=o.templateUrl?o.templateUrl:i,o.container=o.container?o.container:k,o.classes=o.classes?o.classes:"";var p=o.scope?o.scope.$new():e.$new();if(p.$position=o.position?o.position:j,p.$message=o.message,p.$classes=o.classes,p.$messageTemplate=o.messageTemplate,l>0)for(var q=n.length+1-l,r=0;q>r;r++)n[r].$close();b.get(o.templateUrl,{cache:d}).success(function(b){var d=c(b)(p);if(d.bind("webkitTransitionEnd oTransitionEnd otransitionend transitionend msTransitionEnd",function(a){("opacity"===a.propertyName||0===a.currentTarget.style.opacity||a.originalEvent&&"opacity"===a.originalEvent.propertyName)&&(d.remove(),m.splice(m.indexOf(d),1),n.splice(n.indexOf(p),1),i())}),o.messageTemplate){for(var e,h=0;h=0;c--){var d=10,e=m[c],h=e[0].offsetHeight,i=b+h+d;e.attr("data-closing")?i+=20:b+=h+g,e.css("top",i+"px").css("margin-top","-"+(h+d)+"px").css("visibility","visible"),a++}};a(function(){i()}),o.duration>0&&a(function(){p.$close()},o.duration)}).error(function(a){throw new Error("Template specified for cgNotify ("+o.templateUrl+") could not be loaded. "+a)});var s={};return s.close=function(){p.$close&&p.$close()},Object.defineProperty(s,"message",{get:function(){return p.$message},set:function(a){p.$message=a}}),Object.defineProperty(s,"classes",{get:function(){return p.$classes},set:function(a){p.$classes=a}}),n.push(p),s};return o.config=function(a){f=angular.isUndefined(a.startTop)?f:a.startTop,g=angular.isUndefined(a.verticalSpacing)?g:a.verticalSpacing,h=angular.isUndefined(a.duration)?h:a.duration,i=a.templateUrl?a.templateUrl:i,j=angular.isUndefined(a.position)?j:a.position,k=a.container?a.container:k,l=a.maximumOpen?a.maximumOpen:l},o.closeAll=function(){for(var a=m.length-1;a>=0;a--){var b=m[a];b.css("opacity",0)}},o}]),angular.module("cgNotify").run(["$templateCache",function(a){"use strict";a.put("angular-notify.html","
\n\n
\n {{$message}}\n
\n\n"+'
\n \n
\n\n \n\n
')}]); \ No newline at end of file