├── .bowerrc ├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── Gruntfile.js ├── LICENSE ├── bower.json ├── dist ├── angular-growl-notifications.js └── angular-growl-notifications.min.js ├── package.json ├── readme.md ├── src └── growlNotifications │ ├── directives │ ├── growlNotification.js │ └── growlNotifications.js │ ├── growlNotifications.js │ └── services │ └── growlNotifications.js └── test └── unit └── growlNotifications ├── directive └── growlNotificationSpec.js ├── growlNotificationsSpec.js └── services └── growlNotificationsSpec.js /.bowerrc: -------------------------------------------------------------------------------- 1 | { 2 | "directory": "bower" 3 | } -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ._* 2 | .~lock.* 3 | .buildpath 4 | .DS_Store 5 | .idea 6 | .project 7 | .settings 8 | 9 | # Ignore node stuff 10 | node_modules/ 11 | npm-debug.log 12 | libpeerconnection.log 13 | 14 | # OS-specific 15 | .DS_Store 16 | 17 | # Bower components 18 | bower 19 | 20 | # Harp files 21 | _harp -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "es5": true, 4 | "esnext": true, 5 | "bitwise": true, 6 | "camelcase": true, 7 | "curly": true, 8 | "eqeqeq": true, 9 | "immed": true, 10 | "indent": 4, 11 | "latedef": true, 12 | "newcap": true, 13 | "noarg": true, 14 | "quotmark": "single", 15 | "regexp": true, 16 | "undef": true, 17 | "unused": true, 18 | "strict": true, 19 | "trailing": true, 20 | "smarttabs": true, 21 | "white": true 22 | } 23 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - "0.10" 4 | 5 | before_script: 6 | - npm install -qg bower grunt-cli 7 | - npm install 8 | - bower install -F 9 | 10 | script: 11 | - grunt 12 | -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 3 | require('load-grunt-tasks')(grunt); 4 | 5 | grunt.initConfig({ 6 | 7 | pkg: grunt.file.readJSON('package.json'), 8 | 9 | concat: { 10 | options: { 11 | separator: '' 12 | }, 13 | library: { 14 | src: [ 15 | 'src/growlNotifications/growlNotifications.js', 16 | 'src/growlNotifications/directives/**/*.js', 17 | 'src/growlNotifications/services/**/*.js' 18 | ], 19 | dest: 'dist/angular-growl-notifications.js' 20 | } 21 | }, 22 | 23 | uglify: { 24 | options: { 25 | banner: '/*! <%= pkg.name %> <%= grunt.template.today("dd-mm-yyyy") %> */\n' 26 | }, 27 | library: { 28 | files: { 29 | 'dist/angular-growl-notifications.min.js': ['<%= concat.library.dest %>'] 30 | } 31 | } 32 | }, 33 | 34 | jshint: { 35 | beforeConcat: { 36 | src: ['gruntfile.js', 'growlNotifications/**/*.js'] 37 | }, 38 | afterConcat: { 39 | src: [ 40 | '<%= concat.library.dest %>' 41 | ] 42 | }, 43 | options: { 44 | // options here to override JSHint defaults 45 | globals: { 46 | jQuery: true, 47 | console: true, 48 | module: true, 49 | document: true, 50 | angular: true 51 | }, 52 | globalstrict: false 53 | } 54 | }, 55 | 56 | watch: { 57 | options: { 58 | livereload: true 59 | }, 60 | files: [ 61 | 'Gruntfile.js', 62 | 'src/**/*' 63 | ], 64 | tasks: ['default'] 65 | } 66 | 67 | }); 68 | 69 | grunt.registerTask('default', ['jshint:beforeConcat', 'concat', 'jshint:afterConcat', 'uglify']); 70 | grunt.registerTask('livereload', ['default', 'watch']); 71 | 72 | }; 73 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2014 Jurgen Van de Moere 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-growl-notifications", 3 | "version": "2.6.0", 4 | "main": [ 5 | "dist/angular-growl-notifications.js" 6 | ], 7 | "keywords": [ 8 | "angular", 9 | "angularjs", 10 | "growl", 11 | "notification", 12 | "notifications" 13 | ], 14 | "authors": [ 15 | { 16 | "name": "Jurgen Van de Moere", 17 | "email": "jurgen.van.de.moere@gmail.com", 18 | "homepage": "http://www.jvandemo.com" 19 | } 20 | ], 21 | "ignore": [ 22 | "src", 23 | "test", 24 | ".bowerrc", 25 | ".editorconfig", 26 | ".gitignore", 27 | ".jshintrc", 28 | ".travis.yml", 29 | "Gruntfile.js", 30 | "package.json" 31 | ], 32 | "repository": { 33 | "type": "git", 34 | "url": "git://github.com/jvandemo/angular-growl-notifications.git" 35 | }, 36 | "dependencies": { 37 | "angular": ">=1.2.22 <2" 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /dist/angular-growl-notifications.js: -------------------------------------------------------------------------------- 1 | (function () { 2 | 3 | // Config 4 | angular.module('growlNotifications.config', []) 5 | .value('growlNotifications.config', { 6 | debug: true 7 | }); 8 | 9 | // Modules 10 | angular.module('growlNotifications.directives', []); 11 | angular.module('growlNotifications.filters', []); 12 | angular.module('growlNotifications.services', []); 13 | angular.module('growlNotifications', 14 | [ 15 | 'growlNotifications.config', 16 | 'growlNotifications.directives', 17 | 'growlNotifications.filters', 18 | 'growlNotifications.services' 19 | ]); 20 | 21 | })(); 22 | (function () { 23 | 24 | function growlNotificationDirective(growlNotifications, $animate, $interval) { 25 | 26 | var defaults = { 27 | ttl: growlNotifications.options.ttl || 5000 28 | }; 29 | 30 | return { 31 | 32 | /** 33 | * Allow compilation via attributes as well so custom 34 | * markup can be used 35 | */ 36 | restrict: 'AE', 37 | 38 | /** 39 | * Create new child scope 40 | */ 41 | scope: true, 42 | 43 | /** 44 | * Controller 45 | */ 46 | controller: growlNotificationController, 47 | 48 | /** 49 | * Make the controller available in the directive scope 50 | */ 51 | controllerAs: '$growlNotification', 52 | 53 | /** 54 | * Post link function 55 | * 56 | * @param scope 57 | * @param iElem 58 | * @param iAttrs 59 | * @param ctrl 60 | */ 61 | link: function (scope, iElem, iAttrs, ctrl) { 62 | 63 | // Assemble options 64 | var options = angular.extend({}, defaults, scope.$eval(iAttrs.growlNotificationOptions)); 65 | 66 | // The number of times the notification timeout method should be run 67 | // This should always be set to 1 to emulate $timeout 68 | var REPEAT_COUNT = 1; 69 | 70 | if (iAttrs.ttl) { 71 | options.ttl = scope.$eval(iAttrs.ttl); 72 | } 73 | 74 | // Move the element to the right location in the DOM 75 | $animate.move(iElem, growlNotifications.element); 76 | 77 | // Run onOpen handler if there is one 78 | if (iAttrs.onOpen) { 79 | scope.$eval(iAttrs.onOpen); 80 | } 81 | 82 | // Schedule automatic removal unless ttl set to false/-1 83 | if(options.ttl !== -1 && options.ttl !== false) { 84 | ctrl.timer = $interval(function () { 85 | $animate.leave(iElem); 86 | 87 | // Run onClose handler if there is one 88 | if(iAttrs.onClose){ 89 | scope.$eval(iAttrs.onClose); 90 | } 91 | }, options.ttl, REPEAT_COUNT); 92 | } 93 | 94 | } 95 | }; 96 | 97 | } 98 | 99 | // Inject dependencies 100 | growlNotificationDirective.$inject = ['growlNotifications', '$animate', '$interval']; 101 | 102 | /** 103 | * Directive controller 104 | * 105 | * @param $element 106 | * @param $animate 107 | * @param $attrs 108 | * @param $scope 109 | */ 110 | function growlNotificationController($element, $animate, $attrs, $scope, $interval) { 111 | 112 | /** 113 | * Placeholder for timer promise 114 | */ 115 | this.timer = null; 116 | 117 | /** 118 | * Helper method to close notification manually 119 | */ 120 | this.remove = function () { 121 | 122 | // Remove the element 123 | $animate.leave($element); 124 | 125 | // Cancel scheduled automatic removal if there is one 126 | if (this.timer) { 127 | $interval.cancel(this.timer); 128 | 129 | // Run onClose handler if there is one 130 | if($attrs.onClose){ 131 | $scope.$eval($attrs.onClose); 132 | } 133 | } 134 | }; 135 | 136 | } 137 | 138 | // Inject dependencies 139 | growlNotificationController.$inject = ['$element', '$animate', '$attrs', '$scope', '$interval']; 140 | 141 | // Export 142 | angular 143 | .module('growlNotifications.directives') 144 | .directive('growlNotification', growlNotificationDirective); 145 | 146 | })(); 147 | (function () { 148 | 149 | /** 150 | * Create directive definition object 151 | * 152 | * @param growlNotifications 153 | */ 154 | function growlNotificationsDirective(growlNotifications) { 155 | 156 | return { 157 | 158 | /** 159 | * Allow compilation via attributes as well so custom 160 | * markup can be used 161 | */ 162 | restrict: 'AE', 163 | 164 | /** 165 | * Post link function 166 | * 167 | * @param scope 168 | * @param iElem 169 | * @param iAttrs 170 | */ 171 | link: function (scope, iElem, iAttrs) { 172 | growlNotifications.element = iElem; 173 | } 174 | }; 175 | 176 | } 177 | 178 | // Inject dependencies 179 | growlNotificationsDirective.$inject = ['growlNotifications']; 180 | 181 | // Export 182 | angular 183 | .module('growlNotifications.directives') 184 | .directive('growlNotifications', growlNotificationsDirective); 185 | 186 | })();(function () { 187 | 188 | /** 189 | * Growl notifications provider 190 | */ 191 | function growlNotificationsProvider() { 192 | 193 | // Default options 194 | var options = { 195 | ttl: 5000 196 | }; 197 | 198 | /** 199 | * Provider method to change default options 200 | * 201 | * @param newOptions 202 | */ 203 | this.setOptions = function (newOptions) { 204 | angular.extend(options, newOptions); 205 | return this; 206 | }; 207 | 208 | /** 209 | * Provider convenience method to get or set default ttl 210 | * 211 | * @param ttl 212 | * @returns {*} 213 | */ 214 | this.ttl = function (ttl) { 215 | if (angular.isDefined(ttl)) { 216 | options.ttl = ttl; 217 | return this; 218 | } 219 | return options.ttl; 220 | }; 221 | 222 | /** 223 | * Factory method 224 | * 225 | * @param $timeout 226 | * @param $rootScope 227 | * @returns {GrowlNotifications} 228 | */ 229 | this.$get = function () { 230 | 231 | function GrowlNotifications() { 232 | 233 | this.options = options; 234 | this.element = null; 235 | 236 | } 237 | 238 | return new GrowlNotifications(); 239 | 240 | }; 241 | 242 | } 243 | 244 | // Export 245 | angular 246 | .module('growlNotifications.services') 247 | .provider('growlNotifications', growlNotificationsProvider); 248 | 249 | })(); 250 | -------------------------------------------------------------------------------- /dist/angular-growl-notifications.min.js: -------------------------------------------------------------------------------- 1 | /*! angular-growl-notifications 08-03-2017 */ 2 | !function(){angular.module("growlNotifications.config",[]).value("growlNotifications.config",{debug:!0}),angular.module("growlNotifications.directives",[]),angular.module("growlNotifications.filters",[]),angular.module("growlNotifications.services",[]),angular.module("growlNotifications",["growlNotifications.config","growlNotifications.directives","growlNotifications.filters","growlNotifications.services"])}(),function(){function a(a,c,d){var e={ttl:a.options.ttl||5e3};return{restrict:"AE",scope:!0,controller:b,controllerAs:"$growlNotification",link:function(b,f,g,h){var i=angular.extend({},e,b.$eval(g.growlNotificationOptions)),j=1;g.ttl&&(i.ttl=b.$eval(g.ttl)),c.move(f,a.element),g.onOpen&&b.$eval(g.onOpen),-1!==i.ttl&&i.ttl!==!1&&(h.timer=d(function(){c.leave(f),g.onClose&&b.$eval(g.onClose)},i.ttl,j))}}}function b(a,b,c,d,e){this.timer=null,this.remove=function(){b.leave(a),this.timer&&(e.cancel(this.timer),c.onClose&&d.$eval(c.onClose))}}a.$inject=["growlNotifications","$animate","$interval"],b.$inject=["$element","$animate","$attrs","$scope","$interval"],angular.module("growlNotifications.directives").directive("growlNotification",a)}(),function(){function a(a){return{restrict:"AE",link:function(b,c,d){a.element=c}}}a.$inject=["growlNotifications"],angular.module("growlNotifications.directives").directive("growlNotifications",a)}(),function(){function a(){var a={ttl:5e3};this.setOptions=function(b){return angular.extend(a,b),this},this.ttl=function(b){return angular.isDefined(b)?(a.ttl=b,this):a.ttl},this.$get=function(){function b(){this.options=a,this.element=null}return new b}}angular.module("growlNotifications.services").provider("growlNotifications",a)}(); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-growl-notifications", 3 | "version": "2.6.0", 4 | "keywords": [ 5 | "angular", 6 | "angularjs", 7 | "growl", 8 | "notification", 9 | "notifications" 10 | ], 11 | "main": "./dist/angular-growl-notifications.js", 12 | "author": { 13 | "name": "Jurgen Van de Moere", 14 | "email": "jurgen.van.de.moere@gmail.com", 15 | "url": "http://www.jvandemo.com" 16 | }, 17 | "repository": { 18 | "type": "git", 19 | "url": "http://github.com/jvandemo/angular-growl-notifications.git" 20 | }, 21 | "dependencies": { 22 | "angular": ">=1.2.22 <2" 23 | }, 24 | "devDependencies": { 25 | "grunt": "~0.4.1", 26 | "grunt-contrib-concat": "~0.3.0", 27 | "grunt-contrib-jshint": "~0.7.0", 28 | "grunt-contrib-uglify": "~0.2.0", 29 | "grunt-contrib-watch": "~0.5.0", 30 | "grunt-karma": "~0.8.0", 31 | "karma": "~0.12.0", 32 | "karma-chrome-launcher": "~0.1.0", 33 | "karma-phantomjs-launcher": "~0.1.0", 34 | "load-grunt-tasks": "^0.6.0", 35 | "karma-mocha": "^0.1.7" 36 | }, 37 | "engines": { 38 | "node": ">=0.8.0" 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |  2 | 3 | # Growl notifications for AngularJS 4 | [](https://travis-ci.org/jvandemo/angular-growl-notifications) 5 | 6 | Notifications logically belong inside the view layer of your application. 7 | 8 | Most existing growl systems require you to add notifications using JavaScript inside your controller layer. 9 | 10 | This very lightweight library (<2KB) allows you to declaratively create notifications using directives only, supporting both inline expressions and HTML. 11 | 12 | Think Growl, but in AngularJS directives. Oh, and Bootstrap compatible too. 13 | 14 | - [Visit the official website](http://jvandemo.github.io/angular-growl-notifications/) 15 | - [View live examples](http://jvandemo.github.io/angular-growl-notifications/examples/) 16 | - [Read the complete documentation](http://jvandemo.github.io/angular-growl-notifications/docs/) 17 | 18 | [](http://jvandemo.github.io/angular-growl-notifications/) 19 | 20 | # Quick start 21 | 22 | Learn how to create Mac OS X like pop-up notifications in your AngularJS application. 23 | 24 | ### STEP 1: Install the library 25 | 26 | Download the code from [GitHub](https://github.com/jvandemo/angular-growl-notifications) or install it using bower: 27 | 28 | ```sh 29 | $ bower install angular-growl-notifications 30 | ``` 31 | 32 | Load the library in your markup: 33 | 34 | ```html 35 | 36 | 37 | ``` 38 | 39 | Load the `growlNotifications` module in your AngularJS application: 40 | 41 | ```javascript 42 | angular.module('yourApp', ['growlNotifications']); 43 | ``` 44 | 45 | The library is now loaded in your AngularJS application. 46 | 47 | ### STEP 2: Specify where you want to render the notifications 48 | 49 | Before you can create notifications, you need to add the `growl-notifications` (plural) directive to your markup. 50 | 51 | This directive allows you to control where the notifications are rendered in your DOM in case your application requires special behavior. 52 | 53 | In most cases you should simply add it as the first element inside the `body` element: 54 | 55 | ```html 56 |
57 |