@atlassian/aui
Version:
Atlassian User Interface Framework
1,482 lines (1,181 loc) • 596 kB
JavaScript
/*!!
* @atlassian/aui - Atlassian User Interface Framework
* @version v7.8.1
* @link https://docs.atlassian.com/aui/latest/
* @license SEE LICENSE IN LICENSE.md
* @author Atlassian Pty Ltd.
*/
// src/js/aui/polyfills/placeholder.js
(typeof window === 'undefined' ? global : window).__e45fc101c358af7928e5302ca870d102 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
var _skate = __d4d9c8b9c18aa127f23573b1dd4281f7;
var _skate2 = _interopRequireDefault(_skate);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
(function () {
if ('placeholder' in document.createElement('input')) {
return;
}
function applyDefaultText(input) {
var value = String(input.value).trim();
if (!value.length) {
input.value = input.getAttribute('placeholder');
(0, _jquery2.default)(input).addClass('aui-placeholder-shown');
}
}
(0, _skate2.default)('placeholder', {
type: _skate2.default.type.ATTRIBUTE,
events: {
blur: applyDefaultText,
focus: function focus(input) {
if (input.value === input.getAttribute('placeholder')) {
input.value = '';
(0, _jquery2.default)(input).removeClass('aui-placeholder-shown');
}
}
},
created: applyDefaultText
});
})();
return module.exports;
}).call(this);
// src/js/aui/banner.js
(typeof window === 'undefined' ? global : window).__91b5ab420bb3c415092c5a6c80dc6d7c = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
var _animation = __fc1c39a44b973188070a6067fff915f5;
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _globalize = __72a5ad586a97d712f1f222cf9b461386;
var _globalize2 = _interopRequireDefault(_globalize);
var _template = __e22d738deddf918670ff98bd94a429ea;
var _template2 = _interopRequireDefault(_template);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var ID_BANNER_CONTAINER = 'header';
function banner(options) {
var $banner = renderBannerElement(options);
pruneBannerContainer();
insertBanner($banner);
return $banner[0];
}
function renderBannerElement(options) {
var html = '<div class="aui-banner aui-banner-{type}" role="banner">' + '{body}' + '</div>';
var $banner = (0, _jquery2.default)((0, _template2.default)(html).fill({
'type': 'error',
'body:html': options.body || ''
}).toString());
return $banner;
}
function pruneBannerContainer() {
var $container = findContainer();
var $allBanners = $container.find('.aui-banner');
$allBanners.get().forEach(function (banner) {
var isBannerAriaHidden = banner.getAttribute('aria-hidden') === 'true';
if (isBannerAriaHidden) {
(0, _jquery2.default)(banner).remove();
}
});
}
function findContainer() {
return (0, _jquery2.default)('#' + ID_BANNER_CONTAINER);
}
function insertBanner($banner) {
var $bannerContainer = findContainer();
if (!$bannerContainer.length) {
throw new Error('You must implement the application header');
}
$banner.prependTo($bannerContainer);
(0, _animation.recomputeStyle)($banner);
$banner.attr('aria-hidden', 'false');
}
(0, _amdify2.default)('aui/banner', banner);
(0, _globalize2.default)('banner', banner);
exports.default = banner;
module.exports = exports['default'];
return module.exports;
}).call(this);
// src/js/aui/button.js
(typeof window === 'undefined' ? global : window).__b2ab8c5096a6cfc713c5fb368c8af70c = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
var _log = __bdf9202e1b2493b75532363403577f4b;
var logger = _interopRequireWildcard(_log);
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _skate = __d4d9c8b9c18aa127f23573b1dd4281f7;
var _skate2 = _interopRequireDefault(_skate);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _isBusy(button) {
return button.hasAttribute('aria-busy') && button.getAttribute('aria-busy') === 'true';
}
function isInputNode(button) {
return button.nodeName === 'INPUT';
}
(0, _skate2.default)('aui-button', {
type: _skate2.default.type.CLASSNAME,
prototype: {
/**
* Adds a spinner to the button and hides the text
*
* @returns {HTMLElement}
*/
busy: function busy() {
if (isInputNode(this) || _isBusy(this)) {
logger.warn('It is not valid to call busy() on an input button.');
return this;
}
(0, _jquery2.default)(this).spin();
this.setAttribute('aria-busy', true);
this.setAttribute('busy', '');
return this;
},
/**
* Removes the spinner and shows the tick on the button
*
* @returns {HTMLElement}
*/
idle: function idle() {
if (isInputNode(this) || !_isBusy(this)) {
logger.warn('It is not valid to call idle() on an input button.');
return this;
}
(0, _jquery2.default)(this).spinStop();
this.removeAttribute('aria-busy');
this.removeAttribute('busy');
return this;
},
/**
* Removes the spinner and shows the tick on the button
*
* @returns {Boolean}
*/
isBusy: function isBusy() {
if (isInputNode(this)) {
logger.warn('It is not valid to call isBusy() on an input button.');
return false;
}
return _isBusy(this);
}
}
});
(0, _amdify2.default)('aui/button');
return module.exports;
}).call(this);
// src/js-vendor/jquery/jquery.tipsy.js
(typeof window === 'undefined' ? global : window).__5e10735e2638fc9cd5319de10c8b691d = (function () {
var module = {
exports: {}
};
var exports = module.exports;
// tipsy, facebook style tooltips for jquery
// version 1.0.0a
// (c) 2008-2010 jason frame [jason@onehackoranother.com]
// released under the MIT license
//
// Modified by Atlassian
// https://github.com/atlassian/tipsy/tree/9095e37c7570c14acf0dbf040bb2466a0e2f23d4
(function($) {
function maybeCall(thing, ctx) {
return (typeof thing == 'function') ? (thing.call(ctx)) : thing;
};
function isElementInDOM(ele) {
while (ele = ele.parentNode) {
if (ele == document) return true;
}
return false;
};
var tipsyIDcounter = 0;
function tipsyID() {
var tipsyID = tipsyIDcounter++;
return "tipsyuid" + tipsyID;
};
function Tipsy(element, options) {
this.$element = $(element);
this.options = options;
this.enabled = true;
this.fixTitle();
};
Tipsy.prototype = {
show: function() {
// if element is not in the DOM then don't show the Tipsy and return early
if (!isElementInDOM(this.$element[0])) {
return;
}
var title = this.getTitle();
if (title && this.enabled) {
var $tip = this.tip();
$tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title);
$tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity
$tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
var that = this;
function tipOver() {
that.hoverTooltip = true;
}
function tipOut() {
if (that.hoverState == 'in') return; // If field is still focused.
that.hoverTooltip = false;
if (that.options.trigger != 'manual') {
var eventOut = that.options.trigger == 'hover' ? 'mouseleave.tipsy' : 'blur.tipsy';
that.$element.trigger(eventOut);
}
}
if (this.options.hoverable) {
$tip.hover(tipOver, tipOut);
}
if (this.options.className) {
$tip.addClass(maybeCall(this.options.className, this.$element[0]));
}
var pos = $.extend({}, this.$element.offset(), {
width: this.$element[0].getBoundingClientRect().width,
height: this.$element[0].getBoundingClientRect().height
});
var tipCss = {};
var actualWidth = $tip[0].offsetWidth,
actualHeight = $tip[0].offsetHeight;
var gravity = maybeCall(this.options.gravity, this.$element[0]);
if (gravity.length === 2) {
if (gravity.charAt(1) === 'w') {
tipCss.left = pos.left + pos.width / 2 - 15;
} else {
tipCss.left = pos.left + pos.width / 2 - actualWidth + 15;
}
}
switch (gravity.charAt(0)) {
case 'n':
// left could already be set if gravity is 'nw' or 'ne'
if (typeof tipCss.left === 'undefined') {
tipCss.left = pos.left + pos.width / 2 - actualWidth / 2;
}
tipCss.top = pos.top + pos.height + this.options.offset;
break;
case 's':
// left could already be set if gravity is 'sw' or 'se'
if (typeof tipCss.left === 'undefined') {
tipCss.left = pos.left + pos.width / 2 - actualWidth / 2;
// We need to apply the left positioning and then recalculate the tooltip height
// If the tooltip is positioned close to the right edge of the window, it could cause
// the tooltip text to overflow and change height.
$tip.css(tipCss);
actualHeight = $tip[0].offsetHeight;
}
tipCss.top = pos.top - actualHeight - this.options.offset;
break;
case 'e':
tipCss.left = pos.left - actualWidth - this.options.offset;
tipCss.top = pos.top + pos.height / 2 - actualHeight / 2;
break;
case 'w':
tipCss.left = pos.left + pos.width + this.options.offset;
tipCss.top = pos.top + pos.height / 2 - actualHeight / 2;
break;
}
$tip.css(tipCss).addClass('tipsy-' + gravity);
$tip.find('.tipsy-arrow')[0].className = 'tipsy-arrow tipsy-arrow-' + gravity.charAt(0);
if (this.options.fade) {
$tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity});
} else {
$tip.css({visibility: 'visible', opacity: this.options.opacity});
}
if (this.options.aria) {
var $tipID = tipsyID();
$tip.attr("id", $tipID);
this.$element.attr("aria-describedby", $tipID);
}
}
},
destroy: function(){
this.$element.removeData('tipsy');
this.unbindHandlers();
this.hide();
},
unbindHandlers: function() {
if(this.options.live){
$(this.$element.context).off('.tipsy');
} else {
this.$element.unbind('.tipsy');
}
},
hide: function() {
if (this.options.fade) {
this.tip().stop().fadeOut(function() { $(this).remove(); });
} else {
this.tip().remove();
}
if (this.options.aria) {
this.$element.removeAttr("aria-describedby");
}
},
fixTitle: function() {
var $e = this.$element;
if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') {
$e.attr('original-title', $e.attr('title') || '').removeAttr('title');
}
},
getTitle: function() {
var title, $e = this.$element, o = this.options;
this.fixTitle();
var title, o = this.options;
if (typeof o.title == 'string') {
title = $e.attr(o.title == 'title' ? 'original-title' : o.title);
} else if (typeof o.title == 'function') {
title = o.title.call($e[0]);
}
title = ('' + title).replace(/(^\s*|\s*$)/, "");
return title || o.fallback;
},
tip: function() {
if (!this.$tip) {
this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>').attr("role","tooltip");
this.$tip.data('tipsy-pointee', this.$element[0]);
}
return this.$tip;
},
validate: function() {
if (!this.$element[0].parentNode) {
this.hide();
this.$element = null;
this.options = null;
}
},
enable: function() { this.enabled = true; },
disable: function() { this.enabled = false; },
toggleEnabled: function() { this.enabled = !this.enabled; }
};
$.fn.tipsy = function(options) {
if (options === true) {
return this.data('tipsy');
} else if (typeof options == 'string') {
var tipsy = this.data('tipsy');
if (tipsy) tipsy[options]();
return this;
}
options = $.extend({}, $.fn.tipsy.defaults, options);
if (options.hoverable) {
options.delayOut = options.delayOut || 20;
}
function get(ele) {
var tipsy = $.data(ele, 'tipsy');
if (!tipsy) {
tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options));
$.data(ele, 'tipsy', tipsy);
}
return tipsy;
}
function enter() {
var tipsy = get(this);
tipsy.hoverState = 'in';
if (options.delayIn == 0) {
tipsy.show();
} else {
tipsy.fixTitle();
setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn);
}
};
function leave() {
var tipsy = get(this);
tipsy.hoverState = 'out';
if (options.delayOut == 0) {
tipsy.hide();
} else {
setTimeout(function() { if (tipsy.hoverState == 'out' && !tipsy.hoverTooltip) tipsy.hide(); }, options.delayOut);
}
};
if (!options.live) this.each(function() { get(this); });
if (options.trigger != 'manual') {
var eventIn = options.trigger == 'hover' ? 'mouseenter.tipsy focus.tipsy' : 'focus.tipsy',
eventOut = options.trigger == 'hover' ? 'mouseleave.tipsy blur.tipsy' : 'blur.tipsy';
if (options.live) {
$(this.context).on(eventIn, this.selector, enter).on(eventOut, this.selector, leave);
} else {
this.bind(eventIn, enter).bind(eventOut, leave);
}
}
return this;
};
$.fn.tipsy.defaults = {
aria: false,
className: null,
delayIn: 0,
delayOut: 0,
fade: false,
fallback: '',
gravity: 'n',
html: false,
live: false,
hoverable: false,
offset: 0,
opacity: 0.8,
title: 'title',
trigger: 'hover'
};
$.fn.tipsy.revalidate = function() {
$('.tipsy').each(function() {
var pointee = $.data(this, 'tipsy-pointee');
if (!pointee || !isElementInDOM(pointee)) {
$(this).remove();
}
});
};
// Overwrite this method to provide options on a per-element basis.
// For example, you could store the gravity in a 'tipsy-gravity' attribute:
// return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
// (remember - do not modify 'options' in place!)
$.fn.tipsy.elementOptions = function(ele, options) {
return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
};
$.fn.tipsy.autoNS = function() {
return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
};
$.fn.tipsy.autoWE = function() {
return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
};
/**
* yields a closure of the supplied parameters, producing a function that takes
* no arguments and is suitable for use as an autogravity function like so:
*
* @param margin (int) - distance from the viewable region edge that an
* element should be before setting its tooltip's gravity to be away
* from that edge.
* @param prefer (string, e.g. 'n', 'sw', 'w') - the direction to prefer
* if there are no viewable region edges effecting the tooltip's
* gravity. It will try to vary from this minimally, for example,
* if 'sw' is preferred and an element is near the right viewable
* region edge, but not the top edge, it will set the gravity for
* that element's tooltip to be 'se', preserving the southern
* component.
*/
$.fn.tipsy.autoBounds = function(margin, prefer) {
return function() {
var dir = {ns: prefer[0], ew: (prefer.length > 1 ? prefer[1] : false)},
boundTop = $(document).scrollTop() + margin,
boundLeft = $(document).scrollLeft() + margin,
$this = $(this);
if ($this.offset().top < boundTop) dir.ns = 'n';
if ($this.offset().left < boundLeft) dir.ew = 'w';
if ($(window).width() + $(document).scrollLeft() - $this.offset().left < margin) dir.ew = 'e';
if ($(window).height() + $(document).scrollTop() - $this.offset().top < margin) dir.ns = 's';
return dir.ns + (dir.ew ? dir.ew : '');
}
};
})(jQuery);
return module.exports;
}).call(this);
// src/js/aui/tooltip.js
(typeof window === 'undefined' ? global : window).__5dd1783cdd47fd0755eaf3e6b8f17f00 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
__5e10735e2638fc9cd5319de10c8b691d;
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function handleStringOption($self, options, stringOption) {
// Pass string values straight to tipsy
$self.tipsy(stringOption);
if (stringOption === 'destroy') {
if (options.live) {
(0, _jquery2.default)($self.context).off('.tipsy', $self.selector);
} else {
$self.unbind('.tipsy');
}
}
return $self;
}
function bindTooltip($self, options) {
$self.tipsy(options);
var hideOnClick = options && options.hideOnClick && (options.trigger === 'hover' || !options.trigger && $self.tipsy.defaults.trigger === 'hover');
if (hideOnClick) {
var onClick = function onClick() {
(0, _jquery2.default)(this).tipsy('hide');
};
if (options.live) {
(0, _jquery2.default)($self.context).on('click.tipsy', $self.selector, onClick);
} else {
$self.bind('click.tipsy', onClick);
}
}
return $self;
}
_jquery2.default.fn.tooltip = function (options) {
var allOptions = _jquery2.default.extend({}, _jquery2.default.fn.tooltip.defaults, options);
// Handle live option
if (allOptions.live) {
if (typeof options === 'string') {
handleStringOption(this, allOptions, options);
} else {
bindTooltip(this, allOptions);
}
return this;
}
// If not live, bind each object in the collection
return this.each(function () {
var $this = (0, _jquery2.default)(this);
if (typeof options === 'string') {
handleStringOption($this, allOptions, options);
} else {
bindTooltip($this, allOptions);
}
return $this;
});
};
_jquery2.default.fn.tooltip.defaults = {
opacity: 1.0,
offset: 1,
delayIn: 500,
hoverable: true,
hideOnClick: true,
aria: true
};
return module.exports;
}).call(this);
// src/js/aui/checkbox-multiselect.js
(typeof window === 'undefined' ? global : window).__d18fe4615a1089ddc50a16349fb8d176 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
__148da6684d5c9a4db33ee35843e9daca;
__5dd1783cdd47fd0755eaf3e6b8f17f00;
__2150d50df55ec10bd8aaa26b0403c771;
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _skate = __d4d9c8b9c18aa127f23573b1dd4281f7;
var _skate2 = _interopRequireDefault(_skate);
var _uniqueId = __ad4db044f2c6d56be3a86035fab2c25e;
var _uniqueId2 = _interopRequireDefault(_uniqueId);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var templates = {
dropdown: function dropdown(items) {
function createSection() {
return (0, _jquery2.default)('<div class="aui-dropdown2-section">');
}
// clear items section
var $clearItemsSection = createSection();
(0, _jquery2.default)('<button />').attr({
type: 'button',
'data-aui-checkbox-multiselect-clear': '',
class: 'aui-button aui-button-link'
}).text(AJS.I18n.getText('aui.checkboxmultiselect.clear.selected')).appendTo($clearItemsSection);
// list of items
var $section = createSection();
var $itemList = (0, _jquery2.default)('<ul />').appendTo($section);
_jquery2.default.each(items, function (idx, item) {
var $li = (0, _jquery2.default)('<li />').attr({
class: item.styleClass || ''
}).appendTo($itemList);
var $a = (0, _jquery2.default)('<a />').text(item.label).attr('data-value', item.value).addClass('aui-dropdown2-checkbox aui-dropdown2-interactive').appendTo($li);
if (item.icon) {
(0, _jquery2.default)('<span />').addClass('aui-icon').css('backgroundImage', 'url(' + item.icon + ')")').appendTo($a);
}
if (item.selected) {
$a.addClass('aui-dropdown2-checked');
}
});
return (0, _jquery2.default)('<div />').append($clearItemsSection).append($section).html();
},
furniture: function furniture(name, optionsHtml) {
var dropdownId = name + '-dropdown';
var $select = (0, _jquery2.default)('<select />').attr({
name: name,
multiple: 'multiple'
}).html(optionsHtml);
var $dropdown = (0, _jquery2.default)('<div>').attr({
id: dropdownId,
class: 'aui-checkbox-multiselect-dropdown aui-dropdown2 aui-style-default'
});
var $button = (0, _jquery2.default)('<button />').attr({
class: 'aui-checkbox-multiselect-btn aui-button aui-dropdown2-trigger',
type: 'button',
'aria-owns': dropdownId,
'aria-haspopup': true
});
return (0, _jquery2.default)('<div />').append($select).append($button).append($dropdown).html();
}
};
/**
* Handles when user clicks an item in the dropdown list. Either selects or unselects the corresponding
* option in the <select>.
* @private
*/
function handleDropdownSelection(e) {
var $a = (0, _jquery2.default)(e.target);
var value = $a.attr('data-value');
updateOption(this, value, $a.hasClass('aui-dropdown2-checked'));
}
/**
* Selects or unselects the <option> corresponding the given value.
* @private
* @param component - Checkbox MultiSelect web component
* @param value - value of option to update
* @param {Boolean} selected - select or unselect it.
*/
function updateOption(component, value, selected) {
var $toUpdate = component.$select.find('option').filter(function () {
var $this = (0, _jquery2.default)(this);
return $this.attr('value') === value && $this.prop('selected') !== selected;
});
if ($toUpdate.length) {
$toUpdate.prop('selected', selected);
component.$select.trigger('change');
}
}
/**
* Enables 'clear all' button if there are any selected <option>s, otherwise disables it.
* @private
*/
function updateClearAll(component) {
component.$dropdown.find('[data-aui-checkbox-multiselect-clear]').prop('disabled', function () {
return getSelectedDescriptors(component).length < 1;
});
}
/**
* Gets button title used for tipsy. Is blank when dropdown is open so we don't get tipsy hanging over options.
* @private
* @param component
* @returns {string}
*/
function getButtonTitle(component) {
return component.$dropdown.is('[aria-hidden=false]') ? '' : getSelectedLabels(component).join(', ');
}
/**
* Converts a jQuery collection of <option> elements into an object that describes them.
* @param {jQuery} $options
* @returns {Array<Object>}
* @private
*/
function mapOptionDescriptors($options) {
return $options.map(function () {
var $option = (0, _jquery2.default)(this);
return {
value: $option.val(),
label: $option.text(),
icon: $option.data('icon'),
styleClass: $option.data('styleClass'),
title: $option.attr('title'),
disabled: $option.attr('disabled'),
selected: $option.prop('selected')
};
});
}
/**
* Gets label for when nothing is selected
* @returns {string}
* @private
*/
function getImplicitAllLabel(component) {
return (0, _jquery2.default)(component).data('allLabel') || 'All';
}
/**
* Renders dropdown with list of items representing the selected or unselect state of the <option>s in <select>
* @private
*/
function renderDropdown(component) {
component.$dropdown.html(templates.dropdown(getDescriptors(component)));
updateClearAll(component);
}
/**
* Renders button with the selected <option>'s innerText in a comma seperated list. If nothing is selected 'All'
* is displayed.
* @private
*/
function renderButton(component) {
var selectedLabels = getSelectedLabels(component);
var label = isImplicitAll(component) ? getImplicitAllLabel(component) : selectedLabels.join(', ');
component.$btn.text(label);
}
/**
* Gets descriptor for selected options, the descriptor is an object that contains meta information about
* the option, such as value, label, icon etc.
* @private
* @returns Array<Object>
*/
function getDescriptors(component) {
return mapOptionDescriptors(component.getOptions());
}
/**
* Gets descriptor for selected options, the descriptor is an object that contains meta information about
* the option, such as value, label, icon etc.
* @private
* @returns Array<Object>
*/
function getSelectedDescriptors(component) {
return mapOptionDescriptors(component.getSelectedOptions());
}
/**
* Gets the innerText of the selected options
* @private
* @returns Array<String>
*/
function getSelectedLabels(component) {
return _jquery2.default.map(getSelectedDescriptors(component), function (descriptor) {
return descriptor.label;
});
}
/**
* If nothing is selected, we take this to mean that everything is selected.
* @returns Boolean
*/
function isImplicitAll(component) {
return getSelectedDescriptors(component).length === 0;
}
var checkboxMultiselect = (0, _skate2.default)('aui-checkbox-multiselect', {
attached: function attached(component) {
// This used to be template logic, however, it breaks tests if we
// keep it there after starting to use native custom elements. This
// should be refactored.
//
// Ideally we should be templating the element within the "template"
// hook which will ensure it's templated prior to calling the
// "attached" callback.
var name = component.getAttribute('name') || (0, _uniqueId2.default)('aui-checkbox-multiselect-');
component.innerHTML = templates.furniture(name, component.innerHTML);
component.$select = (0, _jquery2.default)('select', component).change(function () {
renderButton(component);
updateClearAll(component);
});
component.$dropdown = (0, _jquery2.default)('.aui-checkbox-multiselect-dropdown', component).on('aui-dropdown2-item-check', handleDropdownSelection.bind(component)).on('aui-dropdown2-item-uncheck', handleDropdownSelection.bind(component)).on('click', 'button[data-aui-checkbox-multiselect-clear]', component.deselectAllOptions.bind(component));
component.$btn = (0, _jquery2.default)('.aui-checkbox-multiselect-btn', component).tooltip({
title: function title() {
return getButtonTitle(component);
}
});
renderButton(component);
renderDropdown(component);
},
prototype: {
/**
* Gets all options regardless of selected or unselected
* @returns {jQuery}
*/
getOptions: function getOptions() {
return this.$select.find('option');
},
/**
* Gets all selected options
* @returns {jQuery}
*/
getSelectedOptions: function getSelectedOptions() {
return this.$select.find('option:selected');
},
/**
* Sets <option> elements matching given value to selected
*/
selectOption: function selectOption(value) {
updateOption(this, value, true);
},
/**
* Sets <option> elements matching given value to unselected
*/
unselectOption: function unselectOption(value) {
updateOption(this, value, false);
},
/**
* Gets value of <select>
* @returns Array
*/
getValue: function getValue() {
return this.$select.val();
},
/**
* Unchecks all items in the dropdown and in the <select>
*/
deselectAllOptions: function deselectAllOptions() {
this.$select.val([]).trigger('change');
this.$dropdown.find('.aui-dropdown2-checked,.checked').removeClass('aui-dropdown2-checked checked');
},
/**
* Adds an option to the <select>
* @param descriptor
*/
addOption: function addOption(descriptor) {
(0, _jquery2.default)('<option />').attr({
value: descriptor.value,
icon: descriptor.icon,
disabled: descriptor.disabled,
selected: descriptor.selected,
title: descriptor.title
}).text(descriptor.label).appendTo(this.$select);
renderButton(this);
renderDropdown(this);
},
/**
* Removes options matching value from <select>
* @param value
*/
removeOption: function removeOption(value) {
this.$select.find("[value='" + value + "']").remove();
renderButton(this);
renderDropdown(this);
}
}
});
(0, _amdify2.default)('aui/checkbox-multiselect');
exports.default = checkboxMultiselect;
module.exports = exports['default'];
return module.exports;
}).call(this);
// src/js/aui/dialog2.js
(typeof window === 'undefined' ? global : window).__9fc6e066b6b4073e13bab373277d7d8e = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _globalize = __72a5ad586a97d712f1f222cf9b461386;
var _globalize2 = _interopRequireDefault(_globalize);
var _layer = __41b1ad31166d577ea97458b608b80510;
var _layer2 = _interopRequireDefault(_layer);
var _widget = __7cb8c37042851f7ef83b5cd4140181de;
var _widget2 = _interopRequireDefault(_widget);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var defaults = {
'aui-focus': 'false', // do not focus by default as it's overridden below
'aui-blanketed': 'true'
};
function applyDefaults($el) {
_jquery2.default.each(defaults, function (key, value) {
var dataKey = 'data-' + key;
if (!$el[0].hasAttribute(dataKey)) {
$el.attr(dataKey, value);
}
});
}
function Dialog2(selector) {
if (selector) {
this.$el = (0, _jquery2.default)(selector);
} else {
this.$el = (0, _jquery2.default)(aui.dialog.dialog2({}));
}
applyDefaults(this.$el);
}
Dialog2.prototype.on = function (event, fn) {
(0, _layer2.default)(this.$el).on(event, fn);
return this;
};
Dialog2.prototype.off = function (event, fn) {
(0, _layer2.default)(this.$el).off(event, fn);
return this;
};
Dialog2.prototype.show = function () {
(0, _layer2.default)(this.$el).show();
return this;
};
Dialog2.prototype.hide = function () {
(0, _layer2.default)(this.$el).hide();
return this;
};
Dialog2.prototype.remove = function () {
(0, _layer2.default)(this.$el).remove();
return this;
};
Dialog2.prototype.isVisible = function () {
return (0, _layer2.default)(this.$el).isVisible();
};
var dialog2Widget = (0, _widget2.default)('dialog2', Dialog2);
dialog2Widget.on = function (eventName, fn) {
_layer2.default.on(eventName, '.aui-dialog2', fn);
return this;
};
dialog2Widget.off = function (eventName, fn) {
_layer2.default.off(eventName, '.aui-dialog2', fn);
return this;
};
/* Live events */
(0, _jquery2.default)(document).on('click', '.aui-dialog2-header-close', function (e) {
e.preventDefault();
dialog2Widget((0, _jquery2.default)(this).closest('.aui-dialog2')).hide();
});
dialog2Widget.on('show', function (e, $el) {
var selectors = ['.aui-dialog2-content', '.aui-dialog2-footer', '.aui-dialog2-header'];
var $selected;
selectors.some(function (selector) {
$selected = $el.find(selector + ' :aui-tabbable');
return $selected.length;
});
$selected && $selected.first().focus();
});
dialog2Widget.on('hide', function (e, $el) {
var layer = (0, _layer2.default)($el);
if ($el.data('aui-remove-on-hide')) {
layer.remove();
}
});
(0, _amdify2.default)('aui/dialog2', dialog2Widget);
(0, _globalize2.default)('dialog2', dialog2Widget);
exports.default = dialog2Widget;
module.exports = exports['default'];
return module.exports;
}).call(this);
// src/js/aui/expander.js
(typeof window === 'undefined' ? global : window).__2efcbf8eb7a482f9535c1601e4ca8e88 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var $document = (0, _jquery2.default)(document);
//convenience function because this needs to be run for all the events.
var getExpanderProperties = function getExpanderProperties(event) {
var properties = {};
properties.$trigger = (0, _jquery2.default)(event.currentTarget);
properties.$content = $document.find('#' + properties.$trigger.attr('aria-controls'));
properties.triggerIsParent = properties.$content.parent().filter(properties.$trigger).length !== 0;
properties.$shortContent = properties.triggerIsParent ? properties.$trigger.find('.aui-expander-short-content') : null;
properties.height = properties.$content.css('min-height');
properties.isCollapsible = properties.$trigger.data('collapsible') !== false;
properties.replaceText = properties.$trigger.attr('data-replace-text'); //can't use .data here because it doesn't update after the first call
properties.replaceSelector = properties.$trigger.data('replace-selector');
return properties;
};
var replaceText = function replaceText(properties) {
if (properties.replaceText) {
var $replaceElement = properties.replaceSelector ? properties.$trigger.find(properties.replaceSelector) : properties.$trigger;
properties.$trigger.attr('data-replace-text', $replaceElement.text());
$replaceElement.text(properties.replaceText);
}
};
//events that the expander listens to
var EXPANDER_EVENTS = {
'aui-expander-invoke': function auiExpanderInvoke(event) {
var $trigger = (0, _jquery2.default)(event.currentTarget);
var $content = $document.find('#' + $trigger.attr('aria-controls'));
var isCollapsible = $trigger.data('collapsible') !== false;
//determine if content should be expanded or collapsed
if ($content.attr('aria-expanded') === 'true' && isCollapsible) {
$trigger.trigger('aui-expander-collapse');
} else {
$trigger.trigger('aui-expander-expand');
}
},
'aui-expander-expand': function auiExpanderExpand(event) {
var properties = getExpanderProperties(event);
// If the expander is already expanded, do nothing.
if (properties.$content.attr('aria-expanded') === 'true') {
return;
}
properties.$content.attr('aria-expanded', 'true');
properties.$trigger.attr('aria-expanded', 'true');
if (properties.$content.outerHeight() > 0) {
properties.$content.attr('aria-hidden', 'false');
}
//handle replace text
replaceText(properties);
//if the trigger is the parent also hide the short-content (default)
if (properties.triggerIsParent) {
properties.$shortContent.hide();
}
properties.$trigger.trigger('aui-expander-expanded');
},
'aui-expander-collapse': function auiExpanderCollapse(event) {
var properties = getExpanderProperties(event);
// If the expander is already collapsed, do nothing.
if (properties.$content.attr('aria-expanded') !== 'true') {
return;
}
//handle replace text
replaceText(properties);
//collapse the expander
properties.$content.attr('aria-expanded', 'false');
properties.$trigger.attr('aria-expanded', 'false');
//if the trigger is the parent also hide the short-content (default)
if (properties.triggerIsParent) {
properties.$shortContent.show();
}
//handle the height option
if (properties.$content.outerHeight() === 0) {
properties.$content.attr('aria-hidden', 'true');
}
properties.$trigger.trigger('aui-expander-collapsed');
},
'click.aui-expander': function clickAuiExpander(event) {
var $target = (0, _jquery2.default)(event.currentTarget);
$target.trigger('aui-expander-invoke', event.currentTarget);
}
};
//delegate events to the triggers on the page
$document.on(EXPANDER_EVENTS, '.aui-expander-trigger');
return module.exports;
}).call(this);
// src/js/aui/flag.js
(typeof window === 'undefined' ? global : window).__b727ab91a318815ce9083a695580c2c8 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
var _animation = __fc1c39a44b973188070a6067fff915f5;
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _globalize = __72a5ad586a97d712f1f222cf9b461386;
var _globalize2 = _interopRequireDefault(_globalize);
var _keyCode = __4bfccaeabc98ece1d9093bf6f637e351;
var _keyCode2 = _interopRequireDefault(_keyCode);
var _template = __e22d738deddf918670ff98bd94a429ea;
var _template2 = _interopRequireDefault(_template);
var _customEvent = __cd2b62d4ca4c264c6c16e73e1b299232;
var _customEvent2 = _interopRequireDefault(_customEvent);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var AUTO_CLOSE_TIME = 5000;
var ID_FLAG_CONTAINER = 'aui-flag-container';
var defaultOptions = {
body: '',
close: 'manual',
title: '',
type: 'info'
};
function flag(options) {
options = _jquery2.default.extend({}, defaultOptions, options);
var $flag = renderFlagElement(options);
extendFlagElement($flag);
if (options.close === 'auto') {
makeCloseable($flag);
makeAutoClosable($flag);
} else if (options.close === 'manual') {
makeCloseable($flag);
}
pruneFlagContainer();
return insertFlag($flag);
}
function extendFlagElement($flag) {
var flag = $flag[0];
flag.close = function () {
closeFlag($flag);
};
}
function renderFlagElement(options) {
var html = '<div class="aui-flag">' + '<div class="aui-message aui-message-{type} {type} {closeable} shadowed">' + '<p class="title">' + '<strong>{title}</strong>' + '</p>' + '{body}<!-- .aui-message -->' + '</div>' + '</div>';
var rendered = (0, _template2.default)(html).fill({
'body:html': options.body || '',
closeable: options.close === 'never' ? '' : 'closeable',
title: options.title || '',
type: options.type
}).toString();
return (0, _jquery2.default)(rendered);
}
function makeCloseable($flag) {
var $icon = (0, _jquery2.default)('<span class="aui-icon icon-close" role="button" tabindex="0"></span>');
$icon.click(function () {
closeFlag($flag);
});
$icon.keypress(function (e) {
if (e.which === _keyCode2.default.ENTER || e.which === _keyCode2.default.SPACE) {
closeFlag($flag);
e.preventDefault();
}
});
return $flag.find('.aui-message').append($icon)[0];
}
function makeAutoClosable($flag) {
$flag.find('.aui-message').addClass('aui-will-close');
setTimeout(function () {
$flag[0].close();
}, AUTO_CLOSE_TIME);
}
function closeFlag($flagToClose) {
var flag = $flagToClose.get(0);
flag.setAttribute('aria-hidden', 'true');
flag.dispatchEvent(new _customEvent2.default('aui-flag-close', { bubbles: true }));
return flag;
}
function pruneFlagContainer() {
var $container = findContainer();
var $allFlags = $container.find('.aui-flag');
$allFlags.get().forEach(function (flag) {
var isFlagAriaHidden = flag.getAttribute('aria-hidden') === 'true';
if (isFlagAriaHidden) {
(0, _jquery2.default)(flag).remove();
}
});
}
function findContainer() {
return (0, _jquery2.default)('#' + ID_FLAG_CONTAINER);
}
function insertFlag($flag) {
var $flagContainer = findContainer();
if (!$flagContainer.length) {
$flagContainer = (0, _jquery2.default)('<div id="' + ID_FLAG_CONTAINER + '"></div>');
(0, _jquery2.default)('body').prepend($flagContainer);
}
$flag.appendTo($flagContainer);
(0, _animation.recomputeStyle)($flag);
return $flag.attr('aria-hidden', 'false')[0];
}
(0, _amdify2.default)('aui/flag', flag);
(0, _globalize2.default)('flag', flag);
exports.default = flag;
module.exports = exports['default'];
return module.exports;
}).call(this);
// src/js/aui/form-notification.js
(typeof window === 'undefined' ? global : window).__de47ee8d82c453b7e83140229bf02c02 = (function () {
var module = {
exports: {}
};
var exports = module.exports;
'use strict';
var _jquery = __078f1f0dae379d17d70c51baf1a7fc2e;
var _jquery2 = _interopRequireDefault(_jquery);
__5e10735e2638fc9cd5319de10c8b691d;
var _log = __bdf9202e1b2493b75532363403577f4b;
var logger = _interopRequireWildcard(_log);
var _amdify = __c22195cc5d37225b372c9a8af628fc78;
var _amdify2 = _interopRequireDefault(_amdify);
var _keyCode = __4bfccaeabc98ece1d9093bf6f637e351;
var _keyCode2 = _interopRequireDefault(_keyCode);
var _skate = __d4d9c8b9c18aa127f23573b1dd4281f7;
var _skate2 = _interopRequireDefault(_skate);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var NOTIFICATION_NAMESPACE = 'aui-form-notification';
var CLASS_NOTIFICATION_INITIALISED = '_aui-form-notification-initialised';
var CLASS_NOTIFICATION_ICON = 'aui-icon-notification';
var CLASS_TOOLTIP = NOTIFICATION_NAMESPACE + '-tooltip';
var CLASS_TOOLTIP_ERROR = CLASS_TOOLTIP + '-error';
var CLASS_TOOLTIP_INFO = CLASS_TOOLTIP + '-info';
var ATTRIBUTE_NOTIFICATION_PREFIX = 'data-aui-notification-';
var ATTRIBUTE_NOTIFICATION_WAIT = ATTRIBUTE_NOTIFICATION_PREFIX + 'wait';
var ATTRIBUTE_NOTIFICATION_INFO = ATTRIBUTE_NOTIFICATION_PREFIX + 'info';
var ATTRIBUTE_NOTIFICATION_ERROR = ATTRIBUTE_NOTIFICATION_PREFIX + 'error';
var ATTR