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

<c:if test="<%= Validator.isNotNull(text) %>">
	<span class="staging-taglib-popover" id="<%= domId %>">
		<span class="staging-taglib-popover-icon-holder">
			<clay:icon
				symbol="question-circle-full"
			/>
		</span>

		<div class="bs-popover-right popover">
			<div class="arrow"></div>
			<div class="inline-scroller">
				<div class="popover-header"><%= title %></div>
				<div class="popover-body">
					<p><%= text %></p>
				</div>
			</div>
		</div>
	</span>

	<aui:script use="aui-base">
		A.ready('aui-base', function (A) {
			var popoverNode = A.one('#<%= domId %>');

			var popover = popoverNode.one('.popover');

			var arrow = popover.one('.arrow');

			var dx = arrow.width();
			var dy = arrow.height() / 2;

			var iconHolderNode = popoverNode.one('.staging-taglib-popover-icon-holder');

			iconHolderNode.on('hover', function alignPopoverToIcon(event) {
				if ('visible' !== popover.get('visibility')) {
					popover.setXY([
						iconHolderNode.getX() + iconHolderNode.width() + dx,
						iconHolderNode.getY() - dy,
					]);
				}
			});
		});
	</aui:script>
</c:if>