Commit 4ff5ed14 authored by Mike Greiling's avatar Mike Greiling

Move select2 initialization

parent 9e014dc1
......@@ -12,6 +12,7 @@ import initPageShortcuts from './shortcuts';
import './toggler_behavior';
import './preview_markdown';
import initCollapseSidebarOnWindowResize from './collapse_sidebar_on_window_resize';
import initSelect2Dropdowns from './select2';
installGlEmojiElement();
initGFMInput();
......@@ -19,3 +20,4 @@ initCopyAsGFM();
initCopyToClipboard();
initPageShortcuts();
initCollapseSidebarOnWindowResize();
initSelect2Dropdowns();
import $ from 'jquery';
export default () => {
if ($('select.select2').length) {
import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => {
$('select.select2').select2({
width: 'resolve',
minimumResultsForSearch: 10,
dropdownAutoWidth: true,
});
// Close select2 on escape
$('.js-select2').on('select2-close', () => {
setTimeout(() => {
$('.select2-container-active').removeClass('select2-container-active');
$(':focus').blur();
}, 1);
});
})
.catch(() => {});
}
};
......@@ -132,27 +132,6 @@ function deferredInitialisation() {
.fadeOut();
});
// Initialize select2 selects
if ($('select.select2').length) {
import(/* webpackChunkName: 'select2' */ 'select2/select2')
.then(() => {
$('select.select2').select2({
width: 'resolve',
minimumResultsForSearch: 10,
dropdownAutoWidth: true,
});
// Close select2 on escape
$('.js-select2').on('select2-close', () => {
setTimeout(() => {
$('.select2-container-active').removeClass('select2-container-active');
$(':focus').blur();
}, 1);
});
})
.catch(() => {});
}
const glTooltipDelay = localStorage.getItem('gl-tooltip-delay');
const delay = glTooltipDelay ? JSON.parse(glTooltipDelay) : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment