Skip to content

Commit

Permalink
chore(release): 0.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Foxandxss committed Oct 16, 2014
1 parent 40cf562 commit 5bd7115
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 12 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## Version 0.5.1

- newestOnTop, with that you can choose whether to add new toasts on the top or bottom. Top by default.

## Version 0.5.0

- Angular 1.3.x support
Expand Down
13 changes: 10 additions & 3 deletions dist/angular-toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ angular.module('toastr', [])
warning: 'toast-warning'
},
messageClass: 'toast-message',
newestOnTop: true,
positionClass: 'toast-top-right',
tapToDismiss: true,
timeOut: 5000,
Expand Down Expand Up @@ -175,9 +176,15 @@ angular.module('toastr', [])
toasts.push(newToast);

_setContainer(options).then(function() {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
newToast.scope.init();
});
if (options.newestOnTop) {
$animate.enter(newToast.el, container).then(function() {
newToast.scope.init();
});
} else {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
newToast.scope.init();
});
}
});

return newToast;
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-toastr.min.js

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-toastr",
"version": "0.5.0",
"version": "0.5.1",
"devDependencies": {
"grunt": "~0.4.5",
"grunt-contrib-less": "~0.11.3",
Expand Down
13 changes: 10 additions & 3 deletions src/toastr.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ angular.module('toastr', [])
warning: 'toast-warning'
},
messageClass: 'toast-message',
newestOnTop: true,
positionClass: 'toast-top-right',
tapToDismiss: true,
timeOut: 5000,
Expand Down Expand Up @@ -175,9 +176,15 @@ angular.module('toastr', [])
toasts.push(newToast);

_setContainer(options).then(function() {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
newToast.scope.init();
});
if (options.newestOnTop) {
$animate.enter(newToast.el, container).then(function() {
newToast.scope.init();
});
} else {
$animate.enter(newToast.el, container, container[0].lastChild).then(function() {
newToast.scope.init();
});
}
});

return newToast;
Expand Down
25 changes: 21 additions & 4 deletions test/toastr_spec.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
describe('toastr', function() {
var $animate, $document, $rootScope, $timeout;
var toastr;
var toastr, toastrConfig;

beforeEach(module('ngAnimate'));
beforeEach(module('ngAnimateMock'));
beforeEach(module('toastr'));

beforeEach(inject(function(_$animate_, _$document_, _$rootScope_, _$timeout_, _toastr_) {
beforeEach(inject(function(_$animate_, _$document_, _$rootScope_, _$timeout_, _toastr_, _toastrConfig_) {
$animate = _$animate_;
$document = _$document_;
$rootScope = _$rootScope_;
$timeout = _$timeout_;
toastr = _toastr_;
toastrConfig = _toastrConfig_;
}));

beforeEach(function() {
Expand Down Expand Up @@ -41,8 +42,6 @@ describe('toastr', function() {

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

Expand Down Expand Up @@ -393,4 +392,22 @@ describe('toastr', function() {
expect(toast).toHaveButtonWith('1');
});
});

describe('toast order', function() {
it('adds the newest toasts on top by default', function() {
var toast1 = openToast('success', 'I will be on the bottom');
var toast2 = openToast('info', 'I like the top part!');
expect($document).toHaveToastWithMessage(toast2.scope.message, 0);
expect($document).toHaveToastWithMessage(toast1.scope.message, 1);
});

it('adds the older toasts on top setting newestOnTop to false', function() {
toastrConfig.newestOnTop = false;

var toast1 = openToast('success', 'I will be on the top now');
var toast2 = openToast('info', 'I dont like the bottom part!');
expect($document).toHaveToastWithMessage(toast2.scope.message, 1);
expect($document).toHaveToastWithMessage(toast1.scope.message, 0);
});
});
});

0 comments on commit 5bd7115

Please # to comment.