Created
January 24, 2015 16:39
-
-
Save walterdavis/00b912cd3ee85aeb99c7 to your computer and use it in GitHub Desktop.
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
document.on('click', 'input[name="commit"]', function(evt, elm){ | |
var f = elm.up('form'); | |
fake_progress = new Element('div', {className: 'progress progress-striped active', style: 'width: 100%; clear:both'}); | |
f.insert({before: fake_progress}); | |
var bar = new Element('div', {className: 'bar'}); | |
fake_progress.insert(bar); | |
bar.setStyle('width: 2%'); | |
var rnd = 0.2 | |
function add_random(){ | |
rnd = Math.random(); | |
var now = parseFloat(bar.getStyle('width')); | |
var w = now + ((100 - now) * rnd) / 40; | |
bar.setStyle('width: ' + w.toString() + '%'); | |
if(now < 100) setTimeout(add_random, (rnd * 1000)); | |
} | |
setTimeout(add_random, (rnd * 1000)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment