{extends file=$element.methods->getTemplatePath('generalClone')}

{block name=counter append}
	<span class="dummy_rowIndex"></span>.
{/block}

{*** NOTE: values should always be set to 0 or to default values. The actual element values are handled by JS  ***}
{block name=input append}
	{if !$element.disabled}
		<input type="hidden"
			name="{$element.name}[sortOrder][]"
			id="{$element.displayID}_sortOrder_.:id:."
			value=".:id:."
		/>
	{/if}

	<input type="text"
		{if $element.style.CSSClass}
			class="{$element.style.CSSClass}"
		{/if}
		name="{$element.name}[title][.:id:.]"
		id="{$element.displayID}_title_.:id:."
		value=""

		{if $element.disabled}
			disabled="disabled"
		{/if}

		style="	{if $element.style.height} height:{$element.style.height}px;{/if}
				{if $element.style.width} width:{$element.style.width}px;{/if}"
	/>
{/block}


<script type="text/javascript">
	{*** NOTE: dont use single quotes(') in the script as there are some replacements automatically made on the main template ***}

	{block name=script prepend}


		{function name="onChange_clonedSortableText"}
		{/function}

		{function name="onClone_clonedSortableText"}
			{*** only initialize the js stuff if the element is not disabled ***}
			{if !$element.disabled}
				{if $element.hasValidator}
					_inputValidator.createOnLoad("{$element.displayID}_title_.:id:.", "{$element.validatorType}", {$element.validatorParams|@json_encode});
				{/if}

			{/if}

			{*** this is used by the generalClone.tpl to initialize and set field values ***}
			{*** NOTE: item is set when we're creating an element with predefined values (ex: on page load, when filling pre-existent elements) ***}
			if(item){
				$("{$element.displayID}_title_.:id:.").value = item;
			}
		{/function}

		{call name='onChange_clonedSortableText' assign=onChange_output}
		{call name='onClone_clonedSortableText' assign=onClone_output}
	{/block}
</script>
