Permalink
Browse files

Table: Implement Classes Option

also adds hasclasses and lacksclasses to table tests

Fixes gh-8341
  • Loading branch information...
cgack authored and arschmitz committed Dec 10, 2015
1 parent 9f23bde commit 2be701dee58659eeb3bdcfd7f9512fb56734558b
Showing with 731 additions and 855 deletions.
  1. +1 −57 js/jquery.mobile.js
  2. +33 −30 js/widgets/table.columntoggle.js
  3. +84 −58 js/widgets/table.columntoggle.popup.js
  4. +9 −12 js/widgets/table.js
  5. +14 −12 js/widgets/table.reflow.js
  6. +15 −16 tests/integration/table/basic_table_core.js
  7. +1 −0 tests/integration/table/columntoggle-disable-tests.html
  8. +1 −0 tests/integration/table/columntoggle-no-ui-tests.html
  9. +3 −3 tests/integration/table/columntoggle-option-tests.html
  10. +25 −25 tests/integration/table/columntoggle-prerendered-option-tests.html
  11. +1 −0 tests/integration/table/columntoggle-table-tests.html
  12. +24 −17 tests/integration/table/columntoggle_destroy_core.js
  13. +13 −14 tests/integration/table/columntoggle_disable_core.js
  14. +19 −29 tests/integration/table/columntoggle_no_ui_core.js
  15. +8 −7 tests/integration/table/columntoggle_option_core.js
  16. +87 −86 tests/integration/table/columntoggle_table_core.js
  17. +16 −13 tests/integration/table/grouped_core.js
  18. +1 −0 tests/integration/table/reflow-table-tests.html
  19. +6 −2 tests/integration/table/reflow_destroy_core.js
  20. +24 −23 tests/integration/table/reflow_table_core.js
  21. +11 −11 tests/integration/table/table_destroy_core.js
  22. +13 −9 tests/integration/table/table_prerendered_destroy_core.js
  23. +150 −140 tests/unit/table/columntoggle_core.js
  24. +4 −5 tests/unit/table/index.html
  25. +1 −0 tests/unit/table/reflow-tests.html
  26. +86 −68 tests/unit/table/reflow_core.js
  27. +0 −110 tests/unit/table/table-reflow-heading-tests.html
  28. +81 −99 tests/unit/table/table_core.js
  29. +0 −9 tests/unit/table/table_reflow_heading_core.js
View
@@ -67,6 +67,7 @@
"./widgets/panel",
"./widgets/table",
"./widgets/table.columntoggle",
"./widgets/table.columntoggle.popup",
"./widgets/table.reflow",
"./widgets/filterable",
"./jquery-ui/tabs",
@@ -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");
@@ -1,3 +1,4 @@
/*!
* jQuery Mobile Column-toggling Table @VERSION
* http://jquerymobile.com
@@ -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() {
@@ -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 ) {
@@ -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" );
}
},
@@ -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,
@@ -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
@@ -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");
} );
Oops, something went wrong.

0 comments on commit 2be701d

Please sign in to comment.