403Webshell
Server IP : 195.134.90.114  /  Your IP : 216.73.216.191
Web Server : Apache/2.4.58
System : Linux nepub 6.8.0-88-generic #89-Ubuntu SMP PREEMPT_DYNAMIC Sat Oct 11 01:02:46 UTC 2025 x86_64
User : www-data ( 33)
PHP Version : 8.2.30
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : OFF
Directory :  /var/www/html/public_html/lib/pkp/js/controllers/form/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /var/www/html/public_html/lib/pkp/js/controllers/form/UserFormHandler.js
/**
 * @file js/controllers/form/UserFormHandler.js
 *
 * Copyright (c) 2014-2021 Simon Fraser University
 * Copyright (c) 2000-2021 John Willinsky
 * Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
 *
 * @class UserFormHandler
 * @ingroup js_controllers_form
 *
 * @brief Add tools to the AjaxFormHandler facilitating user creation/editing.
 */
(function($) {


	/**
	 * @constructor
	 *
	 * @extends $.pkp.controllers.form.AjaxFormHandler
	 *
	 * @param {jQueryObject} $form the wrapped HTML form element.
	 * @param {{
	 *  fetchUsernameSuggestionUrl: string,
	 *  usernameSuggestionTextAlert: string,
	 *  hideNonReviewerInterests: boolean
	 *  }} options options to configure the form handler.
	 */
	$.pkp.controllers.form.UserFormHandler = function($form, options) {
		this.parent($form, options);

		// Set data for suggesting usernames.  Both keys should be present.
		if (options.fetchUsernameSuggestionUrl &&
				options.usernameSuggestionTextAlert) {
			this.fetchUsernameSuggestionUrl_ = options.fetchUsernameSuggestionUrl;
			this.usernameSuggestionTextAlert_ = options.usernameSuggestionTextAlert;
		}

		// Attach handler to suggest username button (if present)
		$('[id^="suggestUsernameButton"]', $form).click(
				this.callbackWrapper(this.generateUsername));

		if (options.hideNonReviewerInterests) {
			$('[id^="reviewerGroup-"]', $form).click(
					this.callbackWrapper(this.setInterestsVisibility_));
			this.setInterestsVisibility_();
		}
	};
	$.pkp.classes.Helper.inherits(
			$.pkp.controllers.form.UserFormHandler,
			$.pkp.controllers.form.AjaxFormHandler);


	//
	// Private properties
	//
	/**
	 * The URL to be called to fetch a username suggestion.
	 * @private
	 * @type {string}
	 */
	$.pkp.controllers.form.UserFormHandler.
			prototype.fetchUsernameSuggestionUrl_ = '';


	/**
	 * The message that will be displayed if users click on suggest
	 * username button with no data in family name.
	 * @private
	 * @type {string}
	 */
	$.pkp.controllers.form.UserFormHandler.
			prototype.usernameSuggestionTextAlert_ = '';


	//
	// Protected methods
	//
	/**
	 * Event handler that is called when the suggest username button is clicked.
	 *
	 * @param {HTMLElement} el clicked by this event
	 * @param {Event} e triggered
	 */
	$.pkp.controllers.form.UserFormHandler.prototype.
			generateUsername = function(el, e) {

		// Don't submit the form!
		e.preventDefault();

		var $form = this.getHtmlElement(),
				givenName, familyName, fetchUrl, sitePrimaryLocale;

		// Fetch entered names
		sitePrimaryLocale =
				/** @type {string} */ ($('[name="sitePrimaryLocale"]', $form).val());
		givenName = /** @type {string} */ ($('[name="givenName[' +
				sitePrimaryLocale + ']"]', $form).val());
		familyName = /** @type {string} */ ($('[name="familyName[' +
				sitePrimaryLocale + ']"]', $form).val());

		// Replace dummy values in the URL with entered values
		fetchUrl = this.fetchUsernameSuggestionUrl_.
				replace('GIVEN_NAME_PLACEHOLDER', givenName).
				replace('FAMILY_NAME_PLACEHOLDER', familyName);

		$.get(fetchUrl, this.callbackWrapper(this.setUsername), 'json');
	};


	/**
	 * Check JSON message and set it to username, back on form.
	 * @param {HTMLElement} formElement The Form HTML element.
	 * @param {JSONType} jsonData The jsonData response.
	 */
	$.pkp.controllers.form.UserFormHandler.prototype.
			setUsername = function(formElement, jsonData) {

		var processedJsonData = this.handleJson(jsonData),
				$form = this.getHtmlElement();

		if (processedJsonData === false) {
			throw new Error('JSON response must be set to true!');
		}

		// Re-validate the field
		$('[id^="username"]', $form).val(processedJsonData.content)
				.trigger('blur');
	};


	//
	// Private methods
	//
	/**
	 * Event handler that is called when a reviewer role checkbox is clicked.
	 * @private
	 */
	$.pkp.controllers.form.UserFormHandler.prototype.
			setInterestsVisibility_ = function() {
		var $form = this.getHtmlElement(), $interestsElement = $('#interests', $form);
		if ($('[id^="reviewerGroup-"]:checked', $form).size()) {
			// At least one checked reviewer role was found; show interests
			$interestsElement.show(300);
		} else {
			// No checked reviewer roles found; hide interests
			$interestsElement.hide(300);
		}
	};
}(jQuery));

Youez - 2016 - github.com/yon3zu
LinuXploit