Permalink
Browse files

Table: Reflow: Convert to proper extension.

  • Loading branch information...
gabrielschulhof committed Mar 26, 2013
1 parent 2151fc1 commit 78a21fd188fb4c4c18becd22dc7ef5920c98d49f
Showing with 45 additions and 49 deletions.
  1. +45 −49 js/widgets/table.reflow.js
@@ -9,57 +9,53 @@ define( [ "jquery", "./table" ], function( jQuery ) {
//>>excludeEnd("jqmBuildExclude"); //>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) { (function( $, undefined ) {
$.mobile.table.prototype.options.mode = "reflow"; $.widget( "mobile.table", $.mobile.table, {
options: {
$.mobile.table.prototype.options.classes = $.extend( mode: "reflow",
$.mobile.table.prototype.options.classes, classes: $.extend( $.mobile.table.prototype.options.classes, {
{ reflowTable: "ui-table-reflow",
reflowTable: "ui-table-reflow", cellLabels: "ui-table-cell-label"
cellLabels: "ui-table-cell-label" })
} },
);
_create: function() {
$.mobile.document.delegate( ":jqmData(role='table')", "tablecreate", function() { var o = this.options;
var $table = $( this ), this._super();
self = $table.data( "mobile-table" ),
o = self.options; // If it's not reflow mode, return here.
if( o.mode !== "reflow" ) {
// If it's not reflow mode, return here. return;
if( o.mode !== "reflow" ){ }
return;
} this.element.addClass( o.classes.reflowTable );
self.element.addClass( o.classes.reflowTable ); // get headers in reverse order so that top-level headers are appended last
$( this.allHeaders.get().reverse() ).each( function( i ) {
// get headers in reverse order so that top-level headers are appended last // create the hide/show toggles
var reverseHeaders = $( self.allHeaders.get().reverse() ); var $cells = $( this ).jqmData( "cells" ),
colstart = $( this ).jqmData( "colstart" ),
// create the hide/show toggles hierarchyClass = $cells.not( this ).filter( "thead th" ).length && " ui-table-cell-label-top",
reverseHeaders.each(function(i){ text = $(this).text();
var $cells = $( this ).jqmData( "cells" ),
colstart = $( this ).jqmData( "colstart" ), if( text !== "" ) {
hierarchyClass = $cells.not( this ).filter( "thead th" ).length && " ui-table-cell-label-top",
text = $(this).text(); if( hierarchyClass ) {
var iteration = parseInt( $( this ).attr( "colspan" ), 10 ),
if( text !== "" ){ filter = "";
if( hierarchyClass ){ if( iteration ){
var iteration = parseInt( $( this ).attr( "colspan" ), 10 ), filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")";
filter = ""; }
$cells.filter( filter ).prepend( "<b class='" + o.classes.cellLabels + hierarchyClass + "'>" + text + "</b>" );
if( iteration ){ }
filter = "td:nth-child("+ iteration +"n + " + ( colstart ) +")"; else {
$cells.prepend( "<b class='" + o.classes.cellLabels + "'>" + text + "</b>" );
} }
$cells.filter( filter ).prepend( "<b class='" + o.classes.cellLabels + hierarchyClass + "'>" + text + "</b>" );
}
else {
$cells.prepend( "<b class='" + o.classes.cellLabels + "'>" + text + "</b>" );
}
}
});
}
});
}
}); });
})( jQuery ); })( jQuery );

0 comments on commit 78a21fd

Please sign in to comment.