Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ You can pass to the `$.toast` function an object with the settings for your toas
| type | Determines the style of the toast based on Bootstrap styles | 'info' | 'info', 'success', 'warning', 'error' |
| delay | Determines how long the Toast shoud be shown for. The default, -1, will show the toast until the user clicks close. | -1 | omit or set to -1 to disable auto close, or timeout value in milliseconds
| img | Shows an image before the title | N/A | { src: '', class: '', title: '', alt: '' }
| icon | Shows an icon before title | N/A | A complete icon class of your own. Example "fas fa-user-secret", show secret user
| pause_on_hover| true/false respectively to pause on hover | false | true/false |
| container | Set the container inside which the toasts will be displayed | $("body") | A JQuery selector |

Expand Down
5 changes: 5 additions & 0 deletions css/toast.css
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,8 @@
.toast-container>.toast-wrapper>.toast>.toast-header strong {
padding-right: 20px;
}

.toast-container > .toast-wrapper > .toast > .toast-header i {
padding-top:2px;
margin-right:7px;
}
2 changes: 1 addition & 1 deletion dist/toast.min.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
* @description Toast - A Bootstrap 4.2+ jQuery plugin for the toast component
* @version 0.7.1
**/
.toast-container{position:sticky;z-index:1055;top:0}.toast-wrapper{position:absolute;z-index:1055;top:0;right:0;margin:5px}.toast-container > .toast-wrapper > .toast{min-width:150px;background-color:rgb(255, 255, 255);border-top:none}.toast-container > .toast-wrapper > .toast > .toast-header strong{padding-right:20px}
.toast-container{position:sticky;z-index:1055;top:0}.toast-wrapper{position:absolute;z-index:1055;top:0;right:0;margin:5px}.toast-container > .toast-wrapper > .toast{min-width:150px;background-color:rgb(255, 255, 255);border-top:none}.toast-container > .toast-wrapper > .toast > .toast-header strong{padding-right:20px}.toast-container > .toast-wrapper > .toast > .toast-header i{padding-top:2px;margin-right:7px;}
17 changes: 17 additions & 0 deletions example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<br>
<button class="btn-block btn-primary" onclick="show_image_toast();">Show Image Toast</button>
<br>
<button class="btn-block btn-primary" onclick="show_icon_toast();">Show Icon Toast</button>
<br>
<button class="btn-block btn-primary" onclick="show_random_snack();">Show Random Snack</button>
<br>
<button class="btn-block btn-primary" onclick="show_toast_in_container();">Show Toast in Container</button>
Expand Down Expand Up @@ -86,6 +88,21 @@
});
}

function show_icon_toast() {
let type = TYPES[Math.floor(Math.random() * TYPES.length)],
title = TITLES[type],
content = CONTENT[type];

$.toast({
title: title,
subtitle: '11 mins ago',
content: content,
type: type,
delay: 5000,
icon: 'fas fa-user-secret'
});
}

function show_random_snack() {
let type = TYPES[Math.floor(Math.random() * TYPES.length)],
content = CONTENT[type].replace('toast', 'snack');
Expand Down
5 changes: 5 additions & 0 deletions js/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
type = opts.type || 'info',
delay = opts.delay || -1,
img = opts.img,
icon = opts.icon,
pause_on_hover = opts.pause_on_hover || false,
pause = false,
delay_or_autohide = '';
Expand Down Expand Up @@ -92,6 +93,10 @@
html += '<img src="' + img.src + '" class="' + (img.class || '') + ' mr-2" alt="' + (img.alt || 'Image') + '" ' + (typeof img.title !== 'undefined' ? 'data-toggle="tooltip" title="' + img.title + '"' : '') + '>';
}

if (typeof icon !== 'undefined') {
html += '<i class="' + (icon || '') + '" aria-hidden="true"></i>';
}

html += '<strong class="mr-auto">' + title + '</strong>';
html += '<small class="' + fg_subtitle_class + '">' + subtitle + '</small>';
html += '<button type="button" class="ml-2 mb-1 close" data-dismiss="toast" aria-label="Close">';
Expand Down