Commit a665a354 authored by Filipa Lacerda's avatar Filipa Lacerda

Remove issuableContext from global namespace

parent cf542f9e
/* eslint-disable comma-dangle, space-before-function-paren, no-new */
/* global IssuableContext */
import IssuableContext from '../../issuable_context';
/* global MilestoneSelect */
/* global LabelsSelect */
/* global Sidebar */
......
/* eslint-disable no-new */
/* global MilestoneSelect */
/* global LabelsSelect */
/* global IssuableContext */
import IssuableContext from './issuable_context';
/* global Sidebar */
import DueDateSelectors from './due_date_select';
......
/* eslint-disable func-names, space-before-function-paren, wrap-iife, no-new, comma-dangle, quotes, prefer-arrow-callback, consistent-return, one-var, no-var, one-var-declaration-per-line, no-underscore-dangle, max-len */
import Cookies from 'js-cookie';
import bp from './breakpoints';
import UsersSelect from './users_select';
const PARTICIPANTS_ROW_COUNT = 7;
(function() {
this.IssuableContext = (function() {
function IssuableContext(currentUser) {
export default class IssuableContext {
constructor(currentUser) {
this.initParticipants();
new UsersSelect(currentUser);
this.userSelect = new UsersSelect(currentUser);
$('select.select2').select2({
width: 'resolve',
dropdownAutoWidth: true
dropdownAutoWidth: true,
});
$(".issuable-sidebar .inline-update").on("change", "select", function() {
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
return $(this).submit();
});
$(".issuable-sidebar .inline-update").on("change", ".js-assignee", function() {
$('.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', function(e) {
return e.preventDefault();
});
$(document).off('click', '.edit-link').on('click', '.edit-link', function(e) {
var $block, $selectbox;
$(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) {
e.preventDefault();
$block = $(this).parents('.block');
$selectbox = $block.find('.selectbox');
const $block = $(this).parents('.block');
const $selectbox = $block.find('.selectbox');
if ($selectbox.is(':visible')) {
$selectbox.hide();
$block.find('.value').show();
......@@ -35,31 +37,31 @@ const PARTICIPANTS_ROW_COUNT = 7;
$selectbox.show();
$block.find('.value').hide();
}
if ($selectbox.is(':visible')) {
return setTimeout(function() {
return $block.find('.dropdown-menu-toggle').trigger('click');
}, 0);
setTimeout(() => $block.find('.dropdown-menu-toggle').trigger('click'), 0);
}
});
window.addEventListener('beforeunload', function() {
window.addEventListener('beforeunload', () => {
// collapsed_gutter cookie hides the sidebar
var bpBreakpoint = bp.getBreakpointSize();
const bpBreakpoint = bp.getBreakpointSize();
if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') {
Cookies.set('collapsed_gutter', true);
}
});
}
IssuableContext.prototype.initParticipants = function() {
initParticipants() {
$(document).on('click', '.js-participants-more', this.toggleHiddenParticipants);
return $('.js-participants-author').each(function(i) {
return $('.js-participants-author').each(function forEachAuthor(i) {
if (i >= PARTICIPANTS_ROW_COUNT) {
return $(this).addClass('js-participants-hidden').hide();
$(this).addClass('js-participants-hidden').hide();
}
});
};
}
IssuableContext.prototype.toggleHiddenParticipants = function() {
toggleHiddenParticipants() {
const currentText = $(this).text().trim();
const lessText = $(this).data('less-text');
const originalText = $(this).data('original-text');
......@@ -73,8 +75,5 @@ const PARTICIPANTS_ROW_COUNT = 7;
}
$('.js-participants-hidden').toggle();
};
return IssuableContext;
})();
}).call(window);
}
}
......@@ -58,8 +58,6 @@ import './gl_form';
import './groups_select';
import './header';
import initImporterStatus from './importer_status';
import './issuable_index';
import './issuable_context';
import './issuable_form';
import './issue';
import './issue_status_select';
......
/* global IssuableContext */
import '~/issuable_context';
import $ from 'jquery';
import IssuableContext from '~/issuable_context';
describe('IssuableContext', () => {
describe('toggleHiddenParticipants', () => {
......
/* eslint-disable no-new */
/* global IssuableContext */
import IssuableContext from '~/issuable_context';
/* global LabelsSelect */
import '~/gl_dropdown';
......
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