@@ -11,6 +11,7 @@ define( [ "jquery", "./listview", "./forms/textinput" ], function( $ ) {
1111$ . mobile . listview . prototype . options . filter = false ;
1212$ . mobile . listview . prototype . options . filterPlaceholder = "Filter items..." ;
1313$ . mobile . listview . prototype . options . filterTheme = "c" ;
14+ $ . mobile . listview . prototype . options . filterReveal = false ;
1415// TODO rename callback/deprecate and default to the item itself as the first argument
1516var defaultFilterCallback = function ( text , searchValue , item ) {
1617 return text . toString ( ) . toLowerCase ( ) . indexOf ( searchValue ) === - 1 ;
@@ -27,6 +28,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
2728 return ;
2829 }
2930
31+ if ( listview . options . filterReveal ) {
32+ list . children ( ) . addClass ( "ui-screen-hidden" ) ;
33+ }
34+
3035 var wrapper = $ ( "<form>" , {
3136 "class" : "ui-listview-filter ui-bar-" + listview . options . filterTheme ,
3237 "role" : "search"
@@ -60,6 +65,10 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
6065
6166 // Only chars added, not removed, only use visible subset
6267 listItems = list . children ( ":not(.ui-screen-hidden)" ) ;
68+
69+ if ( ! listItems . length && listview . options . filterReveal ) {
70+ listItems = list . children ( ".ui-screen-hidden" ) ;
71+ }
6372 }
6473
6574 if ( val ) {
@@ -103,7 +112,7 @@ $( document ).delegate( ":jqmData(role='listview')", "listviewcreate", function(
103112 } else {
104113
105114 //filtervalue is empty => show all
106- listItems . toggleClass ( "ui-screen-hidden" , false ) ;
115+ listItems . toggleClass ( "ui-screen-hidden" , ! ! listview . options . filterReveal ) ;
107116 }
108117 listview . _refreshCorners ( ) ;
109118 } )
0 commit comments