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