/*********************************************************************************** * Add Array.indexOf * ***********************************************************************************/ (function () { if (typeof Array.prototype.indexOf !== 'function') { Array.prototype.indexOf = function(searchElement, fromIndex) { for (var i = (fromIndex || 0), j = this.length; i < j; i += 1) { if ((searchElement === undefined) || (searchElement === null)) { if (this[i] === searchElement) { return i; } } else if (this[i] === searchElement) { return i; } } return -1; }; } })(); /**********************************************************************************/ (function ($,undefined) { var toasting = { gettoaster : function () { var toaster = $('#' + settings.toaster.id); if(toaster.length < 1) { toaster = $(settings.toaster.template).attr('id', settings.toaster.id).css(settings.toaster.css).addClass(settings.toaster['class']); if ((settings.stylesheet) && (!$("link[href=" + settings.stylesheet + "]").length)) { $('head').appendTo(''); } $(settings.toaster.container).append(toaster); } return toaster; }, notify : function (title, message, priority) { var $toaster = this.gettoaster(); var $toast = $(settings.toast.template.replace('%priority%', priority)).hide().css(settings.toast.css).addClass(settings.toast['class']); $('.title', $toast).css(settings.toast.csst).html(title); $('.message', $toast).css(settings.toast.cssm).html(message); if ((settings.debug) && (window.console)) { console.log(toast); } $toaster.append(settings.toast.display($toast)); if (settings.donotdismiss.indexOf(priority) === -1) { var timeout = (typeof settings.timeout === 'number') ? settings.timeout : ((typeof settings.timeout === 'object') && (priority in settings.timeout)) ? settings.timeout[priority] : 1500; setTimeout(function() { settings.toast.remove($toast, function() { $toast.remove(); }); }, timeout); } } }; var defaults = { 'toaster' : { 'id' : 'toaster', 'container' : 'body', 'template' : '
', 'class' : 'toaster', 'css' : { 'position' : 'fixed', 'top' : '10px', 'right' : '10px', 'width' : '400px', 'zIndex' : 50000 } }, 'toast' : { 'template' : '