PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 2ms app.codeStats 0ms

/apps/request/templates/default/list.tpl

http://zoop.googlecode.com/
Smarty Template | 159 lines | 138 code | 21 blank | 0 comment | 12 complexity | eef54cc9b8d40cf2dd2eb0e3a7c08cce MD5 | raw file
  1<div id="filterChoose">
  2	Current Filter: {html_options id="currentFilter" selected=$filterId name="currentFilter" options=$filterList}
  3</div>
  4
  5<hr>
  6
  7<div id="filterbox">
  8	{include file="filter/edit_body.tpl"}
  9	<button id="apply" type="button">Apply</button>
 10	<button id="save" type="button">Save</button>
 11</div>
 12<br>
 13<div><a href="#" onclick="$('#filterbox').toggle(); return false;">show/hide filter</a></div>
 14
 15
 16<script type="text/javascript">
 17
 18var filterId = '{$filterId}';
 19var content = {if $filter->content}{$filter->content}{else}null{/if};
 20
 21{literal}
 22$(document).ready(function() {
 23	$('#apply').click(function() {
 24		$('#list_table tbody').empty();
 25		var getVars = {filterData: getFilterData()};
 26		$.get(zoneUrl + '/listBody', getVars, function(html) {
 27			$("#list_table tbody").append(html); 
 28			$("#list_table tbody").trigger("update"); 
 29			var sorting = [[3,1],[1,0]]; 
 30			$("#list_table tbody").trigger("sorton", [sorting]); 
 31		});
 32		return false;
 33	});
 34	
 35	$('#save').click(function() {
 36		if(filterId)
 37		{
 38			var postData = {
 39				id: filterId,
 40				content: getFilterData()
 41			}
 42			$.post(zoneUrl + '/saveFilter', postData, function(res) {
 43				alert(res.id);
 44			}, 'json');			
 45		}
 46		else
 47			$('#dialog').dialog('open');
 48	});
 49	
 50	$('#currentFilter').change(function() {
 51		document.location = zoneUrl + '/list/' + $('#currentFilter').val();
 52	});
 53	
 54	$.tablesorter.addParser({
 55		id: 'priority',
 56		is: function(s) {
 57			return false;
 58		},
 59		format: function(s) {
 60			if(s == 'Low')
 61				return 1;
 62			else if(s == 'Medium')
 63				return 2;
 64			else if(s == 'High')
 65				return 3;
 66			else
 67				return 0;
 68			// return s.toLowerCase().replace(/low/,1).replace(/medium/,2).replace(/high/,3);
 69		},
 70		type: 'numeric'
 71	});
 72	
 73	$("#list_table").tablesorter({
 74		widgets: ['zebra'],
 75		headers: {
 76			3: {sorter: 'priority'}
 77		}
 78	});
 79	
 80	
 81	$("#dialog").dialog({
 82		autoOpen: false,
 83		modal: true,
 84		buttons: {
 85			'Save': function() {
 86				var newFilterName = $('#newFilterName').val();
 87				var postData = {
 88					id: filterId,
 89					name: newFilterName,
 90					content: getFilterData()
 91				}
 92				$.post(zoneUrl + '/saveFilter', postData, function(res) {
 93					if(!filterId && res.id)
 94						document.location = zoneUrl + '/list/' + res.id
 95				}, 'json');
 96				$(this).dialog('close');
 97			},
 98			Cancel: function() {
 99				$(this).dialog('close');
100			}
101		},
102		close: function() {
103		}
104	});
105	
106	// $("table").tablesorter();
107	// $("#ajax-append").click(function()
108	// {
109	// 	 $.get("assets/ajax-content.html", function(html)
110	// 	{
111	// 		 // append the "ajax'd" data to the table body
112	// 		 $("table tbody").append(html);
113	// 		// let the plugin know that we made a update
114	// 		$("table").trigger("update");
115	// 		// set sorting column and direction, this will sort on the first and third column
116	// 		var sorting = [[2,1],[0,0]];
117	// 		// sort on the first column
118	// 		$("table").trigger("sorton",[sorting]);
119	// 	});
120	// 	return false;
121	// });
122});
123
124
125
126{/literal}
127
128</script>
129
130<div id="main">
131  	<table id="list_table" class="tablesorter" border="0" cellpadding="0" cellspacing="1">
132	<thead>
133	<tr>
134		<th width="25">id</th>
135		<th>name</th>
136		<th>desc</th>
137		<th width="60">priority</th>
138		<th width="60">owner</th>
139		<th width="80">completed</th>
140	</tr>
141	</thead>
142	<tbody>
143		{include file="default/list_body.tpl"}
144	</tbody>
145</table>
146<input id="add" type="button" value="add" onclick="document.location = '{$scriptUrl}/edit'" ACCESSKEY="a">
147
148
149<div id="dialog" title="Save Filter">
150	<p>Please choose a name for this filter.</p>
151	<form>
152		<label for="name">Name:</label>
153		<input type="text" name="name" id="newFilterName" class="text ui-widget-content ui-corner-all" />
154	</form>
155</div>
156
157</div>
158{literal}
159{/literal}