-
Notifications
You must be signed in to change notification settings - Fork 909
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[OJS.de lucene - part II - ap1] Initial search UI re-design.
- Loading branch information
Showing
20 changed files
with
655 additions
and
498 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/** | ||
* @defgroup js_pages_search | ||
*/ | ||
/** | ||
* @file js/pages/search/SearchFormHandler.js | ||
* | ||
* Copyright (c) 2000-2012 John Willinsky | ||
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. | ||
* | ||
* @class SearchFormHandler | ||
* | ||
* @brief Form handler that handles the search form. It checks whether | ||
* at least one search query term has been entered before submitting | ||
* the form. It also handles instant search (if enabled). | ||
*/ | ||
(function($) { | ||
|
||
/** @type {Object} */ | ||
$.pkp.pages = $.pkp.pages || {}; | ||
|
||
|
||
/** @type {Object} */ | ||
$.pkp.pages.search = $.pkp.pages.search || {}; | ||
|
||
|
||
|
||
/** | ||
* @constructor | ||
* | ||
* @extends $.pkp.controllers.form.FormHandler | ||
* | ||
* @param {jQueryObject} $form The wrapped HTML form element. | ||
* @param {Object} options Configuration of the form handler. | ||
*/ | ||
$.pkp.pages.search.SearchFormHandler = function($form, options) { | ||
// Focus the main query field and select all text. | ||
$form.find('input[name="query"]').focus().select(); | ||
|
||
// Configure the form handler. | ||
options.submitHandler = this.submitForm; | ||
options.trackFormChanges = false; | ||
options.transformButtons = false; | ||
this.parent($form, options); | ||
}; | ||
$.pkp.classes.Helper.inherits( | ||
$.pkp.pages.search.SearchFormHandler, | ||
$.pkp.controllers.form.FormHandler); | ||
|
||
|
||
// | ||
// Public methods | ||
// | ||
/** | ||
* Internal callback called after form validation to handle form | ||
* submission. | ||
* | ||
* @param {Object} validator The validator plug-in. | ||
* @param {HTMLElement} formElement The wrapped HTML form. | ||
*/ | ||
$.pkp.pages.search.SearchFormHandler.prototype.submitForm = | ||
function(validator, formElement) { | ||
var $form, allBlank, formFields, i, max; | ||
|
||
$form = this.getHtmlElement(); | ||
|
||
formFields = [ | ||
'query', 'authors', 'title', 'abstract', 'discipline', 'subject', | ||
'type', 'coverage', 'indexTerms', 'suppFiles', 'galleyFullText']; | ||
for (i = 0, max = formFields.length; i < max; i++) { | ||
allBlank = $form.find('input[name="' + formFields[i] + '"]').val() == ''; | ||
if (!allBlank) { | ||
break; | ||
} | ||
} | ||
|
||
if (allBlank) { | ||
alert($.pkp.locale.search_noKeywordError); | ||
return; | ||
} | ||
|
||
this.submitFormWithoutValidation(validator); | ||
}; | ||
|
||
/** @param {jQuery} $ jQuery closure. */ | ||
}(jQuery)); |
Oops, something went wrong.