1/*********************************************************************************** 2* Add Array.indexOf * 3***********************************************************************************/ 4(function () 5{ 6 if (typeof Array.prototype.indexOf !== 'function') 7 { 8 Array.prototype.indexOf = function(searchElement, fromIndex) 9 { 10 for (var i = (fromIndex || 0), j = this.length; i < j; i += 1) 11 { 12 if ((searchElement === undefined) || (searchElement === null)) 13 { 14 if (this[i] === searchElement) 15 { 16 return i; 17 } 18 } 19 else if (this[i] === searchElement) 20 { 21 return i; 22 } 23 } 24 return -1; 25 }; 26 } 27})(); 28/**********************************************************************************/ 29 30(function ($,undefined) 31{ 32 var toasting = 33 { 34 gettoaster : function () 35 { 36 var toaster = $('#' + settings.toaster.id); 37 38 if(toaster.length < 1) 39 { 40 toaster = $(settings.toaster.template).attr('id', settings.toaster.id).css(settings.toaster.css).addClass(settings.toaster['class']); 41 42 if ((settings.stylesheet) && (!$("link[href=" + settings.stylesheet + "]").length)) 43 { 44 $('head').appendTo('<link rel="stylesheet" href="' + settings.stylesheet + '">'); 45 } 46 47 $(settings.toaster.container).append(toaster); 48 } 49 50 return toaster; 51 }, 52 53 notify : function (title, message, priority) 54 { 55 var $toaster = this.gettoaster(); 56 var delimiter = (title && message) ? settings.toast.defaults.delimiter : ''; 57 var $toast = $(settings.toast.template.replace('%priority%', priority).replace('%delimiter%', delimiter)).hide().css(settings.toast.css).addClass(settings.toast['class']); 58 59 $('.title', $toast).css(settings.toast.csst).html(title); 60 $('.message', $toast).css(settings.toast.cssm).html(message); 61 62 if ((settings.debug) && (window.console)) 63 { 64 console.log(toast); 65 } 66 67 $toaster.append(settings.toast.display($toast)); 68 69 if (settings.donotdismiss.indexOf(priority) === -1) 70 { 71 var timeout = (typeof settings.timeout === 'number') ? settings.timeout : ((typeof settings.timeout === 'object') && (priority in settings.timeout)) ? settings.timeout[priority] : 1500; 72 setTimeout(function() 73 { 74 settings.toast.remove($toast, function() 75 { 76 $toast.remove(); 77 }); 78 }, timeout); 79 } 80 } 81 }; 82 83 var defaults = 84 { 85 'toaster' : 86 { 87 'id' : 'toaster', 88 'container' : 'body', 89 'template' : '<div></div>', 90 'class' : 'toaster', 91 'css' : 92 { 93 'position' : 'fixed', 94 'top' : '10px', 95 'right' : '10px', 96 'width' : '300px', 97 'zIndex' : 50000 98 } 99 }, 100 101 'toast' : 102 { 103 'template' : 104 '<div class="alert alert-%priority% alert-dismissible" role="alert">' + 105 '<button type="button" class="close" data-dismiss="alert">' + 106 '<span aria-hidden="true">×</span>' + 107 '<span class="sr-only">Close</span>' + 108 '</button>' + 109 '<span class="title"></span>%delimiter% <span class="message"></span>' + 110 '</div>', 111 112 'defaults' : 113 { 114 'title' : 'Notice', 115 'priority' : 'success', 116 'delimiter' : ':' 117 }, 118 119 'css' : {}, 120 'cssm' : {}, 121 'csst' : { 'fontWeight' : 'bold' }, 122 123 'fade' : 'slow', 124 125 'display' : function ($toast) 126 { 127 return $toast.fadeIn(settings.toast.fade); 128 }, 129 130 'remove' : function ($toast, callback) 131 { 132 return $toast.animate( 133 { 134 opacity : '0', 135 padding : '0px', 136 margin : '0px', 137 height : '0px' 138 }, 139 { 140 duration : settings.toast.fade, 141 complete : callback 142 } 143 ); 144 } 145 }, 146 147 'debug' : false, 148 'timeout' : 1500, 149 'stylesheet' : null, 150 'donotdismiss' : [] 151 }; 152 153 var settings = {}; 154 $.extend(settings, defaults); 155 156 $.toaster = function (options) 157 { 158 if (typeof options === 'object') 159 { 160 if ('settings' in options) 161 { 162 settings = $.extend(true, settings, options.settings); 163 } 164 } 165 else 166 { 167 var values = Array.prototype.slice.call(arguments, 0); 168 var labels = ['message', 'title', 'priority']; 169 options = {}; 170 171 for (var i = 0, l = values.length; i < l; i += 1) 172 { 173 options[labels[i]] = values[i]; 174 } 175 } 176 177 var title = (('title' in options) && (typeof options.title === 'string')) ? options.title : settings.toast.defaults.title; 178 var message = ('message' in options) ? options.message : null;
179 var priority = (('priority' in options) && (typeof options.priority === 'string')) ? options.priority : settings.toast.defaults.priority; 180 181 if (message !== null) 182 { 183 toasting.notify(title, message, priority); 184 } 185 }; 186 187 $.toaster.reset = function () 188 { 189 settings = {}; 190 $.extend(settings, defaults); 191 }; 192})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.