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

(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt (-26 lines)
Lines 181-194 Link Here
181
            cities_table_url += 'q='+ encodeURIComponent(JSON.stringify(city_name_filter));
181
            cities_table_url += 'q='+ encodeURIComponent(JSON.stringify(city_name_filter));
182
        [% END %]
182
        [% END %]
183
183
184
            $('#table_cities thead tr').clone(true).appendTo( '#table_cities thead' );
185
186
187
            var cities_table = $("#table_cities").api({
184
            var cities_table = $("#table_cities").api({
188
                "ajax": {
185
                "ajax": {
189
                    "url": cities_table_url
186
                    "url": cities_table_url
190
                },
187
                },
191
                orderCellsTop: true,
192
                "order": [[ 1, "asc" ]],
188
                "order": [[ 1, "asc" ]],
193
                "columnDefs": [ {
189
                "columnDefs": [ {
194
                    "targets": [0,1,2,3,4],
190
                    "targets": [0,1,2,3,4],
Lines 239-266 Link Here
239
                ]
235
                ]
240
            }, [], 1);
236
            }, [], 1);
241
237
242
243
            var table = cities_table.DataTable();
244
            $('#table_cities thead tr:eq(1) th').each( function (i) {
245
                var is_searchable = table.settings()[0].aoColumns[i].bSearchable;
246
                if ( is_searchable ) {
247
                    var title = $(this).text();
248
                    var search_title = _("Search %s").format(title);
249
                    $(this).html( '<input type="text" placeholder="%s" />'.format(search_title) );
250
251
                    $( 'input', this ).on( 'keyup change', function () {
252
                        if ( table.column(i).search() !== this.value ) {
253
                            table
254
                                .column(i)
255
                                .search( this.value )
256
                                .draw();
257
                        }
258
                    } );
259
                } else {
260
                    $(this).html('');
261
                }
262
            } );
263
264
        });
238
        });
265
    </script>
239
    </script>
266
[% END %]
240
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/datatables.js (-8 / +33 lines)
Lines 511-516 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
511
511
512
    $.fn.api = function(options, columns_settings, add_filters) {
512
    $.fn.api = function(options, columns_settings, add_filters) {
513
        var settings = null;
513
        var settings = null;
514
515
        if ( add_filters ) {
516
            $(this).find('thead tr').clone(true).appendTo( $(this).find('thead') );
517
        }
518
514
        if(options) {
519
        if(options) {
515
            if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains';
520
            if(!options.criteria || ['contains', 'starts_with', 'ends_with', 'exact'].indexOf(options.criteria.toLowerCase()) === -1) options.criteria = 'contains';
516
            options.criteria = options.criteria.toLowerCase();
521
            options.criteria = options.criteria.toLowerCase();
Lines 714-730 jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { Link Here
714
            }
719
            }
715
        );
720
        );
716
721
722
        $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();
723
717
        if ( add_filters ) {
724
        if ( add_filters ) {
718
            // Duplicate the table header row for columnFilter
725
            settings['orderCellsTop'] = true;
719
            thead_row = this.find('thead tr');
720
            clone = thead_row.clone().addClass('filters_row');
721
            clone.find("th.NoSort").html('');
722
            thead_row.before(clone);
723
        }
726
        }
724
727
725
        $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip();
728
        var table = $(this).dataTable(settings);
729
730
        if ( add_filters ) {
731
            var table_dt = table.DataTable();
732
            $(this).find('thead tr:eq(1) th').each( function (i) {
733
                var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable;
734
                if ( is_searchable ) {
735
                    var title = $(this).text();
736
                    var search_title = _("Search %s").format(title);
737
                    $(this).html( '<input type="text" placeholder="%s" />'.format(search_title) );
738
739
                    $( 'input', this ).on( 'keyup change', function () {
740
                        if ( table_dt.column(i).search() !== this.value ) {
741
                            table_dt
742
                                .column(i)
743
                                .search( this.value )
744
                                .draw();
745
                        }
746
                    } );
747
                } else {
748
                    $(this).html('');
749
                }
750
            } );
751
        }
726
752
727
        return $(this).dataTable(settings);
753
        return table;
728
    };
754
    };
729
755
730
})(jQuery);
756
})(jQuery);
731
- 

Return to bug 27402