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

(-)a/koha-tmpl/opac-tmpl/bootstrap/css/datatables.css (+22 lines)
Lines 19-24 div.dataTables_filter { Link Here
19
    margin : 0;
19
    margin : 0;
20
}
20
}
21
21
22
.dt-buttons {
23
    padding: .3em 0 0 0;
24
}
25
22
.dataTables_filter input {
26
.dataTables_filter input {
23
    background-color: #fff;
27
    background-color: #fff;
24
    border-radius: 0.2rem;
28
    border-radius: 0.2rem;
Lines 26-31 div.dataTables_filter { Link Here
26
    color: #495057;
30
    color: #495057;
27
    height: calc(1.5em + 0.5rem + 2px);
31
    height: calc(1.5em + 0.5rem + 2px);
28
    line-height: 1.5;
32
    line-height: 1.5;
33
    margin-left: 3px;
29
    padding: 0.25rem 0.5rem;
34
    padding: 0.25rem 0.5rem;
30
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
35
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out, -webkit-box-shadow 0.15s ease-in-out;
31
}
36
}
Lines 34-36 div.dataTables_filter { Link Here
34
    border-color: #85ca11;
39
    border-color: #85ca11;
35
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(194, 228, 136, 0.6);
40
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 8px rgba(194, 228, 136, 0.6);
36
}
41
}
42
43
div.dt-button-collection {
44
    background-color: white;
45
    border-radius: 5px;
46
    border: 1px solid #ccc;
47
    border: 1px solid rgba(0, 0, 0, 0.4);
48
    box-shadow: 3px 3px 5px rgba(0, 0, 0, 0.3);
49
    column-gap: 8px;
50
    left: 0;
51
    margin-top: 3px;
52
    overflow: hidden;
53
    padding: 8px 8px 4px 8px;
54
    position: absolute;
55
    top: 0;
56
    width: 150px;
57
    z-index: 2002;
58
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/_common.scss (+289 lines)
Lines 34-39 $sci-heading-color: #727272; Link Here
34
    border-radius: $radius;
34
    border-radius: $radius;
35
}
35
}
36
36
37
@mixin input-focus {
38
    border-color: #85CA11;
39
    box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(194, 228, 136, .6);
40
}
37
41
38
/* Bootstrap imports */
42
/* Bootstrap imports */
39
@import "../../../../../node_modules/bootstrap/scss/functions";
43
@import "../../../../../node_modules/bootstrap/scss/functions";
Lines 295-300 textarea, Link Here
295
    }
299
    }
