{#
    Accepted parameters:
    p1tm: {
        bing_app_id: string,
        pixabay_username: string,
        pixabay_api_key: string,
        publishing_mode: enum(publish, draft)
    },
    do_success_redirect: bool,
    messages: [{
        error: bool,
        content: string
    }]
#}

{% include '@dashnex/modal/support.twig' %}

<form id="p1tm-settings-form" class="form-horizontal" method="post">

	<header class="dashnex-frame-header">
		<h2 class="pull-left" id="p1tm-settings-header">Settings</h2>
	
		<div class="dashnex-frame-actions">
			<div class="dashnex-frame-action-buttons">
				<input type="button" value="Discard" class="btn btn-default" data-toggle="modal" data-target="#p1tm-discard-modal"/>
				<input type="submit" value="Save" id="p1tm-settings-save-btn" class="btn btn-primary" data-toggle="modal" data-target="#p1tm-settings-save-confirm-modal"/>
			</div>
			<div class="dashnex-frame-loader-container"></div>
			<button type="button" class="btn btn-info dashnex-frame-popover-btn">Help!</button>
		</div>
	
		<div class="clearfix"></div>
	</header>
	
	<div class="dashnex-frame-popover">
		<div class="dashnex-frame-popover-arrow"></div>
		<h3 class="dashnex-frame-popover-title">Help!</h3>
		<div class="dashnex-frame-popover-content">
			<p>
				<a href="http://www.dashnex.com" target="_blank">Take me to the
					membership site.</a>
			</p>
			<p>
				<a id="show-support-modal-btn" href="#">I need to email support.</a>
			</p>
		</div>
	</div>

	{% if messages %}
	    {% for message in messages %}
	    <div class="{% if message.error %}error{% else %}updated{% endif %} below-h2">
	        <p>{{ message.content }}</p>
	    </div>
	    {% endfor %}
	{% endif %}

	<div class="dashnex-frame-padded-container">
		<h4>Keyword Generator Settings</h4>
		<div class="form-group">
			<label for="p1tm-bing-app-id" class="col-sm-3 control-label">Bing App
				Identifier</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" id="p1tm-bing-app-id"
					name="p1tm[bing_app_id]" value="{{ p1tm.bing_app_id }}" />
			</div>
		</div>
        <div class="form-group">
            <div class="col-sm-3"></div>
            <div class="col-sm-9">
                <p>
                    <em>You can sign up for Bing Search API at <a href="https://datamarket.azure.com/dataset/bing/search" target="_blank">https://datamarket.azure.com/dataset/bing/search</a></em>
                </p>
            </div>
        </div>
	</div>

	<div class="dashnex-frame-padded-container">
		<h4>Content Generator Settings</h4>
		<div class="form-group">
			<label for="p1tm-pixabay-username" class="col-sm-3 control-label">Pixabay
				Username</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" id="p1tm-pixabay-username"
					name="p1tm[pixabay_username]" value="{{ p1tm.pixabay_username }}" />
			</div>
		</div>
		<div class="form-group">
			<label for="p1tm-pixabay-api-key" class="col-sm-3 control-label">Pixabay
				API Key</label>
			<div class="col-sm-9">
				<input type="text" class="form-control" id="p1tm-pixabay-api-key"
					name="p1tm[pixabay_api_key]" value="{{ p1tm.pixabay_api_key }}" />
			</div>
		</div>
        <div class="form-group">
            <div class="col-sm-3"></div>
            <div class="col-sm-9">
                <p>
                    <em>You can sign up for Pixabay service at <a href="http://pixabay.com/en/accounts/register/" target="_blank">http://pixabay.com/en/accounts/register/</a></em>
                </p>
                <p>
                    <em>After signing up and logging in you can go to <a href="http://pixabay.com/api/docs/" target="_blank">http://pixabay.com/api/docs/</a> to receive your API key.</em>
                </p>
            </div>
        </div>
	</div>

	<div class="dashnex-frame-padded-container">
		<h4>Publishing Mode</h4>
		<div class="form-group">
			<label for="p1tm-publishing-mode" class="col-sm-3 control-label">Mode</label>
			<div class="col-sm-9">
				<select name="p1tm[publishing_mode]" id="p1tm-publishing-mode">
					<option value="publish"
						{% if p1tm.publishing_mode == 'publish' %}
							selected="selected"
						{% endif %}>Publish</option>
					<option value="draft"
						{% if p1tm.publishing_mode == 'draft' %}
							selected="selected"
						{% endif %}>Draft</option>
				</select>
			</div>
		</div>
	</div>

</form>
<script type="text/javascript">
/* <![CDATA[ */
var do_success_redirect = {{ do_success_redirect ? 'true' : 'false' }};
/* ]]> */
</script>
{% include '@p1tm/modals/discard.twig' %}
{% include '@p1tm/settings/modals/confirm.twig' %}
