Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Listview: New option to start with all items hidden when search input…

… in blank

Please meet: data-filter-reveal
Fixes #5090
  • Loading branch information...
commit a9c80c5e8a332cb65da38882064699b774392da2 1 parent 68d8cb5
@gseguin gseguin authored
Showing with 10 additions and 1 deletion.
  1. +10 −1 js/widgets/listview.filter.js
View
11 js/widgets/listview.filter.js
@@ -11,6 +11,7 @@ define( [ "jquery", "./listview", "./forms/textinput" ], function( $ ) {
$.mobile.listview.prototype.options.filter = false;
$.mobile.listview.prototype.options.filterPlaceholder = "Filter items...";
$.mobile.listview.prototype.options.filterTheme = "c";
+$.mobile.listview.prototype.options.filterReveal = false;
// TODO rename callback/deprecate and default to the item itself as the first argument
var defaultFilterCallback = function( text, searchValue, item ) {
return text.toString().toLowerCase().indexOf( searchValue ) === -1;
@@ -27,6 +28,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
return;
}
+ if ( listview.options.filterReveal ) {
+ list.children().addClass( "ui-screen-hidden" );
+ }
+
var wrapper = $( "<form>", {
"class": "ui-listview-filter ui-bar-" + listview.options.filterTheme,
"role": "search"
@@ -60,6 +65,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
// Only chars added, not removed, only use visible subset
listItems = list.children( ":not(.ui-screen-hidden)" );
+
+ if ( !listItems.length && listview.options.filterReveal ) {
+ listItems = list.children( ".ui-screen-hidden" );
+ }
}
if ( val ) {
@@ -103,7 +112,7 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
} else {
//filtervalue is empty => show all
- listItems.toggleClass( "ui-screen-hidden", false );
+ listItems.toggleClass( "ui-screen-hidden", !!listview.options.filterReveal );
}
listview._refreshCorners();
})
Please sign in to comment.
Something went wrong with that request. Please try again.