Skip to content

Commit 90054de

Browse files
Fixes #24 by replacing the findIndex usage with ES5 compatible code. For some reason that I have no time to figure out now, the Babel isn't transpiling it to valid ES5. Probably problem with presets.
Also added grunt-banner to print code banner on every file distributed.
1 parent 6029d3f commit 90054de

File tree

9 files changed

+109
-20
lines changed

9 files changed

+109
-20
lines changed

Gruntfile.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ module.exports = function (grunt) {
66
require('time-grunt')(grunt);
77

88
grunt.loadNpmTasks('grunt-bootlint');
9+
grunt.loadNpmTasks('grunt-banner');
910

1011
var distPath = 'dist/';
1112
// Project configuration.
@@ -90,12 +91,24 @@ module.exports = function (grunt) {
9091
relaxerror: ['E001', 'W001', 'W002', 'W003', 'W005']
9192
},
9293
files: ['src/angular-flash.js']
94+
},
95+
usebanner: {
96+
taskName: {
97+
options: {
98+
position: 'top',
99+
banner: '<%= banner %>',
100+
linebreak: true
101+
},
102+
files: {
103+
src: ['dist/*.css', 'dist/*.js']
104+
}
105+
}
93106
}
94107
});
95108

96109
// Default task.
97110
grunt.registerTask('lint', ['jshint', 'bootlint']);
98-
grunt.registerTask('default', ['babel', 'lint', 'connect', 'concat', 'uglify', 'cssmin']);
111+
grunt.registerTask('default', ['babel', 'lint', 'connect', 'concat', 'uglify', 'cssmin', 'usebanner']);
99112
grunt.registerTask('serve', ['connect', 'watch']);
100113
grunt.registerTask('test', ['lint', 'connect']);
101114
};

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-flash-alert",
3-
"version": "2.2.4",
3+
"version": "2.2.5",
44
"homepage": "https://github.com/sachinchoolur/angular-flash",
55
"authors": [
66
"Sachin N <[email protected]>"

dist/angular-flash.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
/*! angular-flash - v2.2.5 - 2016-03-17
2+
* https://github.com/sachinchoolur/angular-flash
3+
* Copyright (c) 2016 Sachin; Licensed MIT */
4+
15
.alert {
26
padding: 15px;
37
margin-bottom: 20px;

dist/angular-flash.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.min.css

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/angular-flash.min.js

Lines changed: 75 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,77 @@
1-
/*! angular-flash - v2.2.4 - 2016-03-05
1+
/*! angular-flash - v2.2.5 - 2016-03-17
22
* https://github.com/sachinchoolur/angular-flash
33
* Copyright (c) 2016 Sachin; Licensed MIT */
4-
"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("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:"&"},template:'<div role="alert" ng-repeat="flash in $root.flashes track by $index" id="{{flash.config.id}}" class="alert {{flash.config.class}} alert-{{flash.type}} alert-dismissible alertIn alertOut"><div type="button" class="close" ng-show="flash.showClose" close-flash="{{flash.id}}"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></div> <span dynamic="flash.text"></span> </div>',link:function(b,c,d){function e(a){"function"==typeof b.onDismiss&&b.onDismiss({flash:a})}a.setDefaultTimeout(b.duration),a.setShowClose(b.showClose),a.setOnDismiss(e)}}}]),app.factory("Flash",["$rootScope","$timeout",function(a,b){function c(b){return a.flashes.findIndex(function(a){return a.id===b})}var d={},e=0;return d.setDefaultTimeout=function(a){"number"==typeof a&&(d.defaultTimeout=a)},d.defaultShowClose=!0,d.setShowClose=function(a){"boolean"==typeof a&&(d.defaultShowClose=a)},d.setOnDismiss=function(a){"function"==typeof a&&(d.onDismiss=a)},d.create=function(c,f,g,h,i){var j=void 0,k=void 0;return j=this,k={type:c,text:f,config:h,id:e++},k.showClose="undefined"!=typeof i?i:d.defaultShowClose,d.defaultTimeout&&"undefined"==typeof g?k.timeout=d.defaultTimeout:g&&(k.timeout=g),a.flashes.push(k),k.timeout&&(k.timeoutObj=b(function(){j.dismiss(k.id)},k.timeout)),k.id},d.pause=function(c){a.flashes[c].timeoutObj&&b.cancel(a.flashes[c].timeoutObj)},d.dismiss=function(b){var e=c(b);if(-1!==e){var f=a.flashes[e];d.pause(e),a.flashes.splice(e,1),a.$digest(),"function"==typeof d.onDismiss&&d.onDismiss(f)}},d.clear=function(){for(;a.flashes.length>0;)d.dismiss(a.flashes[0].id)},d.reset=d.clear,d}]);
4+
5+
/*! angular-flash - v2.2.5 - 2016-03-17
6+
* https://github.com/sachinchoolur/angular-flash
7+
* Copyright (c) 2016 Sachin; Licensed MIT */
8+
"use strict";
9+
var app = angular.module("ngFlash", []);
10+
app.run(["$rootScope", function(a) {
11+
return a.flashes = []
12+
}]), app.directive("dynamic", ["$compile", function(a) {
13+
return {
14+
restrict: "A", replace: !0, link: function(b, c, d) {
15+
return b.$watch(d.dynamic, function(d) {
16+
return c.html(d), a(c.contents())(b)
17+
})
18+
}
19+
}
20+
}]), app.directive("closeFlash", ["$compile", "$rootScope", "Flash", function(a, b, c) {
21+
return {
22+
link: function(a, d, e) {
23+
return d.on("click", function() {
24+
var a = parseInt(e.closeFlash, 10);
25+
c.dismiss(a), b.$apply()
26+
})
27+
}
28+
}
29+
}]), app.directive("flashMessage", ["Flash", function(a) {
30+
return {
31+
restrict: "E",
32+
scope: {duration: "=", showClose: "=", onDismiss: "&"},
33+
template: '<div role="alert" ng-repeat="flash in $root.flashes track by $index" id="{{flash.config.id}}" class="alert {{flash.config.class}} alert-{{flash.type}} alert-dismissible alertIn alertOut"><div type="button" class="close" ng-show="flash.showClose" close-flash="{{flash.id}}"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></div> <span dynamic="flash.text"></span> </div>',
34+
link: function(b, c, d) {
35+
function e(a) {
36+
"function" == typeof b.onDismiss && b.onDismiss({flash: a})
37+
}
38+
39+
a.setDefaultTimeout(b.duration), a.setShowClose(b.showClose), a.setOnDismiss(e)
40+
}
41+
}
42+
}]), app.factory("Flash", ["$rootScope", "$timeout", function(a, b) {
43+
function c(b) {
44+
return a.flashes.map(function(a) {
45+
return a.id
46+
}).indexOf(b)
47+
}
48+
49+
var d = {}, e = 0;
50+
return d.setDefaultTimeout = function(a) {
51+
"number" == typeof a && (d.defaultTimeout = a)
52+
}, d.defaultShowClose = !0, d.setShowClose = function(a) {
53+
"boolean" == typeof a && (d.defaultShowClose = a)
54+
}, d.setOnDismiss = function(a) {
55+
"function" == typeof a && (d.onDismiss = a)
56+
}, d.create = function(c, f, g, h, i) {
57+
var j = void 0, k = void 0;
58+
return j = this, k = {
59+
type: c,
60+
text: f,
61+
config: h,
62+
id: e++
63+
}, k.showClose = "undefined" != typeof i ? i : d.defaultShowClose, d.defaultTimeout && "undefined" == typeof g ? k.timeout = d.defaultTimeout : g && (k.timeout = g), a.flashes.push(k), k.timeout && (k.timeoutObj = b(function() {
64+
j.dismiss(k.id)
65+
}, k.timeout)), k.id
66+
}, d.pause = function(c) {
67+
a.flashes[c].timeoutObj && b.cancel(a.flashes[c].timeoutObj)
68+
}, d.dismiss = function(b) {
69+
var e = c(b);
70+
if (-1 !== e) {
71+
var f = a.flashes[e];
72+
d.pause(e), a.flashes.splice(e, 1), a.$digest(), "function" == typeof d.onDismiss && d.onDismiss(f)
73+
}
74+
}, d.clear = function() {
75+
for (; a.flashes.length > 0;)d.dismiss(a.flashes[0].id)
76+
}, d.reset = d.clear, d
77+
}]);

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-flash-alert",
3-
"version": "2.2.4",
3+
"version": "2.2.5",
44
"description": "Flash message for AngularJS and Bootstrap",
55
"keywords": [
66
"angular-flash",
@@ -44,6 +44,7 @@
4444
"babel-preset-es2015": "^6.3.13",
4545
"grunt": "^0.4.5",
4646
"grunt-babel": "^6.0.0",
47+
"grunt-banner": "^0.6.0",
4748
"grunt-bootlint": "^0.10.0",
4849
"grunt-contrib-clean": "^0.6.0",
4950
"grunt-contrib-concat": "^0.5.0",

src/angular-flash.js

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*! angular-flash - v2.2.1 - 2016-02-06
2-
* https://github.com/sachinchoolur/angular-flash
3-
* Copyright (c) 2016 Sachin; Licensed MIT */
4-
51
const app = angular.module('ngFlash', []);
62

73
app.run([
@@ -131,9 +127,7 @@ app.factory('Flash', [
131127
};
132128
dataFactory.reset = dataFactory.clear;
133129
function findIndexById(id) {
134-
return $rootScope.flashes.findIndex((flash) => {
135-
return flash.id === id;
136-
});
130+
return $rootScope.flashes.map((flash) => flash.id).indexOf(id);
137131
}
138132

139133
return dataFactory;

0 commit comments

Comments
 (0)