// incredible buttons
$(function () {
// create the loading-spinner span
if ($(".incredible-button").length) {
$.grep($(".incredible-button"), function (that, n) {
$(that).parent().css("position", "relative");
var spinner = "<span class='loading-spinner' style='width:" + $(that).innerWidth() + "px; margin-left: -" + ($(that).outerWidth() - (($(that).outerWidth() - $(that).innerWidth()) / 2)) + "px'></span>";
$(that).after($(spinner));
});
}
// upon click
$(".incredible-button").bind('click', function () {
// keep the button object
var that = $(this);
// set it to loading mode
$(that).addClass("loading");
// retrieve the loading spinner
var spinner = $(that).next("span.loading-spinner");
if (spinner) {
// show the spinner
$(spinner).addClass("loading");
switch (that.attr("transition")) {
case "slide-right":
var x = (spinner.innerWidth() / 2) - (32 / 2);
$(spinner).animate({
'background-position-x': x + 'px'
}, {
duration: 300
});
break;
default:
break;
}
}
});
});
// function that notifies the button that it has completed the action (and returns it back to normal)
(function ($) {
$.extend($.fn, {
notify: function () {
// check if the item is of the correct type
if ($(this).is("input[type=submit], button")) {
var that = $(this);
// retrieve the loading spinner
var spinner = $(that).next("span.loading-spinner");
if (spinner) {
switch (that.attr("transition")) {
case "slide-right":
...
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.