Skip to content

Commit

Permalink
0.8.3.beta.7 - Escape special chars in multi select
Browse files Browse the repository at this point in the history
  • Loading branch information
vedmack committed Aug 25, 2014
1 parent 9e1e068 commit cb785a2
Show file tree
Hide file tree
Showing 3 changed files with 2,233 additions and 6 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,4 @@

* Added enable_auto_complete option
* Several code enhancements (added ids to filters etc...)

15 changes: 10 additions & 5 deletions lab/jquery.dataTables.yadcf.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Yet Another DataTables Column Filter - (yadcf)
*
* File: jquery.dataTables.yadcf.js
* Version: 0.8.3.beta.6
* Version: 0.8.3.beta.7
*
* Author: Daniel Reznick
* Info: https://github.com/vedmack/yadcf
Expand Down Expand Up @@ -368,7 +368,8 @@ var yadcf = (function ($) {
var oTable = oTables[table_selector_jq_friendly],
aEscapedTerms = [],
selected_values = $(arg).val(),
i;
i,
stringForSearch;

$(document).data("#yadcf-filter-" + table_selector_jq_friendly + "-" + column_number + "_val", selected_values);

Expand All @@ -380,12 +381,14 @@ var yadcf = (function ($) {
}
}
if (selected_values.length !== 0) {
stringForSearch = selected_values.join("|");
stringForSearch = stringForSearch.replace(/([.*+?^=!:${}()\[\]\/\\])/g, "\\$1");
if (filter_match_mode === "contains") {
oTable.fnFilter(selected_values.join("|"), column_number, true, false, true);
oTable.fnFilter(stringForSearch, column_number, true, false, true);
} else if (filter_match_mode === "exact") {
oTable.fnFilter("^(" + selected_values.join("|") + ")$", column_number, true, false, true);
oTable.fnFilter("^(" + stringForSearch + ")$", column_number, true, false, true);
} else if (filter_match_mode === "startsWith") {
oTable.fnFilter("^(" + selected_values.join("|") + ")", column_number, true, false, true);
oTable.fnFilter("^(" + stringForSearch + ")", column_number, true, false, true);
}
} else {
oTable.fnFilter("", column_number);
Expand Down Expand Up @@ -1380,6 +1383,7 @@ var yadcf = (function ($) {
$('#yadcf-filter-' + table_selector_jq_friendly + '-' + column_number).val(tmpStr).addClass("inuse");
} else if (columnObj.filter_type === "multi_select") {
tmpStr = yadcfParseMatchFilterMultiSelect(tmpStr, getOptions(oTable.selector)[column_number].filter_match_mode);
tmpStr = tmpStr.replace(/\\/g, "");
tmpStr = tmpStr.split("|");
$('#yadcf-filter-' + table_selector_jq_friendly + '-' + column_number).val(tmpStr);
}
Expand Down Expand Up @@ -1459,6 +1463,7 @@ var yadcf = (function ($) {
if (oTable.fnSettings().aoPreSearchCols[column_number].sSearch !== '') {
tmpStr = oTable.fnSettings().aoPreSearchCols[column_number].sSearch;
tmpStr = yadcfParseMatchFilterMultiSelect(tmpStr, getOptions(oTable.selector)[column_number].filter_match_mode);
tmpStr = tmpStr.replace(/\\/g, "");
tmpStr = tmpStr.split("|");
$('#yadcf-filter-' + table_selector_jq_friendly + '-' + column_number).val(tmpStr);
}
Expand Down
Loading

0 comments on commit cb785a2

Please sign in to comment.