<%--
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */
--%>

<%@ include file="/init.jsp" %>

<liferay-frontend:edit-form
	action="javascript:void(0);"
	name="inviteUsersFm"
	onSubmit='<%= liferayPortletResponse.getNamespace() + "submit();" %>'
>
	<liferay-frontend:edit-form-body>
		<aui:input helpMessage="please-enter-valid-email-addresses-separated-by-commas" label="email-addresses" name="emailAddresses" required="<%= true %>" />
	</liferay-frontend:edit-form-body>

	<liferay-frontend:edit-form-footer>
		<liferay-frontend:edit-form-buttons
			submitLabel="invite"
		/>
	</liferay-frontend:edit-form-footer>
</liferay-frontend:edit-form>

<aui:script>
	function <portlet:namespace />submit() {
		var form = Liferay.Form.get('<portlet:namespace />inviteUsersFm');

		var formValidator = form.formValidator;

		formValidator.validate();

		if (!formValidator.hasErrors()) {
			var openingLiferay = Liferay.Util.getOpener().Liferay;

			openingLiferay.fire(
				'<%= HtmlUtil.escapeJS(liferayPortletResponse.getNamespace() + "inviteUsers") %>',
				{
					accountEntryId:
						'<%= ParamUtil.getString(request, "accountEntryId") %>',
					emailAddresses: document.getElementById(
						'<portlet:namespace />emailAddresses'
					).value,
					redirect: '<%= ParamUtil.getString(request, "redirect") %>',
				}
			);
		}
	}
</aui:script>