Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Table: Implement Classes Option
Browse files Browse the repository at this point in the history
also adds hasclasses and lacksclasses to table tests

Fixes gh-8341
  • Loading branch information
cgack authored and arschmitz committed Jul 4, 2016
1 parent 9f23bde commit 2be701d
Show file tree
Hide file tree
Showing 29 changed files with 731 additions and 855 deletions.
58 changes: 1 addition & 57 deletions js/jquery.mobile.js
Expand Up @@ -67,6 +67,7 @@
"./widgets/panel",
"./widgets/table",
"./widgets/table.columntoggle",
"./widgets/table.columntoggle.popup",
"./widgets/table.reflow",
"./widgets/filterable",
"./jquery-ui/tabs",
Expand All @@ -81,60 +82,3 @@
} )( function() {
require( [ "./init" ], function() {} );
} );
define([
"require",
"./widgets/loader",
"./events/navigate",
"./navigation/path",
"./navigation/history",
"./navigation/navigator",
"./navigation/method",
"./transitions/handlers",
"./transitions/visuals",
"./animationComplete",
"./navigation",
"./degradeInputs",
"./widgets/page.dialog",
"./widgets/dialog",
"./widgets/collapsible",
"./widgets/collapsibleSet",
"./fieldContain",
"./grid",
"./widgets/navbar",
"./widgets/listview",
"./widgets/listview.autodividers",
"./widgets/listview.hidedividers",
"./nojs",
"./widgets/forms/checkboxradio",
"./widgets/forms/button",
"./widgets/forms/slider",
"./widgets/forms/slider.tooltip",
"./widgets/forms/flipswitch",
"./widgets/forms/rangeslider",
"./widgets/forms/textinput",
"./widgets/forms/clearButton",
"./widgets/forms/autogrow",
"./widgets/forms/select.custom",
"./widgets/forms/select",
"./buttonMarkup",
"./widgets/controlgroup",
"./links",
"./widgets/toolbar",
"./widgets/fixedToolbar",
"./widgets/fixedToolbar.workarounds",
"./widgets/popup",
"./widgets/popup.arrow",
"./widgets/panel",
"./widgets/table",
"./widgets/table.columntoggle",
"./widgets/table.columntoggle.popup",
"./widgets/table.reflow",
"./widgets/filterable",
"./widgets/filterable.backcompat",
"./widgets/tabs",
"./zoom",
"./zoom/iosorientationfix"
], function( require ) {
require( [ "./init" ], function() {} );
});
//>>excludeEnd("jqmBuildExclude");
63 changes: 33 additions & 30 deletions js/widgets/table.columntoggle.js
@@ -1,3 +1,4 @@

/*!
* jQuery Mobile Column-toggling Table @VERSION
* http://jquerymobile.com
Expand All @@ -14,21 +15,28 @@
//>>demos: http://demos.jquerymobile.com/@VERSION/table-column-toggle/
//>>css.structure: ../css/structure/jquery.mobile.table.columntoggle.css

define( [
"jquery",
"./table" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
( function( factory ) {
if ( typeof define === "function" && define.amd ) {

// AMD. Register as an anonymous module.
define( [
"jquery",
"./table" ], factory );
} else {

factory( jQuery );
}
} )( function( $, undefined ) {

return $.widget( "mobile.table", $.mobile.table, {
options: {
mode: "columntoggle",
classes: $.extend( {}, $.mobile.table.prototype.options.classes, {
cellHidden: "ui-table-cell-hidden",
cellVisible: "ui-table-cell-visible",
priorityPrefix: "ui-table-priority-",
columnToggleTable: "ui-table-columntoggle"
} )
classes: {
"ui-table-cell-hidden": "",
"ui-table-cell-visible": "",
"ui-table-priority-": "",
"ui-table-columntoggle": ""
}
},

_create: function() {
Expand All @@ -52,12 +60,12 @@ return $.widget( "mobile.table", $.mobile.table, {
},

_enhanceColumnToggle: function() {
this.element.addClass( this.options.classes.columnToggleTable );
this._addClass( "ui-table-columntoggle" );
this._updateHeaderPriorities();
},

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

_updateHeaderPriorities: function( state ) {
Expand All @@ -81,7 +89,8 @@ return $.widget( "mobile.table", $.mobile.table, {
if ( cells ) {
cells = cells.add( header );
this._unlock( cells );
cells.addClass( this.options.classes[ visible ? "cellVisible" : "cellHidden" ] );
this._addClass( cells,
visible ? "ui-table-cell-visible" : "ui-table-cell-hidden" );
}
},

Expand Down Expand Up @@ -120,15 +129,14 @@ return $.widget( "mobile.table", $.mobile.table, {
},

_unlock: function( cells ) {
var classes = this.options.classes;

// allow hide/show via CSS only = remove all toggle-locks
( cells ||
// Allow hide/show via CSS only = remove all toggle-locks
var locked = ( cells ||
this.element
.children( "thead, tbody" )
.children( "tr" )
.children( "." + classes.cellHidden + ", ." + classes.cellVisible ) )
.removeClass( classes.cellHidden + " " + classes.cellVisible );
.children( ".ui-table-cell-hidden, .ui-table-cell-visible" ) );
this._removeClass( locked, "ui-table-cell-hidden ui-table-cell-visible" );
},

_recordLockedColumns: $.noop,
Expand All @@ -145,10 +153,10 @@ return $.widget( "mobile.table", $.mobile.table, {
// Record which columns are locked
lockedColumns = this._recordLockedColumns();

// columns not being replaced must be cleared from input toggle-locks
// Columns not being replaced must be cleared from input toggle-locks
this._unlock();

// update priorities
// Update priorities
this._updateHeaderPriorities();

// Make sure columns that were locked before this refresh, and which are still around
Expand All @@ -160,25 +168,20 @@ return $.widget( "mobile.table", $.mobile.table, {
_destroy: function() {
if ( this.options.mode === "columntoggle" ) {
if ( !this.options.enhanced ) {
this.element.removeClass( this.options.classes.columnToggleTable );
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 ));
}, this ) );
}
}
return this._superApply( arguments );
}
} );

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
//>>excludeEnd("jqmBuildExclude");
} );

0 comments on commit 2be701d

Please sign in to comment.