Spinners
Summary
Spinners are used for showing a system process of unknown length going on that ends with the system displaying results to the user.
Status
API status: | general |
---|---|
Web resource key: |
com.atlassian.auiplugin:aui-spinner
|
AMD Module key: | N/A |
Experimental API: | 5.1 |
General API: | 5.8 |
Web Component API: | 7.7 |
Examples
Normal spinner
AUI's spinner is just an HTML element. Add it to wherever you need to indicate progress is being made.
Result
Small spinner
Medium spinner
Large spinner
<h5>Small spinner</h5>
<aui-spinner size="small"></aui-spinner>
<h5>Medium spinner</h5>
<aui-spinner size="medium"></aui-spinner>
<h5>Large spinner</h5>
<aui-spinner size="large"></aui-spinner>
Spinners in buttons
Spinners are integrated in to AUI buttons for you.
Result
<button class="aui-button" id="button-spin-1">Do Something</button>
<button class="aui-button aui-button-primary" id="button-spin-2">Do Something</button>
AJS.$(document).on('click', '#button-spin-1, #button-spin-2', function() {
var that = this;
if (!that.isBusy()) {
that.busy();
setTimeout(function() {
that.idle();
}, 2000);
}
});
Spinners in toggles
Spinners are integrated in to AUI toggles.
Result
var form = document.getElementById('wifi-toggle-form');
form.addEventListener('change', function(e) {
var toggle = document.getElementById('wifi-toggle');
var isChecked = toggle.checked; // new value of the toggle
if (isChecked === false) { // do not call server if unchecked
console.log("toggle is unchecked");
return;
}
toggle.busy = true;
$.post('set/my/variable', { value: isChecked })
.done(function () {
console.log('success');
})
.fail(function () {
toggle.checked = !isChecked;
console.error('display an error message');
})
.always(function () {
toggle.busy = false;
});
});
Positioning spinners inside other components
As a discrete HTML element, spinners can be positioned by adding CSS to the spinner's parent element.
Result
Loading results...
<div id="search-area-example" class="custom-card-style">
<p>Loading results...</p>
<aui-spinner size="large"></aui-spinner>
</div>
#search-area-example {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
#search-area-example aui-spinner {
margin: 1em;
}
.custom-card-style {
border-radius: 3px;
box-shadow:
0 1px 1px rgba(9, 30, 66, 0.25),
0 0 1px 0 rgba(9, 30, 66, 0.31);
margin: 0 auto;
padding: 10px;
width: 20em;
}
HTML API
Name | Attribute | Property | Type | Default | Description |
---|---|---|---|---|---|
size |
Enum | medium |
An Enum which provides size of the spinner.
Possible values are: small (20px), medium (30px) and large (50px).
|
||
filled Deprecated |
Boolean | false |
A Boolean which changes behavior of the spinner.
When present, the spinner element will be placed in the middle of the parent element and have a width and height of zero. |
JavaScript API Deprecated
These functions are deprecated and only available via the com.atlassian.auiplugin:jquery-spin
web-resource.
There are two jQuery functions available you can call on an element to add and remove a filled spinner.
Result
<button class="aui-button" id="spinner-trigger">Do Something</button>
<span class="button-spinner" style="display: inline-block; height: 10px; width: 20px"></span>
AJS.$(function() {
var spinning = false;
AJS.$('#spinner-trigger').on('click', function() {
if (!spinning) {
AJS.$(this).text('Stop Spinning!');
AJS.$('.button-spinner').spin();
spinning = true;
} else {
AJS.$(this).text('Do Something');
AJS.$('.button-spinner').spinStop();
spinning = false;
}
});
});
Calling AJS.$(element).spin()
will append the following spinner to element
:
<aui-spinner size="small" filled></aui-spinner>
Calling AJS.$(element).spinStop()
will remove the spinner element.