2017-03-11 01:45:34 -05:00
|
|
|
import Cookies from 'js-cookie';
|
2017-08-10 09:02:30 -04:00
|
|
|
import bp from './breakpoints';
|
2017-05-12 04:15:28 -04:00
|
|
|
import UsersSelect from './users_select';
|
2017-03-11 01:45:34 -05:00
|
|
|
|
2017-10-26 16:14:18 -04:00
|
|
|
export default class IssuableContext {
|
|
|
|
constructor(currentUser) {
|
|
|
|
this.userSelect = new UsersSelect(currentUser);
|
|
|
|
|
|
|
|
$('select.select2').select2({
|
|
|
|
width: 'resolve',
|
|
|
|
dropdownAutoWidth: true,
|
|
|
|
});
|
|
|
|
|
|
|
|
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$('.issuable-sidebar .inline-update').on('change', '.js-assignee', function onClickAssignee() {
|
|
|
|
return $(this).submit();
|
|
|
|
});
|
|
|
|
$(document)
|
|
|
|
.off('click', '.issuable-sidebar .dropdown-content a')
|
|
|
|
.on('click', '.issuable-sidebar .dropdown-content a', e => e.preventDefault());
|
|
|
|
|
|
|
|
$(document)
|
|
|
|
.off('click', '.edit-link')
|
|
|
|
.on('click', '.edit-link', function onClickEdit(e) {
|
2016-07-24 16:45:11 -04:00
|
|
|
e.preventDefault();
|
2017-10-26 16:14:18 -04:00
|
|
|
const $block = $(this).parents('.block');
|
|
|
|
const $selectbox = $block.find('.selectbox');
|
2016-07-24 16:45:11 -04:00
|
|
|
if ($selectbox.is(':visible')) {
|
|
|
|
$selectbox.hide();
|
|
|
|
$block.find('.value').show();
|
|
|
|
} else {
|
|
|
|
$selectbox.show();
|
|
|
|
$block.find('.value').hide();
|
|
|
|
}
|
2017-10-26 16:14:18 -04:00
|
|
|
|
2016-07-24 16:45:11 -04:00
|
|
|
if ($selectbox.is(':visible')) {
|
2017-10-26 16:14:18 -04:00
|
|
|
setTimeout(() => $block.find('.dropdown-menu-toggle').trigger('click'), 0);
|
2016-07-24 16:45:11 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-10-26 16:14:18 -04:00
|
|
|
window.addEventListener('beforeunload', () => {
|
|
|
|
// collapsed_gutter cookie hides the sidebar
|
|
|
|
const bpBreakpoint = bp.getBreakpointSize();
|
|
|
|
if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') {
|
|
|
|
Cookies.set('collapsed_gutter', true);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|