From bb3080a6ba8a069ce607a202accf24b941b808d4 Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Mon, 6 Jul 2015 22:25:52 +0800 Subject: [PATCH 1/3] Filterable: Add a data-no-filter attribute Add a data-no-filter attribute for an item such that it will always show in both normal and reveal mode when its data-no-filter="true" Closes gh-8184 --- js/widgets/filterable.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/widgets/filterable.js b/js/widgets/filterable.js index 888d830bdbc..8b8cb919ec8 100644 --- a/js/widgets/filterable.js +++ b/js/widgets/filterable.js @@ -92,7 +92,7 @@ $.widget( "mobile.filterable", { }, _filterItems: function( val ) { - var idx, callback, length, dst, + var idx, callback, length, dst, noFilter, show = [], hide = [], opts = this.options, @@ -104,7 +104,8 @@ $.widget( "mobile.filterable", { // Partition the items into those to be hidden and those to be shown for ( idx = 0 ; idx < length ; idx++ ) { - dst = ( callback.call( filterItems[ idx ], idx, val ) ) ? hide : show; + noFilter = ( $.mobile.getAttribute( filterItems[ idx ], "no-filter" ) ); + dst = ( !noFilter && callback.call( filterItems[ idx ], idx, val ) ) ? hide : show; dst.push( filterItems[ idx ] ); } } From e7b4ae01fa27f02e4126f378f3868021251cd11d Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Sat, 11 Jul 2015 17:43:27 +0800 Subject: [PATCH 2/3] Filterable: data-no-filter attr only accept true --- js/widgets/filterable.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/widgets/filterable.js b/js/widgets/filterable.js index 8b8cb919ec8..a053d985d5f 100644 --- a/js/widgets/filterable.js +++ b/js/widgets/filterable.js @@ -104,7 +104,7 @@ $.widget( "mobile.filterable", { // Partition the items into those to be hidden and those to be shown for ( idx = 0 ; idx < length ; idx++ ) { - noFilter = ( $.mobile.getAttribute( filterItems[ idx ], "no-filter" ) ); + noFilter = $.mobile.getAttribute( filterItems[ idx ], "no-filter" ) === true; dst = ( !noFilter && callback.call( filterItems[ idx ], idx, val ) ) ? hide : show; dst.push( filterItems[ idx ] ); } From beda9e3d7fa0d67e6b0d531c56f8026c318fe076 Mon Sep 17 00:00:00 2001 From: Carson Ip Date: Sun, 31 Jul 2016 13:49:33 -0700 Subject: [PATCH 3/3] Filterable: Use data-ignore instead of data-no-filter Replaced data-no-filter with data-ignore according to the comments of jQuery members. Looks more flexible now. --- js/widgets/filterable.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/js/widgets/filterable.js b/js/widgets/filterable.js index a053d985d5f..5db7e3fad89 100644 --- a/js/widgets/filterable.js +++ b/js/widgets/filterable.js @@ -26,6 +26,7 @@ $.widget( "mobile.filterable", { filterCallback: defaultFilterCallback, enhanced: false, input: null, + ignore: null, children: "> li, > option, > optgroup option, > tbody tr, > .ui-controlgroup-controls > .ui-btn, > .ui-controlgroup-controls > .ui-checkbox, > .ui-controlgroup-controls > .ui-radio" }, @@ -92,7 +93,7 @@ $.widget( "mobile.filterable", { }, _filterItems: function( val ) { - var idx, callback, length, dst, noFilter, + var idx, callback, length, dst, noFilter show = [], hide = [], opts = this.options, @@ -104,7 +105,7 @@ $.widget( "mobile.filterable", { // Partition the items into those to be hidden and those to be shown for ( idx = 0 ; idx < length ; idx++ ) { - noFilter = $.mobile.getAttribute( filterItems[ idx ], "no-filter" ) === true; + noFilter = opts.ignore ? $( filterItems[ idx ] ).is( opts.ignore ) : false; dst = ( !noFilter && callback.call( filterItems[ idx ], idx, val ) ) ? hide : show; dst.push( filterItems[ idx ] ); }