' ).addClass( classes.switcher ).addClass( classes.tableToolbar );
+ function addSwitcher(heads) {
+ $switcher = $("
").addClass(classes.switcher).addClass(classes.tableToolbar);
- var html = [ '
");
- $switcher.html( html.join('') );
+ $switcher.html(html.join(""));
- var $firstChild = tblsaw.$toolbar.children().eq( 0 );
- if( $firstChild.length ) {
- $switcher.insertBefore( $firstChild );
+ var $firstChild = tblsaw.$toolbar.children().eq(0);
+ if ($firstChild.length) {
+ $switcher.insertBefore($firstChild);
} else {
- $switcher.appendTo( tblsaw.$toolbar );
+ $switcher.appendTo(tblsaw.$toolbar);
}
- $switcher.find( '.tablesaw-btn' ).tablesawbtn();
- $switcher.find( 'select' ).on( 'change', function() {
- var val = $( this ).val().split( '_' ),
- head = heads.eq( val[ 0 ] );
+ $switcher.find(".tablesaw-btn").tablesawbtn();
+ $switcher.find("select").on("change", function() {
+ var val = $(this).val().split("_"),
+ head = heads.eq(val[0]);
- clearOthers( head.siblings() );
- el[ pluginName ]( 'sortBy', head.get( 0 ), val[ 1 ] === 'asc' );
+ clearOthers(head.siblings());
+ el[pluginName]("sortBy", head.get(0), val[1] === "asc");
});
}
- el.addClass( pluginName );
+ el.addClass(pluginName);
- heads = el.children().filter( "thead" ).find( "th[" + attrs.sortCol + "]" );
+ heads = el.children().filter("thead").find("th[" + attrs.sortCol + "]");
- addClassToHeads( heads );
- makeHeadsActionable( heads , headsOnAction );
- handleDefault( heads );
+ addClassToHeads(heads);
+ makeHeadsActionable(heads, headsOnAction);
+ handleDefault(heads);
- if( el.is( sortableSwitchSelector ) ) {
- addSwitcher( heads );
+ if (el.is(sortableSwitchSelector)) {
+ addSwitcher(heads);
}
},
- sortRows: function( rows, colNum, ascending, col, tbody ){
- function convertCells( cellArr, belongingToTbody ){
+ sortRows: function(rows, colNum, ascending, col, tbody) {
+ function convertCells(cellArr, belongingToTbody) {
var cells = [];
- $.each( cellArr, function( i , cell ){
+ $.each(cellArr, function(i, cell) {
var row = cell.parentNode;
- var $row = $( row );
+ var $row = $(row);
// next row is a subrow
var subrows = [];
var $next = $row.next();
- while( $next.is( "[" + attrs.subRow + "]" ) ) {
- subrows.push( $next[ 0 ] );
+ while ($next.is("[" + attrs.subRow + "]")) {
+ subrows.push($next[0]);
$next = $next.next();
}
var tbody = row.parentNode;
// current row is a subrow
- if( $row.is( "[" + attrs.subRow + "]" ) ) {
- } else if( tbody === belongingToTbody ) {
+ if ($row.is("[" + attrs.subRow + "]")) {
+ } else if (tbody === belongingToTbody) {
cells.push({
element: cell,
- cell: getSortValue( cell ),
+ cell: getSortValue(cell),
row: row,
subrows: subrows.length ? subrows : null,
- ignored: $row.is( "[" + attrs.ignoreRow + "]" )
+ ignored: $row.is("[" + attrs.ignoreRow + "]")
});
}
});
return cells;
}
- function getSortFxn( ascending, forceNumeric ){
+ function getSortFxn(ascending, forceNumeric) {
var fn,
regex = /[^\-\+\d\.]/g;
- if( ascending ){
- fn = function( a , b ){
- if( a.ignored || b.ignored ) {
+ if (ascending) {
+ fn = function(a, b) {
+ if (a.ignored || b.ignored) {
return 0;
}
- if( forceNumeric ) {
- return parseFloat( a.cell.replace( regex, '' ) ) - parseFloat( b.cell.replace( regex, '' ) );
+ if (forceNumeric) {
+ return (
+ parseFloat(a.cell.replace(regex, "")) - parseFloat(b.cell.replace(regex, ""))
+ );
} else {
return a.cell.toLowerCase() > b.cell.toLowerCase() ? 1 : -1;
}
};
} else {
- fn = function( a , b ){
- if( a.ignored || b.ignored ) {
+ fn = function(a, b) {
+ if (a.ignored || b.ignored) {
return 0;
}
- if( forceNumeric ) {
- return parseFloat( b.cell.replace( regex, '' ) ) - parseFloat( a.cell.replace( regex, '' ) );
+ if (forceNumeric) {
+ return (
+ parseFloat(b.cell.replace(regex, "")) - parseFloat(a.cell.replace(regex, ""))
+ );
} else {
return a.cell.toLowerCase() < b.cell.toLowerCase() ? 1 : -1;
}
@@ -2803,12 +2870,14 @@ if( Tablesaw.mustard ) {
return fn;
}
- function convertToRows( sorted ) {
- var newRows = [], i, l;
- for( i = 0, l = sorted.length ; i < l ; i++ ){
- newRows.push( sorted[ i ].row );
- if( sorted[ i ].subrows ) {
- newRows.push( sorted[ i ].subrows );
+ function convertToRows(sorted) {
+ var newRows = [],
+ i,
+ l;
+ for (i = 0, l = sorted.length; i < l; i++) {
+ newRows.push(sorted[i].row);
+ if (sorted[i].subrows) {
+ newRows.push(sorted[i].subrows);
}
}
return newRows;
@@ -2816,212 +2885,232 @@ if( Tablesaw.mustard ) {
var fn;
var sorted;
- var cells = convertCells( col.cells, tbody );
+ var cells = convertCells(col.cells, tbody);
- var customFn = $( col ).data( 'tablesaw-sort' );
+ var customFn = $(col).data("tablesaw-sort");
- fn = ( customFn && typeof customFn === "function" ? customFn( ascending ) : false ) ||
- getSortFxn( ascending, $( col ).is( '[' + attrs.numericCol + ']' ) && !$( col ).is( '[' + attrs.numericCol + '="false"]' ) );
+ fn =
+ (customFn && typeof customFn === "function" ? customFn(ascending) : false) ||
+ getSortFxn(
+ ascending,
+ $(col).is("[" + attrs.numericCol + "]") &&
+ !$(col).is("[" + attrs.numericCol + '="false"]')
+ );
- sorted = cells.sort( fn );
+ sorted = cells.sort(fn);
- rows = convertToRows( sorted );
+ rows = convertToRows(sorted);
return rows;
},
- makeColDefault: function( col , a ){
- var c = $( col );
- c.attr( attrs.defaultCol , "true" );
- if( a ){
- c.removeClass( classes.descend );
- c.addClass( classes.ascend );
+ makeColDefault: function(col, a) {
+ var c = $(col);
+ c.attr(attrs.defaultCol, "true");
+ if (a) {
+ c.removeClass(classes.descend);
+ c.addClass(classes.ascend);
} else {
- c.removeClass( classes.ascend );
- c.addClass( classes.descend );
+ c.removeClass(classes.ascend);
+ c.addClass(classes.descend);
}
},
- sortBy: function( col , ascending ){
- var el = $( this );
+ sortBy: function(col, ascending) {
+ var el = $(this);
var colNum;
- var tbl = el.data( "tablesaw" );
+ var tbl = el.data("tablesaw");
tbl.$tbody.each(function() {
var tbody = this;
- var $tbody = $( this );
- var rows = tbl.getBodyRows( tbody );
+ var $tbody = $(this);
+ var rows = tbl.getBodyRows(tbody);
var sortedRows;
- var map = tbl.headerMapping[ 0 ];
+ var map = tbl.headerMapping[0];
var j, k;
// find the column number that we’re sorting
- for( j = 0, k = map.length; j < k; j++ ) {
- if( map[ j ] === col ) {
+ for (j = 0, k = map.length; j < k; j++) {
+ if (map[j] === col) {
colNum = j;
break;
}
}
- sortedRows = el[ pluginName ]( "sortRows" , rows, colNum, ascending, col, tbody );
+ sortedRows = el[pluginName]("sortRows", rows, colNum, ascending, col, tbody);
// replace Table rows
- for( j = 0, k = sortedRows.length; j < k; j++ ) {
- $tbody.append( sortedRows[ j ] );
+ for (j = 0, k = sortedRows.length; j < k; j++) {
+ $tbody.append(sortedRows[j]);
}
});
- el[ pluginName ]( "makeColDefault" , col , ascending );
+ el[pluginName]("makeColDefault", col, ascending);
- el.trigger( "tablesaw-sorted" );
+ el.trigger("tablesaw-sorted");
}
};
// Collection method.
- $.fn[ pluginName ] = function( arrg ) {
- var args = Array.prototype.slice.call( arguments , 1),
+ $.fn[pluginName] = function(arrg) {
+ var args = Array.prototype.slice.call(arguments, 1),
returnVal;
// if it's a method
- if( arrg && typeof( arrg ) === "string" ){
- returnVal = $.fn[ pluginName ].prototype[ arrg ].apply( this[0], args );
- return (typeof returnVal !== "undefined")? returnVal:$(this);
+ if (arrg && typeof arrg === "string") {
+ returnVal = $.fn[pluginName].prototype[arrg].apply(this[0], args);
+ return typeof returnVal !== "undefined" ? returnVal : $(this);
}
// check init
- if( !$( this ).data( pluginName + "-active" ) ){
- $( this ).data( pluginName + "-active", true );
- $.fn[ pluginName ].prototype._create.call( this , arrg );
+ if (!$(this).data(pluginName + "-active")) {
+ $(this).data(pluginName + "-active", true);
+ $.fn[pluginName].prototype._create.call(this, arrg);
}
return $(this);
};
// add methods
- $.extend( $.fn[ pluginName ].prototype, methods );
+ $.extend($.fn[pluginName].prototype, methods);
- $( document ).on( Tablesaw.events.create, function( e, Tablesaw ) {
- if( Tablesaw.$table.is( initSelector ) ) {
- Tablesaw.$table[ pluginName ]();
+ $(document).on(Tablesaw.events.create, function(e, Tablesaw) {
+ if (Tablesaw.$table.is(initSelector)) {
+ Tablesaw.$table[pluginName]();
}
});
+})();
-}());
-
-(function(){
-
+(function() {
var classes = {
hideBtn: "disabled",
persistWidths: "tablesaw-fix-persist",
- allColumnsVisible: 'tablesaw-all-cols-visible'
+ allColumnsVisible: "tablesaw-all-cols-visible"
};
var attrs = {
disableTouchEvents: "data-tablesaw-no-touch"
};
- function createSwipeTable( tbl, $table ){
- var tblsaw = $table.data( "tablesaw" );
+ function createSwipeTable(tbl, $table) {
+ var tblsaw = $table.data("tablesaw");
- var $btns = $( "
" );
+ var $btns = $("
");
// TODO next major version: remove .btn
- var $prevBtn = $( "
" ).appendTo( $btns );
+ var $prevBtn = $(
+ "
"
+ ).appendTo($btns);
// TODO next major version: remove .btn
- var $nextBtn = $( "
" ).appendTo( $btns );
+ var $nextBtn = $(
+ "
"
+ ).appendTo($btns);
var $headerCells = tbl._getPrimaryHeaderCells();
- var $headerCellsNoPersist = $headerCells.not( '[data-tablesaw-priority="persist"]' );
+ var $headerCellsNoPersist = $headerCells.not('[data-tablesaw-priority="persist"]');
var headerWidths = [];
- var $head = $( document.head || 'head' );
- var tableId = $table.attr( 'id' );
+ var $head = $(document.head || "head");
+ var tableId = $table.attr("id");
- if( !$headerCells.length ) {
- throw new Error( "tablesaw swipe: no header cells found. Are you using
inside of ?" );
+ if (!$headerCells.length) {
+ throw new Error(
+ "tablesaw swipe: no header cells found. Are you using inside of ?"
+ );
}
- $table.addClass( "tablesaw-swipe" );
+ $table.addClass("tablesaw-swipe");
// Calculate initial widths
$headerCells.each(function() {
var width = this.offsetWidth;
- headerWidths.push( width );
+ headerWidths.push(width);
});
- $btns.appendTo( tblsaw.$toolbar );
+ $btns.appendTo(tblsaw.$toolbar);
- if( !tableId ) {
- tableId = 'tableswipe-' + Math.round( Math.random() * 10000 );
- $table.attr( 'id', tableId );
+ if (!tableId) {
+ tableId = "tableswipe-" + Math.round(Math.random() * 10000);
+ $table.attr("id", tableId);
}
- function $getCells( headerCell ) {
- return $( headerCell.cells ).add( headerCell );
+ function $getCells(headerCell) {
+ return $(headerCell.cells).add(headerCell);
}
- function showColumn( headerCell ) {
- $getCells( headerCell ).removeClass( 'tablesaw-cell-hidden' );
+ function showColumn(headerCell) {
+ $getCells(headerCell).removeClass("tablesaw-cell-hidden");
}
- function hideColumn( headerCell ) {
- $getCells( headerCell ).addClass( 'tablesaw-cell-hidden' );
+ function hideColumn(headerCell) {
+ $getCells(headerCell).addClass("tablesaw-cell-hidden");
}
- function persistColumn( headerCell ) {
- $getCells( headerCell ).addClass( 'tablesaw-cell-persist' );
+ function persistColumn(headerCell) {
+ $getCells(headerCell).addClass("tablesaw-cell-persist");
}
- function isPersistent( headerCell ) {
- return $( headerCell ).is( '[data-tablesaw-priority="persist"]' );
+ function isPersistent(headerCell) {
+ return $(headerCell).is('[data-tablesaw-priority="persist"]');
}
function unmaintainWidths() {
- $table.removeClass( classes.persistWidths );
- $( '#' + tableId + '-persist' ).remove();
+ $table.removeClass(classes.persistWidths);
+ $("#" + tableId + "-persist").remove();
}
function maintainWidths() {
- var prefix = '#' + tableId + '.tablesaw-swipe ',
+ var prefix = "#" + tableId + ".tablesaw-swipe ",
styles = [],
tableWidth = $table.width(),
hash = [],
newHash;
// save persistent column widths (as long as they take up less than 75% of table width)
- $headerCells.each(function( index ) {
+ $headerCells.each(function(index) {
var width;
- if( isPersistent( this ) ) {
+ if (isPersistent(this)) {
width = this.offsetWidth;
- if( width < tableWidth * 0.75 ) {
- hash.push( index + '-' + width );
- styles.push( prefix + ' .tablesaw-cell-persist:nth-child(' + ( index + 1 ) + ') { width: ' + width + 'px; }' );
+ if (width < tableWidth * 0.75) {
+ hash.push(index + "-" + width);
+ styles.push(
+ prefix +
+ " .tablesaw-cell-persist:nth-child(" +
+ (index + 1) +
+ ") { width: " +
+ width +
+ "px; }"
+ );
}
}
});
- newHash = hash.join( '_' );
+ newHash = hash.join("_");
- if( styles.length ) {
- $table.addClass( classes.persistWidths );
- var $style = $( '#' + tableId + '-persist' );
+ if (styles.length) {
+ $table.addClass(classes.persistWidths);
+ var $style = $("#" + tableId + "-persist");
// If style element not yet added OR if the widths have changed
- if( !$style.length || $style.data( 'tablesaw-hash' ) !== newHash ) {
+ if (!$style.length || $style.data("tablesaw-hash") !== newHash) {
// Remove existing
$style.remove();
- $( '' )
- .attr( 'id', tableId + '-persist' )
- .data( 'tablesaw-hash', newHash )
- .appendTo( $head );
+ $("")
+ .attr("id", tableId + "-persist")
+ .data("tablesaw-hash", newHash)
+ .appendTo($head);
}
}
}
- function getNext(){
+ function getNext() {
var next = [],
checkFound;
- $headerCellsNoPersist.each(function( i ) {
- var $t = $( this ),
- isHidden = $t.css( "display" ) === "none" || $t.is( ".tablesaw-cell-hidden" );
+ $headerCellsNoPersist.each(function(i) {
+ var $t = $(this),
+ isHidden = $t.css("display") === "none" || $t.is(".tablesaw-cell-hidden");
- if( !isHidden && !checkFound ) {
+ if (!isHidden && !checkFound) {
checkFound = true;
- next[ 0 ] = i;
- } else if( isHidden && checkFound ) {
- next[ 1 ] = i;
+ next[0] = i;
+ } else if (isHidden && checkFound) {
+ next[1] = i;
return false;
}
@@ -3030,45 +3119,45 @@ if( Tablesaw.mustard ) {
return next;
}
- function getPrev(){
+ function getPrev() {
var next = getNext();
- return [ next[ 1 ] - 1 , next[ 0 ] - 1 ];
+ return [next[1] - 1, next[0] - 1];
}
- function nextpair( fwd ){
+ function nextpair(fwd) {
return fwd ? getNext() : getPrev();
}
- function canAdvance( pair ){
- return pair[ 1 ] > -1 && pair[ 1 ] < $headerCellsNoPersist.length;
+ function canAdvance(pair) {
+ return pair[1] > -1 && pair[1] < $headerCellsNoPersist.length;
}
function matchesMedia() {
- var matchMedia = $table.attr( "data-tablesaw-swipe-media" );
- return !matchMedia || ( "matchMedia" in win ) && win.matchMedia( matchMedia ).matches;
+ var matchMedia = $table.attr("data-tablesaw-swipe-media");
+ return !matchMedia || ("matchMedia" in win && win.matchMedia(matchMedia).matches);
}
function fakeBreakpoints() {
- if( !matchesMedia() ) {
+ if (!matchesMedia()) {
return;
}
- var containerWidth = $table.parent().width(),
+ var containerWidth = $table.parent().width(),
persist = [],
sum = 0,
sums = [],
visibleNonPersistantCount = $headerCells.length;
- $headerCells.each(function( index ) {
- var $t = $( this ),
- isPersist = $t.is( '[data-tablesaw-priority="persist"]' );
+ $headerCells.each(function(index) {
+ var $t = $(this),
+ isPersist = $t.is('[data-tablesaw-priority="persist"]');
- persist.push( isPersist );
- sum += headerWidths[ index ];
- sums.push( sum );
+ persist.push(isPersist);
+ sum += headerWidths[index];
+ sums.push(sum);
// is persistent or is hidden
- if( isPersist || sum > containerWidth ) {
+ if (isPersist || sum > containerWidth) {
visibleNonPersistantCount--;
}
});
@@ -3076,310 +3165,316 @@ if( Tablesaw.mustard ) {
// We need at least one column to swipe.
var needsNonPersistentColumn = visibleNonPersistantCount === 0;
- $headerCells.each(function( index ) {
- if( persist[ index ] ) {
-
+ $headerCells.each(function(index) {
+ if (persist[index]) {
// for visual box-shadow
- persistColumn( this );
+ persistColumn(this);
return;
}
- if( sums[ index ] <= containerWidth || needsNonPersistentColumn ) {
+ if (sums[index] <= containerWidth || needsNonPersistentColumn) {
needsNonPersistentColumn = false;
- showColumn( this );
+ showColumn(this);
} else {
- hideColumn( this );
+ hideColumn(this);
}
});
unmaintainWidths();
- $table.trigger( 'tablesawcolumns' );
+ $table.trigger("tablesawcolumns");
}
- function advance( fwd ){
- var pair = nextpair( fwd );
- if( canAdvance( pair ) ){
- if( isNaN( pair[ 0 ] ) ){
- if( fwd ){
+ function advance(fwd) {
+ var pair = nextpair(fwd);
+ if (canAdvance(pair)) {
+ if (isNaN(pair[0])) {
+ if (fwd) {
pair[0] = 0;
- }
- else {
+ } else {
pair[0] = $headerCellsNoPersist.length - 1;
}
}
maintainWidths();
- hideColumn( $headerCellsNoPersist.get( pair[ 0 ] ) );
- showColumn( $headerCellsNoPersist.get( pair[ 1 ] ) );
+ hideColumn($headerCellsNoPersist.get(pair[0]));
+ showColumn($headerCellsNoPersist.get(pair[1]));
- $table.trigger( 'tablesawcolumns' );
+ $table.trigger("tablesawcolumns");
}
}
- $prevBtn.add( $nextBtn ).on( "click", function( e ){
- advance( !!$( e.target ).closest( $nextBtn ).length );
+ $prevBtn.add($nextBtn).on("click", function(e) {
+ advance(!!$(e.target).closest($nextBtn).length);
e.preventDefault();
});
- function getCoord( event, key ) {
- return ( event.touches || event.originalEvent.touches )[ 0 ][ key ];
- }
-
- if( !$table.is( "[" + attrs.disableTouchEvents + "]" ) ) {
-
- $table
- .on( "touchstart.swipetoggle", function( e ){
- var originX = getCoord( e, 'pageX' );
- var originY = getCoord( e, 'pageY' );
- var x;
- var y;
- var scrollTop = window.pageYOffset;
-
- $( win ).off( Tablesaw.events.resize, fakeBreakpoints );
-
- $( this )
- .on( "touchmove.swipetoggle", function( e ){
- x = getCoord( e, 'pageX' );
- y = getCoord( e, 'pageY' );
- })
- .on( "touchend.swipetoggle", function() {
- var cfg = tbl.getConfig({
- swipeHorizontalThreshold: 30,
- swipeVerticalThreshold: 30
- });
+ function getCoord(event, key) {
+ return (event.touches || event.originalEvent.touches)[0][key];
+ }
+
+ if (!$table.is("[" + attrs.disableTouchEvents + "]")) {
+ $table.on("touchstart.swipetoggle", function(e) {
+ var originX = getCoord(e, "pageX");
+ var originY = getCoord(e, "pageY");
+ var x;
+ var y;
+ var scrollTop = window.pageYOffset;
+
+ $(win).off(Tablesaw.events.resize, fakeBreakpoints);
+
+ $(this)
+ .on("touchmove.swipetoggle", function(e) {
+ x = getCoord(e, "pageX");
+ y = getCoord(e, "pageY");
+ })
+ .on("touchend.swipetoggle", function() {
+ var cfg = tbl.getConfig({
+ swipeHorizontalThreshold: 30,
+ swipeVerticalThreshold: 30
+ });
- // This config code is a little awkward because shoestring doesn’t support deep $.extend
- // Trying to work around when devs only override one of (not both) horizontalThreshold or
- // verticalThreshold in their TablesawConfig.
- // @TODO major version bump: remove cfg.swipe, move to just use the swipePrefix keys
- var verticalThreshold = cfg.swipe ? cfg.swipe.verticalThreshold : cfg.swipeVerticalThreshold;
- var horizontalThreshold = cfg.swipe ? cfg.swipe.horizontalThreshold : cfg.swipeHorizontalThreshold;
-
- var isPageScrolled = Math.abs( window.pageYOffset - scrollTop ) >= verticalThreshold;
- var isVerticalSwipe = Math.abs( y - originY ) >= verticalThreshold;
-
- if( !isVerticalSwipe && !isPageScrolled ) {
- if( x - originX < -1 * horizontalThreshold ){
- advance( true );
- }
- if( x - originX > horizontalThreshold ){
- advance( false );
- }
+ // This config code is a little awkward because shoestring doesn’t support deep $.extend
+ // Trying to work around when devs only override one of (not both) horizontalThreshold or
+ // verticalThreshold in their TablesawConfig.
+ // @TODO major version bump: remove cfg.swipe, move to just use the swipePrefix keys
+ var verticalThreshold = cfg.swipe
+ ? cfg.swipe.verticalThreshold
+ : cfg.swipeVerticalThreshold;
+ var horizontalThreshold = cfg.swipe
+ ? cfg.swipe.horizontalThreshold
+ : cfg.swipeHorizontalThreshold;
+
+ var isPageScrolled = Math.abs(window.pageYOffset - scrollTop) >= verticalThreshold;
+ var isVerticalSwipe = Math.abs(y - originY) >= verticalThreshold;
+
+ if (!isVerticalSwipe && !isPageScrolled) {
+ if (x - originX < -1 * horizontalThreshold) {
+ advance(true);
}
+ if (x - originX > horizontalThreshold) {
+ advance(false);
+ }
+ }
- window.setTimeout(function() {
- $( win ).on( Tablesaw.events.resize, fakeBreakpoints );
- }, 300);
+ window.setTimeout(function() {
+ $(win).on(Tablesaw.events.resize, fakeBreakpoints);
+ }, 300);
- $( this ).off( "touchmove.swipetoggle touchend.swipetoggle" );
- });
- });
+ $(this).off("touchmove.swipetoggle touchend.swipetoggle");
+ });
+ });
}
$table
- .on( "tablesawcolumns.swipetoggle", function(){
- var canGoPrev = canAdvance( getPrev() );
- var canGoNext = canAdvance( getNext() );
- $prevBtn[ canGoPrev ? "removeClass" : "addClass" ]( classes.hideBtn );
- $nextBtn[ canGoNext ? "removeClass" : "addClass" ]( classes.hideBtn );
-
- tblsaw.$toolbar[ !canGoPrev && !canGoNext ? 'addClass' : 'removeClass' ]( classes.allColumnsVisible );
+ .on("tablesawcolumns.swipetoggle", function() {
+ var canGoPrev = canAdvance(getPrev());
+ var canGoNext = canAdvance(getNext());
+ $prevBtn[canGoPrev ? "removeClass" : "addClass"](classes.hideBtn);
+ $nextBtn[canGoNext ? "removeClass" : "addClass"](classes.hideBtn);
+
+ tblsaw.$toolbar[!canGoPrev && !canGoNext ? "addClass" : "removeClass"](
+ classes.allColumnsVisible
+ );
+ })
+ .on("tablesawnext.swipetoggle", function() {
+ advance(true);
+ })
+ .on("tablesawprev.swipetoggle", function() {
+ advance(false);
})
- .on( "tablesawnext.swipetoggle", function(){
- advance( true );
- } )
- .on( "tablesawprev.swipetoggle", function(){
- advance( false );
- } )
- .on( Tablesaw.events.destroy + ".swipetoggle", function(){
- var $t = $( this );
-
- $t.removeClass( 'tablesaw-swipe' );
- tblsaw.$toolbar.find( '.tablesaw-advance' ).remove();
- $( win ).off( Tablesaw.events.resize, fakeBreakpoints );
-
- $t.off( ".swipetoggle" );
+ .on(Tablesaw.events.destroy + ".swipetoggle", function() {
+ var $t = $(this);
+
+ $t.removeClass("tablesaw-swipe");
+ tblsaw.$toolbar.find(".tablesaw-advance").remove();
+ $(win).off(Tablesaw.events.resize, fakeBreakpoints);
+
+ $t.off(".swipetoggle");
})
- .on( Tablesaw.events.refresh, function() {
+ .on(Tablesaw.events.refresh, function() {
// manual refresh
headerWidths = [];
$headerCells.each(function() {
var width = this.offsetWidth;
- headerWidths.push( width );
+ headerWidths.push(width);
});
fakeBreakpoints();
});
fakeBreakpoints();
- $( win ).on( Tablesaw.events.resize, fakeBreakpoints );
+ $(win).on(Tablesaw.events.resize, fakeBreakpoints);
}
// on tablecreate, init
- $( document ).on( Tablesaw.events.create, function( e, tablesaw ){
- if( tablesaw.mode === 'swipe' ){
- createSwipeTable( tablesaw, tablesaw.$table );
+ $(document).on(Tablesaw.events.create, function(e, tablesaw) {
+ if (tablesaw.mode === "swipe") {
+ createSwipeTable(tablesaw, tablesaw.$table);
}
+ });
+})();
- } );
-
-}());
-
-;(function(){
-
+(function() {
var MiniMap = {
attr: {
- init: 'data-tablesaw-minimap'
+ init: "data-tablesaw-minimap"
}
};
- function createMiniMap( $table ){
-
- var tblsaw = $table.data( "tablesaw" );
- var $btns = $( '' );
- var $dotNav = $( ' ' ).appendTo( $btns );
- var hideDot = 'tablesaw-advance-dots-hide';
- var $headerCells = $table.find( 'thead th' );
+ function createMiniMap($table) {
+ var tblsaw = $table.data("tablesaw");
+ var $btns = $(' | |