1/** 2 * @file plugins/themes/default/js/main.js 3 * 4 * Copyright (c) 2014-2021 Simon Fraser University 5 * Copyright (c) 2000-2021 John Willinsky 6 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING. 7 * 8 * @brief Handle JavaScript functionality unique to this theme. 9 */ 10(function ($) { 11 // Initialize dropdown navigation menus on large screens 12 // See bootstrap dropdowns: https://getbootstrap.com/docs/4.0/components/dropdowns/ 13 if (typeof $.fn.dropdown !== 'undefined') { 14 var $nav = $('#navigationPrimary, #navigationUser'), 15 $submenus = $('ul', $nav); 16 function toggleDropdowns() { 17 if (window.innerWidth > 992) { 18 $submenus.each(function (i) { 19 var id = 'pkpDropdown' + i; 20 $(this).addClass('dropdown-menu').attr('aria-labelledby', id); 21 $(this) 22 .siblings('a') 23 .attr('data-toggle', 'dropdown') 24 .attr('aria-haspopup', true) 25 .attr('aria-expanded', false) 26 .attr('id', id) 27 .attr('href', '#'); 28 }); 29 $('[data-toggle="dropdown"]').dropdown(); 30 } else { 31 $('[data-toggle="dropdown"]').dropdown('dispose'); 32 $submenus.each(function (i) { 33 $(this).removeClass('dropdown-menu').removeAttr('aria-labelledby'); 34 $(this) 35 .siblings('a') 36 .removeAttr('data-toggle') 37 .removeAttr('aria-haspopup') 38 .removeAttr('aria-expanded') 39 .removeAttr('id') 40 .attr('href', '#'); 41 }); 42 } 43 } 44 window.onresize = toggleDropdowns; 45 $().ready(function () { 46 toggleDropdowns(); 47 }); 48 } 49 50 // Toggle nav menu on small screens 51 $('.pkp_site_nav_toggle').click(function (e) { 52 $('.pkp_site_nav_menu').toggleClass('pkp_site_nav_menu--isOpen'); 53 $('.pkp_site_nav_toggle').toggleClass('pkp_site_nav_toggle--transform'); 54 }); 55 56 // Modify the Chart.js display options used by UsageStats plugin 57 document.addEventListener('usageStatsChartOptions.pkp', function (e) { 58 e.chartOptions.elements.line.backgroundColor = 'rgba(0, 122, 178, 0.6)'; 59 e.chartOptions.elements.bar.backgroundColor = 'rgba(0, 122, 178, 0.6)'; 60 }); 61 62 // Toggle display of consent checkboxes in site-wide registration 63 var $contextOptinGroup = $('#contextOptinGroup'); 64 if ($contextOptinGroup.length) { 65 var $roles = $contextOptinGroup.find('.roles :checkbox'); 66 $roles.change(function () { 67 var $thisRoles = $(this).closest('.roles'); 68 if ($thisRoles.find(':checked').length) { 69 $thisRoles.siblings('.context_privacy').addClass('context_privacy_visible'); 70 } else { 71 $thisRoles.siblings('.context_privacy').removeClass('context_privacy_visible'); 72 } 73 }); 74 } 75 76 // Show or hide the reviewer interests field on the registration form 77 // when a user has opted to register as a reviewer. 78 function reviewerInterestsToggle() { 79 var is_checked = false; 80 $('#reviewerOptinGroup') 81 .find('input') 82 .each(function () { 83 if ($(this).is(':checked')) { 84 is_checked = true; 85 return false; 86 } 87 }); 88 if (is_checked) { 89 $('#reviewerInterests').addClass('is_visible'); 90 } else { 91 $('#reviewerInterests').removeClass('is_visible'); 92 } 93 } 94 95 reviewerInterestsToggle(); 96 $('#reviewerOptinGroup input').on('click', reviewerInterestsToggle); 97 98 var swiper = new Swiper('.swiper', { 99 ally: { 100 prevSlideMessage: pkpDefaultThemeI18N.prevSlide, 101 nextSlideMessage: pkpDefaultThemeI18N.nextSlide, 102 }, 103 autoHeight: true, 104 navigation: { 105 nextEl: '.swiper-button-next', 106 prevEl: '.swiper-button-prev', 107 }, 108 pagination: { 109 el: '.swiper-pagination', 110 type: 'bullets', 111 }, 112 }); 113})(jQuery);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.