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