vendor: 13,514 bytes, lines 1-363
1 2(function (define) { 3 define(['jquery'], function ($) { 4 return (function () { 5 var $container; 6 var listener; 7 var toastId = 0; 8 var toastType = { 9 error: 'error', 10 info: 'info', 11 success: 'success', 12 warning: 'warning' 13 }; 14 15 var toastr = { 16 clear: clear, 17 remove: remove, 18 error: error, 19 getContainer: getContainer, 20 info: info, 21 options: {}, 22 subscribe: subscribe, 23 success: success, 24 version: '2.1.4', 25 warning: warning 26 }; 27 28 var previousToast; 29 30 return toastr; 31 32 //////////////// 33 34 function error(message, title, optionsOverride) { 35 return notify({ 36 type: toastType.error, 37 iconClass: getOptions().iconClasses.error, 38 message: message, 39 optionsOverride: optionsOverride, 40 title: title 41 }); 42 } 43 44 function getContainer(options, create) { 45 if (!options) { options = getOptions(); } 46 $container = $('#' + options.containerId); 47 if ($container.length) { 48 return $container; 49 } 50 if (create) { 51 $container = createContainer(options); 52 } 53 return $container; 54 } 55 56 function info(message, title, optionsOverride) { 57 return notify({ 58 type: toastType.info, 59 iconClass: getOptions().iconClasses.info, 60 message: message, 61 optionsOverride: optionsOverride, 62 title: title 63 }); 64 } 65 66 function subscribe(callback) { 67 listener = callback; 68 } 69 70 function success(message, title, optionsOverride) { 71 return notify({ 72 type: toastType.success, 73 iconClass: getOptions().iconClasses.success, 74 message: message, 75 optionsOverride: optionsOverride, 76 title: title 77 }); 78 } 79 80 function warning(message, title, optionsOverride) { 81 return notify({ 82 type: toastType.warning, 83 iconClass: getOptions().iconClasses.warning, 84 message: message, 85 optionsOverride: optionsOverride, 86 title: title 87 }); 88 } 89 90 function clear($toastElement, clearOptions) { 91 var options = getOptions(); 92 if (!$container) { getContainer(options); } 93 if (!clearToast($toastElement, options, clearOptions)) { 94 clearContainer(options); 95 } 96 } 97 98 function remove($toastElement) { 99 var options = getOptions(); 100 if (!$container) { getContainer(options); } 101 if ($toastElement && $(':focus', $toastElement).length === 0) { 102 removeToast($toastElement); 103 return; 104 } 105 if ($container.children().length) { 106 $container.remove(); 107 } 108 } 109 110 // internal functions 111 112 function clearContainer (options) { 113 var toastsToClear = $container.children(); 114 for (var i = toastsToClear.length - 1; i >= 0; i--) { 115 clearToast($(toastsToClear[i]), options); 116 } 117 } 118 119 function clearToast ($toastElement, options, clearOptions) { 120 var force = clearOptions && clearOptions.force ? clearOptions.force : false; 121 if ($toastElement && (force || $(':focus', $toastElement).length === 0)) { 122 $toastElement[options.hideMethod]({ 123 duration: options.hideDuration, 124 easing: options.hideEasing, 125 complete: function () { removeToast($toastElement); } 126 }); 127 return true; 128 } 129 return false; 130 } 131 132 function createContainer(options) { 133 $container = $('<div/>') 134 .attr('id', options.containerId) 135 .addClass(options.positionClass); 136 137 $container.appendTo($(options.target)); 138 return $container; 139 } 140 141 function getDefaults() { 142 return { 143 tapToDismiss: true, 144 toastClass: 'toast', 145 containerId: 'toast-container', 146 debug: false, 147 148 showMethod: 'fadeIn', //fadeIn, slideDown, and show are built into jQuery 149 showDuration: 300, 150 showEasing: 'swing', //swing and linear are built into jQuery 151 onShown: undefined, 152 hideMethod: 'fadeOut', 153 hideDuration: 1000, 154 hideEasing: 'swing', 155 onHidden: undefined, 156 closeMethod: false, 157 closeDuration: false, 158 closeEasing: false, 159 closeOnHover: true, 160 161 extendedTimeOut: 1000, 162 iconClasses: { 163 error: 'toast-error', 164 info: 'toast-info', 165 success: 'toast-success', 166 warning: 'toast-warning' 167 }, 168 iconClass: 'toast-info', 169 positionClass: 'toast-top-right', 170 timeOut: 5000, // Set timeOut and extendedTimeOut to 0 to make it sticky 171 titleClass: 'toast-title', 172 messageClass: 'toast-message', 173 escapeHtml: false, 174 target: 'body', 175 closeHtml: '<button type="button">×</button>', 176 closeClass: 'toast-close-button', 177 newestOnTop: true, 178 preventDuplicates: false, 179 progressBar: false, 180 progressClass: 'toast-progress', 181 rtl: false 182 }; 183 } 184 185 function publish(args) { 186 if (!listener) { return; } 187 listener(args); 188 } 189 190 function notify(map) { 191 var options = getOptions(); 192 var iconClass = map.iconClass || options.iconClass; 193 194 if (typeof (map.optionsOverride) !== 'undefined') { 195 options = $.extend(options, map.optionsOverride); 196 iconClass = map.optionsOverride.iconClass || iconClass; 197 } 198 199 if (shouldExit(options, map)) { return; } 200 201 toastId++; 202 203 $container = getContainer(options, true); 204 205 var intervalId = null; 206 var $toastElement = $('<div/>'); 207 var $titleElement = $('<div/>'); 208 var $messageElement = $('<div/>'); 209 var $progressElement = $('<div/>'); 210 var $closeElement = $(options.closeHtml); 211 var progressBar = { 212 intervalId: null, 213 hideEta: null, 214 maxHideTime: null 215 }; 216 var response = { 217 toastId: toastId, 218 state: 'visible', 219 startTime: new Date(), 220 options: options, 221 map: map 222 }; 223 224 personalizeToast(); 225 226 displayToast(); 227 228 handleEvents(); 229 230 publish(response); 231 232 if (options.debug && console) { 233 console.log(response); 234 } 235 236 return $toastElement; 237 238 function escapeHtml(source) { 239 if (source == null) { 240 source = ''; 241 } 242 243 return source 244 .replace(/&/g, '&') 245 .replace(/"/g, '"') 246 .replace(/'/g, ''') 247 .replace(/</g, '<') 248 .replace(/>/g, '>'); 249 } 250 251 function personalizeToast() { 252 setIcon(); 253 setTitle(); 254 setMessage(); 255 setCloseButton(); 256 setProgressBar(); 257 setRTL(); 258 setSequence(); 259 setAria(); 260 } 261 262 function setAria() { 263 var ariaValue = ''; 264 switch (map.iconClass) { 265 case 'toast-success': 266 case 'toast-info': 267 ariaValue = 'polite'; 268 break; 269 default: 270 ariaValue = 'assertive'; 271 } 272 $toastElement.attr('aria-live', ariaValue); 273 } 274 275 function handleEvents() { 276 if (options.closeOnHover) { 277 $toastElement.hover(stickAround, delayedHideToast); 278 } 279 280 if (!options.onclick && options.tapToDismiss) { 281 $toastElement.click(hideToast); 282 } 283 284 if (options.closeButton && $closeElement) { 285 $closeElement.click(function (event) { 286 if (event.stopPropagation) { 287 event.stopPropagation(); 288 } else if (event.cancelBubble !== undefined && event.cancelBubble !== true) { 289 event.cancelBubble = true; 290 } 291 292 if (options.onCloseClick) { 293 options.onCloseClick(event); 294 } 295 296 hideToast(true); 297 }); 298 } 299 300 if (options.onclick) { 301 $toastElement.click(function (event) { 302 options.onclick(event); 303 hideToast(); 304 }); 305 } 306 } 307 308 function displayToast() { 309 $toastElement.hide(); 310 311 $toastElement[options.showMethod]( 312 {duration: options.showDuration, easing: options.showEasing, complete: options.onShown} 313 ); 314 315 if (options.timeOut > 0) { 316 intervalId = setTimeout(hideToast, options.timeOut); 317 progressBar.maxHideTime = parseFloat(options.timeOut); 318 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime; 319 if (options.progressBar) { 320 progressBar.intervalId = setInterval(updateProgress, 10); 321 } 322 } 323 } 324 325 function setIcon() { 326 if (map.iconClass) { 327 $toastElement.addClass(options.toastClass).addClass(iconClass); 328 } 329 } 330 331 function setSequence() { 332 if (options.newestOnTop) { 333 $container.prepend($toastElement); 334 } else { 335 $container.append($toastElement); 336 } 337 } 338 339 function setTitle() { 340 if (map.title) { 341 var suffix = map.title; 342 if (options.escapeHtml) { 343 suffix = escapeHtml(map.title); 344 } 345 $titleElement.append(suffix).addClass(options.titleClass); 346 $toastElement.append($titleElement); 347 } 348 } 349 350 function setMessage() { 351 if (map.message) { 352 var suffix = map.message; 353 if (options.escapeHtml) { 354 suffix = escapeHtml(map.message); 355 } 356 $messageElement.append(suffix).addClass(options.messageClass); 357 $toastElement.append($messageElement); 358 } 359 } 360 361 function setCloseButton() { 362 if (options.closeButton) { 363 $closeElement.addClass(options.closeClass).attr('role', 'button');
364 $toastElement.prepend($closeElement); 365 } 366 } 367 368 function setProgressBar() { 369 if (options.progressBar) { 370 $progressElement.addClass(options.progressClass); 371 $toastElement.prepend($progressElement); 372 } 373 } 374 375 function setRTL() { 376 if (options.rtl) { 377 $toastElement.addClass('rtl'); 378 } 379 } 380 381 function shouldExit(options, map) { 382 if (options.preventDuplicates) { 383 if (map.message === previousToast) { 384 return true; 385 } else { 386 previousToast = map.message; 387 } 388 } 389 return false; 390 } 391 392 function hideToast(override) { 393 var method = override && options.closeMethod !== false ? options.closeMethod : options.hideMethod; 394 var duration = override && options.closeDuration !== false ? 395 options.closeDuration : options.hideDuration; 396 var easing = override && options.closeEasing !== false ? options.closeEasing : options.hideEasing; 397 if ($(':focus', $toastElement).length && !override) { 398 return; 399 } 400 clearTimeout(progressBar.intervalId); 401 return $toastElement[method]({ 402 duration: duration, 403 easing: easing, 404 complete: function () { 405 removeToast($toastElement); 406 clearTimeout(intervalId); 407 if (options.onHidden && response.state !== 'hidden') { 408 options.onHidden(); 409 } 410 response.state = 'hidden'; 411 response.endTime = new Date(); 412 publish(response); 413 } 414 }); 415 } 416 417 function delayedHideToast() { 418 if (options.timeOut > 0 || options.extendedTimeOut > 0) { 419 intervalId = setTimeout(hideToast, options.extendedTimeOut); 420 progressBar.maxHideTime = parseFloat(options.extendedTimeOut); 421 progressBar.hideEta = new Date().getTime() + progressBar.maxHideTime; 422 } 423 } 424 425 function stickAround() { 426 clearTimeout(intervalId); 427 progressBar.hideEta = 0; 428 $toastElement.stop(true, true)[options.showMethod]( 429 {duration: options.showDuration, easing: options.showEasing} 430 ); 431 } 432 433 function updateProgress() { 434 var percentage = ((progressBar.hideEta - (new Date().getTime())) / progressBar.maxHideTime) * 100; 435 $progressElement.width(percentage + '%'); 436 } 437 } 438 439 function getOptions() { 440 return $.extend({}, getDefaults(), toastr.options); 441 } 442 443 function removeToast($toastElement) { 444 if (!$container) { $container = getContainer(); } 445 if ($toastElement.is(':visible')) { 446 return; 447 } 448 $toastElement.remove(); 449 $toastElement = null; 450 if ($container.children().length === 0) { 451 $container.remove(); 452 previousToast = undefined; 453 } 454 } 455 456 })(); 457 }); 458}(typeof define === 'function' && define.amd ? define : function (deps, factory) { 459 if (typeof module !== 'undefined' && module.exports) { //Node 460 module.exports = factory(require('jquery')); 461 } else { 462 window.toastr = factory(window.jQuery); 463 } 464})); 465 466$(function () { 467 var i = -1; 468 var toastCount = 0; 469 var $toastlast; 470 471 var getMessage = function () { 472 var msgs = ['My name is Inigo Montoya. You killed my father. Prepare to die!', 473 '<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>', 474 'Are you the six fingered man?', 475 'Inconceivable!', 476 'I do not think that means what you think it means.', 477 'Have fun storming the castle!' 478 ]; 479 i++; 480 if (i === msgs.length) { 481 i = 0; 482 } 483 484 return msgs[i]; 485 }; 486 487 var getMessageWithClearButton = function (msg) { 488 msg = msg ? msg : 'Clear itself?'; 489 msg += '<br /><br /><button type="button" class="btn clear">Yes</button>'; 490 return msg; 491 }; 492 493 $('#closeButton').click(function() { 494 if($(this).is(':checked')) { 495 $('#addBehaviorOnToastCloseClick').prop('disabled', false); 496 } else { 497 $('#addBehaviorOnToastCloseClick').prop('disabled', true); 498 $('#addBehaviorOnToastCloseClick').prop('checked', false); 499 } 500 }); 501 502 $('#showtoast').click(function () {
503 var shortCutFunction = $("#toastTypeGroup input:radio:checked").val(); 504 var msg = $('#message').val(); 505 var title = $('#title').val() || ''; 506 var $showDuration = $('#showDuration'); 507 var $hideDuration = $('#hideDuration'); 508 var $timeOut = $('#timeOut'); 509 var $extendedTimeOut = $('#extendedTimeOut'); 510 var $showEasing = $('#showEasing'); 511 var $hideEasing = $('#hideEasing'); 512 var $showMethod = $('#showMethod'); 513 var $hideMethod = $('#hideMethod'); 514 var toastIndex = toastCount++; 515 var addClear = $('#addClear').prop('checked'); 516 517 toastr.options = { 518 closeButton: $('#closeButton').prop('checked'), 519 debug: $('#debugInfo').prop('checked'), 520 newestOnTop: $('#newestOnTop').prop('checked'), 521 progressBar: $('#progressBar').prop('checked'), 522 rtl: $('#rtl').prop('checked'), 523 positionClass: $('#positionGroup input:radio:checked').val() || 'toast-top-right', 524 preventDuplicates: $('#preventDuplicates').prop('checked'), 525 onclick: null 526 }; 527 528 if ($('#addBehaviorOnToastClick').prop('checked')) { 529 toastr.options.onclick = function () { 530 alert('You can perform some custom action after a toast goes away'); 531 }; 532 } 533 534 if ($('#addBehaviorOnToastCloseClick').prop('checked')) { 535 toastr.options.onCloseClick = function () { 536 alert('You can perform some custom action when the close button is clicked'); 537 }; 538 } 539 540 if ($showDuration.val().length) { 541 toastr.options.showDuration = parseInt($showDuration.val()); 542 } 543 544 if ($hideDuration.val().length) { 545 toastr.options.hideDuration = parseInt($hideDuration.val()); 546 } 547 548 if ($timeOut.val().length) { 549 toastr.options.timeOut = addClear ? 0 : parseInt($timeOut.val()); 550 } 551 552 if ($extendedTimeOut.val().length) { 553 toastr.options.extendedTimeOut = addClear ? 0 : parseInt($extendedTimeOut.val()); 554 } 555 556 if ($showEasing.val().length) { 557 toastr.options.showEasing = $showEasing.val(); 558 } 559 560 if ($hideEasing.val().length) { 561 toastr.options.hideEasing = $hideEasing.val(); 562 } 563 564 if ($showMethod.val().length) { 565 toastr.options.showMethod = $showMethod.val(); 566 } 567 568 if ($hideMethod.val().length) { 569 toastr.options.hideMethod = $hideMethod.val(); 570 } 571 572 if (addClear) { 573 msg = getMessageWithClearButton(msg); 574 toastr.options.tapToDismiss = false; 575 } 576 if (!msg) { 577 msg = getMessage(); 578 } 579 580 $('#toastrOptions').text('Command: toastr["' 581 + shortCutFunction 582 + '"]("' 583 + msg 584 + (title ? '", "' + title : '') 585 + '")\n\ntoastr.options = ' 586 + JSON.stringify(toastr.options, null, 2) 587 ); 588 589 var $toast = toastr[shortCutFunction](msg, title); // Wire up an event handler to a button in the toast, if it exists 590 $toastlast = $toast; 591 592 if(typeof $toast === 'undefined'){ 593 return; 594 } 595 596 if ($toast.find('#okBtn').length) { 597 $toast.delegate('#okBtn', 'click', function () { 598 alert('you clicked me. i was toast #' + toastIndex + '. goodbye!'); 599 $toast.remove(); 600 }); 601 } 602 if ($toast.find('#surpriseBtn').length) { 603 $toast.delegate('#surpriseBtn', 'click', function () { 604 alert('Surprise! you clicked me. i was toast #' + toastIndex + '. You could perform an action here.'); 605 }); 606 } 607 if ($toast.find('.clear').length) { 608 $toast.delegate('.clear', 'click', function () { 609 toastr.clear($toast, { force: true }); 610 }); 611 } 612 }); 613 614 function getLastToast(){ 615 return $toastlast; 616 } 617 $('#clearlasttoast').click(function () { 618 toastr.clear(getLastToast()); 619 }); 620 $('#cleartoasts').click(function () { 621 toastr.clear(); 622 }); 623}) 624 jQuery('<div class="quantity-nav"><div class="quantity-button quantity-up">+</div><div class="quantity-button quantity-down">-</div></div>').insertAfter('.quantity input'); 625 jQuery('.quantity').each(function() { 626 var spinner = jQuery(this), 627 input = spinner.find('input[type="number"]'), 628 btnUp = spinner.find('.quantity-up'), 629 btnDown = spinner.find('.quantity-down'), 630 min = input.attr('min'), 631 max = input.attr('max'); 632 633 btnUp.click(function() { 634 var oldValue = parseFloat(input.val()); 635 if (oldValue >= max) { 636 var newVal = oldValue; 637 } else { 638 var newVal = oldValue + 1; 639 } 640 spinner.find("input").val(newVal); 641 spinner.find("input").trigger("change"); 642 }); 643 644 btnDown.click(function() { 645 var oldValue = parseFloat(input.val()); 646 if (oldValue <= min) { 647 var newVal = oldValue; 648 } else { 649 var newVal = oldValue - 1; 650 } 651 spinner.find("input").val(newVal); 652 spinner.find("input").trigger("change"); 653 }); 654 655 });
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.