Skip to content

Commit 5bd7115

Browse files
committed
chore(release): 0.5.1
1 parent 40cf562 commit 5bd7115

File tree

6 files changed

+47
-12
lines changed

6 files changed

+47
-12
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## Version 0.5.1
4+
5+
- newestOnTop, with that you can choose whether to add new toasts on the top or bottom. Top by default.
6+
37
## Version 0.5.0
48

59
- Angular 1.3.x support

dist/angular-toastr.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ angular.module('toastr', [])
6767
warning: 'toast-warning'
6868
},
6969
messageClass: 'toast-message',
70+
newestOnTop: true,
7071
positionClass: 'toast-top-right',
7172
tapToDismiss: true,
7273
timeOut: 5000,
@@ -175,9 +176,15 @@ angular.module('toastr', [])
175176
toasts.push(newToast);
176177

177178
_setContainer(options).then(function() {
178-
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
179-
newToast.scope.init();
180-
});
179+
if (options.newestOnTop) {
180+
$animate.enter(newToast.el, container).then(function() {
181+
newToast.scope.init();
182+
});
183+
} else {
184+
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
185+
newToast.scope.init();
186+
});
187+
}
181188
});
182189

183190
return newToast;

dist/angular-toastr.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "angular-toastr",
3-
"version": "0.5.0",
3+
"version": "0.5.1",
44
"devDependencies": {
55
"grunt": "~0.4.5",
66
"grunt-contrib-less": "~0.11.3",

src/toastr.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ angular.module('toastr', [])
6767
warning: 'toast-warning'
6868
},
6969
messageClass: 'toast-message',
70+
newestOnTop: true,
7071
positionClass: 'toast-top-right',
7172
tapToDismiss: true,
7273
timeOut: 5000,
@@ -175,9 +176,15 @@ angular.module('toastr', [])
175176
toasts.push(newToast);
176177

177178
_setContainer(options).then(function() {
178-
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
179-
newToast.scope.init();
180-
});
179+
if (options.newestOnTop) {
180+
$animate.enter(newToast.el, container).then(function() {
181+
newToast.scope.init();
182+
});
183+
} else {
184+
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
185+
newToast.scope.init();
186+
});
187+
}
181188
});
182189

183190
return newToast;

test/toastr_spec.js

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
describe('toastr', function() {
22
var $animate, $document, $rootScope, $timeout;
3-
var toastr;
3+
var toastr, toastrConfig;
44

55
beforeEach(module('ngAnimate'));
66
beforeEach(module('ngAnimateMock'));
77
beforeEach(module('toastr'));
88

9-
beforeEach(inject(function(_$animate_, _$document_, _$rootScope_, _$timeout_, _toastr_) {
9+
beforeEach(inject(function(_$animate_, _$document_, _$rootScope_, _$timeout_, _toastr_, _toastrConfig_) {
1010
$animate = _$animate_;
1111
$document = _$document_;
1212
$rootScope = _$rootScope_;
1313
$timeout = _$timeout_;
1414
toastr = _toastr_;
15+
toastrConfig = _toastrConfig_;
1516
}));
1617

1718
beforeEach(function() {
@@ -41,8 +42,6 @@ describe('toastr', function() {
4142

4243
toHaveToastOpen: function(noOfToastr) {
4344
var toastDomEls = this.actual.find('body > #toast-container > .toast');
44-
// console.log(this.actual.find('body').prop('innerHTML'));
45-
// console.log('----');
4645
return toastDomEls.length === noOfToastr;
4746
},
4847

@@ -393,4 +392,22 @@ describe('toastr', function() {
393392
expect(toast).toHaveButtonWith('1');
394393
});
395394
});
395+
396+
describe('toast order', function() {
397+
it('adds the newest toasts on top by default', function() {
398+
var toast1 = openToast('success', 'I will be on the bottom');
399+
var toast2 = openToast('info', 'I like the top part!');
400+
expect($document).toHaveToastWithMessage(toast2.scope.message, 0);
401+
expect($document).toHaveToastWithMessage(toast1.scope.message, 1);
402+
});
403+
404+
it('adds the older toasts on top setting newestOnTop to false', function() {
405+
toastrConfig.newestOnTop = false;
406+
407+
var toast1 = openToast('success', 'I will be on the top now');
408+
var toast2 = openToast('info', 'I dont like the bottom part!');
409+
expect($document).toHaveToastWithMessage(toast2.scope.message, 1);
410+
expect($document).toHaveToastWithMessage(toast1.scope.message, 0);
411+
});
412+
});
396413
});

0 commit comments

Comments
 (0)