Skip to content
Snippets Groups Projects
Commit fbbee413 authored by Fredrik Jonsson's avatar Fredrik Jonsson
Browse files

Lint fixes for javascript.

parent 71585322
No related branches found
No related tags found
No related merge requests found
Showing
with 70 additions and 41 deletions
......@@ -17,11 +17,16 @@
});
// Show scroll to top of activity feed button on scroll
$('.js-activity-feed').on('scroll', function() {
$(this).scrollTop() === 0 ? $('.js-to-top').removeClass('is-visible') : $('.js-to-top').addClass('is-visible');
$('.js-activity-feed').on('scroll', function () {
if ($(this).scrollTop() === 0) {
$('.js-to-top').removeClass('is-visible');
}
else {
$('.js-to-top').addClass('is-visible');
}
});
// Scroll to the top of the activity feed
$('.js-to-top').click(() => $('.js-activity-feed').animate({ scrollTop: 0 }, 250));
$('.js-to-top').click(() => $('.js-activity-feed').animate({scrollTop: 0}, 250));
})(jQuery);
......@@ -6,20 +6,31 @@
$('.js-reviews-table').attachDragger();
// Enable click and drag scrolling within a div
$.fn.attachDragger = function(){
let attachment = false, lastPosition, position, difference;
$($(this).selector ).on('mousedown mouseup mousemove', (e) => {
if(e.type == 'mousedown') attachment = true, lastPosition = [e.clientX, e.clientY];
if(e.type == 'mouseup') attachment = false;
if(e.type == 'mousemove' && attachment == true ){
$.fn.attachDragger = function () {
let attachment = false;
let lastPosition;
let position;
let difference;
$($(this).selector).on('mousedown mouseup mousemove', (e) => {
if (e.type === 'mousedown') {
attachment = true;
lastPosition = [e.clientX, e.clientY];
}
if (e.type === 'mouseup') {
attachment = false;
}
if (e.type === 'mousemove' && attachment === true) {
position = [e.clientX, e.clientY];
difference = [ (position[0]-lastPosition[0]), (position[1]-lastPosition[1])];
$(this).scrollLeft( $(this).scrollLeft() - difference[0]);
$(this).scrollTop( $(this).scrollTop() - difference[1]);
difference = [(position[0] - lastPosition[0]), (position[1] - lastPosition[1])];
$(this).scrollLeft($(this).scrollLeft() - difference[0]);
$(this).scrollTop($(this).scrollTop() - difference[1]);
lastPosition = [e.clientX, e.clientY];
}
});
$(window).on('mouseup', () => attachment = false);
(window).on('mouseup', function () {
attachment = false;
});
};
})(jQuery);
......@@ -3,7 +3,7 @@
'use strict';
let DeterminationCopy = class {
static selector(){
static selector() {
return '#id_outcome';
}
......@@ -12,18 +12,20 @@
this.bindEventListeners();
}
bindEventListeners(){
bindEventListeners() {
this.node.addEventListener('change', (e) => {
this.getMatchingCopy(e.target.value);
}, false);
}
getMatchingCopy(value) {
if (value === '0'){
if (value === '0') {
this.text = document.querySelector('div[data-type="rejected"]').textContent;
} else if (value === '1') {
}
else if (value === '1') {
this.text = document.querySelector('div[data-type="more_info"]').textContent;
} else {
}
else {
this.text = document.querySelector('div[data-type="accepted"]').textContent;
}
this.updateTextArea(this.text);
......
......@@ -3,16 +3,18 @@
'use strict';
$('[data-fancybox]').fancybox({
animationDuration : 350,
animationEffect : 'fade',
afterClose: function(){
animationDuration: 350,
animationEffect: 'fade',
afterClose: function () {
$('.django-select2-checkboxes').select2('close');
}
});
// Close any open select2 dropdowns when inside a modal
$('.modal').click((e) => {
if (e.target.classList.contains('select2-selection__rendered')) return;
if (e.target.classList.contains('select2-selection__rendered')) {
return;
}
$('.django-select2-checkboxes').select2('close');
});
......
......@@ -3,7 +3,7 @@
'use strict';
function listInputFiles() {
$('input[type=file]').change(function() {
$('input[type=file]').change(function () {
// remove any existing files first
$(this).siblings('.form__file').remove();
for (let i = 0; i < $(this)[0].files.length; ++i) {
......
......@@ -18,9 +18,10 @@
let match = $(`.select2-selection[aria-owns="${selectId}"]`);
// if the dropdown contains a clear class, the filters are active
if($(match[0]).find('span.select2-selection__clear').length !== 0) {
if ($(match[0]).find('span.select2-selection__clear').length !== 0) {
match[0].classList.add('is-active');
} else {
}
else {
match[0].classList.remove('is-active');
}
});
......@@ -28,7 +29,9 @@
// remove active class on clearing select2
$('.select2').on('select2:unselecting', (e) => {
const dropdown = e.target.nextElementSibling.firstChild.firstChild;
(dropdown.classList.contains('is-active')) ? dropdown.classList.remove('is-active') : null;
if (dropdown.classList.contains('is-active')) {
dropdown.classList.remove('is-active');
}
});
// open mobile filters
......
......@@ -8,7 +8,7 @@
const titles = Array.prototype.slice.call(document.querySelectorAll('.js-title'));
// if the tile has been truncated...
titles.forEach(function(title) {
titles.forEach(function (title) {
if (title.textContent.indexOf('...') >= 0) {
addToolTip(title);
}
......
......@@ -53,14 +53,14 @@
this.updateUrl(tab);
}
stripTabClasses(){
stripTabClasses() {
// remove active classes from all tabs and tab contents
this.tabItems.forEach(tabItem => tabItem.classList.remove(this.tabActiveClass));
this.tabsContents.forEach(tabsContent => tabsContent.classList.remove(this.tabContentActiveClass));
}
addTabClasses(tab){
if(tab === null) {
addTabClasses(tab) {
if (tab === null) {
tab = document.querySelector(`[data-tab=${this.defaultSelectedTab}]`);
}
......@@ -71,7 +71,7 @@
document.querySelector(`#${tabId}`).classList.add(this.tabContentActiveClass);
}
updateUrl(tab){
updateUrl(tab) {
window.location.hash = tab.getAttribute('href');
}
};
......
......@@ -2,8 +2,8 @@
'use strict';
function toggleActionsPanel(){
$('.js-actions-toggle').click(function(e) {
function toggleActionsPanel() {
$('.js-actions-toggle').click(function (e) {
e.preventDefault();
this.classList.toggle('is-active');
this.nextElementSibling.classList.toggle('is-visible');
......
......@@ -5,12 +5,17 @@
// get all the reviewers that are missing
const reviewers = Array.prototype.slice.call($('.js-reviews-sidebar').find('tr.hidden.no-response'));
$('.js-toggle-reviewers').click(function(e) {
$('.js-toggle-reviewers').click(function (e) {
e.preventDefault();
// toggle class and update text
$(this).toggleClass('is-open');
$(this).hasClass('is-open') ? $(this).html('Hide All Assigned Advisors') : $(this).html('All Assigned Advisors');
if ($(this).hasClass('is-open')) {
$(this).html('Hide All Assigned Advisors');
}
else {
$(this).html('All Assigned Advisors');
}
// toggle the reviewers
toggleReviewers(reviewers);
......@@ -18,9 +23,9 @@
// show/hide the reviewers
function toggleReviewers(reviewers) {
reviewers.forEach(((reviewer) => {
reviewers.forEach(reviewer => {
$(reviewer).toggleClass('hidden');
}));
});
}
})(jQuery);
......@@ -57,14 +57,14 @@
// check if search exists
if (document.body.contains(this.search[0])) {
// reset the search whenever the mobile menu is toggled
if(this.search[0].classList.contains('is-visible')){
if (this.search[0].classList.contains('is-visible')) {
this.search[0].classList.toggle('is-visible');
document.querySelector('.header__inner--menu-open').classList.toggle('header__inner--search-open');
}
}
// reset the search show/hide icons
if(this.mobileMenu[0].classList.contains('is-visible') && document.body.contains(this.search[0])){
if (this.mobileMenu[0].classList.contains('is-visible') && document.body.contains(this.search[0])) {
document.querySelector('.header__icon--open-search-menu-closed').classList.remove('is-hidden');
document.querySelector('.header__icon--close-search-menu-closed').classList.remove('is-unhidden');
}
......@@ -141,7 +141,8 @@
$('.select2').on('click', (e) => {
mobileFilterPadding(e.target);
});
} else {
}
else {
$('body').removeClass('no-scroll');
$('.js-filter-wrapper').removeClass('is-open');
$('.js-filter-list').removeClass('form__filters--mobile');
......@@ -161,7 +162,7 @@
// reset the margin of the select we previously worked
openDropdown.removeClass(expanded);
// store the offset to adjust the new select box (elements above the old dropdown unaffected)
if (dropdown.position().top > openDropdown.position().top ){
if (dropdown.position().top > openDropdown.position().top) {
dropdownMargin = parseInt(openDropdown.css('marginBottom'));
}
openDropdown.css('margin-bottom', '0px');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment