1/** 2 * @defgroup js_pages_search 3 */ 4/** 5 * @file js/pages/search/SearchFormHandler.js 6 * 7 * Copyright (c) 2013-2015 Simon Fraser University Library 8 * Copyright (c) 2000-2015 John Willinsky 9 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. 10 * 11 * @class SearchFormHandler 12 * 13 * @brief Form handler that handles the search form. It checks whether 14 * at least one search query term has been entered before submitting 15 * the form. It also handles instant search (if enabled). 16 */ 17(function($) { 18 19 /** @type {Object} */ 20 $.pkp.pages = $.pkp.pages || {}; 21 22 23 /** @type {Object} */ 24 $.pkp.pages.search = $.pkp.pages.search || {}; 25 26 27 28 /** 29 * @constructor 30 * 31 * @extends $.pkp.controllers.form.FormHandler 32 * 33 * @param {jQueryObject} $form The wrapped HTML form element. 34 * @param {Object} options Configuration of the form handler. 35 */ 36 $.pkp.pages.search.SearchFormHandler = function($form, options) { 37 // Focus the main query field and select all text. 38 $form.find('input[name="query"]').focus().select(); 39 40 // Configure the form handler. 41 options.submitHandler = this.submitForm; 42 options.trackFormChanges = false; 43 options.transformButtons = false; 44 this.parent($form, options); 45 }; 46 $.pkp.classes.Helper.inherits( 47 $.pkp.pages.search.SearchFormHandler, 48 $.pkp.controllers.form.FormHandler); 49 50 51 // 52 // Public methods 53 // 54 /** 55 * Internal callback called after form validation to handle form 56 * submission. 57 * 58 * @param {Object} validator The validator plug-in. 59 * @param {HTMLElement} formElement The wrapped HTML form. 60 */ 61 /*jslint unparam: true*/ 62 $.pkp.pages.search.SearchFormHandler.prototype.submitForm = 63 function(validator, formElement) { 64 var $form, allBlank, formFields, i, max; 65 66 $form = this.getHtmlElement(); 67 68 formFields = [ 69 'query', 'authors', 'title', 'abstract', 'discipline', 'subject', 70 'type', 'coverage', 'indexTerms', 'suppFiles', 'galleyFullText']; 71 for (i = 0, max = formFields.length; i < max; i++) { 72 allBlank = $form.find('input[name="' + formFields[i] + '"]').val() == ''; 73 if (!allBlank) { 74 break; 75 } 76 } 77 78 if (allBlank) { 79 alert($.pkp.locale.search_noKeywordError); 80 return; 81 } 82 83 this.submitFormWithoutValidation(validator); 84 }; 85 /*jslint unparam: false*/ 86 87/** @param {jQuery} $ jQuery closure. */ 88}(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.