-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Gaspare Sganga
committed
Apr 22, 2016
1 parent
b2560bc
commit c1f3cde
Showing
6 changed files
with
187 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
8
extras/loadingoverlay_progress/loadingoverlay_progress.min.js
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.