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 12 // Initialize dropdown navigation menus on large screens 13 // See bootstrap dropdowns: https://getbootstrap.com/docs/4.0/components/dropdowns/ 14 if (typeof $.fn.dropdown !== 'undefined') { 15 var $nav = $('#navigationPrimary, #navigationUser'), 16 $submenus = $('ul', $nav); 17 function toggleDropdowns() { 18 if (window.innerWidth > 992) { 19 $submenus.each(function(i) { 20 var id = 'pkpDropdown' + i; 21 $(this) 22 .addClass('dropdown-menu') 23 .attr('aria-labelledby', id); 24 $(this).siblings('a') 25 .attr('data-toggle', 'dropdown') 26 .attr('aria-haspopup', true) 27 .attr('aria-expanded', false) 28 .attr('id', id) 29 .attr('href', '#'); 30 }); 31 $('[data-toggle="dropdown"]').dropdown(); 32 33 } else { 34 $('[data-toggle="dropdown"]').dropdown('dispose'); 35 $submenus.each(function(i) { 36 $(this) 37 .removeClass('dropdown-menu') 38 .removeAttr('aria-labelledby'); 39 $(this).siblings('a') 40 .removeAttr('data-toggle') 41 .removeAttr('aria-haspopup') 42 .removeAttr('aria-expanded',) 43 .removeAttr('id') 44 .attr('href', '#'); 45 }); 46 } 47 } 48 window.onresize = toggleDropdowns; 49 $().ready(function() { 50 toggleDropdowns(); 51 }); 52 } 53 54 // Toggle nav menu on small screens 55 $('.pkp_site_nav_toggle').click(function(e) { 56 $('.pkp_site_nav_menu').toggleClass('pkp_site_nav_menu--isOpen'); 57 $('.pkp_site_nav_toggle').toggleClass('pkp_site_nav_toggle--transform'); 58 }); 59 60 // Modify the Chart.js display options used by UsageStats plugin 61 document.addEventListener('usageStatsChartOptions.pkp', function(e) { 62 e.chartOptions.elements.line.backgroundColor = 'rgba(0, 122, 178, 0.6)'; 63 e.chartOptions.elements.rectangle.backgroundColor = 'rgba(0, 122, 178, 0.6)'; 64 }); 65 66 // Toggle display of consent checkboxes in site-wide registration 67 var $contextOptinGroup = $('#contextOptinGroup'); 68 if ($contextOptinGroup.length) { 69 var $roles = $contextOptinGroup.find('.roles :checkbox'); 70 $roles.change(function() { 71 var $thisRoles = $(this).closest('.roles'); 72 if ($thisRoles.find(':checked').length) { 73 $thisRoles.siblings('.context_privacy').addClass('context_privacy_visible'); 74 } else { 75 $thisRoles.siblings('.context_privacy').removeClass('context_privacy_visible'); 76 } 77 }); 78 } 79 80 // Show or hide the reviewer interests field on the registration form 81 // when a user has opted to register as a reviewer. 82 function reviewerInterestsToggle() { 83 var is_checked = false; 84 $('#reviewerOptinGroup').find('input').each(function() { 85 if ($(this).is(':checked')) { 86 is_checked = true; 87 return false; 88 } 89 }); 90 if (is_checked) { 91 $('#reviewerInterests').addClass('is_visible'); 92 } else { 93 $('#reviewerInterests').removeClass('is_visible'); 94 } 95 } 96 97 reviewerInterestsToggle(); 98 $('#reviewerOptinGroup input').on('click', reviewerInterestsToggle); 99 100})(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.