Project

General

Profile

1
$(function() {
2

    
3
    if(Modernizr.touch) {
4
        // make table cell focusable
5
        var $focus_highlight = $('.focus-highlight');
6
        if ( $focus_highlight.length ) {
7
            $focus_highlight
8
                .find('td, th')
9
                .attr('tabindex', '1')
10
                .on('touchstart', function() {
11
                    $(this).focus();
12
                });
13
        }
14
        // disable fastclick on table headers (touch devices)
15
        $('.tablesorter').find('th').addClass('needsclick');
16
    }
17

    
18
    // list view
19
    altair_issues.list_view();
20
});
21

    
22
altair_issues = {
23
    list_view: function() {
24

    
25
        var $ts_issues = $("#ts_issues");
26

    
27
        // define pager options
28
        var pagerOptions = {
29
            // target the pager markup - see the HTML block below
30
            container: $(".ts_pager"),
31
            // output string - default is '{page}/{totalPages}'; possible variables: {page}, {totalPages}, {startRow}, {endRow} and {totalRows}
32
            output: '{startRow} - {endRow} / {filteredRows} ({totalRows})',
33
            // if true, the table will remain the same height no matter how many records are displayed. The space is made up by an empty
34
            // table row set to a height to compensate; default is false
35
            fixedHeight: true,
36
            // remove rows from the table to speed up the sort of large tables.
37
            // setting this to false, only hides the non-visible rows; needed if you plan to add/remove rows with the pager enabled.
38
            removeRows: false,
39
            // go to page selector - select dropdown that sets the current page
40
            cssGoto: '.ts_gotoPage'
41
        };
42

    
43
        // Initialize tablesorter
44
        var ts_users = $ts_issues
45
            .tablesorter({
46
                theme: 'altair',
47
                widthFixed: true,
48
                widgets: ['zebra', 'filter']
49
            })
50
            // initialize the pager plugin
51
            .tablesorterPager(pagerOptions)
52
            .on('pagerComplete', function(e, filter){
53
                // update selectize value
54
                if(typeof selectizeObj !== 'undefined' && selectizeObj.data('selectize')) {
55
                    selectizePage = selectizeObj[0].selectize;
56
                    selectizePage.setValue($('select.ts_gotoPage option:selected').index() + 1, false);
57
                }
58
            });
59

    
60
        // replace 'goto Page' select
61
        function createPageSelectize() {
62
            selectizeObj = $('select.ts_gotoPage')
63
                .val($("select.ts_gotoPage option:selected").val())
64
                .after('<div class="selectize_fix"></div>')
65
                .selectize({
66
                    hideSelected: true,
67
                    onDropdownOpen: function($dropdown) {
68
                        $dropdown
69
                            .hide()
70
                            .velocity('slideDown', {
71
                                duration: 280,
72
                                easing: easing_swiftOut
73
                            })
74
                    },
75
                    onDropdownClose: function($dropdown) {
76
                        $dropdown
77
                            .show()
78
                            .velocity('slideUp', {
79
                                duration: 280,
80
                                easing: easing_swiftOut
81
                            });
82
                        // hide tooltip
83
                        $('.uk-tooltip').hide();
84
                    }
85
                });
86
        }
87
        createPageSelectize();
88

    
89
        // replace 'pagesize' select
90
        $('.pagesize.ts_selectize')
91
            .after('<div class="selectize_fix"></div>')
92
            .selectize({
93
                hideSelected: true,
94
                onDropdownOpen: function($dropdown) {
95
                    $dropdown
96
                        .hide()
97
                        .velocity('slideDown', {
98
                            duration: 280,
99
                            easing: easing_swiftOut
100
                        })
101
                },
102
                onDropdownClose: function($dropdown) {
103
                    $dropdown
104
                        .show()
105
                        .velocity('slideUp', {
106
                            duration: 280,
107
                            easing: easing_swiftOut
108
                        });
109

    
110
                    // hide tooltip
111
                    $('.uk-tooltip').hide();
112
                    if(typeof selectizeObj !== 'undefined' && selectizeObj.data('selectize')) {
113
                        selectizePage = selectizeObj[0].selectize;
114
                        selectizePage.destroy();
115
                        $('.ts_gotoPage').next('.selectize_fix').remove();
116
                        setTimeout(function() {
117
                            createPageSelectize()
118
                        })
119
                    }
120

    
121
                }
122
            });
123

    
124
    }
125
};
(73-73/114)