File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/admin/templates/form.view.tpl
<script type="text/javascript">
<!--
var imgWid = "<img src='images/1x1.gif' height='1' width='%%width%%' />";
var typeList = Array();
var typeName = Array();
var optionInfo = Array();
{foreach from=$FieldOptions key=f item=field id=viewTypeLoop}
typeList['{$field.name}'] = Array();
{foreach from=$field.filterOptions key=k item=v id=smallTypeLoop}
typeList['{$field.name}'][{$k}] = '{$v}';
{/foreach}
{/foreach}
{foreach from=$ViewOptions key=o item=view id=viewOptionLoop}
{capture name=ViewTitle}View_{$view}{/capture}
typeName["{$view}"] = "{$lang.$ViewTitle}";
{/foreach}
{foreach from=$OptionInfo key=op item=option id=optionViewLoop}
optionInfo['{$op}'] = Array();
optionInfo['{$op}']['type'] = '{$option.type}';
optionInfo['{$op}']['length'] = '{$option.length}';
{/foreach}
var fC = 0;// fC = filterCount
function addFilterRow() {
fC++;
$('#base_row').clone(true).hide('fast').fadeIn('slow').appendTo($('#base_row').parent()).attr('id', '{$FieldName}_row'+fC).css('display', 'block').addClass('countRows');
$('#{$FieldName}_row'+fC).children('.FieldLabel').html(imgWid.replace(/\%\%width\%\%/gi, $('.countRows:first .FieldLabel').width()));
{capture name=filterName}{$FieldName}_title{/capture}
$('#base_row').next().children('.FieldLabel').html('{$lang.$filterName}:');
$sCh = $('#{$FieldName}_row'+fC).children(':not(.FieldLabel)');
$sCh.filter(':not(.spanView)').show();
$sCh.filter(':eq(0)').children('select').attr('id', 'filtName'+fC).attr('name', 'filtName[]');
$sCh.filter(':eq(1)').children('select').attr('id', 'typeName'+fC).attr('name', 'typeName[]');
$sCh.filter(':eq(2)').attr('id', 'content'+fC).attr('name', 'content[]');
$('.hideFilter:not(last)').fadeIn('slow');
$('.RowTypeFilter').each(function() {
$(this).html(currLogic);
$(this).show();
});
$('.RowTypeFilter:last').hide();
}
function deleteFilterRow(row) {
if($('.countRows').length < 2) {
return;
}
$p = $(row).parent().parent();
$p.fadeOut('fast', function() {
$p.remove();
$('.hideFilter:not(last)').fadeIn('slow');
if($('.countRows').length < 2) {
$('.countRows:last .hideFilter').hide();
}
$('.RowTypeFilter:last').hide();
{capture name=filterName}{$FieldName}_title{/capture}
$('#base_row').next().children('.FieldLabel').html('{$lang.$filterName}:');
});
}
function selectField(item) {
var id = item.id.substr(8, (item.id.length - 8));
var count = item.value ? typeList[item.value].length : 0;
$('#{$FieldName}_row'+id).children('.spanView:eq(1)').css('display', 'inline').fadeIn('slow');
$('#typeName'+id).selectOptions('').removeOption(/./);
$('#typeName'+id).addOption('', '{$lang.PleaseSelectFilter}');
var i = 0;
for(i = 0; i < count; i++) {
$('#typeName'+id).addOption(typeList[item.value][i], typeName[typeList[item.value][i]]);
}
if(i == 1) {
document.getElementById('typeName'+id).selectedIndex = 1;
selectFilter(document.getElementById('typeName'+id));
}
}
function selectFilter(filter) {
var id = filter.id.substr(8, (filter.id.length - 8));
if(filter.value == "") {
return;
}
var myVal = optionInfo[filter.value]['type'];
var mLen = optionInfo[filter.value]['length'];
var element = '';
if(myVal == "text") {
element = "<input type='text' name='filterEntry[]' id='filterEntry"+id+"' maxlength='"+mLen+"' class='FilterEntry Field200' />";
} else if(myVal == "checkbox") {
element = "<input type='checkbox' name='filterEntry[]' id='filterEntry"+id+"' maxlength='"+mLen+"' class='FilterEntry' checked='checked' value='' />";
} else if(myVal == "int") { // Just means there's extra checking
element = "<input type='text' name='filterEntry[]' id='filterEntry"+id+"' value='' maxlength='"+mLen+"' class='FilterEntry Field200' />";
} else if(myVal == "groups") {
// Group list can be generated from a callback, and then populated if results returned as JSON
element = "<select name='filterEntry[]' id='filterEntry"+id+"' class='FilterEntry Field200'></select>";
element += "<script type='text/javascript'><!--\n";
element += "$('#filterEntry"+id+"').ajaxAddOption(\"remote.php?section={$section}&action=viewlist&type=group\");\n//--></scr"+"ipt>\n";
} else if(myVal == "statususer") {
// Status list taken from a callback
element = "<select name='filterEntry[]' id='filterEntry"+id+"' class='FilterEntry Field200'></select>";
element += "<script type='text/javascript'><!--\n";
element += "$('#filterEntry"+id+"').ajaxAddOption(\"remote.php?section={$section}&action=viewlist&type=status\");\n//--></scr"+"ipt>\n";
}
$('#{$FieldName}_row'+id).children('.spanView:eq(2)').css('display', 'inline').fadeIn('slow').html(element);
}
$(document).ready(function() {
addFilterRow();
});
//--></script>
<tr><td colspan="2">
</td></tr></table>
<div id="base_row" class="FieldRow" style="width: 100%; display: none;">
<span class="FieldLabel">{$lang.$filterName}:</span>
<span class="spanView">
<select name="filtName" id="filtName" onchange="selectField(this)" class="FiltName Field150">
<option value="">{$lang.PleaseSelectField}</option>
{foreach from=$FieldOptions key=k item=field id=viewNameLoop}
{capture name=fieldTitle}{$ViewType|ucfirst}_{$field.name}{/capture}
<option value="{$field.name}">{$lang.$fieldTitle}</option>
{/foreach}
</select>
</span>
<span class="spanView" style="display: none">
<select name="typeName" id="typeName" class="TypeName Field150" onchange="selectFilter(this)">
<option value="">{$lang.PleaseSelectFilter}</option>
</select>
</span>
<span id="content" class="spanView" style="display: none"></span>
<span class="RowTypeFilter"></span>
<span class="showFilter">
<img src="images/view_add.gif" onclick="addFilterRow();" title="{$lang.ViewNewFilter}" />
</span>
<span class="hideFilter">
<img src="images/view_del.gif" onclick="deleteFilterRow(this)" title="{$lang.ViewRemoveFilter}" />
</span>
</div>