Skip to content

Commit

Permalink
Version 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaspare Sganga committed Apr 22, 2016
1 parent b2560bc commit c1f3cde
Show file tree
Hide file tree
Showing 6 changed files with 187 additions and 7 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2015 Gaspare Sganga
Copyright (c) 2015-2016 Gaspare Sganga

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
67 changes: 67 additions & 0 deletions extras/loadingoverlay_progress/loadingoverlay_progress.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/***************************************************************************************************
LoadingOverlay Extras - Progress
Author : Gaspare Sganga
Version : 1.2
License : MIT
Documentation : http://gasparesganga.com/labs/jquery-loading-overlay
****************************************************************************************************/
var LoadingOverlayProgress = function(options){
var _bar;
var _text;
var _settings = $.extend(true, {}, {
bar : {
"bottom" : "25px",
"height" : "20px",
"background" : "#9bbb59"
},
text : {
"bottom" : "50px",
"font" : "14pt/1.2 sans-serif",
"color" : "#303030"
}
}, options);

return {
Init : Init,
Update : Update
};

function Init(){
var wrapper = $("<div>", {
class : "loadingoverlay_progress_wrapper",
css : {
"position" : "relative",
"width" : "100%",
"flex" : "1 0 auto"
}
});
_bar = $("<div>", {
class : "loadingoverlay_progress_bar",
css : $.extend(true, {
"position" : "absolute",
"left" : "0"
}, _settings.bar)
}).appendTo(wrapper);
_text = $("<div>", {
class : "loadingoverlay_progress_text",
css : $.extend(true, {
"position" : "absolute",
"left" : "0",
"text-align" : "right",
"white-space" : "nowrap"
}, _settings.text),
text : "0 %"
}).appendTo(wrapper);
Update(0);
return wrapper;
}

function Update(value){
if (value < 0) value = 0;
if (value > 100) value = 100;
var r = {"right" : (100 - value) + "%"};
_bar.css(r);
_text.css(r);
_text.text(value + "%");
}
};
8 changes: 8 additions & 0 deletions extras/loadingoverlay_progress/loadingoverlay_progress.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 94 additions & 0 deletions extras/loadingoverlay_progress/test.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>LoadingOverlay Extras - Progress - Test</title>
<style>
#progress_test {
display : block;
margin : 20px;
font : 12pt/1.2 sans-serif;
font-weight : bold;
padding : 6px;
}
.container {
display : inline-block;
margin-left : 20px;
width : 500px;
height : 500px;
border : 1px solid #008800;
font : 14pt/1.2 sans-serif;
text-align : center;
padding : 10px;
color : #303030;
background : #ffdd88;
}
</style>
<script src="https://code.jquery.com/jquery-2.2.3.min.js" integrity="sha256-a23g1Nt4dtEYOj7bR+vTu7+T8VP13humZFBJNIYoEJo=" crossorigin="anonymous"></script>
<script src="../../src/loadingoverlay.min.js"></script>
<script src="loadingoverlay_progress.min.js"></script>
<script>
$(document).ready(function(){
$("#progress_test").on("click", function Example1(event){
/***** Element 1 *****/
// Initialize Progress and show LoadingOverlay
var progress1 = new LoadingOverlayProgress();
$("#element1").LoadingOverlay("show", {
custom : progress1.Init()
});
// Simulate some action:
var count1 = 0;
var iid1 = setInterval(function(){
if (count1 >= 100) {
clearInterval(iid1);
delete progress1;
$("#element1").LoadingOverlay("hide");
return;
}
count1++;
progress1.Update(count1);
}, 100);
/*********************/


/***** Element 2 *****/
// Initialize Progress and show LoadingOverlay, you can customize it using an object with "bar" and "text" properties:
var progress2 = new LoadingOverlayProgress({
bar : {
"background" : "#dd0000",
"top" : "50px",
"height" : "30px",
"border-radius" : "15px"
},
text : {
"color" : "#aa0000",
"font-family" : "monospace",
"top" : "25px"
}
});
$("#element2").LoadingOverlay("show", {
custom : progress2.Init()
});
// Simulate some other action:
var count2 = 0;
var iid2 = setInterval(function(){
if (count2 >= 100) {
clearInterval(iid2);
delete progress2;
$("#element2").LoadingOverlay("hide");
return;
}
count2++;
progress2.Update(count2);
}, 50);
/*********************/
});
});
</script>
</head>
<body>
<button id="progress_test">Extras "Progress" Test</button>
<div class="container" id="element1">Element 1</div>
<div class="container" id="element2">Element 2</div>
</body>
</html>
19 changes: 15 additions & 4 deletions src/loadingoverlay.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
/***************************************************************************************************
LoadingOverlay - A flexible loading overlay jQuery plugin
Author : Gaspare Sganga
Version : 1.1
Version : 1.2
License : MIT
Documentation : http://gasparesganga.com/labs/jquery-loading-overlay
****************************************************************************************************/
(function($, undefined){
var _defaults = {
color : "rgba(255, 255, 255, 0.8)",
custom : "",
fade : true,
fontawesome : "",
image : "loading.gif",
maxSize : "100px",
Expand Down Expand Up @@ -103,7 +104,15 @@ LoadingOverlay - A flexible loading overlay jQuery plugin
}, settings.resizeInterval);
container.data("LoadingOverlayResizeIntervalId", resizeIntervalId);
}
overlay.appendTo(container);
if (!settings.fade) {
settings.fade = [0, 0];
} else if (settings.fade === true) {
settings.fade = [400, 200];
} else if (typeof settings.fade == "string" || typeof settings.fade == "number") {
settings.fade = [settings.fade, settings.fade];
}
container.data("LoadingOverlayFadeOutDuration", settings.fade[1]);
overlay.hide().appendTo(container).fadeIn(settings.fade[0]);
}
count++;
container.data("LoadingOverlayCount", count);
Expand All @@ -117,8 +126,10 @@ LoadingOverlay - A flexible loading overlay jQuery plugin
if (force || count <= 0) {
var resizeIntervalId = container.data("LoadingOverlayResizeIntervalId");
if (resizeIntervalId) clearInterval(resizeIntervalId);
container.removeData("LoadingOverlayCount").removeData("LoadingOverlayResizeIntervalId");
container.children(".loadingoverlay").remove();
container.children(".loadingoverlay").fadeOut(container.data("LoadingOverlayFadeOutDuration"), function(){
$(this).remove()
});
container.removeData(["LoadingOverlayCount", "LoadingOverlayFadeOutDuration", "LoadingOverlayResizeIntervalId"]);
} else {
container.data("LoadingOverlayCount", count);
}
Expand Down
4 changes: 2 additions & 2 deletions src/loadingoverlay.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c1f3cde

Please sign in to comment.