PageSourceSearch

https://abpnrevista.org.br/plugins/generic/citationStyleLanguage/js/articleCitation.js?v=3.3.0.22

js abpnrevista.org.br collected 2026-10-02 04:58:36 UTC 3,070 bytes, 106 lines download raw bytes

1/**
2 * @file plugins/generic/citationStyleLanguage/js/articleCitation.js
3 *
4 * Copyright (c) 2014-2020 Simon Fraser University
5 * Copyright (c) 2000-2020 John Willinsky
6 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
7 *
8 * @brief Fetch and display an article citation on the article's page
9 *
10 * This script is designed to be compatible with any themes that follow these
11 * steps. First, you need a target element that will display the citation in
12 * the requested format. This should have an id of `citationOutput`:
13 *
14 * <div id="citationOutput"></div>
15 *
16 * You can create a link to retrieve a citation and display it in this div by
17 * assigning the link a `data-load-citation` attribute:
18 *
19 * <a href="{url ...}" data-load-citation="true">View citation in ABNT format</a>
20 *
21 * Downloadable citations should leave the `data-load-citation` attribute out
22 * to allow normal browser download handling.
23 *
24 * To make use of the dropdown display of citation formats, you must include
25 * a button to expand the dropdown with the following attributes:
26 *
27 *	<button aria-controls="cslCitationFormats" aria-expanded="false" data-csl-dropdown="true">
28 *		More Citation Formats
29 *	</button>
30 *
31 * And the dropdown should have the id `cslCitationFormats`:
32 *
33 * <div id="cslCitationFormats" aria-hidden="true">
34 *   // additional citation formats
35 * </div>
36 *
37 * This script requires jQuery. The format you specify should match
38 * a format provided by a CitationFormat plugin.
39 */
40 (function($) {
41
42	// Require jQuery
43	if (typeof $ === 'undefined') {
44		return;
45	}
46
47	var citationOutput = $('#citationOutput'),
48		citationFormatLinks = $('[data-load-citation]'),
49		citationFormatBtn = $('[aria-controls="cslCitationFormats"]'),
50		citationFormatDropdown = $('#cslCitationFormats');
51
52	// Fetch new citations and update diplayed citation
53	if (!citationOutput.length || !citationFormatLinks.length) {
54		return;
55	}
56
57	citationFormatLinks.click(function(e) {
58
59		if (!$(this).data('json-href')) {
60			return true;
61		}
62
63		e.preventDefault();
64
65		var url = $(this).data('json-href');
66
67		citationOutput.css('opacity', 0.5);
68
69		$.ajax({url: url, dataType: 'json'})
70			.done(function(r) {
71				citationOutput.html(r.content)
72					.hide()
73					.css('opacity', 1)
74					.fadeIn();
75			})
76			.fail(function(r) {
77				citationOutput.css('opacity', 1);
78			});
79	});
80
81	// Display dropdown with more citation formats
82	if (!citationFormatBtn.length || !citationFormatDropdown.length) {
83		return;
84	}
85
86	citationFormatBtn.click(function(e) {
87		e.preventDefault();
88		e.stopPropagation();
89
90		var state = citationFormatBtn.attr('aria-expanded');
91
92		if (state === "true") {
93			citationFormatBtn.attr('aria-expanded', false);
94			citationFormatDropdown.attr('aria-hidden', true);
95		} else {
96			citationFormatBtn.attr('aria-expanded', true);
97			citationFormatDropdown.attr('aria-hidden', false);
98		}
99	});
100
101	$('a, button', citationFormatDropdown).click(function(e) {
102		citationFormatBtn.attr('aria-expanded', false);
103		citationFormatDropdown.attr('aria-hidden', true);
104	});
105
106 })(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.