View | Details | Raw Unified | Return to bug 9431
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/en/js/datatables.js (+57 lines)
Lines 414-416 $.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) { Link Here
414
    y = parseFloat( y );
414
    y = parseFloat( y );
415
    return ((x < y) ?  1 : ((x > y) ? -1 : 0));
415
    return ((x < y) ?  1 : ((x > y) ? -1 : 0));
416
};
416
};
417
418
(function() {
419
420
/*
421
 * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
422
 * Author: Jim Palmer (based on chunking idea from Dave Koelle)
423
 * Contributors: Mike Grier (mgrier.com), Clint Priest, Kyle Adams, guillermo
424
 * See: http://js-naturalsort.googlecode.com/svn/trunk/naturalSort.js
425
 */
426
function naturalSort (a, b) {
427
    var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
428
        sre = /(^[ ]*|[ ]*$)/g,
429
        dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
430
        hre = /^0x[0-9a-f]+$/i,
431
        ore = /^0/,
432
        // convert all to strings and trim()
433
        x = a.toString().replace(sre, '') || '',
434
        y = b.toString().replace(sre, '') || '',
435
        // chunk/tokenize
436
        xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
437
        yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
438
        // numeric, hex or date detection
439
        xD = parseInt(x.match(hre), 10) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
440
        yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
441
    // first try and sort Hex codes or Dates
442
    if (yD)
443
        if ( xD < yD ) return -1;
444
        else if ( xD > yD )  return 1;
445
    // natural sorting through split numeric strings and default strings
446
    for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
447
        // find floats not starting with '0', string or 0 if not defined (Clint Priest)
448
        var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
449
        var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
450
        // handle numeric vs string comparison - number < string - (Kyle Adams)
451
        if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? 1 : -1;
452
        // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
453
        else if (typeof oFxNcL !== typeof oFyNcL) {
454
            oFxNcL += '';
455
            oFyNcL += '';
456
        }
457
        if (oFxNcL < oFyNcL) return -1;
458
        if (oFxNcL > oFyNcL) return 1;
459
    }
460
    return 0;
461
}
462
463
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
464
    "natural-asc": function ( a, b ) {
465
        return naturalSort(a,b);
466
    },
467
468
    "natural-desc": function ( a, b ) {
469
        return naturalSort(a,b) * -1;
470
    }
471
} );
472
473
}());
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categorie.tt (-15 / +25 lines)
Lines 5-27 Link Here
5
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
5
[% IF ( delete_confirmed ) %]Category deleted[% END %]</title>
6
[% INCLUDE 'doc-head-close.inc' %]
6
[% INCLUDE 'doc-head-close.inc' %]
7
[% INCLUDE 'calendar.inc' %]
7
[% INCLUDE 'calendar.inc' %]
8
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
8
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
9
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
9
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.dataTables.min.js"></script>
10
<script type="text/javascript" id="js">$(document).ready(function() {
10
[% INCLUDE 'datatables-strings.inc' %]
11
	$("#table_categorie").tablesorter({
11
<script type="text/javascript" src="[% themelang %]/js/datatables.js"></script>
12
		sortList: [[0,0]],
12
<script type="text/javascript" id="js">
13
		widgets: ['zebra'],
13
//<![CDATA[
14
		headers: { 11: { sorter: false}}
14
    $(document).ready(function() {
15
	}).tablesorterPager({container: $("#pagertable_categorie"),positionFixed: false,size: 20});
15
        $("#table_categorie").dataTable($.extend(true, {}, dataTablesDefaults, {
16
            "aoColumnDefs": [
17
                { "aTargets": [ -1, -2 ], "bSortable": false, "bSearchable": false },
18
                { "aTargets": [ 3,4,5 ], "sType": "natural" },
19
            ],
20
            "aaSorting": [[ 1, "asc" ]],
21
            "aLengthMenu": [[10, 20, 50, 100, -1], [10, 20, 50, 100, "All"]],
22
            "iDisplayLength": 20,
23
            "sPaginationType": "four_button"
24
        }));
25
16
    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
26
    $( "#enrolmentperioddate" ).datepicker({ minDate: 1 }); // Require that "until date" be in the future
17
27
18
    if ( $("#branches option:selected").length < 1 ) {
28
    if ( $("#branches option:selected").length < 1 ) {
19
        $("#branches option:first").attr("selected", "selected");
29
        $("#branches option:first").attr("selected", "selected");
20
    }
30
    }
21
}); </script>
31
});
22
<script type="text/javascript">
23
//<![CDATA[
24
	//
25
	function isNotNull(f,noalert) {
32
	function isNotNull(f,noalert) {
26
		if (f.value.length ==0) {
33
		if (f.value.length ==0) {
27
   return false;
34
   return false;
Lines 276-285 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
276
	[% END %]
283
	[% END %]
277
[% IF ( loop ) %]
284
[% IF ( loop ) %]
278
<div id="pagertable_categorie">
285
<div id="pagertable_categorie">
279
[% INCLUDE 'table-pager.inc' perpage='20' %]
280
</div>
286
</div>
281
        <table id="table_categorie">
287
        <table id="table_categorie">
282
		<thead>
288
		<thead>
289
        <tr>
283
			<th scope="col">Code</th>
290
			<th scope="col">Code</th>
284
			<th scope="col">Category name</th>
291
			<th scope="col">Category name</th>
285
			<th scope="col">Type</th>
292
			<th scope="col">Type</th>
Lines 294-301 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
294
            <th scope="col">Messaging</th>
301
            <th scope="col">Messaging</th>
295
            [% END %]
302
            [% END %]
296
            <th scope="col">Branches limitations</th>
303
            <th scope="col">Branches limitations</th>
297
			<th scope="col" colspan="2">&nbsp; </th>
304
            <th scope="col">&nbsp; </th>
305
            <th scope="col">&nbsp; </th>
306
        </tr>
298
		</thead>
307
		</thead>
308
        <tbody>
299
		[% FOREACH loo IN loop %]
309
		[% FOREACH loo IN loop %]
300
			<tr>
310
			<tr>
301
                        <td>[% loo.categorycode |html %]</td>
311
                        <td>[% loo.categorycode |html %]</td>
Lines 368-373 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
368
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
378
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
369
		</tr>
379
		</tr>
370
		[% END %]
380
		[% END %]
381
        </tbody>
371
	</table>
382
	</table>
372
[% ELSE %]
383
[% ELSE %]
373
	<div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categorie.pl?op=add_form">Create a new category</a>.</div>
384
	<div class="dialog alert">No categories have been defined. <a href="/cgi-bin/koha/admin/categorie.pl?op=add_form">Create a new category</a>.</div>
374
- 

Return to bug 9431