PageSourceSearch

https://ives-technicalreviews.eu/plugins/themes/technicalreviews2/js/main.js?v=3.3.0.15

js ives-technicalreviews.eu collected 2026-09-28 08:39:45 UTC 4,835 bytes, 184 lines download raw bytes

1/**
2 * @file plugins/themes/default/js/main.js
3 *
4 * Copyright (c) 2014-2017 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	// Initialize dropdown navigation menus
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
18		$submenus.each(function(i) {
19			var id = 'pkpDropdown' + i;
20			$(this)
21				.addClass('dropdown-menu')
22				.attr('aria-labelledby', id);
23			$(this).siblings('a')
24				.attr('data-toggle', 'dropdown')
25				.attr('aria-haspopup', true)
26				.attr('aria-expanded', false)
27				.attr('id', id)
28				.attr('href', '#');
29		});
30
31		$('[data-toggle="dropdown"]').dropdown();
32	}
33
34	// Register click handlers for the search panel
35	var headerSearchPanelIsClosing = false,
36	    headerSearchForm = $('#headerNavigationContainer .pkp_search'),
37	    headerSearchPrompt = $('.headerSearchPrompt', headerSearchForm),
38		headerSearchCancel = $('.headerSearchCancel', headerSearchForm),
39		headerSearchInput = $('input[name="query"]', headerSearchForm);
40
41	// Register events
42	headerSearchPrompt.on('click', triggerSearchPanel);
43	headerSearchCancel.on('click', closeSearchPanel);
44	headerSearchInput.on('blur', function() {
45		if(!headerSearchInput.val() && headerSearchForm.hasClass('is_open')) {
46			closeSearchPanel();
47		}
48	});
49	headerSearchForm.on('submit', function() {
50		if(headerSearchForm.hasClass('is_searching')) {
51			return;
52		}
53		headerSearchForm.addClass('is_searching');
54	});
55	headerSearchForm.on('keyup', function(e) {
56		if(headerSearchForm.hasClass('is_open') && e.keyCode == 27) {
57			closeSearchPanel();
58		}
59	});
60
61	/**
62	 * Open or submit search form
63	 *
64	 * @param Event e Optional event handler
65	 */
66	function triggerSearchPanel(e) {
67
68		if (headerSearchPanelIsClosing) {
69			return;
70		}
71
72		if (typeof e !== 'undefined') {
73			e.preventDefault();
74			e.stopPropagation();
75		}
76
77		if (headerSearchForm.hasClass('is_open')) {
78			headerSearchForm.submit();
79			return;
80		}
81
82		headerSearchForm.addClass('is_open');
83		setTimeout(function() {
84			headerSearchForm.find('input[type="text"]').focus();
85		},200);
86	}
87
88	/**
89	 * Close the search panel
90	 *
91	 * @param Event e Optional event handler
92	 */
93	function closeSearchPanel(e) {
94
95		if (headerSearchPanelIsClosing) {
96			return;
97		}
98
99		if (typeof e !== 'undefined') {
100			e.preventDefault();
101			e.stopPropagation();
102		}
103
104		headerSearchPanelIsClosing = true;
105		headerSearchForm.removeClass('is_open');
106
107		setTimeout(function() {
108			headerSearchPanelIsClosing = false;
109			headerSearchInput.val('');
110		},300)
111	}
112
113	// Modify the Chart.js display options used by UsageStats plugin
114	document.addEventListener('usageStatsChartOptions.pkp', function(e) {
115		e.chartOptions.elements.line.backgroundColor = 'rgba(0, 122, 178, 0.6)';
116		e.chartOptions.elements.rectangle.backgroundColor = 'rgba(0, 122, 178, 0.6)';
117	});
118
119	// Initialize tag-it components
120	//
121	// The tag-it component is used during registration for the user to enter
122	// their review interests. See: /templates/frontend/pages/userRegister.tpl
123	if (typeof $.fn.tagit !== 'undefined') {
124		$('.tag-it').each(function() {
125			var autocomplete_url = $(this).data('autocomplete-url');
126			$(this).tagit({
127				fieldName: $(this).data('field-name'),
128				allowSpaces: true,
129				autocomplete: {
130					source: function(request, response) {
131						$.ajax({
132							url: autocomplete_url,
133							data: {term: request.term},
134							dataType: 'json',
135							success: function(jsonData) {
136								if (jsonData.status == true) {
137									response(jsonData.content);
138								}
139							}
140						});
141					},
142				},
143			});
144		});
145
146		/**
147		 * Determine if the user has opted to register as a reviewer
148		 *
149		 * @see: /templates/frontend/pages/userRegister.tpl
150		 */
151		function isReviewerSelected() {
152			var group = $('#reviewerOptinGroup').find('input');
153			var is_checked = false;
154			group.each(function() {
155				if ($(this).is(':checked')) {
156					is_checked = true;
157					return false;
158				}
159			});
160
161			return is_checked;
162		}
163
164		/**
165		 * Reveal the reviewer interests field on the registration form when a
166		 * user has opted to register as a reviewer
167		 *
168		 * @see: /templates/frontend/pages/userRegister.tpl
169		 */
170		function reviewerInterestsToggle() {
171			var is_checked = isReviewerSelected();
172			if (is_checked) {
173				$('#reviewerInterests').addClass('is_visible');
174			} else {
175				$('#reviewerInterests').removeClass('is_visible');
176			}
177		}
178
179		// Update interests on page load and when the toggled is toggled
180		reviewerInterestsToggle();
181		$('#reviewerOptinGroup input').click(reviewerInterestsToggle);
182	}
183
184})(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.