CodeSeven / toastr

Simple javascript toast notifications
http://www.toastrjs.com
MIT License
11.99k stars 2.04k forks source link

If you don't want to hide the toast as an important message... #616

Open Ramonbc95 opened 5 years ago

Ramonbc95 commented 5 years ago

·Hi i have an idea to get controlled the exception when we try to get a not hide toast when hideMethod is named with any value. On this case i'm talking to customize the call as if we put:

//CODE
toastr.warning("You should activate your cookies to get a better expieriences and to make possible work fine this website", "Warning",{ hideMethod: "" });

·With this should be fixed the toast, but javascript is throwing an exception because says "$toastElement[method] is not a function", but i have an idea for that, because if we check on line 413 if we have the variable 'method' is empty like "", we can keep the toast with no exceptions. Like this:

//CODE
function hideToast(override) {
                    var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod;
                    var duration = override && options.closeDuration !== false ?
                        options.closeDuration : options.hideDuration;
                    var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing;
                    if ($(':focus', $toastElement).length && !override) {
                        return;
                    }
                    clearTimeout(progressBar.intervalId);
                   /*--------------HERE is my line code-------------*/
                    if(method !== ""){
                    return $toastElement[method]({
                        duration: duration,
                        easing: easing,
                        complete: function () {
                            removeToast($toastElement);
                            clearTimeout(intervalId);
                            if (options.onHidden && response.state !== 'hidden') {
                                options.onHidden();
                            }
                            response.state = 'hidden';
                            response.endTime = new Date();
                            publish(response);
                        }
                    });
                }
                }