296
}
300
}
297
301
302
.dt-button {
303
    background-color: transparent;
304
    border: 0;
305
    color: #0088cc;
306
    display: inline-block;
307
    line-height: 20px;
308
    padding: 4px 12px;
309
    text-align: center;
310
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
311
    vertical-align: middle;
312
313
    &:hover {
314
        color: #005580;
315
316
        &::before {
317
            color: #44AE89;
318
        }
319
    }
320
321
    &::before {
322
        color: #4466AE;
323
        font-family: FontAwesome;
324
        display: inline-block;
325
        padding-right: .5em;
326
    }
327
328
    &.disabled {
329
        color: #333;
330
        opacity: .65;
331
        pointer-events: none;
332
333
        &:hover {
334
            color: #333;
335
            filter: alpha(opacity=65);
336
            opacity: 0.65;
337
        }
338
339
        i {
340
341
            &.fa,
342
            &.fa:hover {
343
                color: #333;
344
                filter: alpha(opacity=65);
345
                opacity: 0.65;
346
            }
347
        }
348
    }
349
}
350
351
div.dt-button-collection button.dt-button,
352
div.dt-button-collection div.dt-button,
353
div.dt-button-collection a.dt-button {
354
    position: relative;
355
    left: 0;
356
    right: 0;
357
    width: 100%;
358
    display: block;
359
    float: none;
360
    margin-bottom: 4px;
361
    margin-right: 0;
362
}
363
364
div.dt-button-collection {
365
    width: auto
366
}
367
368
div.dt-button-collection button.dt-button {
369
    border-radius: 2px;
370
    text-align: left
371
}
372
373
div.dt-button-collection button.dt-button.buttons-collection {
374
    border: 0
375
}
376
377
div.dt-button-collection button.dt-button.buttons-columnVisibility {
378
    background: #fff none;
379
    border: 1px solid #eee;
380
    box-shadow: none;
381
    font-size: 1em;
382
    margin: 0 0 4px;
383
    padding: .3em .7em;
384
    text-shadow: none
385
}
386
387
div.dt-button-collection button.dt-button.buttons-columnVisibility:before {
388
    color: #c00;
389
    content: "\f00d";
390
    display: inline-block;
391
    font-family: FontAwesome;
392
    margin-right: .5em;
393
    width: 1em
394
}
395
396
div.dt-button-collection button.dt-button.buttons-columnVisibility:hover {
397
    background: #ffc none;
398
    border: 1px solid #999;
399
    box-shadow: none
400
}
401
402
div.dt-button-collection button.dt-button.buttons-columnVisibility:hover:before {
403
    color: #538200;
404
    content: "\f00c";
405
    display: inline-block;
406
    font-family: FontAwesome;
407
    margin-right: .5em;
408
    width: 1em
409
}
410
411
div.dt-button-collection button.dt-button.buttons-columnVisibility:active:not(.disabled):hover:not(.disabled) {
412
    background: transparent none;
413
    box-shadow: none
414
}
415
416
div.dt-button-collection button.dt-button.buttons-columnVisibility.active {
417
    background: #e6f0f2 none;
418
    border-color: #999;
419
    box-shadow: none
420
}
421
422
div.dt-button-collection button.dt-button.buttons-columnVisibility.active:hover {
423
    background: #ffc none
424
}
425
426
div.dt-button-collection button.dt-button.buttons-columnVisibility.active:hover:before {
427
    color: #c00;
428
    content: "\f00d";
429
    display: inline-block;
430
    font-family: FontAwesome;
431
    margin-right: .5em;
432
    width: 1em
433
}
434
435
div.dt-button-collection button.dt-button.buttons-columnVisibility.active:not(.disabled):hover:not(.disabled) {
436
    background: transparent none;
437
    box-shadow: none
438
}
439
440
div.dt-button-collection button.dt-button.buttons-columnVisibility.active:before {
441
    color: #538200;
442
    content: "\f00c";
443
    display: inline-block;
444
    font-family: FontAwesome;
445
    margin-right: .5em;
446
    width: 1em;
447
}
448
449
div.dt-button-collection button.dt-button.buttons-html5,
450
div.dt-button-collection button.dt-button.buttons-print {
451
    background: #fff none;
452
    border: 1px solid #eee;
453
    box-shadow: none;
454
    font-size: 1.2em;
455
    margin: 0 0 4px;
456
    padding: .3em .7em;
457
    text-shadow: none
458
}
459
460
div.dt-button-collection button.dt-button.buttons-html5:hover,
461
div.dt-button-collection button.dt-button.buttons-print:hover {
462
    background: #ffc none
463
}
464
465
div.dt-button-collection button.dt-button.buttons-html5:not(.disabled):before {
466
    color: #222bac;
467
    display: inline-block;
468
    font-family: FontAwesome;
469
    margin-right: .5em;
470
    width: 1em
471
}
472
473
div.dt-button-collection button.dt-button.buttons-excel:not(.disabled):before {
474
    content: "\f1c3"
475
}
476
477
div.dt-button-collection button.dt-button.buttons-csv:not(.disabled):before {
478
    content: "\f0ce"
479
}
480
481
div.dt-button-collection button.dt-button.buttons-copy:not(.disabled):before {
482
    content: "\f0c5"
483
}
484
485
div.dt-button-collection button.dt-button.buttons-print:not(.disabled):before {
486
    color: #222bac;
487
    content: "\f02f";
488
    display: inline-block;
489
    font-family: FontAwesome;
490
    margin-right: .5em;
491
    width: 1em
492
}
493
494
.dt-button-info {
495
    position: fixed;
496
    top: 50%;
497
    left: 50%;
498
    width: 400px;
499
    margin-top: -100px;
500
    margin-left: -200px;
501
    background-color: #FFF;
502
    border: 2px solid #005580;
503
    box-shadow: 3px 3px 8px rgba(0, 0, 0, 0.3);
504
    border-radius: 3px;
505
    text-align: center;
506
    z-index: 21;
507
508
    h2 {
509
        padding: 0.5em;
510
        margin: 0;
511
        font-weight: normal;
512
        border-bottom: 1px solid #ddd;
513
        background-color: #f3f3f3;
514
    }
515
516
    &>div {
517
        padding: 1em;
518
    }
519
}
520
521
.buttons-print {
522
    &::before {
523
        content: "\f02f";
524
    }
525
}
526
527
.buttons-csv {
528
    &::before {
529
        content: "\f0ce";
530
    }
531
}
532
533
.buttons-copy {
534
    &::before {
535
        content: "\f0c5";
536
    }
537
}
538
539
.buttons-ical {
540
    &::before {
541
        content: "\f073";
542
    }
543
544
    &:hover {
545
        text-decoration: none;
546
    }
547
}
548
549
.buttons-renew,
550
.buttons-renewall {
551
    &:hover {
552
        i.fa {
553
            color: #44AE89;
554
        }
555
    }
556
}
557
558
.buttons-colvis {
559
    &::before {
560
        content: "\f013";
561
    }
562
}
563
564
.table_controls {
565
    display: flex;
566
567
    .dataTables_filter {
568
        label {
569
            input {
570
                margin-left: 5px;
571
            }
572
        }
573
574
        input {
575
            @extend .form-control;
576
            @extend .form-control-sm;
577
            display: inline-block;
578
            width: auto;
579
580
            &:focus {
581
                @include input-focus;
582
            }
583
        }
584
    }
585
}
586
298
[class^="icon-"] {
587
[class^="icon-"] {
299
    vertical-align: 0;
588
    vertical-align: 0;
300
}
589
}
(-)a/koha-tmpl/opac-tmpl/bootstrap/css/src/opac.scss (-29 / +2 lines)
Lines 10-16 Link Here
10
        padding: 0;
10
        padding: 0;
11
    }
11
    }
12
12
13
    .selections-toolbar {
13
    .selections-toolbar,
14
    #renewall_js {
14
        display: none;
15
        display: none;
15
    }
16
    }
16
17
Lines 542-548 th { Link Here
542
    }
543
    }
