vendor: 27,478 bytes, lines 1-723
1/*************************************************************************************************** 2 LoadingOverlay - A flexible loading overlay jQuery plugin 3 Author : Gaspare Sganga 4 Version : 2.1.6 5 License : MIT 6 Documentation : https://gasparesganga.com/labs/jquery-loading-overlay/ 7 ***************************************************************************************************/ 8;(function (factory) { 9 if (typeof define === "function" && define.amd) { 10 // AMD. Register as an anonymous module 11 define(["jquery"], factory); 12 } else if (typeof module === "object" && module.exports) { 13 // Node/CommonJS 14 factory(require("jquery")); 15 } else { 16 // Browser globals 17 factory(jQuery); 18 } 19}(function ($, undefined) { 20 "use strict"; 21 22 // Default Settings 23 var _defaults = { 24 // Background 25 background: "rgba(255, 255, 255, 0.8)", 26 backgroundClass: "", 27 // Image 28 image: "<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1000 1000'><circle r='80' cx='500' cy='90'/><circle r='80' cx='500' cy='910'/><circle r='80' cx='90' cy='500'/><circle r='80' cx='910' cy='500'/><circle r='80' cx='212' cy='212'/><circle r='80' cx='788' cy='212'/><circle r='80' cx='212' cy='788'/><circle r='80' cx='788' cy='788'/></svg>", 29 imageAnimation: "2000ms rotate_right", 30 imageAutoResize: true, 31 imageResizeFactor: 1, 32 imageColor: "#202020", 33 imageClass: "", 34 imageOrder: 1, 35 // Font Awesome 36 fontawesome: "", 37 fontawesomeAnimation: "", 38 fontawesomeAutoResize: true, 39 fontawesomeResizeFactor: 1, 40 fontawesomeColor: "#202020", 41 fontawesomeOrder: 2, 42 // Custom 43 custom: "", 44 customAnimation: "", 45 customAutoResize: true, 46 customResizeFactor: 1, 47 customOrder: 3, 48 // Text 49 text: "Hold On While We Find The Best Prices", 50 //textAnimation: "", 51 //textAutoResize: false, 52 //textResizeFactor: 1, 53 //textColor: "#202020", 54 textClass: "loadertext", 55 textOrder: 1, 56 // Progress 57 progress: false, 58 progressAutoResize: true, 59 progressResizeFactor: 0.25, 60 progressColor: "#a0a0a0", 61 progressClass: "", 62 progressOrder: 5, 63 progressFixedPosition: "", 64 progressSpeed: 200, 65 progressMin: 0, 66 progressMax: 100, 67 // Sizing 68 size: 50, 69 maxSize: 120, 70 minSize: 20, 71 // Misc 72 direction: "column", 73 fade: true, 74 resizeInterval: 50, 75 zIndex: 2147483647 76 }; 77 78 // Required CSS 79 var _css = { 80 overlay: { 81 "box-sizing": "border-box", 82 "position": "relative", 83 "display": "flex", 84 "flex-wrap": "nowrap", 85 "align-items": "center", 86 "justify-content": "space-around" 87 }, 88 element: { 89 "box-sizing": "border-box", 90 "overflow": "visible", 91 "flex": "0 0 auto", 92 "display": "flex", 93 "justify-content": "center", 94 "align-items": "center" 95 }, 96 element_svg: { 97 "width": "100%", 98 "height": "100%" 99 }, 100 progress_fixed: { 101 "position": "absolute", 102 "left": "0", 103 "width": "100%" 104 }, 105 progress_wrapper: { 106 "position": "absolute", 107 "top": "0", 108 "left": "0", 109 "width": "100%", 110 "height": "100%" 111 }, 112 progress_bar: { 113 "position": "absolute", 114 "left": "0" 115 } 116 }; 117 118 // Data Template 119 var _dataTemplate = { 120 "count": 0, 121 "container": undefined, 122 "settings": undefined, 123 "wholePage": undefined, 124 "resizeIntervalId": undefined, 125 "text": undefined, 126 "progress": undefined 127 }; 128 129 // Whitelists 130 var _whitelists = { 131 animations: [ 132 "rotate_right", 133 "rotate_left", 134 "fadein", 135 "pulse" 136 ], 137 progressPosition: [ 138 "top", 139 "bottom" 140 ] 141 }; 142 143 // Default Values 144 var _defaultValues = { 145 animations: { 146 name: "rotate_right", 147 time: "2000ms" 148 }, 149 fade: [400, 200] 150 }; 151 152 153 $.LoadingOverlaySetup = function (settings) { 154 $.extend(true, _defaults, settings); 155 }; 156 157 $.LoadingOverlay = function (action, options) { 158 switch (action.toLowerCase()) { 159 case "show": 160 var settings = $.extend(true, {}, _defaults, options); 161 Show("body", settings); 162 break; 163 164 case "hide": 165 Hide("body", options); 166 break; 167 168 case "resize": 169 Resize("body", options); 170 break; 171 172 case "text": 173 Text("body", options); 174 break; 175 176 case "progress": 177 Progress("body", options); 178 break; 179 } 180 }; 181 182 $.fn.LoadingOverlay = function (action, options) { 183 switch (action.toLowerCase()) { 184 case "show": 185 var settings = $.extend(true, {}, _defaults, options); 186 return this.each(function () { 187 Show(this, settings); 188 }); 189 190 case "hide": 191 return this.each(function () { 192 Hide(this, options); 193 }); 194 195 case "resize": 196 return this.each(function () { 197 Resize(this, options); 198 }); 199 200 case "text": 201 return this.each(function () { 202 Text(this, options); 203 }); 204 205 case "progress": 206 return this.each(function () { 207 Progress(this, options); 208 }); 209 } 210 }; 211 212 213 function Show(container, settings) { 214 container = $(container); 215 settings.size = _ParseSize(settings.size); 216 settings.maxSize = parseInt(settings.maxSize, 10) || 0; 217 settings.minSize = parseInt(settings.minSize, 10) || 0; 218 settings.resizeInterval = parseInt(settings.resizeInterval, 10) || 0; 219 220 var overlay = _GetOverlay(container); 221 var data = _GetData(container); 222 if (data === false) { 223 // Init data 224 data = $.extend({}, _dataTemplate); 225 data.container = container; 226 data.wholePage = container.is("body"); 227 228 // Overlay 229 overlay = $("<div>", { 230 "class": "loadingoverlay" 231 }) 232 .css(_css.overlay) 233 .css("flex-direction", settings.direction.toLowerCase() === "row" ? "row" : "column"); 234 if (settings.backgroundClass) { 235 overlay.addClass(settings.backgroundClass); 236 } else { 237 overlay.css("background", settings.background); 238 } 239 if (data.wholePage) { 240 overlay.css({ 241 "position": "fixed", 242 "top": 0, 243 "left": 0, 244 "width": "100%", 245 "height": "100%" 246 }); 247 } 248 if (typeof settings.zIndex !== "undefined") overlay.css("z-index", settings.zIndex); 249 250 // Image 251 if (settings.image) { 252 if ($.isArray(settings.imageColor)) { 253 if (settings.imageColor.length === 0) { 254 settings.imageColor = false; 255 } else if (settings.imageColor.length === 1) { 256 settings.imageColor = { 257 "fill": settings.imageColor[0] 258 }; 259 } else { 260 settings.imageColor = { 261 "fill": settings.imageColor[0], 262 "stroke": settings.imageColor[1] 263 }; 264 } 265 } else if (settings.imageColor) { 266 settings.imageColor = { 267 "fill": settings.imageColor 268 }; 269 } 270 var element = _CreateElement(overlay, settings.imageOrder, settings.imageAutoResize, settings.imageResizeFactor, settings.imageAnimation); 271 if (settings.image.slice(0, 4).toLowerCase() === "<svg" && settings.image.slice(-6).toLowerCase() === "</svg>") { 272 // Inline SVG 273 element.append(settings.image); 274 element.children().css(_css.element_svg); 275 if (!settings.imageClass && settings.imageColor) element.find("*").css(settings.imageColor); 276 } else if (settings.image.slice(-4).toLowerCase() === ".svg" || settings.image.slice(0, 14).toLowerCase() === "data:image/svg") { 277 // SVG file or base64-encoded SVG 278 $.ajax({ 279 url: settings.image, 280 type: "GET", 281 dataType: "html", 282 global: false 283 }).done(function (data) { 284 element.html(data); 285 element.children().css(_css.element_svg); 286 if (!settings.imageClass && settings.imageColor) element.find("*").css(settings.imageColor); 287 }); 288 } else { 289 // Raster 290 element.css({ 291 "background-image": "url(" + settings.image + ")", 292 "background-position": "center", 293 "background-repeat": "no-repeat", 294 "background-size": "cover" 295 }); 296 } 297 if (settings.imageClass) element.addClass(settings.imageClass); 298 } 299 300 // Font Awesome 301 if (settings.fontawesome) { 302 var element = _CreateElement(overlay, settings.fontawesomeOrder, settings.fontawesomeAutoResize, settings.fontawesomeResizeFactor, settings.fontawesomeAnimation) 303 .addClass("loadingoverlay_fa"); 304 $("<div>", { 305 "class": settings.fontawesome 306 }).appendTo(element); 307 if (settings.fontawesomeColor) element.css("color", settings.fontawesomeColor); 308 } 309 310 // Custom 311 if (settings.custom) { 312 var element = _CreateElement(overlay, settings.customOrder, settings.customAutoResize, settings.customResizeFactor, settings.customAnimation) 313 .append(settings.custom); 314 } 315 316 // Text 317 if (settings.text && container.is('body')) { 318 data.text = _CreateElement(overlay, settings.textOrder, settings.textAutoResize, settings.textResizeFactor, settings.textAnimation) 319 .addClass("loadingoverlay_text") 320 .text(settings.text); 321 if (settings.textClass) { 322 data.text.addClass(settings.textClass); 323 } else if (settings.textColor) { 324 data.text.css("color", settings.textColor); 325 } 326 } 327 328 // Progress 329 if (settings.progress) { 330 var element = _CreateElement(overlay, settings.progressOrder, settings.progressAutoResize, settings.progressResizeFactor, false) 331 .addClass("loadingoverlay_progress"); 332 var wrapper = $("<div>") 333 .css(_css.progress_wrapper) 334 .appendTo(element); 335 data.progress = { 336 bar: $("<div>").css(_css.progress_bar).appendTo(wrapper), 337 fixed: false, 338 margin: 0, 339 min: parseFloat(settings.progressMin), 340 max: parseFloat(settings.progressMax), 341 speed: parseInt(settings.progressSpeed, 10) 342 }; 343 var progressPositionParts = (settings.progressFixedPosition + "").replace(/\s\s+/g, " ").toLowerCase().split(" "); 344 if (progressPositionParts.length === 2 && _ValidateProgressPosition(progressPositionParts[0])) { 345 data.progress.fixed = progressPositionParts[0]; 346 data.progress.margin = _ParseSize(progressPositionParts[1]); 347 } else if (progressPositionParts.length === 2 && _ValidateProgressPosition(progressPositionParts[1])) { 348 data.progress.fixed = progressPositionParts[1]; 349 data.progress.margin = _ParseSize(progressPositionParts[0]); 350 } else if (progressPositionParts.length === 1 && _ValidateProgressPosition(progressPositionParts[0])) { 351 data.progress.fixed = progressPositionParts[0]; 352 data.progress.margin = 0; 353 } 354 if (data.progress.fixed === "top") { 355 element 356 .css(_css.progress_fixed) 357 .css("top", data.progress.margin ? data.progress.margin.value + (data.progress.margin.fixed ? data.progress.margin.units : "%") : 0); 358 } else if (data.progress.fixed === "bottom") { 359 element 360 .css(_css.progress_fixed) 361 .css("top", "auto"); 362 } 363 if (settings.progressClass) { 364 data.progress.bar.addClass(settings.progressClass); 365 } else if (settings.progressColor) { 366 data.progress.bar.css("background", settings.progressColor); 367 } 368 } 369 370 // Fade 371 if (!settings.fade) { 372 settings.fade = [0, 0]; 373 } else if (settings.fade === true) { 374 settings.fade = _defaultValues.fade; 375 } else if (typeof settings.fade === "string" || typeof settings.fade === "number") { 376 settings.fade = [settings.fade, settings.fade]; 377 } else if ($.isArray(settings.fade) && settings.fade.length < 2) { 378 settings.fade = [settings.fade[0], settings.fade[0]]; 379 } 380 settings.fade = [parseInt(settings.fade[0], 10), parseInt(settings.fade[1], 10)] 381 382 383 // Save settings 384 data.settings = settings; 385 // Save data 386 overlay.data("loadingoverlay_data", data); 387 // Save reference to overlay 388 container.data("loadingoverlay", overlay); 389 390 391 // Resize 392 overlay 393 .fadeTo(0, 0.01) 394 .appendTo("body"); 395 _IntervalResize(container, true); 396 if (settings.resizeInterval > 0) { 397 data.resizeIntervalId = setInterval(function () { 398 _IntervalResize(container, false); 399 }, settings.resizeInterval); 400 } 401 402 // Show LoadingOverlay 403 overlay.fadeTo(settings.fade[0], 1); 404 } 405 data.count++; 406 } 407 408 function Hide(container, force) { 409 container = $(container); 410 var overlay = _GetOverlay(container); 411 var data = _GetData(container); 412 if (data === false) return; 413 414 data.count--; 415 if (force || data.count <= 0) { 416 overlay.animate({ 417 "opacity": 0 418 }, data.settings.fade[1], function () { 419 if (data.resizeIntervalId) clearInterval(data.resizeIntervalId); 420 $(this).remove(); 421 container.removeData("loadingoverlay"); 422 }); 423 } 424 } 425 426 function Resize(container) { 427 _IntervalResize($(container), true); 428 } 429 430 function Text(container, value) { 431 container = $(container); 432 var data = _GetData(container); 433 if (data === false || !data.text) return; 434 435 if (value === false) { 436 data.text.hide(); 437 } else { 438 data.text 439 .show() 440 .text(value); 441 } 442 } 443 444 function Progress(container, value) { 445 container = $(container); 446 var data = _GetData(container); 447 if (data === false || !data.progress) return; 448 449 if (value === false) { 450 data.progress.bar.hide(); 451 } else { 452 var v = ((parseFloat(value) || 0) - data.progress.min) * 100 / (data.progress.max - data.progress.min); 453 if (v < 0) v = 0; 454 if (v > 100) v = 100; 455 data.progress.bar 456 .show() 457 .animate({ 458 "width": v + "%" 459 }, data.progress.speed); 460 } 461 } 462 463 464 function _IntervalResize(container, force) { 465 var overlay = _GetOverlay(container); 466 var data = _GetData(container); 467 if (data === false) return; 468 469 // Overlay 470 if (!data.wholePage) { 471 var isFixed = container.css("position") === "fixed"; 472 var pos = isFixed ? container[0].getBoundingClientRect() : container.offset(); 473 overlay.css({ 474 "position": isFixed ? "fixed" : "absolute", 475 "top": pos.top + parseInt(container.css("border-top-width"), 10), 476 "left": pos.left + parseInt(container.css("border-left-width"), 10), 477 "width": container.innerWidth(), 478 "height": container.innerHeight() 479 }); 480 } 481 482 // Elements 483 if (data.settings.size) { 484 var c = data.wholePage ? $(window) : container; 485 var size = data.settings.size.value; 486 if (!data.settings.size.fixed) { 487 size = Math.min(c.innerWidth(), c.innerHeight()) * size / 100; 488 if (data.settings.maxSize && size > data.settings.maxSize) size = data.settings.maxSize; 489 if (data.settings.minSize && size < data.settings.minSize) size = data.settings.minSize; 490 } 491 overlay.children(".loadingoverlay_element").each(function () { 492 var $this = $(this); 493 if (force || $this.data("loadingoverlay_autoresize")) { 494 var resizeFactor = $this.data("loadingoverlay_resizefactor"); 495 if ($this.hasClass("loadingoverlay_fa") || $this.hasClass("loadingoverlay_text")) { 496 $this.css("font-size", (size * resizeFactor) + data.settings.size.units); 497 } else if ($this.hasClass("loadingoverlay_progress")) { 498 data.progress.bar.css("height", (size * resizeFactor) + data.settings.size.units); 499 if (!data.progress.fixed) { 500 data.progress.bar 501 .css("top", $this.position().top) 502 .css("top", "-=" + (size * resizeFactor * 0.5) + data.settings.size.units); 503 } else if (data.progress.fixed === "bottom") { 504 $this 505 .css("bottom", data.progress.margin ? data.progress.margin.value + (data.progress.margin.fixed ? data.progress.margin.units : "%") : 0) 506 .css("bottom", "+=" + (size * resizeFactor) + data.settings.size.units); 507 } 508 } else { 509 $this.css({ 510 "width": (size * resizeFactor) + data.settings.size.units, 511 "height": (size * resizeFactor) + data.settings.size.units 512 }); 513 } 514 } 515 }); 516 } 517 } 518 519 520 function _GetOverlay(container) { 521 return container.data("loadingoverlay"); 522 } 523 524 function _GetData(container) { 525 var overlay = _GetOverlay(container); 526 var data = (typeof overlay === "undefined") ? undefined : overlay.data("loadingoverlay_data"); 527 if (typeof data === "undefined") { 528 // Clean DOM 529 $(".loadingoverlay").each(function () { 530 var $this = $(this); 531 var data = $this.data("loadingoverlay_data"); 532 if (!document.body.contains(data.container[0])) { 533 if (data.resizeIntervalId) clearInterval(data.resizeIntervalId); 534 $this.remove(); 535 } 536 }); 537 return false; 538 } else { 539 overlay.toggle(container.is(":visible")); 540 return data; 541 } 542 } 543 544 545 function _CreateElement(overlay, order, autoResize, resizeFactor, animation) { 546 var element = $("<div>", { 547 "class": "loadingoverlay_element", 548 "css": { 549 "order": order 550 } 551 }) 552 .css(_css.element) 553 .data({ 554 "loadingoverlay_autoresize": autoResize, 555 "loadingoverlay_resizefactor": resizeFactor 556 }) 557 .appendTo(overlay); 558 559 // Parse animation 560 if (animation === true) animation = _defaultValues.animations.time + " " + _defaultValues.animations.name; 561 if (typeof animation === "string") { 562 var animationName; 563 var animationTime; 564 var parts = animation.replace(/\s\s+/g, " ").toLowerCase().split(" "); 565 if (parts.length === 2 && _ValidateCssTime(parts[0]) && _ValidateAnimation(parts[1])) { 566 animationName = parts[1]; 567 animationTime = parts[0]; 568 } else if (parts.length === 2 && _ValidateCssTime(parts[1]) && _ValidateAnimation(parts[0])) { 569 animationName = parts[0]; 570 animationTime = parts[1]; 571 } else if (parts.length === 1 && _ValidateCssTime(parts[0])) { 572 animationName = _defaultValues.animations.name; 573 animationTime = parts[0]; 574 } else if (parts.length === 1 && _ValidateAnimation(parts[0])) { 575 animationName = parts[0]; 576 animationTime = _defaultValues.animations.time; 577 } 578 element.css({ 579 "animation-name": "loadingoverlay_animation__" + animationName, 580 "animation-duration": animationTime, 581 "animation-timing-function": "linear", 582 "animation-iteration-count": "infinite" 583 }); 584 } 585 586 return element; 587 } 588 589 function _ValidateCssTime(value) { 590 return !isNaN(parseFloat(value)) && (value.slice(-1) === "s" || value.slice(-2) === "ms"); 591 } 592 593 function _ValidateAnimation(value) { 594 return _whitelists.animations.indexOf(value) > -1; 595 } 596 597 function _ValidateProgressPosition(value) { 598 return _whitelists.progressPosition.indexOf(value) > -1; 599 } 600 601 602 function _ParseSize(value) { 603 if (!value || value < 0) { 604 return false; 605 } else if (typeof value === "string" && ["vmin", "vmax"].indexOf(value.slice(-4)) > -1) { 606 return { 607 fixed: true, 608 units: value.slice(-4), 609 value: value.slice(0, -4) 610 }; 611 } else if (typeof value === "string" && ["rem"].indexOf(value.slice(-3)) > -1) { 612 return { 613 fixed: true, 614 units: value.slice(-3), 615 value: value.slice(0, -3) 616 }; 617 } else if (typeof value === "string" && ["px", "em", "cm", "mm", "in", "pt", "pc", "vh", "vw"].indexOf(value.slice(-2)) > -1) { 618 return { 619 fixed: true, 620 units: value.slice(-2), 621 value: value.slice(0, -2) 622 }; 623 } else { 624 return { 625 fixed: false, 626 units: "px", 627 value: parseFloat(value) 628 }; 629 } 630 } 631 632 633 $(function () { 634 $("head").append([ 635 "<style>", 636 "@-webkit-keyframes loadingoverlay_animation__rotate_right {", 637 "to {", 638 "-webkit-transform : rotate(360deg);", 639 "transform : rotate(360deg);", 640 "}", 641 "}", 642 "@keyframes loadingoverlay_animation__rotate_right {", 643 "to {", 644 "-webkit-transform : rotate(360deg);", 645 "transform : rotate(360deg);", 646 "}", 647 "}", 648 649 "@-webkit-keyframes loadingoverlay_animation__rotate_left {", 650 "to {", 651 "-webkit-transform : rotate(-360deg);", 652 "transform : rotate(-360deg);", 653 "}", 654 "}", 655 "@keyframes loadingoverlay_animation__rotate_left {", 656 "to {", 657 "-webkit-transform : rotate(-360deg);", 658 "transform : rotate(-360deg);", 659 "}", 660 "}", 661 662 "@-webkit-keyframes loadingoverlay_animation__fadein {", 663 "0% {", 664 "opacity : 0;", 665 "-webkit-transform : scale(0.1, 0.1);", 666 "transform : scale(0.1, 0.1);", 667 "}", 668 "50% {", 669 "opacity : 1;", 670 "}", 671 "100% {", 672 "opacity : 0;", 673 "-webkit-transform : scale(1, 1);", 674 "transform : scale(1, 1);", 675 "}", 676 "}", 677 "@keyframes loadingoverlay_animation__fadein {", 678 "0% {", 679 "opacity : 0;", 680 "-webkit-transform : scale(0.1, 0.1);", 681 "transform : scale(0.1, 0.1);", 682 "}", 683 "50% {", 684 "opacity : 1;", 685 "}", 686 "100% {", 687 "opacity : 0;", 688 "-webkit-transform : scale(1, 1);", 689 "transform : scale(1, 1);", 690 "}", 691 "}", 692 693 "@-webkit-keyframes loadingoverlay_animation__pulse {", 694 "0% {", 695 "-webkit-transform : scale(0, 0);", 696 "transform : scale(0, 0);", 697 "}", 698 "50% {", 699 "-webkit-transform : scale(1, 1);", 700 "transform : scale(1, 1);", 701 "}", 702 "100% {", 703 "-webkit-transform : scale(0, 0);", 704 "transform : scale(0, 0);", 705 "}", 706 "}", 707 "@keyframes loadingoverlay_animation__pulse {", 708 "0% {", 709 "-webkit-transform : scale(0, 0);", 710 "transform : scale(0, 0);", 711 "}", 712 "50% {", 713 "-webkit-transform : scale(1, 1);", 714 "transform : scale(1, 1);", 715 "}", 716 "100% {", 717 "-webkit-transform : scale(0, 0);", 718 "transform : scale(0, 0);", 719 "}", 720 "}", 721 "</style>" 722 ].join(" ")); 723 });
724 725}));
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.