From 863aee17e8cc9ed90dcc713808ef5a1a0d457db1 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Wed, 20 Mar 2013 14:51:44 -0400
Subject: [PATCH] Bug 9443 [Revised] Use DataTables on MARC frameworks administration

Replace the tablesorter plugin with the DataTables plugin on the
MARC frameworks administration page.

To test, open the MARC frameworks dministration page (Administration ->
MARC bibliographic framework -> MARC structure). Confirm that table
sorting, paging, and searching works correctly.

Revision corrects path to DataTables assets, merges with new
Bootstrap version of the page, and corrects minor markup errors.

Signed-off-by: Frederic Durand <frederic.durand@unilim.fr>
---
 .../prog/en/modules/admin/marctagstructure.tt      |   34 +++++++++++++-------
 1 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt
index 8886fcf..91e7251 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marctagstructure.tt
@@ -5,14 +5,11 @@
 [% IF ( delete_confirmed ) %]MARC frameworks &rsaquo;  Data deleted[% END %]
 [% IF ( else ) %]MARC frameworks[% END %]</title>
 [% INCLUDE 'doc-head-close.inc' %]
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
-<script type="text/javascript" id="js">$(document).ready(function() {
-	$("#table_marctagstructure").tablesorter({
-		sortList: [[0,0]],
-		headers: { 5: { sorter: false},6: { sorter: false},7: { sorter: false}}
-	}).tablesorterPager({container: $("#pagertable_marctagstructure"),positionFixed: false,size: 20});
-}); </script>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
+<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
+[% INCLUDE 'datatables-strings.inc' %]
+<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
+
 <script type="text/javascript">
 //<![CDATA[
 function Check(f) {
@@ -30,6 +27,18 @@ function Check(f) {
         alert(alertString2);
     }
 }
+
+$(document).ready(function() {
+    $("#table_marctagstructure").dataTable($.extend(true, {}, dataTablesDefaults, {
+        "aoColumnDefs": [
+            { "aTargets": [ -1, -2, -3 ], "bSortable": false, "bSearchable": false },
+        ],
+        "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
+        "iDisplayLength": 20,
+        "sPaginationType": "four_button"
+    }));
+});
+
 //]]>
 </script>
 </head>
@@ -152,11 +161,10 @@ function Check(f) {
         [% END %]</p>
 </fieldset>
 </form>
-<div id="pagertable_marctagstructure">
-[% INCLUDE 'table-pager.inc' perpage='20' %]
-</div>
+
     <table id="table_marctagstructure">
     <thead>
+        <tr>
         <th>Tag</th>
         <th>Lib</th>
         <th>Repeatable</th>
@@ -165,8 +173,9 @@ function Check(f) {
         <th>Subfields</th>
         <th>Edit</th>
         <th>Delete</th>
+        </tr>
 	</thead>
-
+    <tbody>
     [% IF ( select_display ) %]
         [% FOREACH loo IN loop %]
             [% IF ( loop.odd ) %]<tr>[% ELSE %]<tr class="highlight">[% END %]
@@ -204,6 +213,7 @@ function Check(f) {
     </tr>
     [% END %]
     [% END %]
+    </tbody>
     </table>
 
 
-- 
1.7.2.5