543
}
544
}
544
545
545
546
.breadcrumb {
546
.breadcrumb {
547
    background-color: #F0F3F3;
547
    background-color: #F0F3F3;
548
    font-size: 85%;
548
    font-size: 85%;
Lines 552-584 th { Link Here
552
    border-radius: 0px;
552
    border-radius: 0px;
553
}
553
}
554
554
555
.buttons-print {
556
    background-color: transparent;
557
    border: 0;
558
    color: #0088cc;
559
    display: inline-block;
560
    line-height: 20px;
561
    padding: 4px 12px;
562
    text-align: center;
563
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
564
    vertical-align: middle;
565
566
    &:hover {
567
        color: #005580;
568
        &::before {
569
            color: #44AE89;
570
        }
571
    }
572
573
    &::before {
574
        color: #4466AE;
575
        content: "\f02f";
576
        font-family: FontAwesome;
577
        display: inline-block;
578
        padding-right: .5em;
579
    }
580
}
581
582
#opac-main-search {
555
#opac-main-search {
583
    background: #f0f3f3;
556
    background: #f0f3f3;
584
    margin: 7px 0;
557
    margin: 7px 0;
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-details.tt (-1 / +5 lines)
Lines 122-130 Link Here
122
        $(document).ready(function() {
122
        $(document).ready(function() {
123
            columns_settings = [% TablesSettings.GetColumns( 'opac', 'biblio-detail', 'course-items-table', 'json' ) | $raw %];
123
            columns_settings = [% TablesSettings.GetColumns( 'opac', 'biblio-detail', 'course-items-table', 'json' ) | $raw %];
124
            KohaTable("#course-items-table", {
124
            KohaTable("#course-items-table", {
125
                "dom": '<"top"f>rt<"clear">',
125
                "dom": '<"top"<"table_controls"f>>t',
126
                "sorting": [[ 1, "asc" ]],
126
                "sorting": [[ 1, "asc" ]],
127
                "autoWidth": false,
127
                "autoWidth": false,
128
                "language": {
129
                    "search": "_INPUT_",
130
                    "searchPlaceholder": _("Search course reserves")
131
                }
128
            }, columns_settings );
132
            }, columns_settings );
129
        });
133
        });
130
    </script>
134
    </script>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-course-reserves.tt (-1 / +1 lines)
Lines 84-90 Link Here
84
                ],
84
                ],
85
                "language": {
85
                "language": {
86
                    "search": "_INPUT_",
86
                    "search": "_INPUT_",
87
                    "searchPlaceholder": "Search courses"
87
                    "searchPlaceholder": _("Search courses")
88
                }
88
                }
89
            }, columns_settings );
89
            }, columns_settings );
90
        });
90
        });
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-18 / +30 lines)
Lines 420-441 Link Here
420
                                </table>
420
                                </table>
421
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
421
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
422
                                    <input type="submit" class="btn btn-primary" value="Renew selected" />
422
                                    <input type="submit" class="btn btn-primary" value="Renew selected" />
423
                                    <button type="button" id="renewall_js" class="btn btn-primary">Renew all</button>
423
                                [% END %]
424
                                [% END %]
424
                                </form>
425
                                </form>
425
426
426
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
427
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
427
                                <form id="renewall" action="/cgi-bin/koha/opac-renew.pl" method="post">
428
                                    <form id="renewall" class="js-hide" action="/cgi-bin/koha/opac-renew.pl" method="post">
428
                                    <input type="hidden" name="from" value="opac_user" />
429
                                        <input type="hidden" name="from" value="opac_user" />
429
                                    <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
430
                                        <input type="hidden" name="borrowernumber" value="[% borrowernumber | html %]" />
430
                                    [% FOREACH ISSUE IN ISSUES %]
431
                                        [% FOREACH ISSUE IN ISSUES %]
431
                                        [% IF ISSUE.status %]
432
                                            [% IF ISSUE.status %]
432
                                            <input type="hidden" name="item" value="[% ISSUE.itemnumber | html %]" />
433
                                                <input type="hidden" name="item" value="[% ISSUE.itemnumber | html %]" />
434
                                            [% END %]
433
                                        [% END %]
435
                                        [% END %]
434
                                    [% END %]
436
                                        <input type="submit" class="btn btn-primary" value="Renew all" />
435
                                    <input type="submit" class="btn btn-primary" value="Renew all" />
437
                                    </form>
436
                                </form>
437
                                [% END %]
438
                                [% END %]
438
                                <p><a href="opac-ics.pl">Download as iCal/.ics file</a></p>
439
                            [% ELSE %]
439
                            [% ELSE %]
440
                                <table class="table table-bordered table-striped">
440
                                <table class="table table-bordered table-striped">
441
                                    <tr><td>You have nothing checked out</td></tr>
441
                                    <tr><td>You have nothing checked out</td></tr>
Lines 797-803 Link Here
797
    [% INCLUDE 'calendar.inc' %]
797
    [% INCLUDE 'calendar.inc' %]
798
    [% INCLUDE 'datatables.inc' %]
798
    [% INCLUDE 'datatables.inc' %]
799
    <script>
799
    <script>
