1/** 2 * @file js/controllers/form/ClientFormHandler.js 3 * 4 * Copyright (c) 2014-2019 Simon Fraser University 5 * Copyright (c) 2000-2019 John Willinsky 6 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING. 7 * 8 * @class ClientFormHandler 9 * @ingroup js_controllers_form 10 * 11 * @brief Form handler that serializes the form on submission and 12 * triggers a "formSubmitted" event with the form data. This enables 13 * other widgets to use forms to request data from users although the 14 * data is not meant to be sent to the server through the form. 15 */ 16(function($) { 17 18 19 /** 20 * @constructor 21 * 22 * @extends $.pkp.controllers.form.FormHandler 23 * 24 * @param {jQueryObject} $form the wrapped HTML form element. 25 * @param {Object} options options to be passed 26 * into the validator plug-in. 27 */ 28 $.pkp.controllers.form.ClientFormHandler = function($form, options) { 29 options.submitHandler = this.submitForm; 30 this.parent($form, options); 31 }; 32 $.pkp.classes.Helper.inherits( 33 $.pkp.controllers.form.ClientFormHandler, 34 $.pkp.controllers.form.FormHandler); 35 36 37 // 38 // Public methods 39 // 40 /** 41 * Internal callback called after form validation to handle form 42 * submission. 43 * 44 * @param {Object} validator The validator plug-in. 45 * @param {HTMLElement} formElement The wrapped HTML form. 46 */ 47 $.pkp.controllers.form.ClientFormHandler.prototype.submitForm = 48 function(validator, formElement) { 49 var $form, formData; 50 51 // This form implementation will trigger an event 52 // with the form data. 53 $form = this.getHtmlElement(); 54 55 // Retrieve form data. 56 formData = $form.serializeArray(); 57 58 // Inform the server that the form has been submitted. 59 formData.push({name: 'clientSubmit', value: true}); 60 61 // Trigger a "form submitted" event with the form 62 // data as argument. 63 this.trigger('formSubmitted', [$.param(formData)]); 64 }; 65 66 67/** @param {jQuery} $ jQuery closure. */ 68}(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.