diff --git a/README.md b/README.md index 57fa022..8d0f4a4 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ You can pass to the `$.toast` function an object with the settings for your toas | subtitle | Shows in the top right corner of the toast header | N/A | | | content | Shows in the toast body | N/A | | type | Determines the style of the toast based on Bootstrap styles | 'info' | 'info', 'success', 'warning', 'error' -| delay | Determines how the toast will show for. Set to -1 to prevent the Toast from closing automatically | 3000 +| delay | Determines how long the Toast shoud be shown for. The default, -1, will show the toast until the user clicks close. | -1 | -1 to disable auto close, or timeout value in milliseconds **Note:** If content is omitted, the toast will not have a `.toast-body` and can be used as a small snack which will be shown below in the examples. By default toasts will be positioned in the top right corner and will in the future (hopefully) have other position options. diff --git a/dist/toast.min.js b/dist/toast.min.js index 0fa9e61..b1d45a9 100644 --- a/dist/toast.min.js +++ b/dist/toast.min.js @@ -1 +1,3 @@ -!function($){const TOAST_CONTAINER_HTML='
',TOAST_WRAPPER_HTML='
';$.toast=function(opts){$("#toast-container").length||($("body").prepend(TOAST_CONTAINER_HTML),$("#toast-container").append(TOAST_WRAPPER_HTML));let bg_header_class="",fg_header_class="",fg_subtitle="text-muted",fg_dismiss="",title="object"==typeof opts?opts.title||"":arguments[0]||"Notice!",subtitle="object"==typeof opts?opts.subtitle||"":arguments[1]||"",content="object"==typeof opts?opts.content||"":arguments[2]||"",type="object"==typeof opts?opts.type||"":arguments[3]||"info",delay="object"==typeof opts?opts.delay||3e3:arguments[4]||3e3;switch(type){case"info":bg_header_class="bg-info",fg_header_class="text-white",fg_subtitle="text-white",fg_dismiss="text-white";break;case"success":bg_header_class="bg-success",fg_header_class="text-white",fg_subtitle="text-white",fg_dismiss="text-white";break;case"warning":case"warn":bg_header_class="bg-warning",fg_header_class="text-white",fg_subtitle="text-white",fg_dismiss="text-white";break;case"error":case"danger":bg_header_class="bg-danger",fg_header_class="text-white",fg_subtitle="text-white",fg_dismiss="text-white"}let delay_or_autohide="",html="";html+='",$("#toast-wrapper").append(html),$("#toast-wrapper .toast:last").toast("show")}}(jQuery); \ No newline at end of file +(function(b){b.toast=function(a,k,g,l,h){b("#toast-container").length||(b("body").prepend('
'),b("#toast-container").append('
'));var c="",d="",e="text-muted",f="",m="object"===typeof a?a.title||"":a||"Notice!";k="object"===typeof a?a.subtitle||"":k||"";g="object"===typeof a?a.content||"":g||"";h="object"===typeof a?a.delay||-1:h||-1;switch("object"===typeof a?a.type||"":l||"info"){case "info":c="bg-info"; +f=e=d="text-white";break;case "success":c="bg-success";f=e=d="text-white";break;case "warning":case "warn":c="bg-warning";f=e=d="text-white";break;case "error":case "danger":c="bg-danger",f=e=d="text-white"}a='";b("#toast-wrapper").append(a);b("#toast-wrapper .toast:last").toast("show")}})(jQuery); \ No newline at end of file diff --git a/js/toast.js b/js/toast.js index a4dc158..40449fd 100644 --- a/js/toast.js +++ b/js/toast.js @@ -17,7 +17,7 @@ subtitle = typeof opts === 'object' ? opts.subtitle || '' : arguments[1] || '', content = typeof opts === 'object' ? opts.content || '' : arguments[2] || '', type = typeof opts === 'object' ? opts.type || '' : arguments[3] || 'info', - delay = typeof opts === 'object' ? opts.delay || 3000 : arguments[4] || 3000; + delay = typeof opts === 'object' ? opts.delay || -1 : arguments[4] || -1; switch (type) { case 'info':