800
800
        function tableInit( tableId ){
801
            if( tableId == "checkoutst" ){
802
                $(".dt-buttons").append("<a class=\"dt-button buttons-ical\" href=\"opac-ics.pl\">iCal</a> ");
803
                [% IF ( OpacRenewalAllowed && canrenew && !userdebarred ) %]
804
                    $(".dt-buttons").append("<button id=\"renewselected_link\" class=\"dt-button buttons-renew\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> "+_("Renew selected")+"</button> <button id=\"renewall_link\" class=\"dt-button buttons-renewall\"><span class=\"fa-stack\"><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i></span> "+_("Renew all")+"</button>");
805
                [% END %]
806
            }
807
        }
801
        $(document).ready(function(){
808
        $(document).ready(function(){
802
            $('#opac-user-views').tabs();
809
            $('#opac-user-views').tabs();
803
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
810
            $(".modal-nojs").addClass("modal").addClass("hide").removeClass("modal-nojs");
Lines 854-866 Link Here
854
            var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table");
861
            var dTables = $("#checkoutst,#holdst,#overduest,#opac-user-relative-issues-table");
855
            dTables.each(function(){
862
            dTables.each(function(){
856
                var thIndex = $(this).find("th.psort").index();
863
                var thIndex = $(this).find("th.psort").index();
857
                $(this).dataTable($.extend(true, {}, dataTablesDefaults, {
864
                $(this).on("init.dt", function() {
865
                        tableInit( $(this).attr("id") );
866
                    })
867
                    .dataTable($.extend(true, {}, dataTablesDefaults, {
858
                    "sorting" : [[ thIndex, 'asc' ]],
868
                    "sorting" : [[ thIndex, 'asc' ]],
869
                    "dom": '<"top"<"table_entries"><"table_controls"fB>>t',
859
                    "columnDefs": [
870
                    "columnDefs": [
860
                        { "targets": [ "nosort" ],"sortable": false,"searchable": false },
871
                        { "targets": [ "nosort" ],"sortable": false,"searchable": false },
861
                        { "type": "anti-the", "targets" : [ "anti-the" ] },
872
                        { "type": "anti-the", "targets" : [ "anti-the" ] },
862
                        { "type": "title-string", "targets" : [ "title-string" ] }
873
                        { "type": "title-string", "targets" : [ "title-string" ] }
863
                    ]
874
                    ],
875
                    "language": {
876
                        "search": "_INPUT_",
877
                        "searchPlaceholder": _("Search")
878
                    }
864
                }));
879
                }));
865
            });
880
            });
866
881
Lines 882-895 Link Here
882
                    e.preventDefault();
897
                    e.preventDefault();
883
                    $("#renewselected").submit();
898
                    $("#renewselected").submit();
884
                });
899
                });
885
                $("body").on("click","#renewall_link",function(e){
900
                $("body").on("click","#renewall_link, #renewall_js",function(e){
886
                    e.preventDefault();
901
                    e.preventDefault();
887
                    $("#renewall").submit();
902
                    $("#renewall").submit();
888
                });
903
                });
889
                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( logged_in_user.is_expired && logged_in_user.category.effective_BlockExpiredPatronOpacActions ) ) %]
904
            [% END # /IF ( OpacRenewalAllowed && canrenew && !userdebarred ) %]
890
                    $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" class=\"btn btn-link\" href=\"#\"><i class=\"fa fa-check\" aria-hidden=\"true\"></i> "+_("Renew selected")+"</a> <a id=\"renewall_link\" class=\"btn btn-link\" href=\"#\"><span class=\"fa-stack\"><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i><i class=\"fa fa-check fa-stack-1x\" aria-hidden=\"true\"></i></span> "+_("Renew all")+"</a></div>");
891
                [% END %]
892
            [% END %]
893
905
894
            [% IF ( Koha.Preference('AllowCheckoutNotes') ) %]
906
            [% IF ( Koha.Preference('AllowCheckoutNotes') ) %]
895
907
(-)a/koha-tmpl/opac-tmpl/bootstrap/js/datatables.js (-377 / +31 lines)
Lines 1-3 Link Here
1
/* global __ */
1
// These default options are for translation but can be used
2
// These default options are for translation but can be used
2
// for any other datatables settings
3
// for any other datatables settings
3
// To use it, write:
4
// To use it, write:
Lines 32-55 var dataTablesDefaults = { Link Here
32
        }
33
        }
33
    },
34
    },
34
    "dom": 't',
35
    "dom": 't',
36
    "buttons": [
37
        'clearFilter', 'copy', 'csv', 'print'
38
    ],
35
    "paginate": false,
39
    "paginate": false,
36
    "buttons": [{
37
        fade: 100,
38
        className: "dt_button_clear_filter",
39
        titleAttr: window.MSG_CLEAR_FILTER,
40
        enabled: false,
41
        text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + window.MSG_CLEAR_FILTER + '</span>',
42
        available: function ( dt ) {
43
            // The "clear filter" button is made available if this test returns true
44
            if( dt.settings()[0].aanFeatures.f ){ // aanFeatures.f is null if there is no search form
45
                return true;
46
            }
47
        },
48
        action: function ( e, dt, node ) {
49
            dt.search( "" ).draw("page");
50
            node.addClass("disabled");
51
        }
52
    }],
