angular-flash-alert
Advanced tools
Comparing version 2.4.0 to 2.5.0
{ | ||
"name": "angular-flash-alert", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"homepage": "https://github.com/sachinchoolur/angular-flash", | ||
@@ -5,0 +5,0 @@ "authors": [ |
@@ -35,3 +35,3 @@ $.fn.putCursorAtEnd = function () { | ||
var app = angular.module('demoApp', ['ngFlash', 'ngAnimate']); | ||
app.controller('FlashDemoCtrl', ['$rootScope', '$scope', 'Flash', '$timeout', function ($rootScope, $scope, Flash, $timeout) { | ||
app.controller('FlashDemoCtrl', ['$rootScope', '$scope', 'Flash', '$interval', function ($rootScope, $scope, Flash, $interval) { | ||
$scope.success = function () { | ||
@@ -142,6 +142,6 @@ var message = '<strong>Well done!</strong> You successfully read this important alert message.'; | ||
if (e.which == 13) { | ||
$timeout(function () { | ||
$interval(function () { | ||
$scope.add(); | ||
return false; | ||
}, 100); | ||
}, 100, 1); | ||
} | ||
@@ -148,0 +148,0 @@ } |
@@ -1,4 +0,4 @@ | ||
/*! angular-flash - v2.4.0 - 2016-10-25 | ||
/*! angular-flash - v2.5.0 - 2017-07-23 | ||
* https://github.com/sachinchoolur/angular-flash | ||
* Copyright (c) 2016 Sachin; Licensed MIT */ | ||
* Copyright (c) 2017 Sachin; Licensed MIT */ | ||
@@ -114,7 +114,13 @@ 'use strict'; | ||
this.setAutoDismiss = function (dismiss) { | ||
if (typeof dismiss !== 'boolean') return; | ||
defaultConfig.autoDismiss = dismiss; | ||
}; | ||
this.setTimeout(5000); | ||
this.setShowClose(true); | ||
this.setTemplatePreset('bootstrap'); | ||
this.setAutoDismiss(false); | ||
this.$get = ['$rootScope', '$timeout', function ($rootScope, $timeout) { | ||
this.$get = ['$rootScope', '$interval', function ($rootScope, $interval) { | ||
var dataFactory = {}; | ||
@@ -129,2 +135,5 @@ var counter = 0; | ||
dataFactory.create = function (type, text, timeout, config, showClose) { | ||
if ($rootScope.flashes.length === 1 && defaultConfig.autoDismiss) { | ||
dataFactory.dismiss($rootScope.flashes[0].id); | ||
} | ||
if (!text) return false; | ||
@@ -148,5 +157,5 @@ var $this = void 0, | ||
if (flash.timeout) { | ||
flash.timeoutObj = $timeout(function () { | ||
flash.timeoutObj = $interval(function () { | ||
$this.dismiss(flash.id); | ||
}, flash.timeout); | ||
}, flash.timeout, 1); | ||
} | ||
@@ -157,3 +166,3 @@ return flash.id; | ||
if ($rootScope.flashes[index].timeoutObj) { | ||
$timeout.cancel($rootScope.flashes[index].timeoutObj); | ||
$interval.cancel($rootScope.flashes[index].timeoutObj); | ||
} | ||
@@ -160,0 +169,0 @@ }; |
@@ -1,6 +0,6 @@ | ||
/*! angular-flash - v2.4.0 - 2016-10-25 | ||
/*! angular-flash - v2.5.0 - 2017-07-23 | ||
* https://github.com/sachinchoolur/angular-flash | ||
* Copyright (c) 2016 Sachin; Licensed MIT */ | ||
* Copyright (c) 2017 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("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 <div ng-repeat="flash in $root.flashes track by $index" ng-if="flash.config.container === name" class="alert-container">\n '+a.config.template+"\n </div>\n "}}]),app.provider("Flash",function(){var a={},b={bootstrap:{html:'\n <div role="alert" id="{{flash.config.id}}"\n class="alert {{flash.config.class}} alert-{{flash.type}} alert-dismissible alertIn alertOut">\n <div type="button" class="close" ng-show="flash.showClose" close-flash="{{flash.id}}">\n <span aria-hidden="true">×</span>\n <span class="sr-only">Close</span>\n </div>\n <span dynamic="flash.text"></span>\n </div>',transclude:!1},transclude:{html:"<div applytransclude></div>",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.setTimeout(5e3),this.setShowClose(!0),this.setTemplatePreset("bootstrap"),this.$get=["$rootScope","$timeout",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,e,g,h,i){if(!e)return!1;var j=void 0,k=void 0;return j=this,k={type:d,text:e,config:h,id:f++},k.showClose="undefined"!=typeof i?i:a.showClose,a.timeout&&"undefined"==typeof g?k.timeout=a.timeout:g&&(k.timeout=g),b.flashes.push(k),k.timeout&&(k.timeoutObj=c(function(){j.dismiss(k.id)},k.timeout)),k.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}]}); | ||
"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 <div ng-repeat="flash in $root.flashes track by $index" ng-if="flash.config.container === name" class="alert-container">\n '+a.config.template+"\n </div>\n "}}]),app.provider("Flash",function(){var a={},b={bootstrap:{html:'\n <div role="alert" id="{{flash.config.id}}"\n class="alert {{flash.config.class}} alert-{{flash.type}} alert-dismissible alertIn alertOut">\n <div type="button" class="close" ng-show="flash.showClose" close-flash="{{flash.id}}">\n <span aria-hidden="true">×</span>\n <span class="sr-only">Close</span>\n </div>\n <span dynamic="flash.text"></span>\n </div>',transclude:!1},transclude:{html:"<div applytransclude></div>",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}]}); | ||
//# sourceMappingURL=angular-flash.min.js.map |
@@ -0,0 +0,0 @@ module.exports = function (grunt) { |
{ | ||
"name": "angular-flash-alert", | ||
"version": "2.4.0", | ||
"version": "2.5.0", | ||
"description": "Flash message for AngularJS and Bootstrap", | ||
@@ -42,3 +42,4 @@ "keywords": [ | ||
"scripts": { | ||
"test": "grunt" | ||
"build": "grunt", | ||
"test": "karma start" | ||
}, | ||
@@ -55,2 +56,3 @@ "dependencies": { | ||
"grunt-bootlint": "^0.10.0", | ||
"grunt-cli": "^1.2.0", | ||
"grunt-contrib-clean": "^0.6.0", | ||
@@ -57,0 +59,0 @@ "grunt-contrib-concat": "^0.5.0", |
@@ -116,3 +116,3 @@ ![license](https://img.shields.io/npm/l/angular-flash-alert.svg) | ||
``` | ||
####Flash types#### | ||
#### Flash types #### | ||
+ success | ||
@@ -164,5 +164,8 @@ + info | ||
#### Running tests | ||
You'll need relatively new versions of Firefox and Chrome installed on your local system to run the tests. | ||
Once you do, run: | ||
``` | ||
npm install | ||
./node_modules/karma/bin/karma start | ||
npm run test | ||
``` | ||
@@ -169,0 +172,0 @@ |
@@ -131,7 +131,13 @@ const app = angular.module('ngFlash', []); | ||
this.setAutoDismiss = function (dismiss) { | ||
if (typeof dismiss !== 'boolean') return; | ||
defaultConfig.autoDismiss = dismiss; | ||
}; | ||
this.setTimeout(5000); | ||
this.setShowClose(true); | ||
this.setTemplatePreset('bootstrap'); | ||
this.setAutoDismiss(false); | ||
this.$get = ['$rootScope', '$timeout', function($rootScope, $timeout) { | ||
this.$get = ['$rootScope', '$interval', function($rootScope, $interval) { | ||
const dataFactory = {}; | ||
@@ -146,2 +152,5 @@ let counter = 0; | ||
dataFactory.create = function(type, text, timeout, config, showClose) { | ||
if ($rootScope.flashes.length === 1 && defaultConfig.autoDismiss) { | ||
dataFactory.dismiss($rootScope.flashes[0].id); | ||
} | ||
if (!text) return false; | ||
@@ -167,5 +176,5 @@ let $this, flash; | ||
if (flash.timeout) { | ||
flash.timeoutObj = $timeout(function() { | ||
flash.timeoutObj = $interval(function() { | ||
$this.dismiss(flash.id); | ||
}, flash.timeout); | ||
}, flash.timeout, 1); | ||
} | ||
@@ -176,3 +185,3 @@ return flash.id; | ||
if ($rootScope.flashes[index].timeoutObj) { | ||
$timeout.cancel($rootScope.flashes[index].timeoutObj); | ||
$interval.cancel($rootScope.flashes[index].timeoutObj); | ||
} | ||
@@ -179,0 +188,0 @@ }; |
describe('Unit testing Angular Flash', function() { | ||
var $compile, | ||
$rootScope, | ||
$timeout, | ||
$interval, | ||
node, | ||
@@ -13,7 +13,7 @@ Flash; | ||
// so they are available to all tests in this describe block | ||
beforeEach(inject(function(_$compile_, _$rootScope_, _$timeout_, _Flash_) { | ||
beforeEach(inject(function(_$compile_, _$rootScope_, _$interval_, _Flash_) { | ||
// The injector unwraps the underscores (_) from around the parameter names when matching | ||
$compile = _$compile_; | ||
$rootScope = _$rootScope_; | ||
$timeout = _$timeout_; | ||
$interval = _$interval_; | ||
Flash = _Flash_; | ||
@@ -81,5 +81,6 @@ })); | ||
var contents = node.contents()[0]; | ||
$interval.flush(3000); | ||
expect(contents.querySelectorAll('.alert').length).toEqual(1); | ||
$timeout.flush(); | ||
$interval.flush(10000); | ||
$rootScope.$digest(); | ||
@@ -86,0 +87,0 @@ expect(contents.querySelectorAll('.alert').length).toEqual(0); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
164778
1667
178
23