1/** 2 * @file plugins/themes/naturezaOnline/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.rectangle.backgroundColor = 60 'rgba(0, 122, 178, 0.6)'; 61 }); 62 63 // Toggle display of consent checkboxes in site-wide registration 64 var $contextOptinGroup = $('#contextOptinGroup'); 65 if ($contextOptinGroup.length) { 66 var $roles = $contextOptinGroup.find('.roles :checkbox'); 67 $roles.change(function () { 68 var $thisRoles = $(this).closest('.roles'); 69 if ($thisRoles.find(':checked').length) { 70 $thisRoles 71 .siblings('.context_privacy') 72 .addClass('context_privacy_visible'); 73 } else { 74 $thisRoles 75 .siblings('.context_privacy') 76 .removeClass('context_privacy_visible'); 77 } 78 }); 79 } 80 81 // Show or hide the reviewer interests field on the registration form 82 // when a user has opted to register as a reviewer. 83 function reviewerInterestsToggle() { 84 var is_checked = false; 85 $('#reviewerOptinGroup') 86 .find('input') 87 .each(function () { 88 if ($(this).is(':checked')) { 89 is_checked = true; 90 return false; 91 } 92 }); 93 if (is_checked) { 94 $('#reviewerInterests').addClass('is_visible'); 95 } else { 96 $('#reviewerInterests').removeClass('is_visible'); 97 } 98 } 99 100 reviewerInterestsToggle(); 101 $('#reviewerOptinGroup input').on('click', reviewerInterestsToggle); 102})(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.