Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Table: Reflow: Convert to proper extension.

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