53
    initComplete: function( settings) {
40
    initComplete: function( settings) {
54
        var tableId = settings.nTable.id
41
        var tableId = settings.nTable.id
55
        // When the DataTables search function is triggered,
42
        // When the DataTables search function is triggered,
Lines 65-289 var dataTablesDefaults = { Link Here
65
    }
52
    }
66
};
53
};
67
54
68
55
$.fn.dataTable.ext.buttons.clearFilter = {
69
// Return an array of string containing the values of a particular column
56
    fade: 100,
70
$.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) {
57
    className: "dt_button_clear_filter",
71
    // check that we have a column id
58
    titleAttr: window.MSG_CLEAR_FILTER,
72
    if ( typeof iColumn == "undefined" ) return new Array();
59
    enabled: false,
73
    // by default we only wany unique data
60
    text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + window.MSG_CLEAR_FILTER + '</span>',
74
    if ( typeof bUnique == "undefined" ) bUnique = true;
61
    available: function ( dt ) {
75
    // by default we do want to only look at filtered data
62
        // The "clear filter" button is made available if this test returns true
76
    if ( typeof bFiltered == "undefined" ) bFiltered = true;
63
        if( dt.settings()[0].aanFeatures.f ){ // aanFeatures.f is null if there is no search form
77
    // by default we do not wany to include empty values
64
            return true;
78
    if ( typeof bIgnoreEmpty == "undefined" ) bIgnoreEmpty = true;
79
    // list of rows which we're going to loop through
80
    var aiRows;
81
    // use only filtered rows
82
    if (bFiltered == true) aiRows = oSettings.aiDisplay;
83
    // use all rows
84
    else aiRows = oSettings.aiDisplayMaster; // all row numbers
85
86
    // set up data array
87
    var asResultData = new Array();
88
    for (var i=0,c=aiRows.length; i<c; i++) {
89
        iRow = aiRows[i];
90
        var aData = this.fnGetData(iRow);
91
        var sValue = aData[iColumn];
92
        // ignore empty values?
93
        if (bIgnoreEmpty == true && sValue.length == 0) continue;
94
        // ignore unique values?
95
        else if (bUnique == true && jQuery.inArray(sValue, asResultData) > -1) continue;
96
        // else push the value onto the result data array
97
        else asResultData.push(sValue);
98
    }
99
    return asResultData;
100
}
101
102
// List of unbind keys (Ctrl, Alt, Direction keys, etc.)
103
// These keys must not launch filtering
104
var blacklist_keys = new Array(0, 16, 17, 18, 37, 38, 39, 40);
105
106
// Set a filtering delay for global search field
107
jQuery.fn.dataTableExt.oApi.fnSetFilteringDelay = function ( oSettings, iDelay ) {
108
    /*
109
     * Inputs:      object:oSettings - dataTables settings object - automatically given
110
     *              integer:iDelay - delay in milliseconds
111
     * Usage:       $('#example').dataTable().fnSetFilteringDelay(250);
112
     * Author:      Zygimantas Berziunas (www.zygimantas.com) and Allan Jardine
113
     * License:     GPL v2 or BSD 3 point style
114
     * Contact:     zygimantas.berziunas /AT\ hotmail.com
115
     */
116
    var
117
        _that = this,
118
        iDelay = (typeof iDelay == 'undefined') ? 250 : iDelay;
119
120
    this.each( function ( i ) {
121
        $.fn.dataTableExt.iApiIndex = i;
122
        var
123
            $this = this,
124
            oTimerId = null,
125
            sPreviousSearch = null,
126
            anControl = $( 'input', _that.fnSettings().aanFeatures.f );
127
128
        anControl.unbind( 'keyup.DT' ).bind( 'keyup.DT', function(event) {
129
            var $$this = $this;
130
            if (blacklist_keys.indexOf(event.keyCode) != -1) {
131
                return this;
132
            }else if ( event.keyCode == '13' ) {
133
                $.fn.dataTableExt.iApiIndex = i;
134
                _that.fnFilter( $(this).val() );
135
            } else {
136
                if (sPreviousSearch === null || sPreviousSearch != anControl.val()) {
137
                    window.clearTimeout(oTimerId);
138
                    sPreviousSearch = anControl.val();
139
                    oTimerId = window.setTimeout(function() {
140
                        $.fn.dataTableExt.iApiIndex = i;
141
                        _that.fnFilter( anControl.val() );
142
                    }, iDelay);
143
                }
144
            }
145
        });
146
147
        return this;
148
    } );
149
    return this;
150
}
151
152
// Add a filtering delay on general search and on all input (with a class 'filter')
153
jQuery.fn.dataTableExt.oApi.fnAddFilters = function ( oSettings, sClass, iDelay ) {
154
    var table = this;
155
    this.fnSetFilteringDelay(iDelay);
156
    var filterTimerId = null;
157
    $(table).find("input."+sClass).keyup(function(event) {
158
      if (blacklist_keys.indexOf(event.keyCode) != -1) {
159
        return this;
160
      }else if ( event.keyCode == '13' ) {
161
        table.fnFilter( $(this).val(), $(this).attr('data-column_num') );
162
      } else {
163
        window.clearTimeout(filterTimerId);
164
        var input = this;
165
        filterTimerId = window.setTimeout(function() {
166
          table.fnFilter($(input).val(), $(input).attr('data-column_num'));
167
        }, iDelay);
168
      }
169
    });
170
    $(table).find("select."+sClass).on('change', function() {
171
        table.fnFilter($(this).val(), $(this).attr('data-column_num'));
172
    });
173
}
174
175
// Sorting on html contains
176
// <a href="foo.pl">bar</a> sort on 'bar'
177
function dt_overwrite_html_sorting_localeCompare() {
178
    jQuery.fn.dataTableExt.oSort['html-asc']  = function(a,b) {
179
        a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
180
        b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
181
        if (typeof(a.localeCompare == "function")) {
182
           return a.localeCompare(b);
183
        } else {
184
           return (a > b) ? 1 : ((a < b) ? -1 : 0);
185
        }
65
        }
186
    };
187
188
    jQuery.fn.dataTableExt.oSort['html-desc'] = function(a,b) {
189
        a = a.replace(/<.*?>/g, "").replace(/\s+/g, " ");
190
        b = b.replace(/<.*?>/g, "").replace(/\s+/g, " ");
191
        if(typeof(b.localeCompare == "function")) {
192
            return b.localeCompare(a);
193
        } else {
194
            return (b > a) ? 1 : ((b < a) ? -1 : 0);
195
        }
196
    };
197
198
    jQuery.fn.dataTableExt.oSort['num-html-asc']  = function(a,b) {
199
        var x = a.replace( /<.*?>/g, "" );
200
        var y = b.replace( /<.*?>/g, "" );
201
        x = parseFloat( x );
202
        y = parseFloat( y );
203
        return ((x < y) ? -1 : ((x > y) ?  1 : 0));
204
    };
205
206
    jQuery.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
207
        var x = a.replace( /<.*?>/g, "" );
208
        var y = b.replace( /<.*?>/g, "" );
209
        x = parseFloat( x );
210
        y = parseFloat( y );
211
        return ((x < y) ?  1 : ((x > y) ? -1 : 0));
212
    };
213
}
214
215
$.fn.dataTableExt.oSort['num-html-asc']  = function(a,b) {
216
    var x = a.replace( /<.*?>/g, "" );
217
    var y = b.replace( /<.*?>/g, "" );
218
    x = parseFloat( x );
219
    y = parseFloat( y );
220
    return ((x < y) ? -1 : ((x > y) ?  1 : 0));
221
};
222
223
$.fn.dataTableExt.oSort['num-html-desc'] = function(a,b) {
224
    var x = a.replace( /<.*?>/g, "" );
225
    var y = b.replace( /<.*?>/g, "" );
226
    x = parseFloat( x );
227
    y = parseFloat( y );
228
    return ((x < y) ?  1 : ((x > y) ? -1 : 0));
229
};
230
231
(function() {
232
233
/*
234
 * Natural Sort algorithm for Javascript - Version 0.7 - Released under MIT license
235
 * Author: Jim Palmer (based on chunking idea from Dave Koelle)
236
 * Contributors: Mike Grier (mgrier.com), Clint Priest, Kyle Adams, guillermo
237
 * See: http://js-naturalsort.googlecode.com/svn/trunk/naturalSort.js
238
 */
239
function naturalSort (a, b) {
240
    var re = /(^-?[0-9]+(\.?[0-9]*)[df]?e?[0-9]?$|^0x[0-9a-f]+$|[0-9]+)/gi,
241
        sre = /(^[ ]*|[ ]*$)/g,
242
        dre = /(^([\w ]+,?[\w ]+)?[\w ]+,?[\w ]+\d+:\d+(:\d+)?[\w ]?|^\d{1,4}[\/\-]\d{1,4}[\/\-]\d{1,4}|^\w+, \w+ \d+, \d{4})/,
243
        hre = /^0x[0-9a-f]+$/i,
244
        ore = /^0/,
245
        // convert all to strings and trim()
246
        x = a.toString().replace(sre, '') || '',
247
        y = b.toString().replace(sre, '') || '',
248
        // chunk/tokenize
249
        xN = x.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
250
        yN = y.replace(re, '\0$1\0').replace(/\0$/,'').replace(/^\0/,'').split('\0'),
251
        // numeric, hex or date detection
252
        xD = parseInt(x.match(hre), 10) || (xN.length != 1 && x.match(dre) && Date.parse(x)),
253
        yD = parseInt(y.match(hre), 10) || xD && y.match(dre) && Date.parse(y) || null;
254
    // first try and sort Hex codes or Dates
255
    if (yD)
256
        if ( xD < yD ) return -1;
257
        else if ( xD > yD )  return 1;
258
    // natural sorting through split numeric strings and default strings
259
    for(var cLoc=0, numS=Math.max(xN.length, yN.length); cLoc < numS; cLoc++) {
260
        // find floats not starting with '0', string or 0 if not defined (Clint Priest)
261
        var oFxNcL = !(xN[cLoc] || '').match(ore) && parseFloat(xN[cLoc]) || xN[cLoc] || 0;
262
        var oFyNcL = !(yN[cLoc] || '').match(ore) && parseFloat(yN[cLoc]) || yN[cLoc] || 0;
263
        // handle numeric vs string comparison - number < string - (Kyle Adams)
264
        if (isNaN(oFxNcL) !== isNaN(oFyNcL)) return (isNaN(oFxNcL)) ? 1 : -1;
265
        // rely on string comparison if different types - i.e. '02' < 2 != '02' < '2'
266
        else if (typeof oFxNcL !== typeof oFyNcL) {
267
            oFxNcL += '';
268
            oFyNcL += '';
269
        }
270
        if (oFxNcL < oFyNcL) return -1;
271
        if (oFxNcL > oFyNcL) return 1;
272
    }
273
    return 0;
274
}
275
276
jQuery.extend( jQuery.fn.dataTableExt.oSort, {
277
    "natural-asc": function ( a, b ) {
278
        return naturalSort(a,b);
279
    },
66
    },
280
67
    action: function ( e, dt, node ) {
281
    "natural-desc": function ( a, b ) {
68
        dt.search( "" ).draw("page");
282
        return naturalSort(a,b) * -1;
69
        node.addClass("disabled");
283
    }
70
    }
284
} );
71
};
285
286
}());
287
72
288
/* Plugin to allow sorting on data stored in a span's title attribute
73
/* Plugin to allow sorting on data stored in a span's title attribute
289
 *
74
 *
Lines 359-365 jQuery.extend( jQuery.fn.dataTableExt.oSort, { Link Here
359
    if (config_exclude_articles_from_sort){
144
    if (config_exclude_articles_from_sort){
360
        var articles = config_exclude_articles_from_sort.split(" ");
145
        var articles = config_exclude_articles_from_sort.split(" ");
361
        var rpattern = "";
146
        var rpattern = "";
362
        for(i=0;i<articles.length;i++){
147
        for( var i=0; i<articles.length; i++){
363
            rpattern += "^" + articles[i] + " ";
148
            rpattern += "^" + articles[i] + " ";
364
            if(i < articles.length - 1){ rpattern += "|"; }
149
            if(i < articles.length - 1){ rpattern += "|"; }
365
        }
150
        }
Lines 385-512 jQuery.extend( jQuery.fn.dataTableExt.oSort, { Link Here
385
170
386
}());
171
}());
387
172
388
// Remove string between NSB NSB characters
389
$.fn.dataTableExt.oSort['nsb-nse-asc'] = function(a,b) {
390
    var pattern = new RegExp("\x88.*\x89");
391
    a = a.replace(pattern, "");
392
    b = b.replace(pattern, "");
393
    return (a > b) ? 1 : ((a < b) ? -1 : 0);
394
}
395
$.fn.dataTableExt.oSort['nsb-nse-desc'] = function(a,b) {
396
    var pattern = new RegExp("\x88.*\x89");
397
    a = a.replace(pattern, "");
398
    b = b.replace(pattern, "");
399
    return (b > a) ? 1 : ((b < a) ? -1 : 0);
400
}
401
402
/* Define two custom functions (asc and desc) for basket callnumber sorting */
403
jQuery.fn.dataTableExt.oSort['callnumbers-asc']  = function(x,y) {
404
        var x_array = x.split("<div>");
405
        var y_array = y.split("<div>");
406
407
        /* Pop the first elements, they are empty strings */
408
        x_array.shift();
409
        y_array.shift();
410
411
        x_array = jQuery.map( x_array, function( a ) {
412
            return parse_callnumber( a );
413
        });
414
        y_array = jQuery.map( y_array, function( a ) {
415
            return parse_callnumber( a );
416
        });
417
418
        x_array.sort();
419
        y_array.sort();
420
421
        x = x_array.shift();
422
        y = y_array.shift();
423
424
        if ( !x ) { x = ""; }
425
        if ( !y ) { y = ""; }
426
427
        return ((x < y) ? -1 : ((x > y) ?  1 : 0));
428
};
429
430
jQuery.fn.dataTableExt.oSort['callnumbers-desc'] = function(x,y) {
431
        var x_array = x.split("<div>");
432
        var y_array = y.split("<div>");
433
434
        /* Pop the first elements, they are empty strings */
435
        x_array.shift();
436
        y_array.shift();
437
438
        x_array = jQuery.map( x_array, function( a ) {
439
            return parse_callnumber( a );
440
        });
441
        y_array = jQuery.map( y_array, function( a ) {
442
            return parse_callnumber( a );
443
        });
444
445
        x_array.sort();
446
        y_array.sort();
447
448
        x = x_array.pop();
449
        y = y_array.pop();
450
451
        if ( !x ) { x = ""; }
452
        if ( !y ) { y = ""; }
453
454
        return ((x < y) ?  1 : ((x > y) ? -1 : 0));
455
};
456
457
function parse_callnumber ( html ) {
458
    var array = html.split('<span class="callnumber">');
459
    if ( array[1] ) {
460
        array = array[1].split('</span>');
461
        return array[0];
462
    } else {
463
        return "";
464
    }
465
}
466
467
// see http://www.datatables.net/examples/advanced_init/footer_callback.html
468
function footer_column_sum( api, column_numbers ) {
469
    // Remove the formatting to get integer data for summation
470
    var intVal = function ( i ) {
471
        if ( typeof i === 'number' ) {
472
            if ( isNaN(i) ) return 0;
473
            return i;
474
        } else if ( typeof i === 'string' ) {
475
            var value = i.replace(/[a-zA-Z ,.]/g, '')*1;
476
            if ( isNaN(value) ) return 0;
477
            return value;
478
        }
479
        return 0;
480
    };
481
482
483
    for ( var indice = 0 ; indice < column_numbers.length ; indice++ ) {
484
        var column_number = column_numbers[indice];
485
486
        var total = 0;
487
        var cells = api.column( column_number, { page: 'current' } ).nodes().to$().find("span.total_amount");
488
        $(cells).each(function(){
489
            total += intVal( $(this).html() );
490
        });
491
        total /= 100; // Hard-coded decimal precision
492
493
        // Update footer
494
        $( api.column( column_number ).footer() ).html(total.format_price());
495
    };
496
}
497
498
function filterDataTable( table, column, term ){
499
    if( column ){
500
        table.column( column ).search( term ).draw("page");
501
    } else {
502
        table.search( term ).draw("page");
503
    }
504
}
505
506
jQuery.fn.dataTable.ext.errMode = function(settings, note, message) {
507
    console.warn(message);
508
};
509
510
(function($) {
173
(function($) {
511
174
512
    $.fn.api = function(options, columns_settings, add_filters) {
175
    $.fn.api = function(options, columns_settings, add_filters) {
Lines 632-643 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
632
295
633
                return newnode.text().replace( /\n/g, ' ' ).trim();
296
                return newnode.text().replace( /\n/g, ' ' ).trim();
634
            }
297
            }
635
        }
298
        };
636
299
637
        var export_buttons = [
300
        var export_buttons = [
638
            {
301
            {
639
                extend: 'excelHtml5',
302
                extend: 'excelHtml5',
640
                text: _("Excel"),
303
                text: __("Excel"),
641
                exportOptions: {
304
                exportOptions: {
642
                    columns: exportColumns,
305
                    columns: exportColumns,
643
                    format:  export_format
306
                    format:  export_format
Lines 645-651 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
645
            },
308
            },
646
            {
309
            {
647
                extend: 'csvHtml5',
310
                extend: 'csvHtml5',
648
                text: _("CSV"),
311
                text: __("CSV"),
649
                exportOptions: {
312
                exportOptions: {
650
                    columns: exportColumns,
313
                    columns: exportColumns,
651
                    format:  export_format
314
                    format:  export_format
Lines 653-659 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
653
            },
316
            },
654
            {
317
            {
655
                extend: 'copyHtml5',
318
                extend: 'copyHtml5',
656
                text: _("Copy"),
319
                text: __("Copy"),
657
                exportOptions: {
320
                exportOptions: {
658
                    columns: exportColumns,
321
                    columns: exportColumns,
659
                    format:  export_format
322
                    format:  export_format
Lines 661-667 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
661
            },
324
            },
662
            {
325
            {
663
                extend: 'print',
326
                extend: 'print',
664
                text: _("Print"),
327
                text: __("Print"),
665
                exportOptions: {
328
                exportOptions: {
666
                    columns: exportColumns,
329
                    columns: exportColumns,
667
                    format:  export_format
330
                    format:  export_format
Lines 673-682 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
673
            {
336
            {
674
                fade: 100,
337
                fade: 100,
675
                className: "dt_button_clear_filter",
338
                className: "dt_button_clear_filter",
676
                titleAttr: _("Clear filter"),
339
                titleAttr: __("Clear filter"),
677
                enabled: false,
340
                enabled: false,
678
                text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + _("Clear filter") + '</span>',
341
                text: '<i class="fa fa-lg fa-remove"></i> <span class="dt-button-text">' + __("Clear filter") + '</span>',
679
                action: function ( e, dt, node, config ) {
342
                action: function ( e, dt, node ) {
680
                    dt.search( "" ).draw("page");
343
                    dt.search( "" ).draw("page");
681
                    node.addClass("disabled");
344
                    node.addClass("disabled");
682
                }
345
                }
Lines 690-697 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
690
                    fade: 100,
353
                    fade: 100,
691
                    columns: included_ids,
354
                    columns: included_ids,
692
                    className: "columns_controls",
355
                    className: "columns_controls",
693
                    titleAttr: _("Columns settings"),
356
                    titleAttr: __("Columns settings"),
694
                    text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + _("Columns") + '</span>',
357
                    text: '<i class="fa fa-lg fa-gear"></i> <span class="dt-button-text">' + __("Columns") + '</span>',
695
                    exportOptions: {
358
                    exportOptions: {
696
                        columns: exportColumns
359
                        columns: exportColumns
697
                    }
360
                    }
Lines 705-724 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
705
                autoClose: true,
368
                autoClose: true,
706
                fade: 100,
369
                fade: 100,
707
                className: "export_controls",
370
                className: "export_controls",
708
                titleAttr: _("Export or print"),
371
                titleAttr: __("Export or print"),
709
                text: '<i class="fa fa-lg fa-download"></i> <span class="dt-button-text">' + _("Export") + '</span>',
372
                text: '<i class="fa fa-lg fa-download"></i> <span class="dt-button-text">' + __("Export") + '</span>',
710
                buttons: export_buttons
373
                buttons: export_buttons
711
            }
374
            }
712
        );
375
        );
713
376
714
        if ( add_filters ) {
715
            // Duplicate the table header row for columnFilter
716
            thead_row = this.find('thead tr');
717
            clone = thead_row.clone().addClass('filters_row');
718
            clone.find("th.NoSort").html('');
719
            thead_row.before(clone);
720
        }
721
722
        $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();
377
        $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();
723
378
724
        return $(this).dataTable(settings);
379
        return $(this).dataTable(settings);
725
- 

Return to bug 25775