<xf:macro name="buttons"
	arg-iconic="{{ false }}"
	arg-hideLink="{{ false }}"
	arg-label=""
	arg-pageUrl=""
	arg-pageTitle=""
	arg-pageDesc=""
	arg-pageImage="">

	<xf:if contentcheck="true">
		<xf:css src="share_controls.less" />

		<div class="shareButtons {{ $iconic ? 'shareButtons--iconic' : '' }}" data-xf-init="share-buttons" data-page-url="{$pageUrl}" data-page-title="{$pageTitle}" data-page-desc="{$pageDesc}" data-page-image="{$pageImage}">
			<xf:if is="$label is not empty">
				<span class="shareButtons-label">{$label}</span>
			</xf:if>

			<div class="shareButtons-buttons">
				<xf:contentcheck>
					<xf:if is="$xf.options.facebookLike">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--facebook" data-href="https://www.facebook.com/sharer.php?u={url}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('facebook') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.tweet.enabled">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--twitter" data-href="https://twitter.com/intent/tweet?url={url}&amp;text={title}{{ $xf.options.tweet.via ? '&amp;via=' . $xf.options.tweet.via : '' }}{{ $xf.options.tweet.related ? '&amp;related=' . $xf.options.tweet.related : '' }}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('twitter') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.redditShare">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--reddit" data-href="https://reddit.com/submit?url={url}&amp;title={title}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('reddit') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.pinterestShare">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--pinterest" data-href="https://pinterest.com/pin/create/bookmarklet/?url={url}&amp;description={title}&amp;media={image}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('pinterest') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.tumblrShare">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--tumblr" data-href="https://www.tumblr.com/widgets/share/tool?canonicalUrl={url}&amp;title={title}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('tumblr') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.whatsAppShare">
						<a class="shareButtons-button shareButtons-button--brand shareButtons-button--whatsApp" data-href="https://api.whatsapp.com/send?text={title}&nbsp;{url}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('whatsapp') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.emailShare">
						<a class="shareButtons-button shareButtons-button--email" data-href="mailto:?subject={title}&amp;body={url}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('email') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.webShare">
						<a class="shareButtons-button shareButtons-button--share is-hidden"
							data-xf-init="web-share"
							data-title="{$pageTitle}" data-text="{$pageDesc}" data-url="{$pageUrl}"
							data-hide=".shareButtons-button:not(.shareButtons-button--share)">

							<i aria-hidden="true"></i>
							<span>{{ phrase('share') }}</span>
						</a>
					</xf:if>

					<xf:if is="$xf.options.linkShare AND !$hideLink">
						<a class="shareButtons-button shareButtons-button--link is-hidden" data-clipboard="{url}">
							<i aria-hidden="true"></i>
							<span>{{ phrase('link') }}</span>
						</a>
					</xf:if>
				</xf:contentcheck>
			</div>
		</div>
	</xf:if>
</xf:macro>

<xf:macro name="share_clipboard_input" arg-label="!" arg-text="!" arg-successText="">
	<xf:css src="share_controls.less" />

	<xf:set var="$id">{{ unique_id() }}</xf:set>

	<div class="shareInput" data-xf-init="share-input" data-success-text="{$successText}">
		<xf:if is="$label">
			<label class="shareInput-label" for="{$id}">{$label}</label>
		</xf:if>
		<div class="inputGroup inputGroup--joined">
			<div class="shareInput-button inputGroup-text js-shareButton is-hidden"
				data-xf-init="tooltip" title="{{ phrase('copy_to_clipboard')|for_attr }}">

				<i aria-hidden="true"></i>
			</div>
			<xf:textbox class="shareInput-input js-shareInput"
				value="{$text}" readonly="true" id="{$id}" />
		</div>
	</div>
</xf:macro>