<tal:block metal:use-macro="python:here.getFormsTool().getForm('site_admin_template').macros['page']">
<h1 metal:fill-slot="title" i18n:translate="">Main sections</h1>
<tal:block metal:fill-slot="section"
	tal:define="site_url here/getSitePath;
				maintopics here/getMainTopics">
<script type="text/javascript">
	$(document).ready(function(){
		$('#maintopicslist').sortable({
			axis: 'y',
			cursor: 'move',
			update: function(event, ui){
				$('#positions').val($(this).sortable('toArray').join('|'));
			}
		});
	});

	function setupWin(url, theWidth, theHeight)
	{
		wwinn=window.open(url,'wwinn','width='+theWidth+',height='+theHeight+',scrollbars,top=50,left=600');
		wwinn.focus();
		return true;
	}

	function createKey(key)
	{
		document.forms['frmEditTopic'].folder_url.value = key;
	}
</script>
<p i18n:translate="">
	The order of display can be set by dragging and dropping the boxes, and then
	clicking <strong i18n:name="save-button" i18n:translate="">Save positions</strong>.
</p>
<form name="frmDragDrop" class="maintopics-drag-drop-form" method="post" action="">
	<ul id="maintopicslist" class="boxy">
		<li tal:repeat="item maintopics" tal:attributes="id python:here.rstk['path_in_site'](item)">
			<input type="checkbox" class="chk" name="ids"
				   tal:attributes="value python:here.rstk['path_in_site'](item)" />
			<span tal:replace="python:here.utTruncateString(item.title_or_id(), 40)" />
		</li>
	</ul>

	<input type="hidden" id="positions" name="positions" />
	<input type="submit" name="../admin_ordermaintopics:method" value="Save positions" i18n:attributes="value"/>
	<input type="submit" name="../admin_deletemaintopics:method" value="Remove" i18n:attributes="value"/>
</form>
<p i18n:translate=""><strong i18n:name="tip" i18n:translate="">Tip:</strong> when you delete a main section, the corresponding folder will be just
	taken out from the main sections' list, not physically deleted.
</p>


<fieldset>
	<legend i18n:translate="">Assign folder as main section</legend>
	<form method="post" tal:attributes="action string:${site_url}/admin_updatemaintopics" name="frmEditTopic">
		<p i18n:translate="">
			Pick a folder from this portal and press the
			<em i18n:name="submit-button" i18n:translate="">Submit</em>
			button in order to mark it as main section.
		</p>

		<div class="field">
			<label for="folder_url" i18n:translate="">URL</label>
			<input type="text" name="folder_url" id="folder_url" size="50" />
			<input type="button" value="Pick" i18n:translate=""
					tal:define="sitemap_path here/getSitePath"
					tal:attributes="onclick string:setupWin('${sitemap_path}/sitemap_add_html?display_root=0&showitems=0', 300, 500);;" />
		</div>
		<div class="field">
			<label for="submit-button" class="invisible" i18n:translate="">Submit button</label>
			<input type="submit" value="Submit" id="submit-button" i18n:attributes="value" />
		</div>
	</form>
</fieldset>
<br />
<fieldset>
	<legend i18n:translate="">Navigation properties</legend>
	<form method="post" tal:attributes="action string:${site_url}/admin_updatemaintopics_navigation" name="frmNavigation">
		<p i18n:translate="">
		Select a default navigation style and press the
		<em i18n:name="submit-button" i18n:translate="">Save</em> button.
		</p>
		<div class="field">
			<label>
				<select name="expanded:boolean" tal:define="if_expr python: getattr(here, 'maintopics_settings', {}).get('expanded', True)">
					<option tal:attributes="selected python: if_expr and 'selected' or ''"
							value="True" i18n:translate="">Yes</option>
					<option tal:attributes="selected python: not if_expr and 'selected' or ''"
							value="False" i18n:translate="">No</option>
				</select>
				<tal:block i18n:translate="">Default expanded</tal:block>
			</label>
			<em class="help-text" i18n:translate="">The above option allows you to specify if the main sections are expanded or collapsed by default.</em>
		</div>
		<div class="field">
			<label>
				<select name="persistent:boolean" tal:define="if_expr python: getattr(here, 'maintopics_settings', {}).get('persistent', True)">
					<option tal:attributes="selected python: if_expr and 'selected' or ''"
							value="True" i18n:translate="">Yes</option>
					<option tal:attributes="selected python: not if_expr and 'selected' or ''"
							value="False" i18n:translate="">No</option>
				</select>
				<tal:block i18n:translate="">Persistent navigation</tal:block>
			</label>
			<em class="help-text" i18n:translate="">The above option allows the user to keep the state of collapsed/expanded items while navigating the site.</em>
		</div>
		<div class="field">
			<label for="expand_levels" i18n:translate="">Expand levels</label>
			<input type="text" name="expand_levels:int" id="expand_levels"
				   tal:attributes="value python: getattr(here, 'maintopics_settings', {}).get('expand_levels', 1)"/>
			<br/>
			<em class="help-text" i18n:translate="">The above option specifies the depth of the expanded navigation tree.</em>
		</div>
		<div class="field">
			<label for="max_levels" i18n:translate="">Maximum levels</label>
			<input type="text" name="max_levels:int" id="max_levels"
				   tal:attributes="value python: getattr(here, 'maintopics_settings', {}).get('max_levels', 2)"/>
			<br/>
			<em class="help-text" i18n:translate="">The above option specifies the maximum depth of the navigation tree.</em>
		</div>
		<div class="field">
			<label for="submit-button" class="invisible" i18n:translate="">Submit button</label>
			<input type="submit" value="Save" id="submit-button" i18n:attributes="value" />
		</div>
	</form>
</fieldset>
</tal:block>

</tal:block>
