diff --git a/opentech/static_src/src/javascript/apply/activity-feed.js b/opentech/static_src/src/javascript/apply/activity-feed.js index 9b6a0719377624e2f16e28af4a468dacd3e6d380..c7daabbb2c779ffc34e0e6d58ac3b6a9307a8023 100644 --- a/opentech/static_src/src/javascript/apply/activity-feed.js +++ b/opentech/static_src/src/javascript/apply/activity-feed.js @@ -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); diff --git a/opentech/static_src/src/javascript/apply/all-reviews-table.js b/opentech/static_src/src/javascript/apply/all-reviews-table.js index 733bd77e14f11a3ba3b07935235e06f8bd24bf73..7ae59760cd26d930d3a0028bf5dcfc50a6327fe4 100644 --- a/opentech/static_src/src/javascript/apply/all-reviews-table.js +++ b/opentech/static_src/src/javascript/apply/all-reviews-table.js @@ -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); diff --git a/opentech/static_src/src/javascript/apply/determination-template.js b/opentech/static_src/src/javascript/apply/determination-template.js index 85d760240bd501cec2c8300f404fa25b215b3d12..092e2ce552c32ecfc727b4fd93ecbfac973dca42 100644 --- a/opentech/static_src/src/javascript/apply/determination-template.js +++ b/opentech/static_src/src/javascript/apply/determination-template.js @@ -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); diff --git a/opentech/static_src/src/javascript/apply/fancybox-global.js b/opentech/static_src/src/javascript/apply/fancybox-global.js index 8b5c9b90ce0c1d1d489ccbecadbc3ca3742cf82f..616c78f49aa0bb3ea7e7990687c7bb680babe55e 100644 --- a/opentech/static_src/src/javascript/apply/fancybox-global.js +++ b/opentech/static_src/src/javascript/apply/fancybox-global.js @@ -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'); }); diff --git a/opentech/static_src/src/javascript/apply/list-input-files.js b/opentech/static_src/src/javascript/apply/list-input-files.js index 4b6407668202c6e18f7af534cd0345467226123a..4ac805e779cd581d1d8cb1d4bcb8552dcebbde75 100644 --- a/opentech/static_src/src/javascript/apply/list-input-files.js +++ b/opentech/static_src/src/javascript/apply/list-input-files.js @@ -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) { diff --git a/opentech/static_src/src/javascript/apply/submission-filters.js b/opentech/static_src/src/javascript/apply/submission-filters.js index 9a310a56a829e2685020f8ac4d3b3cc591d2072f..fe4f36b9c2e7368c7675f98eec0918c616c3dda9 100644 --- a/opentech/static_src/src/javascript/apply/submission-filters.js +++ b/opentech/static_src/src/javascript/apply/submission-filters.js @@ -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 diff --git a/opentech/static_src/src/javascript/apply/submission-tooltips.js b/opentech/static_src/src/javascript/apply/submission-tooltips.js index 13d453e2806fa02bbb47b4df2fbea77a672b68b2..2aa9fd46d04b5a39c41b5ee4eee195c8037e574a 100644 --- a/opentech/static_src/src/javascript/apply/submission-tooltips.js +++ b/opentech/static_src/src/javascript/apply/submission-tooltips.js @@ -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); } diff --git a/opentech/static_src/src/javascript/apply/tabs.js b/opentech/static_src/src/javascript/apply/tabs.js index 20b462e43d55f822f18ded7666e9f6781b639240..d7ade577561e477f2c9371657ce47d62e9f3e93d 100644 --- a/opentech/static_src/src/javascript/apply/tabs.js +++ b/opentech/static_src/src/javascript/apply/tabs.js @@ -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'); } }; diff --git a/opentech/static_src/src/javascript/apply/toggle-actions-panel.js b/opentech/static_src/src/javascript/apply/toggle-actions-panel.js index 64dc0eadde406e0d03e0667b961ad94606de32f1..6050e331591cb40035b06d5cfc79723faf73bb61 100644 --- a/opentech/static_src/src/javascript/apply/toggle-actions-panel.js +++ b/opentech/static_src/src/javascript/apply/toggle-actions-panel.js @@ -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'); diff --git a/opentech/static_src/src/javascript/apply/toggle-reviewers.js b/opentech/static_src/src/javascript/apply/toggle-reviewers.js index cfbb5c9905bf3c4c149674dd4be9c5f664a51704..ed8715e3d52b57c466b066dbce921f33354a26d4 100644 --- a/opentech/static_src/src/javascript/apply/toggle-reviewers.js +++ b/opentech/static_src/src/javascript/apply/toggle-reviewers.js @@ -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); diff --git a/opentech/static_src/src/javascript/main.js b/opentech/static_src/src/javascript/main.js index ea8e83040b49d5b0a8e76389aa94d68a9ffd0e4d..34772e074dc58b5544b49a17a562ab52469be5a3 100755 --- a/opentech/static_src/src/javascript/main.js +++ b/opentech/static_src/src/javascript/main.js @@ -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');