├── .editorconfig ├── .gitignore ├── .jshintrc ├── .travis.yml ├── Gruntfile.js ├── LICENSE ├── README.md ├── bower.json ├── contributing.md ├── demo ├── images │ ├── bg_hr.png │ ├── blacktocat.png │ ├── body-bg.png │ ├── highlight-bg.jpg │ ├── hr.png │ ├── icon_download.png │ ├── octocat-icon.png │ ├── sprite_download.png │ ├── tar-gz-icon.png │ └── zip-icon.png ├── index.html ├── javascripts │ ├── main.js │ └── prettify.js └── stylesheets │ ├── prettify.css │ └── stylesheet.css ├── dist ├── angular-flash.css ├── angular-flash.js ├── angular-flash.js.map ├── angular-flash.min.css ├── angular-flash.min.js └── angular-flash.min.js.map ├── index.js ├── karma.conf.js ├── package-lock.json ├── package.json ├── src ├── .jshintrc ├── angular-flash.css └── angular-flash.js └── test ├── .jshintrc └── angular-flash_test.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 4 6 | end_of_line = lf 7 | charset = utf-8 8 | trim_trailing_whitespace = true 9 | insert_final_newline = true 10 | 11 | [package.json] 12 | indent_style = space 13 | indent_size = 4 14 | 15 | [*.md] 16 | trim_trailing_whitespace = false 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | /bower_components/ 3 | .idea/* 4 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "node": true, 3 | "browser": 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 | "undef": true, 16 | "unused": true, 17 | "strict": true 18 | } 19 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - '0.10' 4 | before_script: 5 | - 'npm install -g bower grunt-cli' 6 | - 'bower install' -------------------------------------------------------------------------------- /Gruntfile.js: -------------------------------------------------------------------------------- 1 | module.exports = function (grunt) { 2 | 'use strict'; 3 | // Load all grunt tasks 4 | require('load-grunt-tasks')(grunt); 5 | // Show elapsed time at the end 6 | require('time-grunt')(grunt); 7 | 8 | grunt.loadNpmTasks('grunt-bootlint'); 9 | grunt.loadNpmTasks('grunt-banner'); 10 | 11 | var distPath = 'dist/'; 12 | // Project configuration. 13 | grunt.initConfig({ 14 | // Metadata. 15 | pkg: grunt.file.readJSON('package.json'), 16 | babel: { 17 | options: { 18 | sourceMap: true, 19 | presets: ['es2015'] 20 | }, 21 | dist: { 22 | files: { 23 | 'dist/angular-flash.js': 'src/angular-flash.js' 24 | } 25 | } 26 | }, 27 | banner: '/*! angular-flash - v<%= pkg.version %> - ' + 28 | '<%= grunt.template.today("yyyy-mm-dd") %>\n' + 29 | '<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' + 30 | '* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' + 31 | ' Licensed MIT */\n', 32 | // Task configuration. 33 | concat: { 34 | basic: { 35 | src: [distPath + 'angular-flash.js'], 36 | dest: distPath + 'angular-flash.js' 37 | }, 38 | extras: { 39 | src: ['src/angular-flash.css'], 40 | dest: distPath + 'angular-flash.css' 41 | } 42 | }, 43 | uglify: { 44 | options: { 45 | sourceMap: true 46 | }, 47 | dist: { 48 | src: distPath + 'angular-flash.js', 49 | dest: distPath + 'angular-flash.min.js' 50 | } 51 | }, 52 | cssmin: { 53 | target: { 54 | files: [{ 55 | expand: true, 56 | cwd: '', 57 | src: [distPath + '*.css', '!*.min.css'], 58 | dest: '', 59 | ext: '.min.css' 60 | }] 61 | } 62 | }, 63 | jshint: { 64 | options: { 65 | reporter: require('jshint-stylish') 66 | }, 67 | gruntfile: { 68 | options: { 69 | jshintrc: '.jshintrc', 70 | reporterOutput: '' 71 | }, 72 | src: 'Gruntfile.js' 73 | } 74 | }, 75 | watch: { 76 | src: { 77 | files: ['Gruntfile.js', 'src/*.*'], 78 | tasks: ['default'] 79 | } 80 | }, 81 | connect: { 82 | server: { 83 | options: { 84 | hostname: '*', 85 | port: 9000 86 | } 87 | } 88 | }, 89 | bootlint: { 90 | options: { 91 | stoponerror: false, 92 | relaxerror: ['E001', 'W001', 'W002', 'W003', 'W005'] 93 | }, 94 | files: ['src/angular-flash.js'] 95 | }, 96 | usebanner: { 97 | taskName: { 98 | options: { 99 | position: 'top', 100 | banner: '<%= banner %>', 101 | linebreak: true 102 | }, 103 | files: { 104 | src: ['dist/*.css', 'dist/*.js'] 105 | } 106 | } 107 | } 108 | }); 109 | 110 | // Default task. 111 | grunt.registerTask('lint', ['jshint', 'bootlint']); 112 | grunt.registerTask('default', ['babel', 'lint', 'connect', 'concat', 'uglify', 'cssmin', 'usebanner']); 113 | grunt.registerTask('serve', ['connect', 'watch']); 114 | grunt.registerTask('test', ['lint', 'connect']); 115 | }; 116 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Sachin N 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![license](https://img.shields.io/npm/l/angular-flash-alert.svg) 2 | ![travis](https://travis-ci.org/sachinchoolur/angular-flash.svg?branch=master) 3 | ![bower](https://img.shields.io/bower/v/angular-flash-alert.svg) 4 | ![npm](https://img.shields.io/npm/v/angular-flash-alert.svg) 5 | # angular-flash 6 | A simple lightweight flash message module for AngularJS and Bootstrap. 7 | 8 | 9 | ## Demo 10 | [angular-flash](http://sachinchoolur.github.io/angular-flash/) | [jsfiddle](http://jsfiddle.net/roopehakulinen/uxeg4nze/) | [codepen](http://codepen.io/RoopeHakulinen/pen/QyZjxm) 11 | 12 | 13 | 14 | ## Install 15 | 16 | #### npm 17 | 18 | You can also find angular-flash on [npm](http://npmjs.org) 19 | 20 | ```sh 21 | $ npm install angular-flash-alert 22 | ``` 23 | 24 | #### Bower 25 | 26 | You can Install angular-flash using the [Bower](http://bower.io) package manager. 27 | 28 | ```sh 29 | $ bower install angular-flash-alert --save 30 | ``` 31 | 32 | Add the Following code to the <head> of your document. 33 | ```html 34 | 35 | // If you are using bootstrap v3 no need to include angular-flash.css 36 | 37 | 38 | // Do not include both angular-flash.js and angular-flash.min.js 39 | ``` 40 | Add `ngFlash` dependency to your module 41 | ```javascript 42 | var myApp = angular.module("app", ["ngFlash"]) 43 | ``` 44 | Include directive below in your HTML template. 45 | ```html 46 | 47 | ``` 48 | 49 | ## Configure 50 | You can configure angular-flash by two ways: 51 | 52 | Add attributes on the `` directive. 53 | ```html 54 | 59 | 64 | ``` 65 | 66 | Set configuration with `flashProvider`. 67 | ```javascript 68 | app.config((FlashProvider) => { 69 | FlashProvider.setTimeout(5000); 70 | FlashProvider.setShowClose(true); 71 | FlashProvider.setOnDismiss(myCallback); 72 | }); 73 | ``` 74 | 75 | #### Use a custom template 76 | 77 | By default, angular-flash use the Bootstrap flash standard template, but you can set your own template. 78 | 79 | **By giving it in the Js**: use `.setTemplate(...)` with the template in parameter. 80 | ```javascript 81 | app.config((FlashProvider) => { 82 | FlashProvider.setTemplate(` 83 |
{{ flash.text }}
84 | `); 85 | }); 86 | ``` 87 | 88 | **By giving it in the HTML**: use `.setTemplatePreset('transclude')` with the template transcluded in the `` directive. 89 | ```javascript 90 | app.config((FlashProvider) => { 91 | FlashProvider.setTemplatePreset('transclude'); 92 | }); 93 | ``` 94 | ```html 95 | 96 |
{{ flash.text }}
97 |
98 | ``` 99 | 100 | ## How to use 101 | Inject the `Flash` factory in your controller 102 | ```javascript 103 | myApp.controller('demoCtrl', ['Flash', function(Flash) { 104 | $scope.successAlert = function () { 105 | var message = 'Well done! You successfully read this important alert message.'; 106 | var id = Flash.create('success', message, 0, {class: 'custom-class', id: 'custom-id'}, true); 107 | // First argument (string) is the type of the flash alert. 108 | // Second argument (string) is the message displays in the flash alert (HTML is ok). 109 | // Third argument (number, optional) is the duration of showing the flash. 0 to not automatically hide flash (user needs to click the cross on top-right corner). 110 | // Fourth argument (object, optional) is the custom class and id to be added for the flash message created. 111 | // Fifth argument (boolean, optional) is the visibility of close button for this flash. 112 | // Returns the unique id of flash message that can be used to call Flash.dismiss(id); to dismiss the flash message. 113 | } 114 | }]); 115 | ``` 116 | #### Flash types #### 117 | + success 118 | + info 119 | + warning 120 | + danger 121 | 122 | #### Methods 123 | These methods are mostly for internal usage but can be used also from outside. 124 | 125 | ``` javascript 126 | Flash.dismiss(1); 127 | // Dismiss the flash with id of 1. Id is not the index of flash but instead a value returned by Flash.create() 128 | ``` 129 | 130 | ``` javascript 131 | Flash.clear(); 132 | // Dismisses all flashes shown. 133 | ``` 134 | 135 | #### Animating 136 | You can animate the flash messages via traditional Angular way by including _ngAnimate_ as a dependency of your application and then defining the CSS transitions for different classes (_ng-enter_, _ng-move_, _ng-leave_) provided by Angular. 137 | 138 | Example: 139 | ``` 140 | .alert.ng-leave { 141 | opacity: 1; 142 | transition: opacity 1.5s ease-out; 143 | } 144 | .alert.ng-leave-active { 145 | opacity: 0; 146 | } 147 | ``` 148 | 149 | #### Multiple flash containers 150 | 151 | You can send flashes to different containers by naming them and specifying their name in the config you pass to the `Flash.create` function. 152 | 153 | ```html 154 | 155 | ``` 156 | ```js 157 | Flash.create('success', 'Hooray!', 0, {container: 'flash-fixed'}); 158 | ``` 159 | 160 | #### [Guidelines for contributors](https://github.com/sachinchoolur/angular-flash/blob/master/contributing.md) 161 | 162 | #### Running tests 163 | You'll need relatively new versions of Firefox and Chrome installed on your local system to run the tests. 164 | 165 | Once you do, run: 166 | ``` 167 | npm install 168 | npm run test 169 | ``` 170 | 171 | #### Contributors 172 | * [Sachin Choluur](https://github.com/sachinchoolur) (Original author) 173 | * [Roope Hakulinen](https://github.com/RoopeHakulinen) (Version 2) 174 | * [Nicolas Coden](https://github.com/ncoden) 175 | 176 | #### License 177 | MIT © [Sachin Choluur](https://twitter.com/sachinchoolur) 178 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-flash-alert", 3 | "version": "2.5.0", 4 | "homepage": "https://github.com/sachinchoolur/angular-flash", 5 | "authors": [ 6 | "Sachin N ", 7 | "Roope Hakulinen ", 8 | "Nicolas Coden " 9 | ], 10 | "description": "Flash messages for AngularJS and Bootstrap", 11 | "main": ["dist/angular-flash.js", "dist/angular-flash.css"], 12 | "keywords": [ 13 | "angular-flash", 14 | "flash", 15 | "message", 16 | "alert", 17 | "angularjs", 18 | "bootstrap" 19 | ], 20 | "dependencies": { 21 | "angular": ">=1.4.8" 22 | }, 23 | "ignore": [ 24 | "README.md", 25 | "demo" 26 | ] 27 | } 28 | -------------------------------------------------------------------------------- /contributing.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | ## Important notes 4 | Please don't edit files in the root directory of repository as they are generated via Grunt. You'll find source code in the `src` subdirectory! 5 | 6 | ### Code style 7 | Regarding code style like indentation and whitespace, **follow the conventions you see used in the source already.** There is also a `.editorconfig` to apply styles on your IDE of choice. 8 | 9 | ## Modifying the code 10 | First, ensure that you have the latest [Node.js](http://nodejs.org/) and [npm](http://npmjs.org/) installed. 11 | 12 | Test that Grunt's CLI and Bower are installed by running `grunt --version`. If the command isn't found, run `npm install -g grunt-cli`. For more information about installing the tools, see the [getting started with Grunt guide](http://gruntjs.com/getting-started). 13 | 14 | 1. Fork and clone the repo. 15 | 1. Run `npm install` to install all build dependencies (including Grunt). 16 | 1. Run `grunt` to compile the code. 17 | 1. Run tests as described on README.md. 18 | 19 | Assuming that you don't see anything on red, you're ready to go. Just be sure to run `grunt` after making any changes, to ensure that nothing is broken. 20 | 21 | ## Submitting pull requests 22 | 23 | 1. Create a new branch, please don't work in your `master` branch directly. 24 | 1. Add failing tests for the change you want to make. Run `grunt` to see the tests fail. 25 | 1. Fix stuff. 26 | 1. Run tests (see README for instructions) and see the tests pass. Repeat steps 2-4 until all tests pass. 27 | 1. Update the documentation to reflect any changes. 28 | 1. Push to your fork and submit a pull request. 29 | -------------------------------------------------------------------------------- /demo/images/bg_hr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/bg_hr.png -------------------------------------------------------------------------------- /demo/images/blacktocat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/blacktocat.png -------------------------------------------------------------------------------- /demo/images/body-bg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/body-bg.png -------------------------------------------------------------------------------- /demo/images/highlight-bg.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/highlight-bg.jpg -------------------------------------------------------------------------------- /demo/images/hr.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/hr.png -------------------------------------------------------------------------------- /demo/images/icon_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/icon_download.png -------------------------------------------------------------------------------- /demo/images/octocat-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/octocat-icon.png -------------------------------------------------------------------------------- /demo/images/sprite_download.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/sprite_download.png -------------------------------------------------------------------------------- /demo/images/tar-gz-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/tar-gz-icon.png -------------------------------------------------------------------------------- /demo/images/zip-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sachinchoolur/angular-flash/3f93ecfe36b85ecb90c5c8083141cda99fec848f/demo/images/zip-icon.png -------------------------------------------------------------------------------- /demo/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | Angular-flash 18 | 19 | 20 | 21 | 22 | 23 |
24 |
25 | View on GitHub 26 | 27 |

Angular-flash

28 |

Flash message for AngularJS and Bootstrap.

29 | 32 | 41 | 43 | 52 | 54 | 55 |
56 | Download 57 | this project as a .zip file 58 | Download 59 | this project as a tar.gz file 60 |
61 |
62 |
63 | 64 | 65 |
66 |
67 |
68 |

Demo

70 |

Flash message for AngularJS and Bootstrap.

71 | 72 | 73 | 74 | 75 | 76 |
77 |
78 |

Another Demo

80 |
81 |
    82 |
  • 83 |
    84 | {{list.content}} 85 | 86 | Delete 87 | 88 |
    89 |
  • 90 |
    91 |
    92 | 94 | 95 | add 96 | 97 |
    98 |
    99 |
100 |
101 |
102 |
103 |

104 | Install angular-flash

106 |

Add the following code to the <head> of your document.

107 |
108 | <link type="text/css" rel="stylesheet" href="dist/angular-flash.min.css" />
109 | // If you are using bootstrap v3 no need to include angular-flash.min.css
110 | <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
111 | <script src="dist/angular-flash.min.js"></script>
112 | // Do not include both angular-flash.js and angular-flash.min.js
113 |     
114 |

Add ngFlash dependency to your module

115 |
116 | var myApp = angular.module("app", ["ngFlash"]);
117 |

Include flash-message directive in your 118 | HTML.

119 |
120 | <flash-message></flash-message>
121 |
122 | 123 |
124 |

125 | Configure

127 |

You can configure angular-flash by two ways:

128 | 129 |

Add attributes on the <flash-message> directive.

130 |
131 | <flash-message
132 |     duration="5000"
133 |     show-close="true"
134 |     on-dismiss="myCallback(flash)"
135 | ></flash-message>
136 | // 5000ms as the default duration to show flash message.
137 | // Show the close button (x on the right).
138 | // Call myCallback with flash dismissed as parameter when flash has been dismissed.
139 | 140 |

Set configuration with flashProvider.

141 |
142 | app.config((FlashProvider) => {
143 |     FlashProvider.setTimeout(5000);
144 |     FlashProvider.setShowClose(true);
145 |     FlashProvider.setOnDismiss(myCallback);
146 |     FlashProvider.setAutoDismiss(false);
147 | });
148 | 149 |

150 | Use a custom template

152 |

By default, angular-flash use the Bootstrap flash standard template, but you can set your own template.

153 | 154 |

By giving it in the Js: use .setTemplate(...) with the template in parameter.

155 |
156 | app.config((FlashProvider) => {
157 |     FlashProvider.setTemplate(`
158 |         
{{ flash.text }}
159 | `); 160 | });
161 | 162 |

By giving it in the HTML: use .setTemplatePreset('transclude') with the template transcluded in the <flash-message> directive.

163 |
164 | app.config((FlashProvider) => {
165 |     FlashProvider.setTemplatePreset('transclude');
166 | });
167 |
168 | <flash-message>
169 |     <div class="my-flash">{{ flash.text }}</div>
170 | </flash-message>
171 |
172 | 173 |
174 |

175 | How to use

177 |

Inject the Flash factory in your controller

178 |
179 | myApp.controller('demoCtrl', ['Flash', function(Flash) {
180 |   $scope.successAlert = function () {
181 |     var message = '<strong> Well done!</strong>  You successfully read this important alert message.';
182 |     var id = Flash.create('success', message, 0, {class: 'custom-class', id: 'custom-id'}, true);
183 |     // First argument (string) is the type of the flash alert.
184 |     // Second argument (string) is the message displays in the flash alert (HTML is ok).
185 |     // Third argument (number, optional) is the duration of showing the flash. 0 to not automatically hide flash (user needs to click the cross on top-right corner).
186 |     // Fourth argument (object, optional) is the custom class and id to be added for the flash message created.
187 |     // Fifth argument (boolean, optional) is the visibility of close button for this flash.
188 |     // Returns the unique id of flash message that can be used to call Flash.dismiss(id); to dismiss the flash message.
189 |   }
190 | }]);
191 | 192 |
193 |
194 |

Flash alert types

196 |
    197 |
  • success
  • 198 |
  • info
  • 199 |
  • warning
  • 200 |
  • danger
  • 201 |
202 |
203 | 204 |
205 |

Methods

207 |

208 | These methods are mostly for internal usage but can be used also from outside. 209 |

210 |
211 | Flash.dismiss(1);
212 | // Dismiss the flash with id of 1. Id is not the index of flash but instead a value returned by Flash.create()
213 |                 
214 |
215 | Flash.clear();
216 | // Dismisses all flashes shown.
217 |                 
218 |
219 | 220 |
221 |

Bootstrap

223 |

Angular-flash is fully compatible with Twitter Bootstrap. It uses standard Bootstrap classes. If 224 | Bootstrap CSS is already included in your document there is no need to include angular-flash.css in your 225 | document.

226 |
227 | 228 |
229 |

ngAnimate

231 |

If you want to use animations, include ngAnimate module. You can then use regular Angular animation 232 | technique for applying your own transitions.

233 |
234 | var myApp = angular.module("app", ["ngFlash", "ngAnimate"]);
235 | 
236 |
237 | .alert {...}
238 | .alert.ng-enter, .alert.ng-enter.ng-enter-active {...}
239 | .alert.ng-leave, .alert.ng-leave.ng-leave-active {...}
240 | 
241 |
242 |
243 |

Edit on Codepen

245 |

See the Pen Flash message for AngularJS by Sachin choolur (@sachinchoolur) on CodePen. 249 |

250 | 251 |
252 |
253 | 254 | 255 | 259 | 262 |
263 |
264 |

Like angular-flash? You may also like

266 | 271 |
272 |
273 | 276 | 285 | 287 | 296 | 298 | 299 |
300 |
301 | 302 |
303 | 304 | 305 | 306 | 307 | 308 | 309 | 310 | 311 | 314 | 315 | 316 | 317 | 318 | 319 | -------------------------------------------------------------------------------- /demo/javascripts/main.js: -------------------------------------------------------------------------------- 1 | $.fn.putCursorAtEnd = function () { 2 | 3 | return this.each(function () { 4 | 5 | $(this).focus(); 6 | 7 | // If this function exists... 8 | if (this.setSelectionRange) { 9 | // ... then use it (Doesn't work in IE) 10 | 11 | // Double the length because Opera is inconsistent about whether a carriage return is one character or two. Sigh. 12 | var len = $(this).val().length * 2; 13 | 14 | this.setSelectionRange(len, len); 15 | 16 | } else { 17 | // ... otherwise replace the contents with itself 18 | // (Doesn't work in Google Chrome) 19 | 20 | $(this).val($(this).val()); 21 | 22 | } 23 | 24 | // Scroll to the bottom, in case we're in a tall textarea 25 | // (Necessary for Firefox and Google Chrome) 26 | this.scrollTop = 999999; 27 | 28 | }); 29 | 30 | }; 31 | 32 | 33 | // Demo controller 34 | var app = angular.module('demoApp', ['ngFlash', 'ngAnimate']); 35 | app.controller('FlashDemoCtrl', ['$rootScope', '$scope', 'Flash', '$interval', function ($rootScope, $scope, Flash, $interval) { 36 | $scope.success = function () { 37 | var message = 'Well done! You successfully read this important alert message.'; 38 | Flash.create('success', message); 39 | }; 40 | $scope.info = function () { 41 | var message = 'Heads up! This alert needs your attention, but it\'s not super important.'; 42 | Flash.create('info', message); 43 | }; 44 | $scope.warning = function () { 45 | var message = 'Warning! Better check yourself, you\'re not looking too good.'; 46 | Flash.create('warning', message); 47 | }; 48 | $scope.danger = function () { 49 | var message = 'Oh snap! Change a few things up and try submitting again.'; 50 | Flash.create('danger', message); 51 | }; 52 | $scope.myCallback = function(flash) { 53 | console.log('Received flash: ' + JSON.stringify(flash)); 54 | }; 55 | function addMinutes(minutes) { 56 | var d1 = new Date(), 57 | d2 = new Date(d1); 58 | d2.setMinutes(d1.getMinutes() - minutes); 59 | return d2; 60 | } 61 | 62 | $scope.editing = {}; 63 | 64 | $scope.lists = [{ 65 | content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', 66 | createdOn: addMinutes(30) 67 | }, { 68 | content: 'Ut rhoncus tortor eu mollis viverra.', 69 | createdOn: addMinutes(20) 70 | }, { 71 | content: 'Nulla commodo arcu id turpis fermentum fringilla.', 72 | createdOn: addMinutes(10) 73 | } 74 | 75 | ]; 76 | 77 | $scope.lastAdded = []; 78 | 79 | 80 | $scope.add = function () { 81 | $scope.lastAdded = { 82 | content: $scope.newList, 83 | createdOn: new Date() 84 | }; 85 | $scope.lists.push($scope.lastAdded); 86 | $scope.newList = ''; 87 | var message = "List Created! The list " + $scope.lastAdded.content + " has been created. Undo"; 88 | Flash.create('danger', message, 0, 'customAlert'); 89 | }; 90 | 91 | $scope.delete = function (item) { 92 | $scope.deletedItem = item; 93 | $scope.lists.splice($scope.lists.indexOf(item), 1); 94 | var message = "List Deleted! The list " + $scope.deletedItem.content + " has been deleted. Undo"; 95 | Flash.create('danger', message, 0, 'customAlert'); 96 | }; 97 | 98 | $scope.undoAdd = function () { 99 | $scope.deletedItem = $scope.lastAdded; 100 | $scope.lists.splice($scope.lists.indexOf($scope.lastAdded), 1); 101 | var message = "List Deleted! The list " + $scope.deletedItem.content + " has been deleted."; 102 | Flash.create('danger', message, 0, 'customAlert'); 103 | }; 104 | 105 | $scope.undoDelete = function () { 106 | Flash.create('danger', '', 'customAlert'); 107 | Flash.pause(); 108 | setTimeout(function(){ 109 | var opts = { 110 | lines: 13, // The number of lines to draw 111 | length: 6, // The length of each line 112 | width: 2, // The line thickness 113 | radius: 6, // The radius of the inner circle 114 | corners: 1, // Corner roundness (0..1) 115 | rotate: 0, // The rotation offset 116 | direction: 1, // 1: clockwise, -1: counterclockwise 117 | color: '#000', // #rgb or #rrggbb or array of colors 118 | speed: 1, // Rounds per second 119 | trail: 60, // Afterglow percentage 120 | shadow: false, // Whether to render a shadow 121 | hwaccel: false, // Whether to use hardware acceleration 122 | className: 'spinner', // The CSS class to assign to the spinner 123 | zIndex: 2e9, // The z-index (defaults to 2000000000) 124 | top: '50%', // Top position relative to parent 125 | left: '50%' // Left position relative to parent 126 | }; 127 | var target = document.getElementById('spinner'); 128 | var spinner = new Spinner(opts).spin(target); 129 | },100); 130 | 131 | setTimeout(function(){ 132 | $scope.lists.push($scope.deletedItem); 133 | var message = "List Restored! The list '" + $scope.deletedItem.content + "' has been restored."; 134 | Flash.create('danger', message, 'customAlert'); 135 | },800); 136 | }; 137 | 138 | $('#newList').on('keypress', function (e) { 139 | if ($(this).val() !== '') { 140 | if (e.which == 13) { 141 | $interval(function () { 142 | $scope.add(); 143 | return false; 144 | }, 100, 1); 145 | } 146 | } 147 | }); 148 | 149 | }]); 150 | -------------------------------------------------------------------------------- /demo/javascripts/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p .pln, a> .pun{ 13 | color:#CD3420; 14 | } 15 | 16 | .prettyprint { 17 | background-color: #F7F7F9; 18 | border: 1px solid #E8E8E8; 19 | font-size: 12px; 20 | padding: 8px; 21 | white-space:pre-wrap; 22 | } 23 | 24 | /* Specify class=linenums on a pre to get line numbering */ 25 | 26 | ol.linenums { 27 | margin: 0; 28 | padding-left: 33px; 29 | list-style-position: outside; 30 | } 31 | ol.linenums li { 32 | padding-left: 12px; 33 | color: #bebec5; 34 | line-height: 20px; 35 | text-shadow: 0 1px 0 #fff; 36 | } -------------------------------------------------------------------------------- /demo/stylesheets/stylesheet.css: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | Slate Theme for GitHub Pages 3 | by Jason Costello, @jsncostello 4 | *******************************************************************************/ 5 | 6 | 7 | /******************************************************************************* 8 | MeyerWeb Reset 9 | *******************************************************************************/ 10 | 11 | html, body, div, span, applet, object, iframe, 12 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 13 | a, abbr, acronym, address, big, cite, code, 14 | del, dfn, em, img, ins, kbd, q, s, samp, 15 | small, strike, strong, sub, sup, tt, var, 16 | b, u, i, center, 17 | dl, dt, dd, ol, ul, li, 18 | fieldset, form, label, legend, 19 | table, caption, tbody, tfoot, thead, tr, th, td, 20 | article, aside, canvas, details, embed, 21 | figure, figcaption, footer, header, hgroup, 22 | menu, nav, output, ruby, section, summary, 23 | time, mark, audio, video { 24 | margin: 0; 25 | padding: 0; 26 | border: 0; 27 | font: inherit; 28 | vertical-align: baseline; 29 | } 30 | 31 | /* HTML5 display-role reset for older browsers */ 32 | article, aside, details, figcaption, figure, 33 | footer, header, hgroup, menu, nav, section { 34 | display: block; 35 | } 36 | 37 | ol, ul { 38 | list-style: none; 39 | } 40 | 41 | table { 42 | border-collapse: collapse; 43 | border-spacing: 0; 44 | } 45 | 46 | /******************************************************************************* 47 | Theme Styles 48 | *******************************************************************************/ 49 | 50 | body { 51 | box-sizing: border-box; 52 | color:#373737; 53 | background: #212121; 54 | font-size: 16px; 55 | font-family: 'Myriad Pro', Calibri, Helvetica, Arial, sans-serif; 56 | line-height: 1.5; 57 | -webkit-font-smoothing: antialiased; 58 | } 59 | 60 | h1, h2, h3, h4, h5, h6 { 61 | margin: 10px 0; 62 | font-weight: 700; 63 | color:#222222; 64 | font-family: 'Lucida Grande', 'Calibri', Helvetica, Arial, sans-serif; 65 | letter-spacing: -1px; 66 | } 67 | 68 | h1 { 69 | font-size: 36px; 70 | font-weight: 700; 71 | } 72 | 73 | h2 { 74 | padding-bottom: 10px; 75 | font-size: 32px; 76 | background: url('../images/bg_hr.png') repeat-x bottom; 77 | } 78 | 79 | h3 { 80 | font-size: 24px; 81 | } 82 | 83 | h4 { 84 | font-size: 21px; 85 | } 86 | 87 | h5 { 88 | font-size: 18px; 89 | } 90 | 91 | h6 { 92 | font-size: 16px; 93 | } 94 | 95 | p { 96 | margin: 10px 0 15px 0; 97 | } 98 | 99 | footer p { 100 | color: #f2f2f2; 101 | } 102 | 103 | a { 104 | text-decoration: none; 105 | color: #007edf; 106 | text-shadow: none; 107 | 108 | transition: color 0.5s ease; 109 | transition: text-shadow 0.5s ease; 110 | -webkit-transition: color 0.5s ease; 111 | -webkit-transition: text-shadow 0.5s ease; 112 | -moz-transition: color 0.5s ease; 113 | -moz-transition: text-shadow 0.5s ease; 114 | -o-transition: color 0.5s ease; 115 | -o-transition: text-shadow 0.5s ease; 116 | -ms-transition: color 0.5s ease; 117 | -ms-transition: text-shadow 0.5s ease; 118 | } 119 | 120 | a:hover, a:focus {text-decoration: underline;} 121 | 122 | footer a { 123 | color: #F2F2F2; 124 | text-decoration: underline; 125 | } 126 | 127 | em { 128 | font-style: italic; 129 | } 130 | 131 | strong { 132 | font-weight: bold; 133 | } 134 | 135 | img { 136 | position: relative; 137 | margin: 0 auto; 138 | max-width: 739px; 139 | padding: 5px; 140 | margin: 10px 0 10px 0; 141 | border: 1px solid #ebebeb; 142 | 143 | box-shadow: 0 0 5px #ebebeb; 144 | -webkit-box-shadow: 0 0 5px #ebebeb; 145 | -moz-box-shadow: 0 0 5px #ebebeb; 146 | -o-box-shadow: 0 0 5px #ebebeb; 147 | -ms-box-shadow: 0 0 5px #ebebeb; 148 | } 149 | 150 | p img { 151 | display: inline; 152 | margin: 0; 153 | padding: 0; 154 | vertical-align: middle; 155 | text-align: center; 156 | border: none; 157 | } 158 | 159 | pre, code { 160 | width: 100%; 161 | color: #222; 162 | background-color: #fff; 163 | 164 | font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace; 165 | font-size: 14px; 166 | 167 | border-radius: 2px; 168 | -moz-border-radius: 2px; 169 | -webkit-border-radius: 2px; 170 | } 171 | 172 | pre { 173 | width: 100%; 174 | padding: 10px; 175 | box-shadow: 0 0 10px rgba(0,0,0,.1); 176 | overflow: auto; 177 | } 178 | 179 | code { 180 | padding: 3px; 181 | margin: 0 3px; 182 | box-shadow: 0 0 10px rgba(0,0,0,.1); 183 | } 184 | 185 | pre code { 186 | display: block; 187 | box-shadow: none; 188 | } 189 | 190 | blockquote { 191 | color: #666; 192 | margin-bottom: 20px; 193 | padding: 0 0 0 20px; 194 | border-left: 3px solid #bbb; 195 | } 196 | 197 | 198 | ul, ol, dl { 199 | margin-bottom: 15px 200 | } 201 | 202 | ul { 203 | list-style-position: inside; 204 | list-style: disc; 205 | padding-left: 20px; 206 | } 207 | 208 | ol { 209 | list-style-position: inside; 210 | list-style: decimal; 211 | padding-left: 20px; 212 | } 213 | 214 | dl dt { 215 | font-weight: bold; 216 | } 217 | 218 | dl dd { 219 | padding-left: 20px; 220 | font-style: italic; 221 | } 222 | 223 | dl p { 224 | padding-left: 20px; 225 | font-style: italic; 226 | } 227 | 228 | hr { 229 | height: 1px; 230 | margin-bottom: 5px; 231 | border: none; 232 | background: url('../images/bg_hr.png') repeat-x center; 233 | } 234 | 235 | table { 236 | border: 1px solid #373737; 237 | margin-bottom: 20px; 238 | text-align: left; 239 | } 240 | 241 | th { 242 | font-family: 'Lucida Grande', 'Helvetica Neue', Helvetica, Arial, sans-serif; 243 | padding: 10px; 244 | background: #373737; 245 | color: #fff; 246 | } 247 | 248 | td { 249 | padding: 10px; 250 | border: 1px solid #373737; 251 | } 252 | 253 | form { 254 | background: #f2f2f2; 255 | padding: 20px; 256 | } 257 | 258 | /******************************************************************************* 259 | Full-Width Styles 260 | *******************************************************************************/ 261 | 262 | .outer { 263 | width: 100%; 264 | } 265 | 266 | .inner { 267 | position: relative; 268 | max-width: 800px; 269 | padding: 20px 10px; 270 | margin: 0 auto; 271 | } 272 | 273 | #forkme_banner { 274 | display: block; 275 | position: absolute; 276 | top:0; 277 | right: 10px; 278 | z-index: 10; 279 | padding: 10px 50px 10px 10px; 280 | color: #fff; 281 | background: url('../images/blacktocat.png') #0090ff no-repeat 95% 50%; 282 | font-weight: 700; 283 | box-shadow: 0 0 10px rgba(0,0,0,.5); 284 | border-bottom-left-radius: 2px; 285 | border-bottom-right-radius: 2px; 286 | } 287 | 288 | #header_wrap { 289 | background: #212121; 290 | background: -moz-linear-gradient(top, #373737, #212121); 291 | background: -webkit-linear-gradient(top, #373737, #212121); 292 | background: -ms-linear-gradient(top, #373737, #212121); 293 | background: -o-linear-gradient(top, #373737, #212121); 294 | background: linear-gradient(top, #373737, #212121); 295 | } 296 | 297 | #header_wrap .inner { 298 | padding: 50px 10px 30px 10px; 299 | } 300 | 301 | #project_title { 302 | margin: 0; 303 | color: #fff; 304 | font-size: 42px; 305 | font-weight: 700; 306 | text-shadow: #111 0px 0px 10px; 307 | } 308 | 309 | #project_tagline { 310 | color: #fff; 311 | font-size: 24px; 312 | font-weight: 300; 313 | background: none; 314 | text-shadow: #111 0px 0px 10px; 315 | } 316 | 317 | #downloads { 318 | position: absolute; 319 | width: 210px; 320 | z-index: 10; 321 | bottom: -40px; 322 | right: 0; 323 | height: 70px; 324 | background: url('../images/icon_download.png') no-repeat 0% 90%; 325 | } 326 | 327 | .zip_download_link { 328 | display: block; 329 | float: right; 330 | width: 90px; 331 | height:70px; 332 | text-indent: -5000px; 333 | overflow: hidden; 334 | background: url(../images/sprite_download.png) no-repeat bottom left; 335 | } 336 | 337 | .tar_download_link { 338 | display: block; 339 | float: right; 340 | width: 90px; 341 | height:70px; 342 | text-indent: -5000px; 343 | overflow: hidden; 344 | background: url(../images/sprite_download.png) no-repeat bottom right; 345 | margin-left: 10px; 346 | } 347 | 348 | .zip_download_link:hover { 349 | background: url(../images/sprite_download.png) no-repeat top left; 350 | } 351 | 352 | .tar_download_link:hover { 353 | background: url(../images/sprite_download.png) no-repeat top right; 354 | } 355 | 356 | #main_content_wrap { 357 | background: #f2f2f2; 358 | border-top: 1px solid #111; 359 | border-bottom: 1px solid #111; 360 | } 361 | 362 | #main_content { 363 | padding-top: 90px; 364 | overflow: hidden; 365 | } 366 | .section{ 367 | margin-bottom: 40px; 368 | } 369 | #footer_wrap { 370 | background: #212121; 371 | } 372 | 373 | 374 | 375 | /******************************************************************************* 376 | Small Device Styles 377 | *******************************************************************************/ 378 | 379 | @media screen and (max-width: 480px) { 380 | body { 381 | font-size:14px; 382 | } 383 | 384 | #downloads { 385 | display: none; 386 | } 387 | 388 | .inner { 389 | min-width: 320px; 390 | max-width: 480px; 391 | } 392 | 393 | #project_title { 394 | font-size: 32px; 395 | } 396 | 397 | h1 { 398 | font-size: 28px; 399 | } 400 | 401 | h2 { 402 | font-size: 24px; 403 | } 404 | 405 | h3 { 406 | font-size: 21px; 407 | } 408 | 409 | h4 { 410 | font-size: 18px; 411 | } 412 | 413 | h5 { 414 | font-size: 14px; 415 | } 416 | 417 | h6 { 418 | font-size: 12px; 419 | } 420 | 421 | code, pre { 422 | min-width: 320px; 423 | max-width: 480px; 424 | font-size: 11px; 425 | } 426 | 427 | } 428 | .btn{ 429 | margin-right: 20px; 430 | } 431 | .mRb15{ 432 | margin-bottom: 15px !important; 433 | } 434 | 435 | 436 | .prettyprint{ 437 | background: none repeat scroll 0 0 #fafafa !important; 438 | border: 1px solid rgba(0, 0, 0, 0.12) !important; 439 | } 440 | 441 | 442 | /*/ Demo */ 443 | 444 | 445 | .listDemo { 446 | list-style-type: none; 447 | margin: 0; 448 | padding: 0; 449 | } 450 | .listDemo li, .listDemo .newList { 451 | border-top: 1px solid rgba(0, 0, 0, 0.12); 452 | margin: 0; 453 | padding: 12px 20px; 454 | color: #555; 455 | position: relative; 456 | } 457 | .listDemo a { 458 | font-size: 13px; 459 | margin-left: 5px; 460 | } 461 | .listDemo .action { 462 | margin-left: 10px; 463 | position: absolute; 464 | right: 15px; 465 | } 466 | .listDemo input { 467 | border: medium none; 468 | box-shadow: none; 469 | display: inline; 470 | font-size: 16px; 471 | height: 21px; 472 | width: 100%; 473 | padding: 0px; 474 | } 475 | .form-control::-moz-placeholder { 476 | color: #aaa; 477 | line-height: 1.5; 478 | opacity: 1; 479 | } 480 | .form-control:-ms-input-placeholder { 481 | color: #aaa; 482 | line-height: 1.5; 483 | } 484 | .form-control::-webkit-input-placeholder { 485 | color: #aaa; 486 | line-height: 1.5; 487 | } 488 | .form-control:focus { 489 | border-color: #bcbcbc; 490 | -moz-box-shadow: none; 491 | -webkit-box-shadow: none; 492 | box-shadow: none; 493 | outline: 0 none; 494 | } 495 | a[disabled] { 496 | background-color: #eee; 497 | cursor: default; 498 | opacity: 0.5; 499 | pointer-events: none; 500 | } 501 | 502 | 503 | .listDemoCont { 504 | background: none repeat scroll 0 0 #fafafa; 505 | border: 1px solid rgba(0, 0, 0, 0.12); 506 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 507 | width: 520px; 508 | } 509 | .listDemo li:first-child { 510 | border-top: 0 none; 511 | } 512 | 513 | 514 | /*/ customAlert */ 515 | .alert.customAlert { 516 | background-color: #fafafa; 517 | border: 1px solid rgba(0, 0, 0, 0.12); 518 | border-radius: 0; 519 | box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); 520 | color: #666; 521 | min-width: 403px; 522 | padding : 20px 50px 20px 30px; 523 | position: fixed; 524 | right: 20px; 525 | top: 20px; 526 | z-index: 9999; 527 | height: 92px; 528 | } 529 | 530 | .customAlert strong { 531 | display: block; 532 | font-size: 16px; 533 | margin-bottom: 5px; 534 | } 535 | .customAlert .close { 536 | position: absolute !important; 537 | right: 15px !important; 538 | top: 5px !important; 539 | } 540 | .customAlert em { 541 | color: #999; 542 | display: inline-block; 543 | margin: 0 5px; 544 | max-width: 100px; 545 | overflow: hidden; 546 | text-overflow: ellipsis; 547 | vertical-align: middle; 548 | white-space: pre; 549 | } 550 | .listAddCont .action{ 551 | top: 13px; 552 | } 553 | 554 | .alert.ng-leave { 555 | opacity: 1; 556 | transition: opacity 1.5s ease-out; 557 | } 558 | 559 | .alert.ng-leave-active { 560 | opacity: 0; 561 | } 562 | -------------------------------------------------------------------------------- /dist/angular-flash.css: -------------------------------------------------------------------------------- 1 | /*! angular-flash - v2.5.0 - 2017-07-23 2 | * https://github.com/sachinchoolur/angular-flash 3 | * Copyright (c) 2017 Sachin; Licensed MIT */ 4 | 5 | .alert { 6 | padding: 15px; 7 | margin-bottom: 20px; 8 | border: 1px solid transparent; 9 | border-radius: 4px; 10 | } 11 | .alert h4 { 12 | margin-top: 0; 13 | color: inherit; 14 | } 15 | .alert .alert-link { 16 | font-weight: bold; 17 | } 18 | .alert > p, 19 | .alert > ul { 20 | margin-bottom: 0; 21 | } 22 | .alert > p + p { 23 | margin-top: 5px; 24 | } 25 | .alert-dismissable, 26 | .alert-dismissible { 27 | padding-right: 35px; 28 | } 29 | .alert-dismissable .close, 30 | .alert-dismissible .close { 31 | position: relative; 32 | top: -2px; 33 | right: -21px; 34 | color: inherit; 35 | } 36 | .alert-success { 37 | color: #3c763d; 38 | background-color: #dff0d8; 39 | border-color: #d6e9c6; 40 | } 41 | .alert-success hr { 42 | border-top-color: #c9e2b3; 43 | } 44 | .alert-success .alert-link { 45 | color: #2b542c; 46 | } 47 | .alert-info { 48 | color: #31708f; 49 | background-color: #d9edf7; 50 | border-color: #bce8f1; 51 | } 52 | .alert-info hr { 53 | border-top-color: #a6e1ec; 54 | } 55 | .alert-info .alert-link { 56 | color: #245269; 57 | } 58 | .alert-warning { 59 | color: #8a6d3b; 60 | background-color: #fcf8e3; 61 | border-color: #faebcc; 62 | } 63 | .alert-warning hr { 64 | border-top-color: #f7e1b5; 65 | } 66 | .alert-warning .alert-link { 67 | color: #66512c; 68 | } 69 | .alert-danger { 70 | color: #a94442; 71 | background-color: #f2dede; 72 | border-color: #ebccd1; 73 | } 74 | .alert-danger hr { 75 | border-top-color: #e4b9c0; 76 | } 77 | .alert-danger .alert-link { 78 | color: #843534; 79 | } 80 | 81 | .close { 82 | float: right; 83 | font-size: 21px; 84 | font-weight: bold; 85 | line-height: 1; 86 | color: #000; 87 | text-shadow: 0 1px 0 #fff; 88 | filter: alpha(opacity=20); 89 | opacity: .2; 90 | } 91 | .close:hover, 92 | .close:focus { 93 | color: #000; 94 | text-decoration: none; 95 | cursor: pointer; 96 | filter: alpha(opacity=50); 97 | opacity: .5; 98 | } 99 | 100 | div.close { 101 | -webkit-appearance: none; 102 | padding: 0; 103 | cursor: pointer; 104 | background: transparent; 105 | border: 0; 106 | font-size: 1.7em; 107 | } 108 | .sr-only { 109 | position: absolute; 110 | width: 1px; 111 | height: 1px; 112 | padding: 0; 113 | margin: -1px; 114 | overflow: hidden; 115 | clip: rect(0, 0, 0, 0); 116 | border: 0; 117 | } 118 | -------------------------------------------------------------------------------- /dist/angular-flash.js: -------------------------------------------------------------------------------- 1 | /*! angular-flash - v2.5.0 - 2017-07-23 2 | * https://github.com/sachinchoolur/angular-flash 3 | * Copyright (c) 2017 Sachin; Licensed MIT */ 4 | 5 | 'use strict'; 6 | 7 | var app = angular.module('ngFlash', []); 8 | 9 | app.run(['$rootScope', function ($rootScope) { 10 | return $rootScope.flashes = []; 11 | }]); 12 | 13 | app.directive('dynamic', ['$compile', function ($compile) { 14 | return { 15 | restrict: 'A', 16 | replace: true, 17 | link: function link(scope, ele, attrs) { 18 | return scope.$watch(attrs.dynamic, function (html) { 19 | ele.html(html); 20 | return $compile(ele.contents())(scope); 21 | }); 22 | } 23 | }; 24 | }]); 25 | 26 | app.directive('applytransclude', ['$compile', function ($compile) { 27 | return { 28 | restrict: 'A', 29 | link: function link(scope, ele, attrs) { 30 | scope._transclude(scope, function (clone, scope) { 31 | ele.empty().append(clone); 32 | }); 33 | } 34 | }; 35 | }]); 36 | 37 | app.directive('closeFlash', ['$compile', '$rootScope', 'Flash', function ($compile, $rootScope, Flash) { 38 | return { 39 | link: function link(scope, ele, attrs) { 40 | return ele.on('click', function () { 41 | var id = parseInt(attrs.closeFlash, 10); 42 | Flash.dismiss(id); 43 | $rootScope.$apply(); 44 | }); 45 | } 46 | }; 47 | }]); 48 | 49 | app.directive('flashMessage', ['Flash', function (Flash) { 50 | return { 51 | restrict: 'E', 52 | scope: { 53 | duration: '=', 54 | showClose: '=', 55 | onDismiss: '&', 56 | name: '@' 57 | }, 58 | link: function link(scope, ele, attrs, ctrl, transclude) { 59 | Flash.setTimeout(scope.duration); 60 | Flash.setShowClose(scope.showClose); 61 | function onDismiss(flash) { 62 | if (typeof scope.onDismiss !== 'function') return; 63 | scope.onDismiss({ flash: flash }); 64 | } 65 | 66 | Flash.setOnDismiss(onDismiss); 67 | 68 | if (Flash.config.templateTransclude) { 69 | scope._transclude = transclude; 70 | } 71 | }, 72 | transclude: Flash.config.templateTransclude, 73 | template: '\n
\n ' + Flash.config.template + '\n
\n ' 74 | }; 75 | }]); 76 | 77 | app.provider('Flash', function () { 78 | var defaultConfig = {}; 79 | var templatePresets = { 80 | bootstrap: { 81 | html: '\n ', 82 | transclude: false 83 | }, 84 | transclude: { 85 | html: '
', 86 | transclude: true 87 | } 88 | }; 89 | 90 | this.setTimeout = function (timeout) { 91 | if (typeof timeout !== 'number') return; 92 | defaultConfig.timeout = timeout; 93 | }; 94 | this.setShowClose = function (value) { 95 | if (typeof value !== 'boolean') return; 96 | defaultConfig.showClose = value; 97 | }; 98 | this.setTemplate = function (template) { 99 | if (typeof template !== 'string') return; 100 | defaultConfig.template = template; 101 | }; 102 | this.setTemplatePreset = function (preset) { 103 | if (typeof preset !== 'string' || !(preset in templatePresets)) return; 104 | 105 | var template = templatePresets[preset]; 106 | this.setTemplate(template.html); 107 | defaultConfig.templateTransclude = template.transclude; 108 | }; 109 | this.setOnDismiss = function (callback) { 110 | if (typeof callback !== 'function') return; 111 | defaultConfig.onDismiss = callback; 112 | }; 113 | 114 | this.setAutoDismiss = function (dismiss) { 115 | if (typeof dismiss !== 'boolean') return; 116 | defaultConfig.autoDismiss = dismiss; 117 | }; 118 | 119 | this.setTimeout(5000); 120 | this.setShowClose(true); 121 | this.setTemplatePreset('bootstrap'); 122 | this.setAutoDismiss(false); 123 | 124 | this.$get = ['$rootScope', '$interval', function ($rootScope, $interval) { 125 | var dataFactory = {}; 126 | var counter = 0; 127 | 128 | dataFactory.setTimeout = this.setTimeout; 129 | dataFactory.setShowClose = this.setShowClose; 130 | dataFactory.setOnDismiss = this.setOnDismiss; 131 | dataFactory.config = defaultConfig; 132 | 133 | dataFactory.create = function (type, text, timeout, config, showClose) { 134 | if ($rootScope.flashes.length === 1 && defaultConfig.autoDismiss) { 135 | dataFactory.dismiss($rootScope.flashes[0].id); 136 | } 137 | if (!text) return false; 138 | var $this = void 0, 139 | flash = void 0; 140 | $this = this; 141 | flash = { 142 | type: type, 143 | text: text, 144 | config: config, 145 | id: counter++ 146 | }; 147 | flash.showClose = typeof showClose !== 'undefined' ? showClose : defaultConfig.showClose; 148 | if (defaultConfig.timeout && typeof timeout === 'undefined') { 149 | flash.timeout = defaultConfig.timeout; 150 | } else if (timeout) { 151 | flash.timeout = timeout; 152 | } 153 | $rootScope.flashes.push(flash); 154 | if (flash.timeout) { 155 | flash.timeoutObj = $interval(function () { 156 | $this.dismiss(flash.id); 157 | }, flash.timeout, 1); 158 | } 159 | return flash.id; 160 | }; 161 | dataFactory.pause = function (index) { 162 | if ($rootScope.flashes[index].timeoutObj) { 163 | $interval.cancel($rootScope.flashes[index].timeoutObj); 164 | } 165 | }; 166 | dataFactory.dismiss = function (id) { 167 | var index = findIndexById(id); 168 | if (index !== -1) { 169 | var flash = $rootScope.flashes[index]; 170 | dataFactory.pause(index); 171 | $rootScope.flashes.splice(index, 1); 172 | if (typeof defaultConfig.onDismiss === 'function') { 173 | defaultConfig.onDismiss(flash); 174 | } 175 | } 176 | }; 177 | dataFactory.clear = function () { 178 | while ($rootScope.flashes.length > 0) { 179 | dataFactory.dismiss($rootScope.flashes[0].id); 180 | } 181 | }; 182 | dataFactory.reset = dataFactory.clear; 183 | function findIndexById(id) { 184 | return $rootScope.flashes.map(function (flash) { 185 | return flash.id; 186 | }).indexOf(id); 187 | } 188 | 189 | return dataFactory; 190 | }]; 191 | }); 192 | //# sourceMappingURL=angular-flash.js.map 193 | -------------------------------------------------------------------------------- /dist/angular-flash.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["../src/angular-flash.js"],"names":["app","angular","module","run","$rootScope","flashes","directive","$compile","restrict","replace","link","scope","ele","attrs","$watch","dynamic","html","contents","_transclude","clone","empty","append","Flash","on","id","parseInt","closeFlash","dismiss","$apply","duration","showClose","onDismiss","name","ctrl","transclude","setTimeout","setShowClose","flash","setOnDismiss","config","templateTransclude","template","provider","defaultConfig","templatePresets","bootstrap","timeout","value","setTemplate","setTemplatePreset","preset","callback","setAutoDismiss","autoDismiss","$get","$interval","dataFactory","counter","create","type","text","length","$this","push","timeoutObj","pause","index","cancel","findIndexById","splice","clear","reset","map","indexOf"],"mappings":";;AAAA,IAAMA,MAAMC,QAAQC,MAAR,CAAe,SAAf,EAA0B,EAA1B,CAAZ;;AAEAF,IAAIG,GAAJ,CAAQ,CACJ,YADI,EACU,UAASC,UAAT,EAAqB;AAC/B,WAAOA,WAAWC,OAAX,GAAqB,EAA5B;AACH,CAHG,CAAR;;AAMAL,IAAIM,SAAJ,CAAc,SAAd,EAAyB,CACrB,UADqB,EACT,UAASC,QAAT,EAAmB;AAC3B,WAAO;AACHC,kBAAU,GADP;AAEHC,iBAAS,IAFN;AAGHC,cAAM,cAASC,KAAT,EAAgBC,GAAhB,EAAqBC,KAArB,EAA4B;AAC9B,mBAAOF,MAAMG,MAAN,CAAaD,MAAME,OAAnB,EAA4B,UAASC,IAAT,EAAe;AAC9CJ,oBAAII,IAAJ,CAASA,IAAT;AACA,uBAAOT,SAASK,IAAIK,QAAJ,EAAT,EAAyBN,KAAzB,CAAP;AACH,aAHM,CAAP;AAIH;AARE,KAAP;AAUH,CAZoB,CAAzB;;AAeAX,IAAIM,SAAJ,CAAc,iBAAd,EAAiC,CAC7B,UAD6B,EACjB,UAASC,QAAT,EAAmB;AAC3B,WAAO;AACHC,kBAAU,GADP;AAEHE,cAAM,cAASC,KAAT,EAAgBC,GAAhB,EAAqBC,KAArB,EAA4B;AAC9BF,kBAAMO,WAAN,CAAkBP,KAAlB,EAAyB,UAASQ,KAAT,EAAgBR,KAAhB,EAAuB;AAC5CC,oBAAIQ,KAAJ,GAAYC,MAAZ,CAAmBF,KAAnB;AACH,aAF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aAAT,CAAuB5C,EAAvB,EAA2B;AACvB,mBAAOpB,WAAWC,OAAX,CAAmBmE,GAAnB,CAAuB,UAACnC,KAAD;AAAA,uBAAWA,MAAMb,EAAjB;AAAA,aAAvB,EAA4CiD,OAA5C,CAAoDjD,EAApD,CAAP;AACH;;AAED,eAAOgC,WAAP;AACH,KAlEW,CAAZ;AAmEH,CA3HD","file":"angular-flash.js","sourcesContent":["const app = angular.module('ngFlash', []);\n\napp.run([\n '$rootScope', function($rootScope) {\n return $rootScope.flashes = [];\n }\n]);\n\napp.directive('dynamic', [\n '$compile', function($compile) {\n return {\n restrict: 'A',\n replace: true,\n link: function(scope, ele, attrs) {\n return scope.$watch(attrs.dynamic, function(html) {\n ele.html(html);\n return $compile(ele.contents())(scope);\n });\n }\n };\n }\n]);\n\napp.directive('applytransclude', [\n '$compile', function($compile) {\n return {\n restrict: 'A',\n link: function(scope, ele, attrs) {\n scope._transclude(scope, function(clone, scope) {\n ele.empty().append(clone);\n });\n }\n };\n }\n]);\n\napp.directive('closeFlash', [\n '$compile', '$rootScope', 'Flash', function($compile, $rootScope, Flash) {\n return {\n link: function(scope, ele, attrs) {\n return ele.on('click', function() {\n let id = parseInt(attrs.closeFlash, 10);\n Flash.dismiss(id);\n $rootScope.$apply();\n });\n }\n };\n }\n]);\n\napp.directive('flashMessage', [\n 'Flash', function(Flash) {\n return {\n restrict: 'E',\n scope: {\n duration: '=',\n showClose: '=',\n onDismiss: '&',\n name: '@'\n },\n link: function(scope, ele, attrs, ctrl, transclude) {\n Flash.setTimeout(scope.duration);\n Flash.setShowClose(scope.showClose);\n function onDismiss(flash) {\n if (typeof scope.onDismiss !== 'function') return;\n scope.onDismiss({flash: flash});\n }\n\n Flash.setOnDismiss(onDismiss);\n\n if (Flash.config.templateTransclude) {\n scope._transclude = transclude;\n }\n },\n transclude: Flash.config.templateTransclude,\n template: `\n
\n ` + Flash.config.template + `\n
\n `\n };\n }\n]);\n\napp.provider('Flash', function() {\n let defaultConfig = {};\n let templatePresets = {\n bootstrap: {\n html: `\n
\n
\n ×\n Close\n
\n \n
`,\n transclude: false\n },\n transclude: {\n html: `
`,\n transclude: true\n }\n };\n\n this.setTimeout = function(timeout) {\n if (typeof timeout !== 'number') return;\n defaultConfig.timeout = timeout;\n };\n this.setShowClose = function(value) {\n if (typeof value !== 'boolean') return;\n defaultConfig.showClose = value;\n };\n this.setTemplate = function(template) {\n if (typeof template !== 'string') return;\n defaultConfig.template = template;\n };\n this.setTemplatePreset = function(preset) {\n if (typeof preset !== 'string'\n || !(preset in templatePresets)) return;\n\n let template = templatePresets[preset];\n this.setTemplate(template.html);\n defaultConfig.templateTransclude = template.transclude;\n };\n this.setOnDismiss = function(callback) {\n if (typeof callback !== 'function') return;\n defaultConfig.onDismiss = callback;\n };\n\n this.setAutoDismiss = function (dismiss) {\n if (typeof dismiss !== 'boolean') return;\n defaultConfig.autoDismiss = dismiss;\n };\n\n this.setTimeout(5000);\n this.setShowClose(true);\n this.setTemplatePreset('bootstrap');\n this.setAutoDismiss(false);\n\n this.$get = ['$rootScope', '$interval', function($rootScope, $interval) {\n const dataFactory = {};\n let counter = 0;\n\n dataFactory.setTimeout = this.setTimeout;\n dataFactory.setShowClose = this.setShowClose;\n dataFactory.setOnDismiss = this.setOnDismiss;\n dataFactory.config = defaultConfig;\n\n dataFactory.create = function(type, text, timeout, config, showClose) {\n if ($rootScope.flashes.length === 1 && defaultConfig.autoDismiss) {\n dataFactory.dismiss($rootScope.flashes[0].id);\n }\n if (!text) return false;\n let $this, flash;\n $this = this;\n flash = {\n type: type,\n text: text,\n config: config,\n id: counter++\n };\n flash.showClose =\n typeof showClose !== 'undefined' ?\n showClose : defaultConfig.showClose;\n if (defaultConfig.timeout && typeof timeout === 'undefined') {\n flash.timeout = defaultConfig.timeout;\n }\n else if (timeout) {\n flash.timeout = timeout;\n }\n $rootScope.flashes.push(flash);\n if (flash.timeout) {\n flash.timeoutObj = $interval(function() {\n $this.dismiss(flash.id);\n }, flash.timeout, 1);\n }\n return flash.id;\n };\n dataFactory.pause = function(index) {\n if ($rootScope.flashes[index].timeoutObj) {\n $interval.cancel($rootScope.flashes[index].timeoutObj);\n }\n };\n dataFactory.dismiss = function(id) {\n const index = findIndexById(id);\n if (index !== -1) {\n const flash = $rootScope.flashes[index];\n dataFactory.pause(index);\n $rootScope.flashes.splice(index, 1);\n if (typeof defaultConfig.onDismiss === 'function') {\n defaultConfig.onDismiss(flash);\n }\n }\n };\n dataFactory.clear = function() {\n while ($rootScope.flashes.length > 0) {\n dataFactory.dismiss($rootScope.flashes[0].id);\n }\n };\n dataFactory.reset = dataFactory.clear;\n function findIndexById(id) {\n return $rootScope.flashes.map((flash) => flash.id).indexOf(id);\n }\n\n return dataFactory;\n }];\n});\n"]} -------------------------------------------------------------------------------- /dist/angular-flash.min.css: -------------------------------------------------------------------------------- 1 | /*! angular-flash - v2.5.0 - 2017-07-23 2 | * https://github.com/sachinchoolur/angular-flash 3 | * Copyright (c) 2017 Sachin; Licensed MIT */ 4 | 5 | .alert .alert-link,.close{font-weight:700}/*! angular-flash - v2.5.0 - 2017-07-23 6 | * https://github.com/sachinchoolur/angular-flash 7 | * Copyright (c) 2017 Sachin; Licensed MIT *//*! angular-flash - v2.5.0 - 2017-07-23 8 | * https://github.com/sachinchoolur/angular-flash 9 | * Copyright (c) 2017 Sachin; Licensed MIT *//*! angular-flash - v2.5.0 - 2017-07-23 10 | * https://github.com/sachinchoolur/angular-flash 11 | * Copyright (c) 2017 Sachin; Licensed MIT *//*! angular-flash - v2.5.0 - 2017-07-23 12 | * https://github.com/sachinchoolur/angular-flash 13 | * Copyright (c) 2017 Sachin; Licensed MIT *//*! angular-flash - v2.5.0 - 2017-07-23 14 | * https://github.com/sachinchoolur/angular-flash 15 | * Copyright (c) 2017 Sachin; Licensed MIT *//*! angular-flash - v2.4.0 - 2016-10-25 16 | * https://github.com/sachinchoolur/angular-flash 17 | * Copyright (c) 2016 Sachin; Licensed MIT *//*! angular-flash - v2.3.0 - 2016-10-25 18 | * https://github.com/sachinchoolur/angular-flash 19 | * Copyright (c) 2016 Sachin; Licensed MIT *//*! angular-flash - v2.3.0 - 2016-08-23 20 | * https://github.com/sachinchoolur/angular-flash 21 | * Copyright (c) 2016 Sachin; Licensed MIT *//*! angular-flash - v2.3.0 - 2016-08-23 22 | * https://github.com/sachinchoolur/angular-flash 23 | * Copyright (c) 2016 Sachin; Licensed MIT *//*! angular-flash - v2.3.0 - 2016-08-23 24 | * https://github.com/sachinchoolur/angular-flash 25 | * Copyright (c) 2016 Sachin; Licensed MIT *//*! angular-flash - v2.3.0 - 2016-04-24 26 | * https://github.com/sachinchoolur/angular-flash 27 | * Copyright (c) 2016 Sachin; Licensed MIT */.alert{padding:15px;margin-bottom:20px;border:1px solid transparent;border-radius:4px}.alert h4{margin-top:0;color:inherit}.alert>p,.alert>ul{margin-bottom:0}.alert>p+p{margin-top:5px}.alert-dismissable,.alert-dismissible{padding-right:35px}.alert-dismissable .close,.alert-dismissible .close{position:relative;top:-2px;right:-21px;color:inherit}.alert-success{color:#3c763d;background-color:#dff0d8;border-color:#d6e9c6}.alert-success hr{border-top-color:#c9e2b3}.alert-success .alert-link{color:#2b542c}.alert-info{color:#31708f;background-color:#d9edf7;border-color:#bce8f1}.alert-info hr{border-top-color:#a6e1ec}.alert-info .alert-link{color:#245269}.alert-warning{color:#8a6d3b;background-color:#fcf8e3;border-color:#faebcc}.alert-warning hr{border-top-color:#f7e1b5}.alert-warning .alert-link{color:#66512c}.alert-danger{color:#a94442;background-color:#f2dede;border-color:#ebccd1}.alert-danger hr{border-top-color:#e4b9c0}.sr-only,div.close{padding:0;border:0}.alert-danger .alert-link{color:#843534}.close{float:right;font-size:21px;line-height:1;color:#000;text-shadow:0 1px 0 #fff;filter:alpha(opacity=20);opacity:.2}.close:focus,.close:hover{color:#000;text-decoration:none;cursor:pointer;filter:alpha(opacity=50);opacity:.5}div.close{-webkit-appearance:none;cursor:pointer;background:0 0;font-size:1.7em}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;overflow:hidden;clip:rect(0,0,0,0)} -------------------------------------------------------------------------------- /dist/angular-flash.min.js: -------------------------------------------------------------------------------- 1 | /*! angular-flash - v2.5.0 - 2017-07-23 2 | * https://github.com/sachinchoolur/angular-flash 3 | * Copyright (c) 2017 Sachin; Licensed MIT */ 4 | 5 | "use strict";var app=angular.module("ngFlash",[]);app.run(["$rootScope",function(a){return a.flashes=[]}]),app.directive("dynamic",["$compile",function(a){return{restrict:"A",replace:!0,link:function(b,c,d){return b.$watch(d.dynamic,function(d){return c.html(d),a(c.contents())(b)})}}}]),app.directive("applytransclude",["$compile",function(a){return{restrict:"A",link:function(a,b,c){a._transclude(a,function(a,c){b.empty().append(a)})}}}]),app.directive("closeFlash",["$compile","$rootScope","Flash",function(a,b,c){return{link:function(a,d,e){return d.on("click",function(){var a=parseInt(e.closeFlash,10);c.dismiss(a),b.$apply()})}}}]),app.directive("flashMessage",["Flash",function(a){return{restrict:"E",scope:{duration:"=",showClose:"=",onDismiss:"&",name:"@"},link:function(b,c,d,e,f){function g(a){"function"==typeof b.onDismiss&&b.onDismiss({flash:a})}a.setTimeout(b.duration),a.setShowClose(b.showClose),a.setOnDismiss(g),a.config.templateTransclude&&(b._transclude=f)},transclude:a.config.templateTransclude,template:'\n
\n '+a.config.template+"\n
\n "}}]),app.provider("Flash",function(){var a={},b={bootstrap:{html:'\n ',transclude:!1},transclude:{html:"
",transclude:!0}};this.setTimeout=function(b){"number"==typeof b&&(a.timeout=b)},this.setShowClose=function(b){"boolean"==typeof b&&(a.showClose=b)},this.setTemplate=function(b){"string"==typeof b&&(a.template=b)},this.setTemplatePreset=function(c){if("string"==typeof c&&c in b){var d=b[c];this.setTemplate(d.html),a.templateTransclude=d.transclude}},this.setOnDismiss=function(b){"function"==typeof b&&(a.onDismiss=b)},this.setAutoDismiss=function(b){"boolean"==typeof b&&(a.autoDismiss=b)},this.setTimeout(5e3),this.setShowClose(!0),this.setTemplatePreset("bootstrap"),this.setAutoDismiss(!1),this.$get=["$rootScope","$interval",function(b,c){function d(a){return b.flashes.map(function(a){return a.id}).indexOf(a)}var e={},f=0;return e.setTimeout=this.setTimeout,e.setShowClose=this.setShowClose,e.setOnDismiss=this.setOnDismiss,e.config=a,e.create=function(d,g,h,i,j){if(1===b.flashes.length&&a.autoDismiss&&e.dismiss(b.flashes[0].id),!g)return!1;var k=void 0,l=void 0;return k=this,l={type:d,text:g,config:i,id:f++},l.showClose=void 0!==j?j:a.showClose,a.timeout&&void 0===h?l.timeout=a.timeout:h&&(l.timeout=h),b.flashes.push(l),l.timeout&&(l.timeoutObj=c(function(){k.dismiss(l.id)},l.timeout,1)),l.id},e.pause=function(a){b.flashes[a].timeoutObj&&c.cancel(b.flashes[a].timeoutObj)},e.dismiss=function(c){var f=d(c);if(-1!==f){var g=b.flashes[f];e.pause(f),b.flashes.splice(f,1),"function"==typeof a.onDismiss&&a.onDismiss(g)}},e.clear=function(){for(;b.flashes.length>0;)e.dismiss(b.flashes[0].id)},e.reset=e.clear,e}]}); 6 | //# sourceMappingURL=angular-flash.min.js.map -------------------------------------------------------------------------------- /dist/angular-flash.min.js.map: -------------------------------------------------------------------------------- 1 | {"version":3,"sources":["angular-flash.js"],"names":["app","angular","module","run","$rootScope","flashes","directive","$compile","restrict","replace","link","scope","ele","attrs","$watch","dynamic","html","contents","_transclude","clone","empty","append","Flash","on","id","parseInt","closeFlash","dismiss","$apply","duration","showClose","onDismiss","name","ctrl","transclude","flash","setTimeout","setShowClose","setOnDismiss","config","templateTransclude","template","provider","defaultConfig","templatePresets","bootstrap","this","timeout","value","setTemplate","setTemplatePreset","preset","callback","setAutoDismiss","autoDismiss","$get","$interval","findIndexById","map","indexOf","dataFactory","counter","create","type","text","length","$this","push","timeoutObj","pause","index","cancel","splice","clear","reset"],"mappings":"AAAA,YAEA,IAAIA,KAAMC,QAAQC,OAAO,aAEzBF,KAAIG,KAAK,aAAc,SAAUC,GAC7B,MAAOA,GAAWC,cAGtBL,IAAI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EAAMY,QAAUJ,EAAcI,QACvBA,IACPZ,EAAMY,QAAUA,GAEpB3C,EAAWC,QAAQ8D,KAAKhC,GACpBA,EAAMY,UACNZ,EAAMiC,WAAaZ,EAAU,WACzBU,EAAMvC,QAAQQ,EAAMX,KACrBW,EAAMY,QAAS,IAEfZ,EAAMX,IAEjBoC,EAAYS,MAAQ,SAAUC,GACtBlE,EAAWC,QAAQiE,GAAOF,YAC1BZ,EAAUe,OAAOnE,EAAWC,QAAQiE,GAAOF,aAGnDR,EAAYjC,QAAU,SAAUH,GAC5B,GAAI8C,GAAQb,EAAcjC,EAC1B,KAAe,IAAX8C,EAAc,CACd,GAAInC,GAAQ/B,EAAWC,QAAQiE,EAC/BV,GAAYS,MAAMC,GAClBlE,EAAWC,QAAQmE,OAAOF,EAAO,GACM,kBAA5B3B,GAAcZ,WACrBY,EAAcZ,UAAUI,KAIpCyB,EAAYa,MAAQ,WAChB,KAAOrE,EAAWC,QAAQ4D,OAAS,GAC/BL,EAAYjC,QAAQvB,EAAWC,QAAQ,GAAGmB,KAGlDoC,EAAYc,MAAQd,EAAYa,MAOzBb","file":"angular-flash.min.js"} -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | require('./dist/angular-flash'); 2 | module.exports = 'ngFlash'; 3 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration 2 | // Generated on Sun Jan 17 2016 10:18:31 GMT+0200 (FLE Standard Time) 3 | 4 | module.exports = function(config) { 5 | config.set({ 6 | // base path that will be used to resolve all patterns (eg. files, exclude) 7 | basePath: '', 8 | 9 | // frameworks to use 10 | // available frameworks: https://npmjs.org/browse/keyword/karma-adapter 11 | frameworks: ['jasmine'], 12 | 13 | // list of files / patterns to load in the browser 14 | files: [ 15 | //'node_modules/**/*.js', 16 | 'node_modules/angular/angular.js', 17 | 'node_modules/angular-mocks/angular-mocks.js', 18 | 'dist/angular-flash.js', 19 | 'test/*_test.js' 20 | ], 21 | 22 | // list of files to exclude 23 | exclude: [], 24 | 25 | // preprocess matching files before serving them to the browser 26 | // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor 27 | preprocessors: { 28 | 'src/*.js': ['babel'] 29 | }, 30 | 31 | babelPreprocessor: { 32 | options: { 33 | presets: ['es2015'], 34 | sourceMap: 'inline' 35 | }, 36 | filename: function(file) { 37 | return file.originalPath.replace(/\.js$/, '.es5.js'); 38 | }, 39 | sourceFileName: function(file) { 40 | return file.originalPath; 41 | } 42 | }, 43 | 44 | // test results reporter to use 45 | // possible values: 'dots', 'progress' 46 | // available reporters: https://npmjs.org/browse/keyword/karma-reporter 47 | reporters: ['progress'], 48 | 49 | // web server port 50 | port: 9876, 51 | 52 | // enable / disable colors in the output (reporters and logs) 53 | colors: true, 54 | 55 | // level of logging 56 | // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG 57 | logLevel: config.LOG_INFO, 58 | 59 | // enable / disable watching file and executing tests whenever any file changes 60 | autoWatch: true, 61 | 62 | // start these browsers 63 | // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher 64 | browsers: ['Chrome', 'Firefox'], 65 | 66 | // Continuous Integration mode 67 | // if true, Karma captures browsers, runs the tests and exits 68 | singleRun: false, 69 | 70 | // Concurrency level 71 | // how many browser should be started simultaneous 72 | concurrency: Infinity 73 | }) 74 | }; 75 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "angular-flash-alert", 3 | "version": "2.5.0", 4 | "description": "Flash message for AngularJS and Bootstrap", 5 | "keywords": [ 6 | "angular-flash", 7 | "flash", 8 | "message", 9 | "alert", 10 | "angularjs", 11 | "bootstrap" 12 | ], 13 | "homepage": "https://github.com/sachinchoolur/angular-flash", 14 | "bugs": { 15 | "url": "https://github.com/sachinchoolur/angular-flash/issues", 16 | "email": "sachi77n@gmail.com" 17 | }, 18 | "author": { 19 | "name": "Sachin", 20 | "email": "sachi77n@gmail.com", 21 | "url": "https://github.com/sachinchoolur" 22 | }, 23 | "contributors": [ 24 | { 25 | "name": "Roope Hakulinen", 26 | "email": "roope.hakulinen@gmail.com", 27 | "url": "https://github.com/RoopeHakulinen" 28 | }, 29 | { 30 | "name": "Nicolas Coden", 31 | "email": "nicolas@ncoden.fr", 32 | "url": "https://github.com/ncoden" 33 | } 34 | ], 35 | "repository": { 36 | "type": "git", 37 | "url": "git@github.com:sachinchoolur/angular-flash.git" 38 | }, 39 | "main": "index.js", 40 | "license": "MIT", 41 | "scripts": { 42 | "build": "grunt", 43 | "test": "karma start" 44 | }, 45 | "dependencies": { 46 | "angular": "^1.4.8" 47 | }, 48 | "devDependencies": { 49 | "angular-mocks": "^1.4.8", 50 | "babel-preset-es2015": "^6.3.13", 51 | "grunt": "^0.4.5", 52 | "grunt-babel": "^6.0.0", 53 | "grunt-banner": "^0.6.0", 54 | "grunt-bootlint": "^0.10.0", 55 | "grunt-cli": "^1.2.0", 56 | "grunt-contrib-clean": "^0.6.0", 57 | "grunt-contrib-concat": "^0.5.0", 58 | "grunt-contrib-connect": "^0.9.0", 59 | "grunt-contrib-cssmin": "^0.12.1", 60 | "grunt-contrib-jshint": "^0.10.0", 61 | "grunt-contrib-uglify": "^0.7.0", 62 | "grunt-contrib-watch": "^0.6.1", 63 | "jasmine-core": "^2.4.1", 64 | "jshint-stylish": "^1.0.0", 65 | "karma": "^0.13.19", 66 | "karma-babel-preprocessor": "^6.0.1", 67 | "karma-chrome-launcher": "^0.2.2", 68 | "karma-firefox-launcher": "^0.1.7", 69 | "karma-jasmine": "^0.3.6", 70 | "load-grunt-tasks": "^2.0.0", 71 | "time-grunt": "^1.0.0" 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /src/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "browser": true, 14 | "predef": [ 15 | "angular" 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /src/angular-flash.css: -------------------------------------------------------------------------------- 1 | .alert { 2 | padding: 15px; 3 | margin-bottom: 20px; 4 | border: 1px solid transparent; 5 | border-radius: 4px; 6 | } 7 | .alert h4 { 8 | margin-top: 0; 9 | color: inherit; 10 | } 11 | .alert .alert-link { 12 | font-weight: bold; 13 | } 14 | .alert > p, 15 | .alert > ul { 16 | margin-bottom: 0; 17 | } 18 | .alert > p + p { 19 | margin-top: 5px; 20 | } 21 | .alert-dismissable, 22 | .alert-dismissible { 23 | padding-right: 35px; 24 | } 25 | .alert-dismissable .close, 26 | .alert-dismissible .close { 27 | position: relative; 28 | top: -2px; 29 | right: -21px; 30 | color: inherit; 31 | } 32 | .alert-success { 33 | color: #3c763d; 34 | background-color: #dff0d8; 35 | border-color: #d6e9c6; 36 | } 37 | .alert-success hr { 38 | border-top-color: #c9e2b3; 39 | } 40 | .alert-success .alert-link { 41 | color: #2b542c; 42 | } 43 | .alert-info { 44 | color: #31708f; 45 | background-color: #d9edf7; 46 | border-color: #bce8f1; 47 | } 48 | .alert-info hr { 49 | border-top-color: #a6e1ec; 50 | } 51 | .alert-info .alert-link { 52 | color: #245269; 53 | } 54 | .alert-warning { 55 | color: #8a6d3b; 56 | background-color: #fcf8e3; 57 | border-color: #faebcc; 58 | } 59 | .alert-warning hr { 60 | border-top-color: #f7e1b5; 61 | } 62 | .alert-warning .alert-link { 63 | color: #66512c; 64 | } 65 | .alert-danger { 66 | color: #a94442; 67 | background-color: #f2dede; 68 | border-color: #ebccd1; 69 | } 70 | .alert-danger hr { 71 | border-top-color: #e4b9c0; 72 | } 73 | .alert-danger .alert-link { 74 | color: #843534; 75 | } 76 | 77 | .close { 78 | float: right; 79 | font-size: 21px; 80 | font-weight: bold; 81 | line-height: 1; 82 | color: #000; 83 | text-shadow: 0 1px 0 #fff; 84 | filter: alpha(opacity=20); 85 | opacity: .2; 86 | } 87 | .close:hover, 88 | .close:focus { 89 | color: #000; 90 | text-decoration: none; 91 | cursor: pointer; 92 | filter: alpha(opacity=50); 93 | opacity: .5; 94 | } 95 | 96 | div.close { 97 | -webkit-appearance: none; 98 | padding: 0; 99 | cursor: pointer; 100 | background: transparent; 101 | border: 0; 102 | font-size: 1.7em; 103 | } 104 | .sr-only { 105 | position: absolute; 106 | width: 1px; 107 | height: 1px; 108 | padding: 0; 109 | margin: -1px; 110 | overflow: hidden; 111 | clip: rect(0, 0, 0, 0); 112 | border: 0; 113 | } 114 | -------------------------------------------------------------------------------- /src/angular-flash.js: -------------------------------------------------------------------------------- 1 | const app = angular.module('ngFlash', []); 2 | 3 | app.run([ 4 | '$rootScope', function($rootScope) { 5 | return $rootScope.flashes = []; 6 | } 7 | ]); 8 | 9 | app.directive('dynamic', [ 10 | '$compile', function($compile) { 11 | return { 12 | restrict: 'A', 13 | replace: true, 14 | link: function(scope, ele, attrs) { 15 | return scope.$watch(attrs.dynamic, function(html) { 16 | ele.html(html); 17 | return $compile(ele.contents())(scope); 18 | }); 19 | } 20 | }; 21 | } 22 | ]); 23 | 24 | app.directive('applytransclude', [ 25 | '$compile', function($compile) { 26 | return { 27 | restrict: 'A', 28 | link: function(scope, ele, attrs) { 29 | scope._transclude(scope, function(clone, scope) { 30 | ele.empty().append(clone); 31 | }); 32 | } 33 | }; 34 | } 35 | ]); 36 | 37 | app.directive('closeFlash', [ 38 | '$compile', '$rootScope', 'Flash', function($compile, $rootScope, Flash) { 39 | return { 40 | link: function(scope, ele, attrs) { 41 | return ele.on('click', function() { 42 | let id = parseInt(attrs.closeFlash, 10); 43 | Flash.dismiss(id); 44 | $rootScope.$apply(); 45 | }); 46 | } 47 | }; 48 | } 49 | ]); 50 | 51 | app.directive('flashMessage', [ 52 | 'Flash', function(Flash) { 53 | return { 54 | restrict: 'E', 55 | scope: { 56 | duration: '=', 57 | showClose: '=', 58 | onDismiss: '&', 59 | name: '@' 60 | }, 61 | link: function(scope, ele, attrs, ctrl, transclude) { 62 | Flash.setTimeout(scope.duration); 63 | Flash.setShowClose(scope.showClose); 64 | function onDismiss(flash) { 65 | if (typeof scope.onDismiss !== 'function') return; 66 | scope.onDismiss({flash: flash}); 67 | } 68 | 69 | Flash.setOnDismiss(onDismiss); 70 | 71 | if (Flash.config.templateTransclude) { 72 | scope._transclude = transclude; 73 | } 74 | }, 75 | transclude: Flash.config.templateTransclude, 76 | template: ` 77 |
78 | ` + Flash.config.template + ` 79 |
80 | ` 81 | }; 82 | } 83 | ]); 84 | 85 | app.provider('Flash', function() { 86 | let defaultConfig = {}; 87 | let templatePresets = { 88 | bootstrap: { 89 | html: ` 90 | `, 98 | transclude: false 99 | }, 100 | transclude: { 101 | html: `
`, 102 | transclude: true 103 | } 104 | }; 105 | 106 | this.setTimeout = function(timeout) { 107 | if (typeof timeout !== 'number') return; 108 | defaultConfig.timeout = timeout; 109 | }; 110 | this.setShowClose = function(value) { 111 | if (typeof value !== 'boolean') return; 112 | defaultConfig.showClose = value; 113 | }; 114 | this.setTemplate = function(template) { 115 | if (typeof template !== 'string') return; 116 | defaultConfig.template = template; 117 | }; 118 | this.setTemplatePreset = function(preset) { 119 | if (typeof preset !== 'string' 120 | || !(preset in templatePresets)) return; 121 | 122 | let template = templatePresets[preset]; 123 | this.setTemplate(template.html); 124 | defaultConfig.templateTransclude = template.transclude; 125 | }; 126 | this.setOnDismiss = function(callback) { 127 | if (typeof callback !== 'function') return; 128 | defaultConfig.onDismiss = callback; 129 | }; 130 | 131 | this.setAutoDismiss = function (dismiss) { 132 | if (typeof dismiss !== 'boolean') return; 133 | defaultConfig.autoDismiss = dismiss; 134 | }; 135 | 136 | this.setTimeout(5000); 137 | this.setShowClose(true); 138 | this.setTemplatePreset('bootstrap'); 139 | this.setAutoDismiss(false); 140 | 141 | this.$get = ['$rootScope', '$interval', function($rootScope, $interval) { 142 | const dataFactory = {}; 143 | let counter = 0; 144 | 145 | dataFactory.setTimeout = this.setTimeout; 146 | dataFactory.setShowClose = this.setShowClose; 147 | dataFactory.setOnDismiss = this.setOnDismiss; 148 | dataFactory.config = defaultConfig; 149 | 150 | dataFactory.create = function(type, text, timeout, config, showClose) { 151 | if ($rootScope.flashes.length === 1 && defaultConfig.autoDismiss) { 152 | dataFactory.dismiss($rootScope.flashes[0].id); 153 | } 154 | if (!text) return false; 155 | let $this, flash; 156 | $this = this; 157 | flash = { 158 | type: type, 159 | text: text, 160 | config: config, 161 | id: counter++ 162 | }; 163 | flash.showClose = 164 | typeof showClose !== 'undefined' ? 165 | showClose : defaultConfig.showClose; 166 | if (defaultConfig.timeout && typeof timeout === 'undefined') { 167 | flash.timeout = defaultConfig.timeout; 168 | } 169 | else if (timeout) { 170 | flash.timeout = timeout; 171 | } 172 | $rootScope.flashes.push(flash); 173 | if (flash.timeout) { 174 | flash.timeoutObj = $interval(function() { 175 | $this.dismiss(flash.id); 176 | }, flash.timeout, 1); 177 | } 178 | return flash.id; 179 | }; 180 | dataFactory.pause = function(index) { 181 | if ($rootScope.flashes[index].timeoutObj) { 182 | $interval.cancel($rootScope.flashes[index].timeoutObj); 183 | } 184 | }; 185 | dataFactory.dismiss = function(id) { 186 | const index = findIndexById(id); 187 | if (index !== -1) { 188 | const flash = $rootScope.flashes[index]; 189 | dataFactory.pause(index); 190 | $rootScope.flashes.splice(index, 1); 191 | if (typeof defaultConfig.onDismiss === 'function') { 192 | defaultConfig.onDismiss(flash); 193 | } 194 | } 195 | }; 196 | dataFactory.clear = function() { 197 | while ($rootScope.flashes.length > 0) { 198 | dataFactory.dismiss($rootScope.flashes[0].id); 199 | } 200 | }; 201 | dataFactory.reset = dataFactory.clear; 202 | function findIndexById(id) { 203 | return $rootScope.flashes.map((flash) => flash.id).indexOf(id); 204 | } 205 | 206 | return dataFactory; 207 | }]; 208 | }); 209 | -------------------------------------------------------------------------------- /test/.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "immed": true, 5 | "latedef": true, 6 | "newcap": true, 7 | "noarg": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "boss": true, 12 | "eqnull": true, 13 | "browser": true, 14 | "node": true, 15 | "predef": [ 16 | "QUnit", 17 | "angular", 18 | "module", 19 | "test", 20 | "asyncTest", 21 | "expect", 22 | "start", 23 | "stop", 24 | "ok", 25 | "equal", 26 | "notEqual", 27 | "deepEqual", 28 | "notDeepEqual", 29 | "strictEqual", 30 | "notStrictEqual", 31 | "throws" 32 | ] 33 | } 34 | -------------------------------------------------------------------------------- /test/angular-flash_test.js: -------------------------------------------------------------------------------- 1 | describe('Unit testing Angular Flash', function() { 2 | var $compile, 3 | $rootScope, 4 | $interval, 5 | node, 6 | Flash; 7 | 8 | // Load the myApp module, which contains the directive 9 | beforeEach(module('ngFlash')); 10 | 11 | // Store references to $rootScope and $compile 12 | // so they are available to all tests in this describe block 13 | beforeEach(inject(function(_$compile_, _$rootScope_, _$interval_, _Flash_) { 14 | // The injector unwraps the underscores (_) from around the parameter names when matching 15 | $compile = _$compile_; 16 | $rootScope = _$rootScope_; 17 | $interval = _$interval_; 18 | Flash = _Flash_; 19 | })); 20 | 21 | beforeEach(function() { 22 | node = $compile('
')($rootScope); 23 | }); 24 | 25 | it('replaces the element with the appropriate content', function() { 26 | var contents = node.contents(); 27 | expect(contents[0].nodeType).toEqual(Node.ELEMENT_NODE); 28 | }); 29 | 30 | it('avoid to display flash when it does not have content', function() { 31 | created = Flash.create('success', ''); 32 | $rootScope.$digest(); 33 | var contents = node.contents()[0]; 34 | expect(contents.querySelectorAll('.alert').length).toEqual(0); 35 | expect(created).toEqual(false); 36 | }); 37 | 38 | it('has the class specified', function() { 39 | var testClassName = 'test-class'; 40 | Flash.create('success', 'Good job', 10000, {class: testClassName}); 41 | $rootScope.$digest(); 42 | var contents = node.contents()[0]; 43 | expect(contents.querySelectorAll('.alert')[0].classList).toContain(testClassName); 44 | }); 45 | 46 | it('has the id specified', function() { 47 | var testIdName = 'test-id'; 48 | Flash.create('success', 'Good job', 10000, {id: testIdName}); 49 | $rootScope.$digest(); 50 | var contents = node.contents()[0]; 51 | expect(contents.querySelectorAll('.alert')[0].id).toContain(testIdName); 52 | }); 53 | 54 | it('shows the flash when created and removes when deleted', function() { 55 | Flash.create('success', 'All good'); 56 | $rootScope.$digest(); 57 | var contents = node.contents()[0]; 58 | expect(contents.querySelectorAll('.alert').length).toEqual(1); 59 | Flash.dismiss(0); 60 | $rootScope.$digest(); 61 | expect(contents.querySelectorAll('.alert').length).toEqual(0); 62 | }); 63 | 64 | it('clears all when clear is called', function() { 65 | for (var i = 0; i < 10; ++i) { 66 | Flash.create('success', 'All good'); 67 | } 68 | $rootScope.$digest(); 69 | var contents = node.contents()[0]; 70 | expect(contents.querySelectorAll('.alert').length).toEqual(10); 71 | Flash.clear(); 72 | $rootScope.$digest(); 73 | expect(contents.querySelectorAll('.alert').length).toEqual(0); 74 | }); 75 | 76 | it('is dismissed after timeout', function() { 77 | Flash.create('success', 'All good', 10000); 78 | $rootScope.$digest(); 79 | var contents = node.contents()[0]; 80 | $interval.flush(3000); 81 | expect(contents.querySelectorAll('.alert').length).toEqual(1); 82 | 83 | $interval.flush(10000); 84 | $rootScope.$digest(); 85 | expect(contents.querySelectorAll('.alert').length).toEqual(0); 86 | }); 87 | 88 | describe('show flashes in designated containers', function() { 89 | var containers; 90 | 91 | beforeEach(function() { 92 | containers = $compile( 93 | '' + 94 | '' + 95 | '')($rootScope); 96 | 97 | Flash.create('success', 'All good'); 98 | Flash.create('success', 'All good - A', 0, { container: 'flash-container-a'}); 99 | Flash.create('success', 'All good - B', 0, { container: 'flash-container-b'}); 100 | 101 | $rootScope.$digest(); 102 | }); 103 | 104 | it('only shows default alert in default container', function() { 105 | expect(containers[0].querySelectorAll('.alert').length).toEqual(1); 106 | expect(containers[0].outerHTML).toContain('All good'); 107 | expect(containers[0].outerHTML).not.toContain('All good - A'); 108 | expect(containers[0].outerHTML).not.toContain('All good - B'); 109 | }); 110 | 111 | it('only shows alert A in container A', function() { 112 | expect(containers[1].querySelectorAll('.alert').length).toEqual(1); 113 | expect(containers[1].outerHTML).toContain('All good - A'); 114 | expect(containers[1].outerHTML).not.toContain('All good - B'); 115 | }); 116 | 117 | it('only shows alert B in container B', function() { 118 | expect(containers[2].querySelectorAll('.alert').length).toEqual(1); 119 | expect(containers[2].outerHTML).toContain('All good - B'); 120 | expect(containers[2].outerHTML).not.toContain('All good - A'); 121 | }); 122 | }); 123 | 124 | describe('close button', function () { 125 | it('is shown by default', function() { 126 | Flash.create('success', 'All good'); 127 | $rootScope.$digest(); 128 | var contents = node.contents()[0]; 129 | expect(contents.querySelectorAll('.close')[0].classList.contains('ng-hide')).toEqual(false); 130 | }); 131 | 132 | it('can be hidden with directive parameter', function() { 133 | node = $compile('
')($rootScope); 134 | Flash.create('success', 'All good'); 135 | $rootScope.$digest(); 136 | var contents = node.contents()[0]; 137 | expect(contents.querySelectorAll('.close')[0].classList.contains('ng-hide')).toEqual(true); 138 | }); 139 | 140 | it('can be hidden with create function parameter', function() { 141 | Flash.create('success', 'All good', 0, '', false); 142 | $rootScope.$digest(); 143 | var contents = node.contents()[0]; 144 | expect(contents.querySelectorAll('.close')[0].classList.contains('ng-hide')).toEqual(true); 145 | }); 146 | 147 | it('can be overriden with create function parameter', function() { 148 | node = $compile('
')($rootScope); 149 | Flash.create('success', 'All good', 0, '', true); 150 | $rootScope.$digest(); 151 | var contents = node.contents()[0]; 152 | expect(contents.querySelectorAll('.close')[0].classList.contains('ng-hide')).toEqual(false); 153 | }); 154 | }); 155 | 156 | describe('dismiss callback', function() { 157 | it('is called when dismissed', function() { 158 | $rootScope.myCallback = function(flash) { 159 | }; 160 | spyOn($rootScope, "myCallback"); 161 | node = $compile('
')($rootScope); 162 | const id = Flash.create('success', 'All good'); 163 | Flash.dismiss(id); 164 | $rootScope.$digest(); 165 | expect($rootScope.myCallback).toHaveBeenCalled(); 166 | }); 167 | }) 168 | }); 169 | --------------------------------------------------------------------------------