<%--
/**
 * 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="/document_library/init.jsp" %>

<%
DLAccessFromDesktopDisplayContext dlAccessFromDesktopDisplayContext = new DLAccessFromDesktopDisplayContext(request);
%>

<div id="<%= dlAccessFromDesktopDisplayContext.getRandomNamespace() %>webDav" style="display: none;">
	<div class="portlet-document-library">
		<liferay-ui:message key="<%= dlAccessFromDesktopDisplayContext.getWebDAVHelpMessage() %>" />

		<liferay-learn:message
			key="webdav"
			resource="document-library-web"
		/>

		<br /><br />

		<aui:input cssClass="webdav-url-resource" id='<%= dlAccessFromDesktopDisplayContext.getRandomNamespace() + "webDavURL" %>' name="webDavURL" type="resource" value="<%= dlAccessFromDesktopDisplayContext.getWebDAVURL() %>" />
	</div>
</div>

<aui:script>
	Liferay.Util.setPortletConfigurationIconAction(
		'<portlet:namespace />accessFromDesktop',
		() => {
			var webdavContentContainer = document.getElementById(
				'<%= dlAccessFromDesktopDisplayContext.getRandomNamespace() %>webDav'
			);

			var html = '';

			if (webdavContentContainer) {
				html = webdavContentContainer.innerHTML;

				webdavContentContainer.remove();

				Liferay.Util.openModal({
					bodyHTML: html,
					onOpen: function (event) {
						var webdavURLInput = document.getElementById(
							'<portlet:namespace /><%= dlAccessFromDesktopDisplayContext.getRandomNamespace() %>webDavURL'
						);

						if (webdavURLInput) {
							webdavURLInput.focus();
						}
					},
					title:
						'<%= UnicodeLanguageUtil.get(request, "access-from-desktop") %>',
				});
			}
		}
	);
</aui:script>