Commit ccf43cf5 authored by David Stutz's avatar David Stutz

Merge pull request #104 from bsy/master

case insensitive filtering.
parents d8ddb2d9 da1d845b
......@@ -98,6 +98,10 @@ The value by which the select all option is identified.
Define if a text input should be created to filter results. Note that 'select all' option will select all **FILTERED** options. Default is false.
**enableCaseInsensitiveFiltering**
Define case insensitive text input filtering. Default is false.
**filterPlaceholder**
Define the placeholder for the text input above. Note that 'select all' option will select all **FILTERED** options. Default is false.
......
......@@ -68,7 +68,7 @@
}
// Enable filtering.
if (this.options.enableFiltering) {
if (this.options.enableFiltering || this.options.enableCaseInsensitiveFiltering) {
$('.multiselect-container', this.$container).prepend('<div class="input-prepend" style="padding:3px;"><span class="add-on"><i class="icon-search"></i></span><input class="multiselect-search" type="text" placeholder="' + this.options.filterPlaceholder + '"></div>');
$('.multiselect-search', this.$container).val(this.query).on('click', function (event) {
......@@ -90,12 +90,18 @@
if (value && text && value != this.options.selectAllValue ) {
// by default lets assume that element is not interesting for this search
var showElement = false;
if ( (this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both') && text.indexOf(this.query) > -1) {
showElement = true;
}
if ( (this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both') && value.indexOf(this.query) > -1) {
showElement = true;
}
var filterCandidate = '';
if ( (this.options.filterBehavior == 'text' || this.options.filterBehavior == 'both')) {
filterCandidate = text;
}
if ( (this.options.filterBehavior == 'value' || this.options.filterBehavior == 'both')) {
filterCandidate = value;
}
if(this.options.enableCaseInsensitiveFiltering && filterCandidate.toLowerCase().indexOf(this.query.toLowerCase()) > -1) {
showElement = true;
} else if(filterCandidate.indexOf(this.query) > -1) {
showElement = true;
}
if (showElement) {
$(element).show();
} else {
......@@ -157,7 +163,8 @@
selectAllText: ' Select all',
selectAllValue: 'multiselect-all',
enableFiltering: false,
filterPlaceholder: 'Search',
enableCaseInsensitiveFiltering: false,
filterPlaceholder: 'Search',
filterBehavior: 'text', // possible options: 'text', 'value', 'both'
},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment