From 7d3017841fb235977671ae88016a747cf95a1be1 Mon Sep 17 00:00:00 2001 From: Thomas Himblot Date: Mon, 15 Sep 2014 15:34:04 +0200 Subject: [PATCH 1/2] Allow to configure timeout duration by a provider Hi, I really enjoy the work done on postman, it's beautiful and simple. I needed to change the duration of the timeout, so I propose to add a provider which can be use during the config phase (so it can be extended in the future for others parameters). If you agree with this, can you do the merge ? Thank you --- js/postman.js | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/js/postman.js b/js/postman.js index 6a978d9..695cc2a 100644 --- a/js/postman.js +++ b/js/postman.js @@ -9,8 +9,20 @@ if($rootElement[0].tagName !== 'HTML') $rootElement.append($elem); else angular.element(document.body).append($elem); }]) - - .directive('postmanParcels', ['$timeout', function ($timeout) { + .provider('postmanSettings', function() { + var timeout = 1000; + return { + setTimeout : function (value) { + timeout = value; + }, + $get : function () { + return { + timeout : timeout + }; + } + }; + }) + .directive('postmanParcels', ['$timeout', 'postmanSettings', function ($timeout, postmanSettings) { return { restrict: 'EA', template: '' + @@ -55,7 +67,7 @@ scope.startTimer = function(parcel) { parcel.timeout = $timeout(function() { scope.dismiss(parcel, false); - }, 6000); + }, postmanSettings.timeout); }; // start timer on new item added @@ -108,4 +120,4 @@ } }; }]); -})(); \ No newline at end of file +})(); From 0fa12eb3c510474648e27b968dbc9213a7f3ceca Mon Sep 17 00:00:00 2001 From: Thomas Himblot Date: Mon, 15 Sep 2014 15:37:50 +0200 Subject: [PATCH 2/2] Update postman.js --- js/postman.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/postman.js b/js/postman.js index 695cc2a..2a860e9 100644 --- a/js/postman.js +++ b/js/postman.js @@ -10,7 +10,7 @@ else angular.element(document.body).append($elem); }]) .provider('postmanSettings', function() { - var timeout = 1000; + var timeout = 6000; return { setTimeout : function (value) { timeout = value;