(function() {
// Customized progressbar extension.
$.widget( "app.progressbar", $.ui.progressbar, {
// Constructor. Check if a "deferred" option was passed.
// If so, setup a proxy handler to the "_notify()" method
// when progress notifications on the deferred take place.
_create: function() {
this._super();
var deferred = this.options.deferred;
if ( deferred ) {
deferred.progress( $.proxy( this, "_notify" ) );
}
},
// This is the deferred.progress() handler. Increment the
// value till the "max" option is reached or exceeded.
_notify: function() {
console.log(this.value());
var value = this.value() || 0,
max = this.options.max;
if ( value >= max ) {
return;
}
this.value( value + 1 );
}
});
$(function() {
// Creates a deferred and a progressbar instance. The deferred
// is passed to the progressbar as an option.
var dfd = new $.Deferred(),
$progressbar = $( "#progressbar" ).progressbar({
deferred: dfd
});
// Bootstrap the update process.
(function() {
function update() {
// Notifying the deferred will increment the
// progressbar value by 1 until complete.
dfd.notify();
setTimeout( update, 100 );
}
setTimeout( update, 3000 );
})();
});
})( jQuery );
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.