Skip to content

Commit

Permalink
Merge pull request #184 from showwin/issue75
Browse files Browse the repository at this point in the history
Add toast-top-center / issue#75
  • Loading branch information
johnpapa committed Oct 5, 2014
2 parents 02df30b + c156985 commit 86a4798
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 5 deletions.
6 changes: 6 additions & 0 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ <h1>toastr</h1>
<label class="radio">
<input type="radio" name="positions" value="toast-bottom-full-width" />Bottom Full Width
</label>
<label class="radio">
<input type="radio" name="positions" value="toast-top-center" />Top Center
</label>
<label class="radio">
<input type="radio" name="positions" value="toast-bottom-center" />Bottom Center
</label>
</div>
</div>
</div>
Expand Down
30 changes: 29 additions & 1 deletion tests/unit/toastr-tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
topRight: 'toast-top-right',
bottomRight: 'toast-bottom-right',
bottomLeft: 'toast-bottom-left',
topLeft: 'toast-top-left'
topLeft: 'toast-top-left',
topCenter: 'toast-top-center',
bottomCenter: 'toast-bottom-center'
};
var sampleMsg = 'I don\'t think they really exist';
var sampleTitle = 'ROUS';
Expand Down Expand Up @@ -497,6 +499,32 @@
$toast.remove();
resetContainer();
});
test('Container - position top-center', 1, function () {
//Arrange
resetContainer();
toastr.options.positionClass = positionClasses.topCenter;
//Act
var $toast = toastr.success(sampleMsg);
var $container = toastr.getContainer();
//Assert
ok($container.hasClass(positionClasses.topCenter), 'Has position top center');
//Teardown
$toast.remove();
resetContainer();
});
test('Container - position bottom-center', 1, function () {
//Arrange
resetContainer();
toastr.options.positionClass = positionClasses.bottomCenter;
//Act
var $toast = toastr.success(sampleMsg);
var $container = toastr.getContainer();
//Assert
ok($container.hasClass(positionClasses.bottomCenter), 'Has position bottom center');
//Teardown
$toast.remove();
resetContainer();
});

function resetContainer() {
var $container = toastr.getContainer();
Expand Down
15 changes: 15 additions & 0 deletions toastr.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ button.toast-close-button {
border: 0;
-webkit-appearance: none;
}
.toast-top-center {
top: 0;
right: 0;
width: 100%;
}
.toast-bottom-center {
bottom: 0;
right: 0;
width: 100%;
}
.toast-top-full-width {
top: 0;
right: 0;
Expand Down Expand Up @@ -131,6 +141,11 @@ button.toast-close-button {
#toast-container > .toast-warning {
background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGYSURBVEhL5ZSvTsNQFMbXZGICMYGYmJhAQIJAICYQPAACiSDB8AiICQQJT4CqQEwgJvYASAQCiZiYmJhAIBATCARJy+9rTsldd8sKu1M0+dLb057v6/lbq/2rK0mS/TRNj9cWNAKPYIJII7gIxCcQ51cvqID+GIEX8ASG4B1bK5gIZFeQfoJdEXOfgX4QAQg7kH2A65yQ87lyxb27sggkAzAuFhbbg1K2kgCkB1bVwyIR9m2L7PRPIhDUIXgGtyKw575yz3lTNs6X4JXnjV+LKM/m3MydnTbtOKIjtz6VhCBq4vSm3ncdrD2lk0VgUXSVKjVDJXJzijW1RQdsU7F77He8u68koNZTz8Oz5yGa6J3H3lZ0xYgXBK2QymlWWA+RWnYhskLBv2vmE+hBMCtbA7KX5drWyRT/2JsqZ2IvfB9Y4bWDNMFbJRFmC9E74SoS0CqulwjkC0+5bpcV1CZ8NMej4pjy0U+doDQsGyo1hzVJttIjhQ7GnBtRFN1UarUlH8F3xict+HY07rEzoUGPlWcjRFRr4/gChZgc3ZL2d8oAAAAASUVORK5CYII=") !important;
}
#toast-container.toast-top-center > div,
#toast-container.toast-bottom-center > div {
width: 300px;
margin: auto;
}
#toast-container.toast-top-full-width > div,
#toast-container.toast-bottom-full-width > div {
width: 96%;
Expand Down
20 changes: 19 additions & 1 deletion toastr.less
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,18 @@ button.toast-close-button {

//#endregion

.toast-top-center {
top: 0;
right: 0;
width: 100%;
}

.toast-bottom-center {
bottom: 0;
right: 0;
width: 100%;
}

.toast-top-full-width {
top: 0;
right: 0;
Expand Down Expand Up @@ -164,6 +176,12 @@ button.toast-close-button {
}

/*overrides*/
&.toast-top-center > div,
&.toast-bottom-center > div {
width: 300px;
margin: auto;
}

&.toast-top-full-width > div,
&.toast-bottom-full-width > div {
width: 96%;
Expand Down Expand Up @@ -229,4 +247,4 @@ button.toast-close-button {
width: 25em;
}
}
}
}
2 changes: 1 addition & 1 deletion toastr.min.css

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

Loading

0 comments on commit 86a4798

Please sign in to comment.