Clean up notification, add animated progress indicator.

This commit is contained in:
Michael Jumper
2013-06-25 13:21:59 -07:00
parent c1f1e0adfc
commit a902155a59
3 changed files with 46 additions and 3 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 473 B

View File

@@ -773,16 +773,32 @@ GuacUI.Client.attach = function(guac) {
* Prompt to download file when file received.
*/
function getSizeString(bytes) {
if (bytes > 1000000000)
return Math.round(bytes / 100000000)/10 + " GB";
else if (bytes > 1000000)
return Math.round(bytes / 100000)/10 + " MB";
else if (bytes > 1000)
return Math.round(bytes / 100)/10 + " KB";
else
return bytes + " B";
}
guac.onblob = function(blob) {
var download = new GuacUI.Download(blob.name);
download.updateProgress("0");
download.updateProgress(getSizeString(0));
document.body.appendChild(download.getElement());
// Update progress as data is received
blob.ondata = function() {
download.updateProgress(blob.getLength());
download.updateProgress(getSizeString(blob.getLength()));
};
// When complete, prompt for download

View File

@@ -316,14 +316,41 @@ p.hint {
color: silver;
}
@keyframes progress {
from {background-position-x: 0px;}
to {background-position-x: 64px;}
}
@-webkit-keyframes progress {
from {background-position-x: 0px;}
to {background-position-x: 64px;}
}
.download.notification .progress {
margin-left: 0.75em;
padding: 0.25em;
min-width: 5em;
border: 1px solid gray;
background: #444;
border-radius: 0.2em;
text-align: center;
background: #444 url('../images/progress.png');
background-size: 16px 16px;
-moz-background-size: 16px 16px;
-webkit-background-size: 16px 16px;
-khtml-background-size: 16px 16px;
animation-name: progress;
animation-duration: 2s;
animation-timing-function: linear;
animation-iteration-count: infinite;
-webkit-animation-name: progress;
-webkit-animation-duration: 2s;
-webkit-animation-timing-function: linear;
-webkit-animation-iteration-count: infinite;
}
.download.notification .download {