1/*! Tablesaw - v2.0.3 - 2016-05-02 2* https://github.com/filamentgroup/tablesaw 3* Copyright (c) 2016 Filament Group; Licensed MIT */ 4/* 5* tablesaw: A set of plugins for responsive tables 6* Stack and Column Toggle tables 7* Copyright (c) 2013 Filament Group, Inc. 8* MIT License 9*/ 10 11if( typeof Tablesaw === "undefined" ) { 12 Tablesaw = { 13 i18n: { 14 modes: [ 'Stack', 'Swipe', 'Toggle' ], 15 columns: 'Col<span class=\"a11y-sm\">umn</span>s', 16 columnBtnText: 'Columns', 17 columnsDialogError: 'No eligible columns.', 18 sort: 'Sort' 19 }, 20 // cut the mustard 21 mustard: 'querySelector' in document && 22 ( !window.blackberry || window.WebKitPoint ) && 23 !window.operamini 24 }; 25} 26if( !Tablesaw.config ) { 27 Tablesaw.config = {}; 28} 29if( Tablesaw.mustard ) { 30 jQuery( document.documentElement ).addClass( 'tablesaw-enhanced' ); 31} 32 33;(function( $ ) { 34 var pluginName = "table", 35 classes = { 36 toolbar: "tablesaw-bar" 37 }, 38 events = { 39 create: "tablesawcreate", 40 destroy: "tablesawdestroy", 41 refresh: "tablesawrefresh" 42 }, 43 defaultMode = "stack", 44 initSelector = "table[data-tablesaw-mode],table[data-tablesaw-sortable]"; 45 46 var Table = function( element ) { 47 if( !element ) { 48 throw new Error( "Tablesaw requires an element." ); 49 } 50 51 this.table = element; 52 this.$table = $( element ); 53 54 this.mode = this.$table.attr( "data-tablesaw-mode" ) || defaultMode; 55 56 this.init(); 57 }; 58 59 Table.prototype.init = function() { 60 // assign an id if there is none 61 if ( !this.$table.attr( "id" ) ) { 62 this.$table.attr( "id", pluginName + "-" + Math.round( Math.random() * 10000 ) ); 63 } 64 65 this.createToolbar(); 66 67 var colstart = this._initCells(); 68 69 this.$table.trigger( events.create, [ this, colstart ] ); 70 }; 71 72 Table.prototype._initCells = function() { 73 var colstart, 74 thrs = this.table.querySelectorAll( "thead tr" ), 75 self = this; 76 77 $( thrs ).each( function(){ 78 var coltally = 0; 79 80 $( this ).children().each( function(){ 81 var span = parseInt( this.getAttribute( "colspan" ), 10 ), 82 sel = ":nth-child(" + ( coltally + 1 ) + ")"; 83 84 colstart = coltally + 1; 85 86 if( span ){ 87 for( var k = 0; k < span - 1; k++ ){ 88 coltally++; 89 sel += ", :nth-child(" + ( coltally + 1 ) + ")"; 90 } 91 } 92 93 // Store "cells" data on header as a reference to all cells in the same column as this TH 94 this.cells = self.$table.find("tr").not( thrs[0] ).not( this ).children().filter( sel ); 95 coltally++; 96 }); 97 }); 98 99 return colstart; 100 }; 101 102 Table.prototype.refresh = function() { 103 this._initCells(); 104 105 this.$table.trigger( events.refresh ); 106 }; 107 108 Table.prototype.createToolbar = function() { 109 // Insert the toolbar 110 // TODO move this into a separate component 111 var $toolbar = this.$table.prev().filter( '.' + classes.toolbar ); 112 if( !$toolbar.length ) { 113 $toolbar = $( '<div>' ) 114 .addClass( classes.toolbar ) 115 .insertBefore( this.$table ); 116 } 117 this.$toolbar = $toolbar; 118 119 if( this.mode ) { 120 this.$toolbar.addClass( 'mode-' + this.mode ); 121 } 122 }; 123 124 Table.prototype.destroy = function() { 125 // Donât remove the toolbar. Some of the table features are not yet destroy-friendly. 126 this.$table.prev().filter( '.' + classes.toolbar ).each(function() { 127 this.className = this.className.replace( /\bmode\-\w*\b/gi, '' ); 128 }); 129 130 var tableId = this.$table.attr( 'id' ); 131 $( document ).unbind( "." + tableId ); 132 $( window ).unbind( "." + tableId ); 133 134 // other plugins 135 this.$table.trigger( events.destroy, [ this ] ); 136 137 this.$table.removeData( pluginName ); 138 }; 139 140 // Collection method. 141 $.fn[ pluginName ] = function() { 142 return this.each( function() { 143 var $t = $( this ); 144 145 if( $t.data( pluginName ) ){ 146 return; 147 } 148 149 var table = new Table( this ); 150 $t.data( pluginName, table ); 151 }); 152 }; 153 154 $( document ).on( "enhance.tablesaw", function( e ) { 155 // Cut the mustard 156 if( Tablesaw.mustard ) { 157 $( e.target ).find( initSelector )[ pluginName ](); 158 } 159 }); 160 161}( jQuery )); 162 163;(function( win, $, undefined ){ 164 165 var classes = { 166 stackTable: 'tablesaw-stack', 167 cellLabels: 'tablesaw-cell-label', 168 cellContentLabels: 'tablesaw-cell-content' 169 }; 170 171 var data = { 172 obj: 'tablesaw-stack' 173 }; 174 175 var attrs = { 176 labelless: 'data-tablesaw-no-labels', 177 hideempty: 'data-tablesaw-hide-empty' 178 }; 179 180 var Stack = function( element ) { 181 182 this.$table = $( element ); 183 184 this.labelless = this.$table.is( '[' + attrs.labelless + ']' ); 185 this.hideempty = this.$table.is( '[' + attrs.hideempty + ']' ); 186 187 if( !this.labelless ) { 188 // allHeaders references headers, plus all THs in the thead, which may include several rows, or not 189 this.allHeaders = this.$table.find( "th" ); 190 } 191 192 this.$table.data( data.obj, this ); 193 }; 194 195 Stack.prototype.init = function( colstart ) { 196 this.$table.addClass( classes.stackTable ); 197 198 if( this.labelless ) { 199 return; 200 } 201 202 // get headers in reverse order so that top-level headers are appended last 203 var reverseHeaders = $( this.allHeaders ); 204 var hideempty = this.hideempty; 205 206 // create the hide/show toggles 207 reverseHeaders.each(function(){ 208 var $t = $( this ), 209 $cells = $( this.cells ).filter(function() { 210 return !$( this ).parent().is( "[" + attrs.labelless + "]" ) && ( !hideempty || !$( this ).is( ":empty" ) ); 211 }), 212 hierarchyClass = $cells.not( this ).filter( "thead th" ).length && " tablesaw-cell-label-top", 213 // TODO reduce coupling with sortable
214 $sortableButton = $t.find( ".tablesaw-sortable-btn" ), 215 html = $sortableButton.length ? $sortableButton.html() : $t.html(); 216 217 if( html !== "" ){ 218 if( hierarchyClass ){ 219 var iteration = parseInt( $( this ).attr( "colspan" ), 10 ), 220 filter = ""; 221 222 if( iteration ){ 223 filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")"; 224 } 225 $cells.filter( filter ).prepend( "<b class='" + classes.cellLabels + hierarchyClass + "'>" + html + "</b>" ); 226 } else { 227 $cells.wrapInner( "<span class='" + classes.cellContentLabels + "'></span>" ); 228 $cells.prepend( "<b class='" + classes.cellLabels + "'>" + html + "</b>" ); 229 } 230 } 231 }); 232 }; 233 234 Stack.prototype.destroy = function() { 235 this.$table.removeClass( classes.stackTable ); 236 this.$table.find( '.' + classes.cellLabels ).remove(); 237 this.$table.find( '.' + classes.cellContentLabels ).each(function() { 238 $( this ).replaceWith( this.childNodes ); 239 }); 240 }; 241 242 // on tablecreate, init 243 $( document ).on( "tablesawcreate", function( e, Tablesaw, colstart ){ 244 if( Tablesaw.mode === 'stack' ){ 245 var table = new Stack( Tablesaw.table ); 246 table.init( colstart ); 247 } 248 249 } ); 250 251 $( document ).on( "tablesawdestroy", function( e, Tablesaw ){ 252 253 if( Tablesaw.mode === 'stack' ){ 254 $( Tablesaw.table ).data( data.obj ).destroy(); 255 } 256 257 } ); 258 259}( this, 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.