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

Commit

Permalink
Merge pull request #5852 from frequent/table_refresh_XXX
Browse files Browse the repository at this point in the history
table: added refresh method and tests for 1.3.1 - fixes #5842 and #5841 missing table-refresh methods
  • Loading branch information
jaspermdegroot committed Apr 4, 2013
2 parents c9322d1 + 4bd5c29 commit 8dc4b1b
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
17 changes: 9 additions & 8 deletions js/widgets/table.columntoggle.js
Expand Up @@ -34,11 +34,11 @@ $.mobile.table.prototype.options.classes = $.extend(
}
);

$.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate", function( e ) {

$.mobile.document.delegate( ":jqmData(role='table')", "tablecreate refresh", function( e ) {
var $table = $( this ),
event = e.type,
self = $table.data( "mobile-table" ),
event = e.type,
o = self.options,
ns = $.mobile.ns,
id = ( $table.attr( "id" ) || o.classes.popup ) + "-popup"; //TODO BETTER FALLBACK ID HERE
Expand All @@ -47,7 +47,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
return;
}

if ( event !== "tableupdate" ) {
if ( event !== "refresh" ) {
self.element.addClass( o.classes.columnToggleTable );

var $menuButton = $( "<a href='#" + id + "' class='" + o.classes.columnBtn + "' data-" + ns + "rel='popup' data-" + ns + "mini='true'>" + o.columnBtnText + "</a>" ),
Expand All @@ -65,7 +65,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",

$cells.addClass( o.classes.priorityPrefix + priority );

if ( event !== "tableupdate" ) {
if ( event !== "refresh" ) {
$("<label><input type='checkbox' checked />" + $( this ).text() + "</label>" )
.appendTo( $menu )
.children( 0 )
Expand All @@ -78,7 +78,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
}
}
});
if ( event !== "tableupdate" ) {
if ( event !== "refresh" ) {
$menu.appendTo( $popup );
}

Expand All @@ -89,7 +89,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
$switchboard = $menu;
}

if (event !== "tableupdate") {
if (event !== "refresh") {
$switchboard.on( "change", "input", function( e ){
if( this.checked ){
$( this ).jqmData( "cells" ).removeClass( "ui-table-cell-hidden" ).addClass( "ui-table-cell-visible" );
Expand All @@ -114,7 +114,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
$switchboard.find( "input" ).each( function(){
if (this.checked) {
this.checked = $( this ).jqmData( "cells" ).eq(0).css( "display" ) === "table-cell";
if (event === "tableupdate") {
if (event === "refresh") {
$( this ).jqmData( "cells" ).addClass('ui-table-cell-visible');
}
} else {
Expand All @@ -129,6 +129,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
self.update();

});

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
Expand Down
4 changes: 2 additions & 2 deletions js/widgets/table.js
Expand Up @@ -24,7 +24,6 @@ $.widget( "mobile.table", $.mobile.widget, {
},

refresh: function (create) {

var self = this,
trs = this.element.find( "thead tr" );

Expand Down Expand Up @@ -72,7 +71,7 @@ $.widget( "mobile.table", $.mobile.widget, {

// update table modes
if ( create === undefined ) {
this.element.trigger( 'tableupdate' );
this.element.trigger( 'refresh' );
}
}

Expand All @@ -82,6 +81,7 @@ $.widget( "mobile.table", $.mobile.widget, {
$.mobile.document.bind( "pagecreate create", function( e ) {
$.mobile.table.prototype.enhanceWithin( e.target );
});

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
Expand Down
5 changes: 3 additions & 2 deletions js/widgets/table.reflow.js
Expand Up @@ -19,7 +19,7 @@ $.mobile.table.prototype.options.classes = $.extend(
}
);

$.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate", function( e ) {
$.mobile.document.delegate( ":jqmData(role='table')", "tablecreate refresh", function( e ) {

var $table = $( this ),
event = e.type,
Expand All @@ -31,7 +31,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
return;
}

if ( event !== "tableupdate" ) {
if ( event !== "refresh" ) {
self.element.addClass( o.classes.reflowTable );
}

Expand Down Expand Up @@ -64,6 +64,7 @@ $.mobile.document.delegate( ":jqmData(role='table')", "tablecreate tableupdate",
});

});

})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
});
Expand Down
1 change: 0 additions & 1 deletion tests/unit/table/index.html
Expand Up @@ -35,7 +35,6 @@
<script src="../../swarminject.js"></script>

<script type="text/javascript">
// basic
$(window).on('refresh_test_table', function (e, data) {
var tb = $(data).find('tbody'),
newRow = '<tr><th data-test="abc">1</th><td>2</td><td>3</td><td data-col="3">4</td><td>5</td></tr>';
Expand Down
1 change: 0 additions & 1 deletion tests/unit/table/table_core.js
Expand Up @@ -137,7 +137,6 @@
start();
}, 800);
});

asyncTest( "Column toggle table refresh" , function(){
setTimeout(function () {
// hide one column and refresh
Expand Down

0 comments on commit 8dc4b1b

Please sign in to comment.