Created
September 27, 2016 13:52
-
-
Save elhardoum/22e4ae0f2bca905f88a89d9b2f056713 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
xhr: function() { | |
var xhr = new window.XMLHttpRequest(); | |
xhr.upload.addEventListener("progress", function(evt){ | |
if (evt.lengthComputable) { | |
var percentComplete = evt.loaded / evt.total; | |
percentComplete = (percentComplete.toFixed(2) * 100); | |
// add a progress bar container | |
if ( $('#upload-progress',container).length == 0 ) { | |
$(container).append('<div id="upload-progress" style="background: rgba(255, 186, 186, 0.32); width: 0; overflow: hidden; padding: 4px;"></div>'); | |
} | |
$('#upload-progress',container).css({ | |
width: percentComplete + '%' | |
}); | |
} | |
}, false); | |
return xhr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment