Skip to content

Commit

Permalink
Fixes #24 by replacing the findIndex usage with ES5 compatible code. …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
RoopeHakulinen committed Mar 17, 2016
1 parent 6029d3f commit 90054de
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 20 deletions.
15 changes: 14 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module.exports = function (grunt) {
require('time-grunt')(grunt);

grunt.loadNpmTasks('grunt-bootlint');
grunt.loadNpmTasks('grunt-banner');

var distPath = 'dist/';
// Project configuration.
Expand Down Expand Up @@ -90,12 +91,24 @@ module.exports = function (grunt) {
relaxerror: ['E001', 'W001', 'W002', 'W003', 'W005']
},
files: ['src/angular-flash.js']
},
usebanner: {
taskName: {
options: {
position: 'top',
banner: '<%= banner %>',
linebreak: true
},
files: {
src: ['dist/*.css', 'dist/*.js']
}
}
}
});

// Default task.
grunt.registerTask('lint', ['jshint', 'bootlint']);
grunt.registerTask('default', ['babel', 'lint', 'connect', 'concat', 'uglify', 'cssmin']);
grunt.registerTask('default', ['babel', 'lint', 'connect', 'concat', 'uglify', 'cssmin', 'usebanner']);
grunt.registerTask('serve', ['connect', 'watch']);
grunt.registerTask('test', ['lint', 'connect']);
};
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-flash-alert",
"version": "2.2.4",
"version": "2.2.5",
"homepage": "https://github.com/sachinchoolur/angular-flash",
"authors": [
"Sachin N <sachi77n@gmail.com>"
Expand Down
4 changes: 4 additions & 0 deletions dist/angular-flash.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
/*! angular-flash - v2.2.5 - 2016-03-17
* https://github.com/sachinchoolur/angular-flash
* Copyright (c) 2016 Sachin; Licensed MIT */

.alert {
padding: 15px;
margin-bottom: 20px;
Expand Down
12 changes: 6 additions & 6 deletions dist/angular-flash.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions dist/angular-flash.js.map

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions dist/angular-flash.min.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

77 changes: 75 additions & 2 deletions dist/angular-flash.min.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,77 @@
/*! angular-flash - v2.2.4 - 2016-03-05
/*! angular-flash - v2.2.5 - 2016-03-17
* https://github.com/sachinchoolur/angular-flash
* Copyright (c) 2016 Sachin; Licensed MIT */
"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}]);

/*! angular-flash - v2.2.5 - 2016-03-17
* https://github.com/sachinchoolur/angular-flash
* Copyright (c) 2016 Sachin; Licensed MIT */
"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.map(function(a) {
return a.id
}).indexOf(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
}]);
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-flash-alert",
"version": "2.2.4",
"version": "2.2.5",
"description": "Flash message for AngularJS and Bootstrap",
"keywords": [
"angular-flash",
Expand Down Expand Up @@ -44,6 +44,7 @@
"babel-preset-es2015": "^6.3.13",
"grunt": "^0.4.5",
"grunt-babel": "^6.0.0",
"grunt-banner": "^0.6.0",
"grunt-bootlint": "^0.10.0",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-concat": "^0.5.0",
Expand Down
8 changes: 1 addition & 7 deletions src/angular-flash.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*! angular-flash - v2.2.1 - 2016-02-06
* https://github.com/sachinchoolur/angular-flash
* Copyright (c) 2016 Sachin; Licensed MIT */

const app = angular.module('ngFlash', []);

app.run([
Expand Down Expand Up @@ -131,9 +127,7 @@ app.factory('Flash', [
};
dataFactory.reset = dataFactory.clear;
function findIndexById(id) {
return $rootScope.flashes.findIndex((flash) => {
return flash.id === id;
});
return $rootScope.flashes.map((flash) => flash.id).indexOf(id);
}

return dataFactory;
Expand Down

0 comments on commit 90054de

Please sign in to comment.