1(function($) { 2 $(document).trigger('enhance.tablesaw').ready( function() { 3 $( '.custom-sort-column' ).data( 'tablesaw-sort', function( ascending ) { 4 // Return a function 5 return function( a, b ) { 6 // Grab the data attributes 7 var aScoreRaw = a.element.dataset.tableScore, 8 aScore = parseInt( aScoreRaw, 10 ), 9 bScoreRaw = b.element.dataset.tableScore, 10 bScore = parseInt( bScoreRaw, 10 ), 11 aName = a.element.dataset.tableScorecardName, 12 bName = b.element.dataset.tableScorecardName; 13 if( aScore === bScore ) { 14 // Compare the names. Signs reversed because "a" < "b" but should come first 15 if( ascending ) { 16 return aName < bName ? 1 : -1; 17 } else { // descending 18 return aName >= bName ? 1 : -1; 19 } 20 } 21 22 if( ascending ) { 23 return aScore >= bScore ? 1 : -1; 24 } else { // descending 25 return aScore < bScore ? 1 : -1; 26 } 27 } 28 }) 29 30 $( '.custom-alpha-sort-column' ).data( 'tablesaw-sort', function( ascending ) { 31 // Return a function 32 return function( a, b ) { 33 // Grab the contents 34 var aText = a.element.outerText, 35 bText = b.element.outerText; 36 37 // Compare the values. Signs reversed because "a" < "b" but should come first 38 if( ascending ) { 39 return aText < bText ? 1 : -1; 40 } else { // descending 41 return aText >= bText ? 1 : -1; 42 } 43 } 44 }) 45 $( '.tablesaw-sortable-btn' ).click( function() { 46 if( $( this ).parent().hasClass( 'rating-column' ) ) { 47 for( i = 0; i < 6; i++ ) { 48 $( '.segment-breakout' ).show(); 49 var sectionHeader = $( 'tr[data-segment-rating="' + i + '"]' ); 50 var firstRecordInSection = $( 'tr[data-record-rating="' + i + '"]' ).first(); 51 sectionHeader.insertBefore( firstRecordInSection ); 52 } 53 } else { 54 $( '.segment-breakout' ).hide(); 55 } 56 }) 57 58 $( '.btn.btn-select select' ).change( function() { 59 $( '.segment-breakout' ).hide(); 60 }) 61 62 $( '.tooltip' ).tooltipster({ 63 trigger: 'custom', 64 triggerOpen: { 65 mouseenter: true, 66 touchstart: true, 67 tap: true 68 }, 69 triggerClose: { 70 mouseleave: true, 71 click: true, 72 scroll: true, 73 tap: true 74 }, 75 maxWidth: 800 76 }); 77 78 var timer = null; 79 80 $( '#cornucopia-search' ).keyup( function() { 81 clearTimeout( timer ); 82 timer = setTimeout( filterTable, 1000 ) 83 }); 84 85 $( '#cornucopia-print' ).click( function() { 86 $( '#cornucopia-scorecard' ).removeClass( 'tablesaw-sortable' ); 87 $( '#cornucopia-scorecard' ).printThis({ 88 loadCSS: '/wp-content/plugins/cornucopia-scorecard/css/cornucopia-custom-print.css' 89 }); 90 setTimeout( function addClassBack() { $( '#cornucopia-scorecard' ).addClass( 'tablesaw-sortable' ); }, 1000); 91 }) 92 }); 93 94 $( window ).on( 'load resize', function() { 95 96 // Only run this when there's a hidden cell 97 var hiddenColumns = $( '.cornucopia-scorecard th.tablesaw-cell-hidden' ); 98 if( hiddenColumns.length > 0 ) { 99 // This fixes an issue where the table doesn't display correctly on load 100 $( '.cornucopia-scorecard' ).addClass( 'tablesaw-fix-persist' ); 101 } 102 }); 103 104 function filterTable() { 105 106 var input, filter, table, rows, tr, td, i; 107 input = $( '#cornucopia-search' ); 108 filter = input.val().toUpperCase(); 109 table = $( '#cornucopia-scorecard' ); 110 tableBody = table.find( 'tbody' ); 111 rows = tableBody.find( 'tr' ); 112 rows.each( function( index ) { 113 var cells; 114 var showThisRow = false; 115 cells = $( this ).find( 'td' ); 116 cells.each( function( index ) { 117 // Skip the column that has the images in it. The span in 118 // that column has a class of 'skip-filter' 119 if(filter.substr(0,1) == '"') 120 var regex = new RegExp('\\b'+filter.replace(/\"/g,'')+'\\b'); 121 else 122 var regex = new RegExp(filter); 123 124 //if( $( this ).html().toUpperCase().indexOf( filter ) > -1 ) { 125 if( $( this ).html().toUpperCase().search( regex ) > -1 ) { 126 if( $( this ).html().indexOf( 'skip-filter' ) <= -1 ) { 127 showThisRow = true; 128 } 129 } 130 }) 131 if( showThisRow ) { 132 $( this ).removeClass( 'hide-this-row' ); 133 } else { 134 $( this ).addClass( 'hide-this-row' ); 135 } 136 }) 137 138 $( '.segment-breakout' ).hide(); 139 } 140 141 function columnWidth() { 142 143 } 144 145})( jQuery );
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.