Skip to content

Commit

Permalink
Table: Implment Classes Option
Browse files Browse the repository at this point in the history
post review changes

Fixes jquery-archivegh-8341
  • Loading branch information
cgack authored and arschmitz committed Mar 26, 2016
1 parent 7057e3a commit 2a61608
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
7 changes: 3 additions & 4 deletions js/widgets/table.columntoggle.js
@@ -1,3 +1,4 @@

/*!
* jQuery Mobile Column-toggling Table @VERSION
* http://jquerymobile.com
Expand Down Expand Up @@ -63,7 +64,7 @@ return $.widget( "mobile.table", $.mobile.table, {
this._updateHeaderPriorities();
},

_updateVariableColumn: function( header, cells, priority/*, state */ ) {
_updateVariableColumn: function( header, cells, priority ) {
this._addClass( cells, "ui-table-priority-" + priority );
},

Expand Down Expand Up @@ -167,16 +168,14 @@ return $.widget( "mobile.table", $.mobile.table, {
_destroy: function() {
if ( this.options.mode === "columntoggle" ) {
if ( !this.options.enhanced ) {
this._removeClass( "ui-table-columntoggle" );
this.headers.each( $.proxy( function( index, element ) {
var header,
priority = $.mobile.getAttribute( element, "priority" );

if ( priority ) {
header = $( element );
header
.add( header.jqmData( "cells" ) )
.removeClass( this.options.classes.priorityPrefix + priority );
.add( header.jqmData( "cells" ) );
}
}, this ) );
}
Expand Down
4 changes: 3 additions & 1 deletion js/widgets/table.columntoggle.popup.js
Expand Up @@ -22,6 +22,7 @@
"./table.columntoggle",
"./popup",
"./controlgroup",
"./forms/button",
"./widget.theme",
"./forms/checkboxradio" ], factory );
} else {
Expand All @@ -40,7 +41,7 @@ return $.widget( "mobile.table", $.mobile.table, {
columnUi: true,
classes: {
"ui-table-columntoggle-popup": "",
"ui-table-columntoggle-btn": "ui-button ui-corner-all ui-shadow ui-mini"
"ui-table-columntoggle-btn": "ui-corner-all ui-shadow ui-mini"
}
},

Expand Down Expand Up @@ -274,6 +275,7 @@ return $.widget( "mobile.table", $.mobile.table, {
"id='" + id + "-button' " +
"data-" + $.mobile.ns + "rel='popup'>" + options.columnButtonText + "</a>" );

button.button();
this._addClass( button, "ui-table-columntoggle-btn" +
( buttonTheme ? " " + buttonTheme : "" ) );

Expand Down
4 changes: 0 additions & 4 deletions js/widgets/table.js
Expand Up @@ -122,10 +122,6 @@ return $.widget( "mobile.table", {
_destroy: function() {
var table = this.element;

if ( !this.options.enhanced ) {
this._removeClass( "ui-table" );
}

// We have to remove "cells" data even if the table was originally enhanced, because it is
// added during refresh
table.find( "thead tr" ).children().each( function() {
Expand Down
3 changes: 1 addition & 2 deletions js/widgets/table.reflow.js
Expand Up @@ -77,7 +77,7 @@ return $.widget( "mobile.table", $.mobile.table, {
iteration = parseInt( headerCell.getAttribute( "colspan" ), 10 );

if ( iteration ) {
cells = cells.filter( "td:nth-child("+ iteration + "n + " + colstart + ")" );
cells = cells.filter( "td:nth-child(" + iteration + "n + " + colstart + ")" );
}
}

Expand Down Expand Up @@ -112,7 +112,6 @@ return $.widget( "mobile.table", $.mobile.table, {
.removeAttr( colstartAttr )
.end()
.end()
.removeClass( "ui-table-reflow" )
.children( "tbody" )
.find( "b.ui-table-cell-label" )
.remove();
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/table/columntoggle_core.js
Expand Up @@ -89,7 +89,7 @@ QUnit.skip( "_updateVariableColumn() adds priority classes to cells",
}, null, cells, 2 );

assert.deepEqual( cells.is( function() {
return !$( this ).hasClass( "prio-prefix-2" );
return assert.lacksClasses( $( this ), "prio-prefix-2" );
} ), false, "All cells have class 'prio-prefix-2'" );
} );

Expand Down Expand Up @@ -122,13 +122,13 @@ QUnit.skip( "_updateHeaderPriorities() iterates over headers and adds classes",

assert.deepEqual( headers.eq( 0 ).add( headers.eq( 0 ).jqmData( "cells" ) )
.is( function() {
return !$( this ).hasClass( "prio-prefix-3" );
return assert.lacksClasses( $( this ), "prio-prefix-3" );
} ),
false, "first column cells all have priorty class, including header" );

assert.deepEqual( headers.eq( 1 ).add( headers.eq( 1 ).jqmData( "cells" ) )
.is( function() {
return !$( this ).hasClass( "prio-prefix-5" );
return assert.lacksClasses( $( this ), "prio-prefix-5" );
} ),
false, "second column cells all have priorty class, including header" );
} );
Expand Down Expand Up @@ -160,7 +160,7 @@ QUnit.skip( "_setColumnVisibility() forces column to be visible/hidden",
}, header, visible );

assert.deepEqual( cells.add( header ).is( function() {
return $( this ).hasClass( expectedAbsent );
return assert.hasClasses( this, expectedAbsent );
} ),
false, "Neither header nor cells have class '" + expectedAbsent + "'" );
}
Expand Down Expand Up @@ -212,8 +212,8 @@ QUnit.skip( "_unlock() removes classes from cells", function( assert ) {
}, cellList );

assert.deepEqual( cellList.is( function() {
return $( this ).hasClass( "ui-table-cell-hidden" ) ||
$( this ).hasClass( "ui-table-cell-visible" );
return assert.hasClasses( $( this ), "ui-table-cell-hidden" ) ||
assert.hasClasses( $( this ), "ui-table-cell-visible" );
} ),
false, "Both 'ui-table-cell-hidden' and 'ui-table-cell-visible' have been removed" );
} );
Expand Down

0 comments on commit 2a61608

Please sign in to comment.