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="/intranet-tmpl/prog/en/css/datatables.css" />
9
<script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.pager.js"></script>
9
<script type="text/javascript" src="/intranet-tmpl/prog/en/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="/intranet-tmpl/prog/en/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 294-303 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
294
	[% END %]
301
	[% END %]
295
[% IF ( loop ) %]
302
[% IF ( loop ) %]
296
<div id="pagertable_categorie">
303
<div id="pagertable_categorie">
297
[% INCLUDE 'table-pager.inc' perpage='20' %]
298
</div>
304
</div>
299
        <table id="table_categorie">
305
        <table id="table_categorie">
300
		<thead>
306
		<thead>
307
        <tr>
301
			<th scope="col">Code</th>
308
			<th scope="col">Code</th>
302
			<th scope="col">Category name</th>
309
			<th scope="col">Category name</th>
303
			<th scope="col">Type</th>
310
			<th scope="col">Type</th>
Lines 312-319 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
312
            <th scope="col">Messaging</th>
319
            <th scope="col">Messaging</th>
313
            [% END %]
320
            [% END %]
314
            <th scope="col">Branches limitations</th>
321
            <th scope="col">Branches limitations</th>
315
			<th scope="col" colspan="2">&nbsp; </th>
322
            <th scope="col">&nbsp; </th>
323
            <th scope="col">&nbsp; </th>
324
        </tr>
316
		</thead>
325
		</thead>
326
        <tbody>
317
		[% FOREACH loo IN loop %]
327
		[% FOREACH loo IN loop %]
318
			<tr>
328
			<tr>
319
                        <td>[% loo.categorycode |html %]</td>
329
                        <td>[% loo.categorycode |html %]</td>
Lines 386-391 Confirm deletion of category [% categorycode |html %][% END %]</legend> Link Here
386
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
396
                        <td><a href="[% loo.script_name %]?op=delete_confirm&amp;categorycode=[% loo.categorycode |uri %]">Delete</a></td>
387
		</tr>
397
		</tr>
388
		[% END %]
398
		[% END %]
399
        </tbody>
389
	</table>
400
	</table>
390
[% ELSE %]
401
[% ELSE %]
391
	<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>
402
	<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>
392
- 

Return to bug 9431