PageSourceSearch

https://sajhrm.co.za/plugins/generic/lucene/js/LuceneAutocompleteHandler.js

js sajhrm.co.za collected 2026-10-02 14:54:20 UTC 2,203 bytes, 82 lines download raw bytes

1/**
2 * @defgroup plugins_generic_lucene_js
3 */
4/**
5 * @file plugins/generic/lucene/js/LuceneAutocompleteHandler.js
6 *
7 * Copyright (c) 2013-2019 Simon Fraser University
8 * Copyright (c) 2000-2019 John Willinsky
9 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
10 *
11 * @class LuceneAutocompleteHandler
12 * @ingroup plugins_generic_lucene_js
13 *
14 * @brief Controller for lucene autocomplete.
15 */
16(function($) {
17
18	/** @type {Object} */
19	$.pkp.plugins.generic.lucene = $.pkp.plugins.generic.lucene || {};
20
21
22
23	/**
24	 * @constructor
25	 *
26	 * @extends $.pkp.controllers.AutocompleteHandler
27	 *
28	 * @param {jQueryObject} $autocompleteField the wrapped HTML input element.
29	 * @param {Object} options options to be passed
30	 *  into the jqueryUI SimpleSearchForm plugin.
31	 */
32	$.pkp.plugins.generic.lucene.LuceneAutocompleteHandler =
33			function($autocompleteField, options) {
34
35		options.minLength = 1;
36		options.searchForm = options.searchForm || 'searchForm';
37		this.searchForm_ = options.searchForm;
38		this.parent($autocompleteField, options);
39	};
40	$.pkp.classes.Helper.inherits(
41			$.pkp.plugins.generic.lucene.LuceneAutocompleteHandler,
42			$.pkp.controllers.AutocompleteHandler);
43
44
45	//
46	// Private Properties
47	//
48	/**
49	 * The text input inside the autocomplete div that holds the label.
50	 * @private
51	 * @type {string}
52	 */
53	$.pkp.plugins.generic.lucene.LuceneAutocompleteHandler.prototype.
54			searchForm_ = '';
55
56
57	//
58	// Public Methods
59	//
60	/**
61	 * Fetch autocomplete results.
62	 * @param {HTMLElement} callingElement The calling HTML element.
63	 * @param {Object} request The autocomplete search request.
64	 * @param {Function} response The response handler function.
65	 */
66	/*jslint unparam: true*/
67	$.pkp.plugins.generic.lucene.LuceneAutocompleteHandler.prototype.
68			fetchAutocomplete = function(callingElement, request, response) {
69		var $textInput;
70
71		$textInput = this.textInput;
72		$textInput.addClass('spinner');
73		$.post(this.getAutocompleteUrl(), $('#' + this.searchForm_).serialize(),
74				function(data) {
75					$textInput.removeClass('spinner');
76					response(data.content);
77				}, 'json');
78	};
79	/*jslint unparam: false*/
80
81/** @param {jQuery} $ jQuery closure. */
82}(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.