PageSourceSearch

https://safpj.co.za/lib/pkp/js/controllers/form/ClientFormHandler.js

js safpj.co.za collected 2026-10-02 10:26:17 UTC 1,974 bytes, 70 lines download raw bytes

1/**
2 * @file js/controllers/form/ClientFormHandler.js
3 *
4 * Copyright (c) 2013-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	/*jslint unparam: true*/
48	$.pkp.controllers.form.ClientFormHandler.prototype.submitForm =
49			function(validator, formElement) {
50		var $form, formData;
51
52		// This form implementation will trigger an event
53		// with the form data.
54		$form = this.getHtmlElement();
55
56		// Retrieve form data.
57		formData = $form.serializeArray();
58
59		// Inform the server that the form has been submitted.
60		formData.push({name: 'clientSubmit', value: true});
61
62		// Trigger a "form submitted" event with the form
63		// data as argument.
64		this.trigger('formSubmitted', [$.param(formData)]);
65	};
66	/*jslint unparam: false*/
67
68
69/** @param {jQuery} $ jQuery closure. */
70}(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.