gitlab-org--gitlab-foss/app/assets/javascripts/subscription_select.js

29 lines
777 B
JavaScript
Raw Normal View History

import $ from 'jquery';
import { __ } from './locale';
import initDeprecatedJQueryDropdown from '~/deprecated_jquery_dropdown';
2017-11-20 20:28:29 +00:00
export default function subscriptionSelect() {
$('.js-subscription-event').each((i, element) => {
2018-02-20 22:20:48 +00:00
const fieldName = $(element).data('fieldName');
return initDeprecatedJQueryDropdown($(element), {
2017-11-20 20:28:29 +00:00
selectable: true,
fieldName,
toggleLabel(selected, el, instance) {
let label = __('Subscription');
2017-11-20 20:28:29 +00:00
const $item = instance.dropdown.find('.is-active');
if ($item.length) {
label = $item.text();
}
2017-11-20 20:28:29 +00:00
return label;
},
clicked(options) {
return options.e.preventDefault();
},
id(obj, el) {
return $(el).data('id');
},
});
2017-11-20 20:28:29 +00:00
});
}