Remove issuableContext from global namespace
This commit is contained in:
parent
cf542f9ed0
commit
a665a35438
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable comma-dangle, space-before-function-paren, no-new */
|
/* eslint-disable comma-dangle, space-before-function-paren, no-new */
|
||||||
/* global IssuableContext */
|
import IssuableContext from '../../issuable_context';
|
||||||
/* global MilestoneSelect */
|
/* global MilestoneSelect */
|
||||||
/* global LabelsSelect */
|
/* global LabelsSelect */
|
||||||
/* global Sidebar */
|
/* global Sidebar */
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/* eslint-disable no-new */
|
/* eslint-disable no-new */
|
||||||
/* global MilestoneSelect */
|
/* global MilestoneSelect */
|
||||||
/* global LabelsSelect */
|
/* global LabelsSelect */
|
||||||
/* global IssuableContext */
|
import IssuableContext from './issuable_context';
|
||||||
/* global Sidebar */
|
/* global Sidebar */
|
||||||
|
|
||||||
import DueDateSelectors from './due_date_select';
|
import DueDateSelectors from './due_date_select';
|
||||||
|
|
|
@ -1,33 +1,35 @@
|
||||||
/* 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 Cookies from 'js-cookie';
|
||||||
import bp from './breakpoints';
|
import bp from './breakpoints';
|
||||||
import UsersSelect from './users_select';
|
import UsersSelect from './users_select';
|
||||||
|
|
||||||
const PARTICIPANTS_ROW_COUNT = 7;
|
const PARTICIPANTS_ROW_COUNT = 7;
|
||||||
|
|
||||||
(function() {
|
export default class IssuableContext {
|
||||||
this.IssuableContext = (function() {
|
constructor(currentUser) {
|
||||||
function IssuableContext(currentUser) {
|
this.initParticipants();
|
||||||
this.initParticipants();
|
this.userSelect = new UsersSelect(currentUser);
|
||||||
new UsersSelect(currentUser);
|
|
||||||
$('select.select2').select2({
|
$('select.select2').select2({
|
||||||
width: 'resolve',
|
width: 'resolve',
|
||||||
dropdownAutoWidth: true
|
dropdownAutoWidth: true,
|
||||||
});
|
});
|
||||||
$(".issuable-sidebar .inline-update").on("change", "select", function() {
|
|
||||||
return $(this).submit();
|
$('.issuable-sidebar .inline-update').on('change', 'select', function onClickSelect() {
|
||||||
});
|
return $(this).submit();
|
||||||
$(".issuable-sidebar .inline-update").on("change", ".js-assignee", function() {
|
});
|
||||||
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', function(e) {
|
});
|
||||||
return e.preventDefault();
|
$(document)
|
||||||
});
|
.off('click', '.issuable-sidebar .dropdown-content a')
|
||||||
$(document).off('click', '.edit-link').on('click', '.edit-link', function(e) {
|
.on('click', '.issuable-sidebar .dropdown-content a', e => e.preventDefault());
|
||||||
var $block, $selectbox;
|
|
||||||
|
$(document)
|
||||||
|
.off('click', '.edit-link')
|
||||||
|
.on('click', '.edit-link', function onClickEdit(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
$block = $(this).parents('.block');
|
const $block = $(this).parents('.block');
|
||||||
$selectbox = $block.find('.selectbox');
|
const $selectbox = $block.find('.selectbox');
|
||||||
if ($selectbox.is(':visible')) {
|
if ($selectbox.is(':visible')) {
|
||||||
$selectbox.hide();
|
$selectbox.hide();
|
||||||
$block.find('.value').show();
|
$block.find('.value').show();
|
||||||
|
@ -35,46 +37,43 @@ const PARTICIPANTS_ROW_COUNT = 7;
|
||||||
$selectbox.show();
|
$selectbox.show();
|
||||||
$block.find('.value').hide();
|
$block.find('.value').hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($selectbox.is(':visible')) {
|
if ($selectbox.is(':visible')) {
|
||||||
return setTimeout(function() {
|
setTimeout(() => $block.find('.dropdown-menu-toggle').trigger('click'), 0);
|
||||||
return $block.find('.dropdown-menu-toggle').trigger('click');
|
|
||||||
}, 0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
window.addEventListener('beforeunload', function() {
|
|
||||||
// collapsed_gutter cookie hides the sidebar
|
|
||||||
var bpBreakpoint = bp.getBreakpointSize();
|
|
||||||
if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') {
|
|
||||||
Cookies.set('collapsed_gutter', true);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
window.addEventListener('beforeunload', () => {
|
||||||
|
// collapsed_gutter cookie hides the sidebar
|
||||||
|
const bpBreakpoint = bp.getBreakpointSize();
|
||||||
|
if (bpBreakpoint === 'xs' || bpBreakpoint === 'sm') {
|
||||||
|
Cookies.set('collapsed_gutter', true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
initParticipants() {
|
||||||
|
$(document).on('click', '.js-participants-more', this.toggleHiddenParticipants);
|
||||||
|
return $('.js-participants-author').each(function forEachAuthor(i) {
|
||||||
|
if (i >= PARTICIPANTS_ROW_COUNT) {
|
||||||
|
$(this).addClass('js-participants-hidden').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
toggleHiddenParticipants() {
|
||||||
|
const currentText = $(this).text().trim();
|
||||||
|
const lessText = $(this).data('less-text');
|
||||||
|
const originalText = $(this).data('original-text');
|
||||||
|
|
||||||
|
if (currentText === originalText) {
|
||||||
|
$(this).text(lessText);
|
||||||
|
|
||||||
|
if (gl.lazyLoader) gl.lazyLoader.loadCheck();
|
||||||
|
} else {
|
||||||
|
$(this).text(originalText);
|
||||||
}
|
}
|
||||||
|
|
||||||
IssuableContext.prototype.initParticipants = function() {
|
$('.js-participants-hidden').toggle();
|
||||||
$(document).on('click', '.js-participants-more', this.toggleHiddenParticipants);
|
}
|
||||||
return $('.js-participants-author').each(function(i) {
|
}
|
||||||
if (i >= PARTICIPANTS_ROW_COUNT) {
|
|
||||||
return $(this).addClass('js-participants-hidden').hide();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
IssuableContext.prototype.toggleHiddenParticipants = function() {
|
|
||||||
const currentText = $(this).text().trim();
|
|
||||||
const lessText = $(this).data('less-text');
|
|
||||||
const originalText = $(this).data('original-text');
|
|
||||||
|
|
||||||
if (currentText === originalText) {
|
|
||||||
$(this).text(lessText);
|
|
||||||
|
|
||||||
if (gl.lazyLoader) gl.lazyLoader.loadCheck();
|
|
||||||
} else {
|
|
||||||
$(this).text(originalText);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('.js-participants-hidden').toggle();
|
|
||||||
};
|
|
||||||
|
|
||||||
return IssuableContext;
|
|
||||||
})();
|
|
||||||
}).call(window);
|
|
||||||
|
|
|
@ -58,8 +58,6 @@ import './gl_form';
|
||||||
import './groups_select';
|
import './groups_select';
|
||||||
import './header';
|
import './header';
|
||||||
import initImporterStatus from './importer_status';
|
import initImporterStatus from './importer_status';
|
||||||
import './issuable_index';
|
|
||||||
import './issuable_context';
|
|
||||||
import './issuable_form';
|
import './issuable_form';
|
||||||
import './issue';
|
import './issue';
|
||||||
import './issue_status_select';
|
import './issue_status_select';
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
/* global IssuableContext */
|
|
||||||
import '~/issuable_context';
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
|
import IssuableContext from '~/issuable_context';
|
||||||
|
|
||||||
describe('IssuableContext', () => {
|
describe('IssuableContext', () => {
|
||||||
describe('toggleHiddenParticipants', () => {
|
describe('toggleHiddenParticipants', () => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable no-new */
|
/* eslint-disable no-new */
|
||||||
/* global IssuableContext */
|
import IssuableContext from '~/issuable_context';
|
||||||
/* global LabelsSelect */
|
/* global LabelsSelect */
|
||||||
|
|
||||||
import '~/gl_dropdown';
|
import '~/gl_dropdown';
|
||||||
|
|
Loading…
Reference in New Issue