Skip to content

Commit

Permalink
Toggle LoadingOverlay visibility according to target element
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
Gaspare Sganga committed Jul 3, 2018
1 parent 8eda5b0 commit ff40900
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions src/loadingoverlay.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/***************************************************************************************************
LoadingOverlay - A flexible loading overlay jQuery plugin
Author : Gaspare Sganga
Version : 2.1.4
Version : 2.1.5dev
License : MIT
Documentation : https://gasparesganga.com/labs/jquery-loading-overlay/
***************************************************************************************************/
Expand Down Expand Up @@ -217,8 +217,8 @@ LoadingOverlay - A flexible loading overlay jQuery plugin
settings.minSize = parseInt(settings.minSize, 10) || 0;
settings.resizeInterval = parseInt(settings.resizeInterval, 10) || 0;

var overlay = container.data("loadingoverlay");
var data = _GetData(overlay);
var overlay = _GetOverlay(container);
var data = _GetData(container);
if (data === false) {
// Init data
data = $.extend({}, _dataTemplate);
Expand Down Expand Up @@ -407,8 +407,8 @@ LoadingOverlay - A flexible loading overlay jQuery plugin

function Hide(container, force){
container = $(container);
var overlay = container.data("loadingoverlay");
var data = _GetData(overlay);
var overlay = _GetOverlay(container);
var data = _GetData(container);
if (data === false) return;

data.count--;
Expand All @@ -427,8 +427,7 @@ LoadingOverlay - A flexible loading overlay jQuery plugin

function Text(container, value){
container = $(container);
var overlay = container.data("loadingoverlay");
var data = _GetData(overlay);
var data = _GetData(container);
if (data === false || !data.text) return;

if (value === false) {
Expand All @@ -442,8 +441,7 @@ LoadingOverlay - A flexible loading overlay jQuery plugin

function Progress(container, value){
container = $(container);
var overlay = container.data("loadingoverlay");
var data = _GetData(overlay);
var data = _GetData(container);
if (data === false || !data.progress) return;

if (value === false) {
Expand All @@ -462,8 +460,8 @@ LoadingOverlay - A flexible loading overlay jQuery plugin


function _IntervalResize(container, force){
var overlay = container.data("loadingoverlay");
var data = _GetData(overlay);
var overlay = _GetOverlay(container);
var data = _GetData(container);
if (data === false) return;

// Overlay
Expand Down Expand Up @@ -517,8 +515,13 @@ LoadingOverlay - A flexible loading overlay jQuery plugin
}


function _GetData(overlay){
var data = (typeof overlay === "undefined") ? undefined : overlay.data("loadingoverlay_data");
function _GetOverlay(container){
return container.data("loadingoverlay");
}

function _GetData(container){
var overlay = _GetOverlay(container);
var data = (typeof overlay === "undefined") ? undefined : overlay.data("loadingoverlay_data");
if (typeof data === "undefined") {
// Clean DOM
$(".loadingoverlay").each(function(){
Expand All @@ -527,6 +530,7 @@ LoadingOverlay - A flexible loading overlay jQuery plugin
});
return false;
} else {
overlay.toggle(container.is(":visible"));
return data;
}
}
Expand Down

0 comments on commit ff40900

Please sign in to comment.