/***************************************************************************************************
LoadingOverlay - A flexible loading overlay jQuery plugin
Author : Gaspare Sganga
Version : 2.1.6
License : MIT
Documentation : https://gasparesganga.com/labs/jquery-loading-overlay/
***************************************************************************************************/
;(function(factory){
if (typeof define === "function" && define.amd) {
// AMD. Register as an anonymous module
define(["jquery"], factory);
} else if (typeof module === "object" && module.exports) {
// Node/CommonJS
factory(require("jquery"));
} else {
// Browser globals
factory(jQuery);
}
}(function($, undefined){
"use strict";
// Default Settings
var _defaults = {
// Background
background : "rgba(255, 255, 255, 0.8)",
backgroundClass : "",
// Image
image : "",
imageAnimation : "2000ms rotate_right",
imageAutoResize : true,
imageResizeFactor : 1,
imageColor : "#202020",
imageClass : "",
imageOrder : 1,
// Font Awesome
fontawesome : "",
fontawesomeAnimation : "",
fontawesomeAutoResize : true,
fontawesomeResizeFactor : 1,
fontawesomeColor : "#202020",
fontawesomeOrder : 2,
// Custom
custom : "",
customAnimation : "",
customAutoResize : true,
customResizeFactor : 1,
customOrder : 3,
// Text
text : "",
textAnimation : "",
textAutoResize : true,
textResizeFactor : 0.5,
textColor : "#202020",
textClass : "",
textOrder : 4,
// Progress
progress : false,
progressAutoResize : true,
progressResizeFactor : 0.25,
progressColor : "#a0a0a0",
progressClass : "",
progressOrder : 5,
progressFixedPosition : "",
progressSpeed : 200,
progressMin : 0,
progressMax : 100,
// Sizing
size : 50,
maxSize : 120,
minSize : 20,
// Misc
direction : "column",
fade : true,
resizeInterval : 50,
zIndex : 2147483647
};
// Required CSS
var _css = {
overlay : {
"box-sizing" : "border-box",
"position" : "relative",
"display" : "flex",
"flex-wrap" : "nowrap",
"align-items" : "center",
"justify-content" : "space-around"
},
element : {
"box-sizing" : "border-box",
"overflow" : "visible",
"flex" : "0 0 auto",
"display" : "flex",
"justify-content" : "center",
"align-items" : "center"
},
element_svg : {
"width" : "100%",
"height" : "100%"
},
progress_fixed : {
"position" : "absolute",
"left" : "0",
"width" : "100%"
},
progress_wrapper : {
"position" : "absolute",
"top" : "0",
"left" : "0",
"width" : "100%",
"height" : "100%"
},
progress_bar : {
"position" : "absolute",
"left" : "0"
}
};
// Data Template
var _dataTemplate = {
"count" : 0,
"container" : undefined,
"settings" : undefined,
"wholePage" : undefined,
"resizeIntervalId" : undefined,
"text" : undefined,
"progress" : undefined
};
// Whitelists
var _whitelists = {
animations : [
"rotate_right",
"rotate_left",
"fadein",
"pulse"
],
progressPosition : [
"top",
"bottom"
]
};
// Default Values
var _defaultValues = {
animations : {
name : "rotate_right",
time : "2000ms"
},
fade : [400, 200]
};
$.LoadingOverlaySetup = function(settings){
$.extend(true, _defaults, settings);
};
$.LoadingOverlay = function(action, options){
switch (action.toLowerCase()) {
case "show":
var settings = $.extend(true, {}, _defaults, options);
Show("body", settings);
break;
case "hide":
Hide("body", options);
break;
case "resize":
Resize("body", options);
break;
case "text":
Text("body", options);
break;
case "progress":
Progress("body", options);
break;
}
};
$.fn.LoadingOverlay = function(action, options){
switch (action.toLowerCase()) {
case "show":
var settings = $.extend(true, {}, _defaults, options);
return this.each(function(){
Show(this, settings);
});
case "hide":
return this.each(function(){
Hide(this, options);
});
case "resize":
return this.each(function(){
Resize(this, options);
});
case "text":
return this.each(function(){
Text(this, options);
});
case "progress":
return this.each(function(){
Progress(this, options);
});
}
};
function Show(container, settings){
container = $(container);
settings.size = _ParseSize(settings.size);
settings.maxSize = parseInt(settings.maxSize, 10) || 0;
settings.minSize = parseInt(settings.minSize, 10) || 0;
settings.resizeInterval = parseInt(settings.resizeInterval, 10) || 0;
var overlay = _GetOverlay(container);
var data = _GetData(container);
if (data === false) {
// Init data
data = $.extend({}, _dataTemplate);
data.container = container;
data.wholePage = container.is("body");
// Overlay
overlay = $("
", {
"class" : "loadingoverlay"
})
.css(_css.overlay)
.css("flex-direction", settings.direction.toLowerCase() === "row" ? "row" : "column");
if (settings.backgroundClass) {
overlay.addClass(settings.backgroundClass);
} else {
overlay.css("background", settings.background);
}
if (data.wholePage) {
overlay.css({
"position" : "fixed",
"top" : 0,
"left" : 0,
"width" : "100%",
"height" : "100%"
});
}
if (typeof settings.zIndex !== "undefined") overlay.css("z-index", settings.zIndex);
// Image
if (settings.image) {
if ($.isArray(settings.imageColor)) {
if (settings.imageColor.length === 0) {
settings.imageColor = false;
} else if (settings.imageColor.length === 1) {
settings.imageColor = {
"fill" : settings.imageColor[0]
};
} else {
settings.imageColor = {
"fill" : settings.imageColor[0],
"stroke" : settings.imageColor[1]
};
}
} else if (settings.imageColor) {
settings.imageColor = {
"fill" : settings.imageColor
};
}
var element = _CreateElement(overlay, settings.imageOrder, settings.imageAutoResize, settings.imageResizeFactor, settings.imageAnimation);
if (settings.image.slice(0, 4).toLowerCase() === "