Skip to content

Instantly share code, notes, and snippets.

@walterdavis
Created January 24, 2015 16:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save walterdavis/00b912cd3ee85aeb99c7 to your computer and use it in GitHub Desktop.
Save walterdavis/00b912cd3ee85aeb99c7 to your computer and use it in GitHub Desktop.
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