1/** 2 * @file /js/main.js 3 * 4 * Copyright (c) 2014-2018 Simon Fraser University 5 * Copyright (c) 2000-2017 John Willinsky 6 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. 7 * 8 * @brief Handle JavaScript functionality unique to this theme. 9 */ 10(function($) { 11 12 // Open login modal when nav menu links clicked 13 $('.nmi_type_user_login').click(function() { 14 $('#loginModal').modal(); 15 return false; 16 }) 17})(jQuery); 18 19(function ($) { 20 21 // Show author affiliation under authors list (for large screen only) 22 var authorString = $('.author-string-href'); 23 $(authorString).click(function(event) { 24 event.preventDefault(); 25 var elementId = $(this).attr('href').replace('#', ''); 26 $('.article-details-author').each(function () { 27 28 // Show only targeted author's affiliation on click 29 if ($(this).attr('id') === elementId && $(this).hasClass('hideAuthor')) { 30 $(this).removeClass('hideAuthor'); 31 } else { 32 $(this).addClass('hideAuthor'); 33 } 34 35 // Add specifiers to the clicked author's link 36 $(authorString).each(function () { 37 if ($(this).attr('href') === ('#' + elementId) && !$(this).hasClass('active')){ 38 $(this).addClass('active'); 39 $(this).children('.author-plus').addClass('hide'); 40 $(this).children('.author-minus').removeClass('hide'); 41 } else if ($(this).attr('href') !== ('#' + elementId) || $(this).hasClass('active')) { 42 $(this).removeClass('active'); 43 $(this).children('.author-plus').removeClass('hide'); 44 $(this).children('.author-minus').addClass('hide'); 45 } 46 }); 47 }) 48 }) 49})(jQuery); 50 51 52// initiating tag-it 53$(document).ready(function() { 54 $("#tagitInput").tagit(); 55}); 56 57(function () { 58 var checkbox = document.getElementsByClassName("if-reviewer-checkbox")[0]; 59 if (checkbox != null) { 60 checkbox.onclick = function () { 61 var tagitInput = document.getElementById("reviewerInterests"); 62 if (checkbox.checked == true) { 63 tagitInput.classList.remove("hidden"); 64 } else { 65 tagitInput.classList.add("hidden"); 66 } 67 } 68 } 69})(); 70 71// change article's blocks logic for small screens 72 73(function () { 74 75 var mainArticleContent = $("#mainArticleContent"); 76 77 if (mainArticleContent.length === 0) return false; 78 79 var articleDetailsWrapper = $("#articleDetailsWrapper"); 80 var articleDetails = $("#articleDetails"); 81 var articleDetailsChildren = articleDetails.children(); 82 83 var articleMainWrapper = $("#articleMainWrapper"); 84 var articleMain = $("#articleMain"); 85 var articleMainChildren = articleMain.children(); 86 87 var dataForMobilesMark = "data-for-mobiles"; 88 89 function reorganizeArticleBlocks() { 90 if (mainArticleContent && !mainArticleContent.hasClass(dataForMobilesMark) && window.innerWidth < 992) { 91 $("#articleDetails").unwrap(); 92 $("#articleMain").unwrap(); 93 94 articleDetailsChildren.unwrap(); 95 articleMainChildren.unwrap(); 96 97 mainArticleContent.children().wrapAll("<div class='col-lg article-blocks-mobile'></div>"); 98 99 mainArticleContent.addClass(dataForMobilesMark); 100 101 } else if (mainArticleContent && mainArticleContent.hasClass(dataForMobilesMark) && window.innerWidth >= 992) { 102 $('#mainArticleContent > *').children().unwrap(); 103 104 articleDetailsChildren.wrapAll(articleDetails); 105 articleMainChildren.wrapAll(articleMain); 106 107 $("#articleDetails").wrap(articleDetailsWrapper); 108 $("#articleMain").wrap(articleMainWrapper); 109 110 111 mainArticleContent.removeClass(dataForMobilesMark); 112 } 113 } 114 115 reorganizeArticleBlocks(); 116 117 window.addEventListener("resize", function () { 118 reorganizeArticleBlocks(); 119 }); 120})(); 121 122// Functionality of more/less buttons for the journal description (index journal page) 123 124(function () { 125 var journalDescription = document.getElementById('homepageDescription'); 126 127 if (!journalDescription) return false; 128 129 var moreButton = document.getElementById('homepageDescriptionMore'); 130 var lessButton = document.getElementById('homepageDescriptionLess'); 131 var descriptionButtons = document.getElementById('homepageDescriptionButtons'); 132 133 if (journalDescription.offsetHeight < journalDescription.scrollHeight) { 134 moreButton.classList.remove('hidden'); 135 descriptionButtons.classList.remove('hidden'); 136 } 137 138 moreButton.onclick = function () { 139 journalDescription.classList.remove('long-text'); 140 this.classList.add('hidden'); 141 lessButton.classList.remove('hidden'); 142 }; 143 144 lessButton.onclick = function () { 145 journalDescription.classList.add('long-text'); 146 this.classList.add('hidden'); 147 moreButton.classList.remove('hidden'); 148 }; 149})(); 150 151// Toggle display of consent checkboxes in site-wide registration 152var $contextOptinGroup = $('#contextOptinGroup'); 153if ($contextOptinGroup.length) { 154 var $roles = $contextOptinGroup.find('.roles :checkbox'); 155 $roles.change(function() { 156 var $thisRoles = $(this).closest('.roles'); 157 if ($thisRoles.find(':checked').length) { 158 $thisRoles.siblings('.context_privacy').addClass('context_privacy_visible'); 159 } else { 160 $thisRoles.siblings('.context_privacy').removeClass('context_privacy_visible'); 161 } 162 }); 163}
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.