13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* tablesaw: A set of plugins for responsive tables
* minimap: a set of dots to show which columns are currently visible.
* Copyright (c) 2013 Filament Group, Inc.
* MIT License
*/
 
;(function( win, $, undefined ){
 
    var MM = {
        attr: {
            init: 'data-tablesaw-minimap'
        }
    };
 
    function createMiniMap( $table ){
 
        var $btns = $( '<div class="tablesaw-advance minimap">' ),
            $dotNav = $( '<ul class="tablesaw-advance-dots">' ).appendTo( $btns ),
            hideDot = 'tablesaw-advance-dots-hide',
            $headerCells = $table.find( 'thead th' );
 
        // populate dots
        $headerCells.each(function(){
            $dotNav.append( '<li><i></i></li>' );
        });
 
        $btns.appendTo( $table.prev().filter( '.tablesaw-bar' ) );
 
        function showMinimap( $table ) {
            var mq = $table.attr( MM.attr.init );
            return !mq || win.matchMedia && win.matchMedia( mq ).matches;
        }
 
        function showHideNav(){
            if( !showMinimap( $table ) ) {
                $btns.hide();
                return;
            }
            $btns.show();
 
            // show/hide dots
            var dots = $dotNav.find( "li" ).removeClass( hideDot );
            $table.find( "thead th" ).each(function(i){
                if( $( this ).css( "display" ) === "none" ){
                    dots.eq( i ).addClass( hideDot );
                }
            });
        }
 
        // run on init and resize
        showHideNav();
        $( win ).on( "resize", showHideNav );
 
 
        $table
            .bind( "tablesawcolumns.minimap", function(){
                showHideNav();
            })
            .bind( "tablesawdestroy.minimap", function(){
                var $t = $( this );
 
                $t.prev().filter( '.tablesaw-bar' ).find( '.tablesaw-advance' ).remove();
                $( win ).off( "resize", showHideNav );
 
                $t.unbind( ".minimap" );
            });
    }
 
 
 
    // on tablecreate, init
    $( document ).on( "tablesawcreate", function( e, Tablesaw ){
 
        if( ( Tablesaw.mode === 'swipe' || Tablesaw.mode === 'columntoggle' ) && Tablesaw.$table.is( '[ ' + MM.attr.init + ']' ) ){
            createMiniMap( Tablesaw.$table );
        }
 
    } );
 
}( this, jQuery ));