2 lines
3.2 KiB
JavaScript
2 lines
3.2 KiB
JavaScript
!function(e){"use strict";function t(){return a}var a,n=-1,i=0,r=function(){var e=["My name is Inigo Montoya. You killed my father. Prepare to die!",'<div><input class="input-small" value="textbox"/> <a href="http://johnpapa.net" target="_blank">This is a hyperlink</a></div><div><button type="button" id="okBtn" class="btn btn-primary">Close me</button><button type="button" id="surpriseBtn" class="btn" style="margin: 0 8px 0 8px">Surprise me</button></div>',"Are you the six fingered man?","Inconceivable!","I do not think that means what you think it means.","Have fun storming the castle!"];return n++,n===e.length&&(n=0),e[n]},o=function(e){return e=e?e:"Clear itself?",e+='<br /><br /><button type="button" class="btn clear">Yes</button>'};e("#closeButton").on("click",function(){return e(this).is(":checked")?e("#addBehaviorOnToastCloseClick").prop("disabled",!1):(e("#addBehaviorOnToastCloseClick").prop("disabled",!0),e("#addBehaviorOnToastCloseClick").prop("checked",!1)),!1}),e("#showtoast").on("click",function(){var t=e("#toastTypeGroup input:radio:checked").val(),n=e("#message").val(),l=e("#title").val()||"",s=e("#showDuration"),c=e("#hideDuration"),u=e("#timeOut"),d=e("#extendedTimeOut"),m=e("#showEasing"),h=e("#hideEasing"),y=e("#showMethod"),p=e("#hideMethod"),f=i++,g=e("#addClear").prop("checked");toastr.options={closeButton:e("#closeButton").prop("checked"),debug:e("#debugInfo").prop("checked"),newestOnTop:e("#newestOnTop").prop("checked"),progressBar:e("#progressBar").prop("checked"),rtl:e("#rtl").prop("checked"),positionClass:e("#positionGroup input:radio:checked").val()||"toast-top-right",preventDuplicates:e("#preventDuplicates").prop("checked"),onclick:null},e("#addBehaviorOnToastClick").prop("checked")&&(toastr.options.onclick=function(){alert("You can perform some custom action after a toast goes away")}),e("#addBehaviorOnToastCloseClick").prop("checked")&&(toastr.options.onCloseClick=function(){alert("You can perform some custom action when the close button is clicked")}),s.val().length&&(toastr.options.showDuration=parseInt(s.val())),c.val().length&&(toastr.options.hideDuration=parseInt(c.val())),u.val().length&&(toastr.options.timeOut=g?0:parseInt(u.val())),d.val().length&&(toastr.options.extendedTimeOut=g?0:parseInt(d.val())),m.val().length&&(toastr.options.showEasing=m.val()),h.val().length&&(toastr.options.hideEasing=h.val()),y.val().length&&(toastr.options.showMethod=y.val()),p.val().length&&(toastr.options.hideMethod=p.val()),g&&(n=o(n),toastr.options.tapToDismiss=!1),n||(n=r()),e("#toastrOptions").text('Command: toastr["'+t+'"]("'+n+(l?'", "'+l:"")+'")\n\ntoastr.options = '+JSON.stringify(toastr.options,null,2));var x=toastr[t](n,l);return a=x,"undefined"!=typeof x?(x.find("#okBtn").length&&x.delegate("#okBtn","click",function(){alert("you clicked me. i was toast #"+f+". goodbye!"),x.remove()}),x.find("#surpriseBtn").length&&x.delegate("#surpriseBtn","click",function(){alert("Surprise! you clicked me. i was toast #"+f+". You could perform an action here.")}),x.find(".clear").length&&x.delegate(".clear","click",function(){toastr.clear(x,{force:!0})}),!1):void 0}),e("#clearlasttoast").on("click",function(){return toastr.clear(t()),!1}),e("#cleartoasts").on("click",function(){return toastr.clear(),!1})}(jQuery);
|