contextPath
The AJS.contextPath() function returns the "path" to the application, which is needed when creating
absolute urls within the application.
3.5.5
var url = AJS.contextPath() + "/rest/some/resource";
url = AJS.contextPath() + "/dashboard.action";
dim
Blanket management.
5.4.0
AJS.dim();
setTimeout(function () { AJS.undim(); }, 1000);
undim
Blanket management.
5.4.0
AJS.dim();
setTimeout(function () { AJS.undim(); }, 1000);
format
Provides an easy way to substitute parameters into a string.
5.4.0
console.log(
AJS.format("This is a {0} test of {1}", "simple", "message format")
);
I18n
I18n keys.
5.4.0
// Possible, but AJS.I18n.getText is recommended
console.log(
AJS.I18n.keys['aui.toggle.on']
);
// Gets the i18n value
console.log(
AJS.I18n.getText('aui.toggle.on')
);
// Returns the key
console.log(
AJS.I18n.getText('aui.key.that.does.not.exist')
);
// If there are keys that have {0} params in them, AJS formatting can apply
// Note: don't modify existing entries in AJS.I18N.keys directly, this is
// done for demonstration purposes
AJS.I18n.keys['aui.test'] = 'this is a {0} test';
console.log(
AJS.I18n.getText('aui.test', 'formatting')
);
messages
Messages creation.
5.4.0
AJS.messages.generic({
title: 'This is a title in a default message.',
body: ' And this is just content in a Default message.
'
});
navigation
Used for manipulating navigation. Used in the header, and in the sidebar such as expanding and collapsing.
5.6.0
console.log(AJS.navigation('#sidebar-nav').isCollapsed());
params
Takes meta tags from the page and populates an object with them.
5.4.0
AJS.populateParameters();
console.log(AJS.params);
populateParameters
Takes meta tags from the page and populates an object with them.
5.4.0
AJS.populateParameters();
console.log(AJS.params);
whenIType
Keyboard shortcuts library.
5.4.0
AJS.whenIType('ze').execute(function () {
alert('I have executed.');
});
AJS.whenIType('c').click('#create');
AJS.whenIType('gh').or('gd').goTo('http://example.com/');
AJS.whenIType('n').moveToNextItem('.selector');
AJS.whenIType('p').moveToPrevItem('.selector');
version
Returns the version of AUI.
5.4.0
console.log(AJS.version);
$
jQuery.
5.4.0
console.log(AJS.$.fn.jquery);
banner
Creates a banner for the top of the page.
5.9.0
AJS.banner({
body: 'Your license has expired! There are two days left to renew your license .'
});
dialog2
Constructor for dialog 2.
5.4.0
// Shows the dialog when the "Show dialog" button is clicked
AJS.$("#dialog-show-button").click(function() {
AJS.dialog2("#demo-dialog").show();
});
// Hides the dialog
AJS.$("#dialog-close-button").click(function(e) {
e.preventDefault();
AJS.dialog2("#demo-dialog").hide();
});
// Show event - this is triggered when the dialog is shown
AJS.dialog2("#demo-dialog").on("show", function() {
console.log("demo-dialog was shown");
});
// Hide event - this is triggered when the dialog is hidden
AJS.dialog2("#demo-dialog").on("hide", function() {
console.log("demo-dialog was hidden");
});
// Global show event - this is triggered when any dialog is show
AJS.dialog2.on("show", function() {
console.log("a dialog was shown");
});
// Global hide event - this is triggered when any dialog is hidden
AJS.dialog2.on("hide", function() {
console.log("a dialog was hidden");
});
flag
Creates a flag.
5.7.0
var myFlag = AJS.flag({
type: 'info',
title: 'Issue ADG-745 has been created.',
body: ''
});
formValidation
Utilities for doing form validation.
5.9.0
// Register a plugin validator that ensures an input field must start with a certain sequence of characters.
AJS.formValidation.register(['startswith'], function(field) {
if (field.el.value.indexOf(field.args('startswith')) !== 0){
field.invalidate(AJS.format('Input must start with {0}', field.args('startswith')));
} else {
field.validate();
}
});
progressBars
Utility for handling progress indicators.
5.9.0
AJS.progressBars.update("#some-id", 0.2);
select
Constructor for aui-select . To move to AJS.element.
5.8.0
https://docs.atlassian.com/aui/latest/docs/single-select.html
sidebar
Constructor for the sidebar element.
5.6.0
https://docs.atlassian.com/aui/latest/docs/sidebar.html
tablessortable
Sortable table utility functions.
5.6.0
https://docs.atlassian.com/aui/latest/docs/sortable-table.html
Cookie Deprecated
Store values in a persistent cookie without worrying about the application using too many cookies.
3.5.5
// Save a value to the conglomerate cookie
AJS.Cookie.save("COOKIES_ARE_COOL", "true");
// Save will also update a value previously saved
AJS.Cookie.save("COOKIES_ARE_COOL", "not true");
// retrieve a value from the conglomerate cookie
AJS.Cookie.read("COOKIES_ARE_COOL");
// remove a value from the conglomerate cookie
AJS.Cookie.erase("COOKIES_ARE_COOL");
debounce
Ensure that a constantly firing function doesn't cause performance issues.
Don't use when binding to an infrequently firing event.
5.1
function myFunction() {
//function code
}
// This function won't fire if it has been less than 300ms before the last call
var myDebouncedFunction = AJS.debounce(myFunction, 300);
AJS.$(window).resize(myDebouncedFunction);
debounceImmediate
Like debounce()
, makes sure that a constantly firing function doesn't cause
performance issues, but fires at the start rather than at the end of the wait period.
Don't use when binding to an infrequently firing event.
5.9
function myFunction(){
//function code}
// This function fires immediately and will not fire again until the last call passes 300ms
var myDebouncedFunction = AJS.debounceImmediate(myFunction, 300);
AJS.$(window).resize(myDebouncedFunction);
escapeHTML
The AJS.escapeHtml() performs html-safe escaping of the input string. Specifically, it encodes:
4.0
var url = "\u005C\u003E\u003Cscript\u003Ealert(\u0027XSS\u0027)\u003B\u003C/script\u003E";
// BAD: XSS problem
$("#mydiv").html(url);
// GOOD
$("#mydiv").html(AJS.escapeHtml(url));
format
Provides an easy way to substitute parameters into a string.
1.0
AJS.format("Have a {0} day", "good"); /* Have a good day */
AJS.format("Have a '{0}' day", "good"); /* Have a '{0}' day */
AJS.format("Have a ''{0}'' {1}", "good", "Monday"); /* Have a 'good' Monday */
I18n.getText
AUI includes a web resource transformer that will translate some javascript into the literal strings
before being served.
3.5.5
isDirty
Make sure users cannot accidentally lose data.
2.0
AJS.$("formname=jiraform").isDirty();
log
A safe alternative to console.log()
. It ensures that both console and the console.log
method exist
before executing. This means if you happen to leave one in your code, browsers which don't support
console.log
(eg. IE, some mobile browsers) shouldn't break.
1.0
AJS.log("Your message here.");
version
Detects the version of AUI on the current page.
1.2
// for peace-of-mind checking
AJS.log(AJS.version); // "3.0"
// To use it in all its glory
if (AJS.version == "3.0") {
// take advantage of the awesomeness of AUI 3.0
} else {
// write awesome custom code
}