diff --git a/dist/js/widgets/widget-filter.min.js b/dist/js/widgets/widget-filter.min.js index 5783836c..ff41477d 100644 --- a/dist/js/widgets/widget-filter.min.js +++ b/dist/js/widgets/widget-filter.min.js @@ -1,2 +1,2 @@ /*! Widget: filter - updated 12/13/2017 (v2.29.1) */ -!function(e){"use strict";var t,r,i=e.tablesorter||{},l=i.css,a=i.keyCodes;e.extend(l,{filterRow:"tablesorter-filter-row",filter:"tablesorter-filter",filterDisabled:"disabled",filterRowHide:"hideme"}),e.extend(a,{backSpace:8,escape:27,space:32,left:37,down:40}),i.addWidget({id:"filter",priority:50,options:{filter_cellFilter:"",filter_childRows:!1,filter_childByColumn:!1,filter_childWithSibs:!0,filter_columnAnyMatch:!0,filter_columnFilters:!0,filter_cssFilter:"",filter_defaultAttrib:"data-value",filter_defaultFilter:{},filter_excludeFilter:{},filter_external:"",filter_filteredRow:"filtered",filter_formatter:null,filter_functions:null,filter_hideEmpty:!0,filter_hideFilters:!1,filter_ignoreCase:!0,filter_liveSearch:!0,filter_matchType:{input:"exact",select:"exact"},filter_onlyAvail:"filter-onlyAvail",filter_placeholder:{search:"",select:""},filter_reset:null,filter_resetOnEsc:!0,filter_saveFilters:!1,filter_searchDelay:300,filter_searchFiltered:!0,filter_selectSource:null,filter_selectSourceSeparator:"|",filter_serversideFiltering:!1,filter_startsWith:!1,filter_useParsedData:!1},format:function(e,r,i){r.$table.hasClass("hasFilters")||t.init(e,r,i)},remove:function(t,r,a,n){var s,o,c=r.$table,f=r.$tbodies,d="addRows updateCell update updateRows updateComplete appendCache filterReset filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit ".split(" ").join(r.namespace+"filter ");if(c.removeClass("hasFilters").unbind(d.replace(i.regex.spaces," ")).find("."+l.filterRow).remove(),a.filter_initialized=!1,!n){for(s=0;s=]/g,query:"(q|query)",wild01:/\?/g,wild0More:/\*/g,quote:/\"/g,isNeg1:/(>=?\s*-\d)/,isNeg2:/(<=?\s*\d)/},types:{or:function(i,l,a){if((r.orTest.test(l.iFilter)||r.orSplit.test(l.filter))&&!r.regex.test(l.filter)){var n,s,o,c,f=e.extend({},l),d=l.filter.split(r.orSplit),u=l.iFilter.split(r.orSplit),h=d.length;for(n=0;n=d:n>d:r.ltTest.test(a.iFilter)&&(s=r.lteTest.test(a.iFilter)?n<=d:n=0)))}return null},exact:function(i,l){if(r.exact.test(l.iFilter)){var a=l.iFilter.replace(r.exact,""),n=t.parseFilter(i,a,l)||"";return l.anyMatch?e.inArray(n,l.rowArray)>=0:n==l.iExact}return null},range:function(e,l){if(r.toTest.test(l.iFilter)){var a,n,s,o,c=e.table,f=l.index,d=l.parsed[f],u=l.iFilter.split(r.toSplit);return n=u[0].replace(i.regex.nondigit,"")||"",s=i.formatFloat(t.parseFilter(e,n,l),c),n=u[1].replace(i.regex.nondigit,"")||"",o=i.formatFloat(t.parseFilter(e,n,l),c),(d||"numeric"===e.parsers[f].type)&&(s=""===(a=e.parsers[f].format(""+u[0],c,e.$headers.eq(f),f))||isNaN(a)?s:a,o=""===(a=e.parsers[f].format(""+u[1],c,e.$headers.eq(f),f))||isNaN(a)?o:a),!d&&"numeric"!==e.parsers[f].type||isNaN(s)||isNaN(o)?(n=isNaN(l.iExact)?l.iExact.replace(i.regex.nondigit,""):l.iExact,a=i.formatFloat(n,c)):a=l.cache,s>o&&(n=s,s=o,o=n),a>=s&&a<=o||""===s||""===o}return null},wild:function(e,i){if(r.wildOrTest.test(i.iFilter)){var l=""+(t.parseFilter(e,i.iFilter,i)||"");!r.wildTest.test(l)&&i.nestedFilters&&(l=i.isMatch?l:"^("+l+")$");try{return new RegExp(l.replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*"),e.widgetOptions.filter_ignoreCase?"i":"").test(i.exact)}catch(e){return null}}return null},fuzzy:function(e,i){if(r.fuzzyTest.test(i.iFilter)){var l,a=0,n=i.iExact.length,s=i.iFilter.slice(1),o=t.parseFilter(e,s,i)||"";for(l=0;l]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(c.data("placeholder")||c.attr("data-placeholder")||g.filter_placeholder.select||"")+"":"",d=s,o=s,s.indexOf(g.filter_selectSourceSeparator)>=0&&(o=(d=s.split(g.filter_selectSourceSeparator))[1],d=d[0]),n+="");p.$table.find("thead").find("select."+l.filter+'[data-column="'+f+'"]').append(n),(u="function"==typeof(o=g.filter_selectSource)||i.getColumnData(a,o,f))&&t.buildSelect(p.table,f,"",!0,c.hasClass(g.filter_onlyAvail))}t.buildDefault(a,!0),t.bindSearch(a,p.$table.find("."+l.filter),!0),g.filter_external&&t.bindSearch(a,g.filter_external),g.filter_hideFilters&&t.hideFilters(p),p.showProcessing&&(o="filterStart filterEnd ".split(" ").join(p.namespace+"filter "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(t,r){c=r?p.$table.find("."+l.header).filter("[data-column]").filter(function(){return""!==r[e(this).data("column")]}):"",i.isProcessing(a,"filterStart"===t.type,r?c:"")})),p.filteredRows=p.totalRows,o="tablesorter-initialized pagerBeforeInitialized ".split(" ").join(p.namespace+"filter "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(){t.completeInit(this)}),p.pager&&p.pager.initialized&&!g.filter_initialized?(p.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){t.filterInitComplete(p)},100)):g.filter_initialized||t.completeInit(a)},completeInit:function(e){var r=e.config,l=r.widgetOptions,a=t.setDefaults(e,r,l)||[];a.length&&(r.delayInit&&""===a.join("")||i.setFilters(e,a,!0)),r.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){l.filter_initialized||t.filterInitComplete(r)},100)},formatterUpdated:function(e,t){var r=e&&e.closest("table"),i=r.length&&r[0].config,l=i&&i.widgetOptions;l&&!l.filter_initialized&&(l.filter_formatterInit[t]=1)},filterInitComplete:function(r){var i,l,a=r.widgetOptions,n=0,s=function(){a.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(a.filter_formatter))s();else{for(l=a.filter_formatterInit.length,i=0;i';for(c=0;c<_;c++)a.$headerIndexed[c].length&&(w+=(g=a.$headerIndexed[c]&&a.$headerIndexed[c][0].colSpan||0)>1?'").appendTo(a.$table.children("thead").eq(0)).children("td"),c=0;c<_;c++)u=!1,(f=a.$headerIndexed[c])&&f.length&&(s=t.getColumnElm(a,a.$filters,c),p=i.getColumnData(r,n.filter_functions,c),d=n.filter_functions&&p&&"function"!=typeof p||f.hasClass("filter-select"),o=i.getColumnData(r,a.headers,c),u="false"===i.getData(f[0],o,"filter")||"false"===i.getData(f[0],o,"parser"),d?w=e("').appendTo(s),w&&(g=f.data("placeholder")||f.attr("data-placeholder")||n.filter_placeholder.search||"",w.attr("placeholder",g))),w&&(h=(e.isArray(n.filter_cssFilter)?void 0!==n.filter_cssFilter[c]?n.filter_cssFilter[c]||"":"":n.filter_cssFilter)||"",w.addClass(l.filter+" "+h).attr("data-column",s.attr("data-column")),u&&(w.attr("placeholder","").addClass(l.filterDisabled)[0].disabled=!0)))},bindSearch:function(r,l,n){if(r=e(r)[0],(l=e(l)).length){var s,o=r.config,c=o.widgetOptions,f=o.namespace+"filter",d=c.filter_$externalFilters;!0!==n&&(s=c.filter_anyColumnSelector+","+c.filter_multipleColumnSelector,c.filter_$anyMatch=l.filter(s),d&&d.length?c.filter_$externalFilters=c.filter_$externalFilters.add(l):c.filter_$externalFilters=l,i.setFilters(r,o.$table.data("lastSearch")||[],!1===n)),s="keypress keyup keydown search change input ".split(" ").join(f+" "),l.attr("data-lastSearchTime",(new Date).getTime()).unbind(s.replace(i.regex.spaces," ")).bind("keydown"+f,function(e){if(e.which===a.escape&&!r.config.widgetOptions.filter_resetOnEsc)return!1}).bind("keyup"+f,function(l){c=r.config.widgetOptions;var n=parseInt(e(this).attr("data-column"),10),s="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,n);if(void 0===s&&(s=c.filter_liveSearch.fallback||!1),e(this).attr("data-lastSearchTime",(new Date).getTime()),l.which===a.escape)this.value=c.filter_resetOnEsc?"":o.lastSearch[n];else{if(""!==this.value&&("number"==typeof s&&this.value.length=a.left&&l.which<=a.down)))return;if(!1===s&&""!==this.value&&l.which!==a.enter)return}t.searching(r,!0,!0,n)}).bind("search change keypress input blur ".split(" ").join(f+" "),function(l){var n=parseInt(e(this).attr("data-column"),10),s=l.type,f="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,n);!r.config.widgetOptions.filter_initialized||l.which!==a.enter&&"search"!==s&&"blur"!==s&&("change"!==s&&"input"!==s||!0!==f&&(!0===f||"INPUT"===l.target.nodeName)||this.value===o.lastSearch[n])||(l.preventDefault(),e(this).attr("data-lastSearchTime",(new Date).getTime()),t.searching(r,"keypress"!==s,!0,n))})}},searching:function(e,r,l,a){var n,s=e.config.widgetOptions;void 0===a?n=!1:void 0===(n="boolean"==typeof s.filter_liveSearch?s.filter_liveSearch:i.getColumnData(e,s.filter_liveSearch,a))&&(n=s.filter_liveSearch.fallback||!1),clearTimeout(s.filter_searchTimer),void 0===r||!0===r?s.filter_searchTimer=setTimeout(function(){t.checkFilters(e,r,l)},n?s.filter_searchDelay:10):t.checkFilters(e,r,l)},equalFilters:function(t,r,i){var l,a=[],n=[],s=t.columns+1;for(r=e.isArray(r)?r:[],i=e.isArray(i)?i:[],l=0;l1?e.trim(t).split(/\s/):[e.trim(t)],s=n.length-1,o=0,c=i;for(s<1&&a>1&&(n[1]=n[0]);l.test(c);)c=c.replace(l,n[o++]||""),l.test(c)&&o(s=parseInt(a[1],10)||e.columns-1)&&(i=n,n=s,s=i),s>=e.columns&&(s=e.columns-1);n<=s;n++)u[u.length]=n;t=t.replace(l[f],"")}if(!r&&/,/.test(t))for(d=(o=t.split(/\s*,\s*/)).length,c=0;c-1})},multipleColumns:function(r,i){var l=r.widgetOptions,a=l.filter_initialized||!i.filter(l.filter_anyColumnSelector).length,n=e.trim(t.getLatestSearch(i).attr("data-column")||"");return t.findRange(r,n,!a)},processTypes:function(r,i,l){var a,n=null,s=null;for(a in t.types)e.inArray(a,l.excludeMatch)<0&&null===s&&null!==(s=t.types[a](r,i,l))&&(i.matchedOn=a,n=s);return n},matchType:function(e,t){var r,i=e.widgetOptions,a=e.$headerIndexed[t];return a.hasClass("filter-exact")?r=!1:a.hasClass("filter-match")?r=!0:(i.filter_columnFilters?a=e.$filters.find("."+l.filter).add(i.filter_$externalFilters).filter('[data-column="'+t+'"]'):i.filter_$externalFilters&&(a=i.filter_$externalFilters.filter('[data-column="'+t+'"]')),r=!!a.length&&"match"===e.widgetOptions.filter_matchType[(a[0].nodeName||"").toLowerCase()]),r},processRow:function(l,a,n){var s,o,c,f,d,u=l.widgetOptions,h=!0,p=u.filter_$anyMatch&&u.filter_$anyMatch.length,g=u.filter_$anyMatch&&u.filter_$anyMatch.length?t.multipleColumns(l,u.filter_$anyMatch):[];if(a.$cells=a.$row.children(),a.matchedOn=null,a.anyMatchFlag&&g.length>1||a.anyMatchFilter&&!p){if(a.anyMatch=!0,a.isMatch=!0,a.rowArray=a.$cells.map(function(t){if(e.inArray(t,g)>-1||a.anyMatchFilter&&!p)return a.parsed[t]?d=a.cacheArray[t]:(d=a.rawArray[t],d=e.trim(u.filter_ignoreCase?d.toLowerCase():d),l.sortLocaleCompare&&(d=i.replaceAccents(d))),d}).get(),a.filter=a.anyMatchFilter,a.iFilter=a.iAnyMatchFilter,a.exact=a.rowArray.join(" "),a.iExact=u.filter_ignoreCase?a.exact.toLowerCase():a.exact,a.cache=a.cacheArray.slice(0,-1).join(" "),n.excludeMatch=n.noAnyMatch,null!==(o=t.processTypes(l,a,n)))h=o;else if(u.filter_startsWith)for(h=!1,g=Math.min(l.columns,a.rowArray.length);!h&&g>0;)g--,h=h||0===a.rowArray[g].indexOf(a.iFilter);else h=(a.iExact+a.childRowText).indexOf(a.iFilter)>=0;if(a.anyMatch=!1,a.filters.join("")===a.filter)return h}for(g=0;g=0:a.filter===a.exact:(d=(a.iExact+a.childRowText).indexOf(t.parseFilter(l,a.iFilter,a)),s=!u.filter_startsWith&&d>=0||u.filter_startsWith&&0===d):s=o):s=o,h=!!s&&h);return h},findRows:function(l,a,n){if(!t.equalFilters(l.config,l.config.lastSearch,n)&&l.config.widgetOptions.filter_initialized){var s,o,c,f,d,u,h,p,g,m,_,y,w,F,x,C,b,v,$,S,R,T,A,O=e.extend([],a),E=l.config,M=E.widgetOptions,I={anyMatch:!1,filters:a,filter_regexCache:[]},D={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:i.getColumnData(l,M.filter_defaultFilter,E.columns,!0)||""};for(I.parsed=[],g=0;g1&&(isNaN(R[0])?e.each(E.headerContent,function(e,t){t.toLowerCase().indexOf(R[0])>-1&&(a[T=e]=R[1])}):T=parseInt(R[0],10)-1,T>=0&&T")>=0)return f;if(e.isArray(f))s=f;else if("object"===e.type(o)&&f&&null===(s=f(r,l,a)))return null}return!1===s&&(s=t.getOptions(r,l,a)),t.processOptions(r,l,s)},processOptions:function(t,r,l){if(!e.isArray(l))return!1;var a,n,s,o,c,f,d=(t=e(t)[0]).config,u=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||_.filter_placeholder.select||"")+"",F=m.$table.find("thead").find("select."+l.filter+'[data-column="'+a+'"]').val();if(void 0!==n&&""!==n||null!==(n=t.getOptionSource(i,a,o))){if(e.isArray(n)){for(c=0;c"}else""+g!="[object Object]"&&(f=d=g=(""+g).replace(r.quote,"""),d.indexOf(_.filter_selectSourceSeparator)>=0&&(f=(u=d.split(_.filter_selectSourceSeparator))[0],d=u[1]),w+=""!==g?"":"");n=[]}h=(m.$filters?m.$filters:m.$table.children("thead")).find("."+l.filter),_.filter_$externalFilters&&(h=h&&h.length?h.add(_.filter_$externalFilters):_.filter_$externalFilters),(p=h.filter('select[data-column="'+a+'"]')).length&&(p[s?"html":"append"](w),e.isArray(n)||p.append(n).val(F),p.val(F))}}},buildDefault:function(e,r){var l,a,n,s=e.config,o=s.widgetOptions,c=s.columns;for(l=0;l1&&(c=c.slice(1)),s===u.columns&&(c=(f=c.filter(h.filter_anyColumnSelector)).length?f:c),c.val(a[s]).trigger("change"+u.namespace)):(d[s]=c.val()||"",s===u.columns?c.slice(1).filter('[data-column*="'+c.attr("data-column")+'"]').val(d[s]):c.slice(1).val(d[s])),s===u.columns&&c.length&&(h.filter_$anyMatch=c));return d},i.setFilters=function(r,l,a,n){var s=r?e(r)[0].config:"",o=i.getFilters(r,!0,l,n);return void 0===a&&(a=!0),s&&a&&(s.lastCombinedFilter=null,s.lastSearch=[],t.searching(s.table,l,n),s.$table.triggerHandler("filterFomatterUpdate")),0!==o.length}}(jQuery); \ No newline at end of file +!function(e){"use strict";var t,r,i=e.tablesorter||{},l=i.css,a=i.keyCodes;e.extend(l,{filterRow:"tablesorter-filter-row",filter:"tablesorter-filter",filterDisabled:"disabled",filterRowHide:"hideme"}),e.extend(a,{backSpace:8,escape:27,space:32,left:37,down:40}),i.addWidget({id:"filter",priority:50,options:{filter_cellFilter:"",filter_childRows:!1,filter_childByColumn:!1,filter_childWithSibs:!0,filter_columnAnyMatch:!0,filter_columnFilters:!0,filter_cssFilter:"",filter_defaultAttrib:"data-value",filter_defaultFilter:{},filter_excludeFilter:{},filter_external:"",filter_filteredRow:"filtered",filter_filterLabel:'Filter "{{label}}" column by...',filter_formatter:null,filter_functions:null,filter_hideEmpty:!0,filter_hideFilters:!1,filter_ignoreCase:!0,filter_liveSearch:!0,filter_matchType:{input:"exact",select:"exact"},filter_onlyAvail:"filter-onlyAvail",filter_placeholder:{search:"",select:""},filter_reset:null,filter_resetOnEsc:!0,filter_saveFilters:!1,filter_searchDelay:300,filter_searchFiltered:!0,filter_selectSource:null,filter_selectSourceSeparator:"|",filter_serversideFiltering:!1,filter_startsWith:!1,filter_useParsedData:!1},format:function(e,r,i){r.$table.hasClass("hasFilters")||t.init(e,r,i)},remove:function(t,r,a,n){var s,o,c=r.$table,f=r.$tbodies,d="addRows updateCell update updateRows updateComplete appendCache filterReset filterAndSortReset filterFomatterUpdate filterEnd search stickyHeadersInit ".split(" ").join(r.namespace+"filter ");if(c.removeClass("hasFilters").unbind(d.replace(i.regex.spaces," ")).find("."+l.filterRow).remove(),a.filter_initialized=!1,!n){for(s=0;s=]/g,query:"(q|query)",wild01:/\?/g,wild0More:/\*/g,quote:/\"/g,isNeg1:/(>=?\s*-\d)/,isNeg2:/(<=?\s*\d)/},types:{or:function(i,l,a){if((r.orTest.test(l.iFilter)||r.orSplit.test(l.filter))&&!r.regex.test(l.filter)){var n,s,o,c,f=e.extend({},l),d=l.filter.split(r.orSplit),u=l.iFilter.split(r.orSplit),h=d.length;for(n=0;n=d:n>d:r.ltTest.test(a.iFilter)&&(s=r.lteTest.test(a.iFilter)?n<=d:n=0)))}return null},exact:function(i,l){if(r.exact.test(l.iFilter)){var a=l.iFilter.replace(r.exact,""),n=t.parseFilter(i,a,l)||"";return l.anyMatch?e.inArray(n,l.rowArray)>=0:n==l.iExact}return null},range:function(e,l){if(r.toTest.test(l.iFilter)){var a,n,s,o,c=e.table,f=l.index,d=l.parsed[f],u=l.iFilter.split(r.toSplit);return n=u[0].replace(i.regex.nondigit,"")||"",s=i.formatFloat(t.parseFilter(e,n,l),c),n=u[1].replace(i.regex.nondigit,"")||"",o=i.formatFloat(t.parseFilter(e,n,l),c),(d||"numeric"===e.parsers[f].type)&&(s=""===(a=e.parsers[f].format(""+u[0],c,e.$headers.eq(f),f))||isNaN(a)?s:a,o=""===(a=e.parsers[f].format(""+u[1],c,e.$headers.eq(f),f))||isNaN(a)?o:a),!d&&"numeric"!==e.parsers[f].type||isNaN(s)||isNaN(o)?(n=isNaN(l.iExact)?l.iExact.replace(i.regex.nondigit,""):l.iExact,a=i.formatFloat(n,c)):a=l.cache,s>o&&(n=s,s=o,o=n),a>=s&&a<=o||""===s||""===o}return null},wild:function(e,i){if(r.wildOrTest.test(i.iFilter)){var l=""+(t.parseFilter(e,i.iFilter,i)||"");!r.wildTest.test(l)&&i.nestedFilters&&(l=i.isMatch?l:"^("+l+")$");try{return new RegExp(l.replace(r.wild01,"\\S{1}").replace(r.wild0More,"\\S*"),e.widgetOptions.filter_ignoreCase?"i":"").test(i.exact)}catch(e){return null}}return null},fuzzy:function(e,i){if(r.fuzzyTest.test(i.iFilter)){var l,a=0,n=i.iExact.length,s=i.iFilter.slice(1),o=t.parseFilter(e,s,i)||"";for(l=0;l]=?/,gtTest:/>/,gteTest:/>=/,ltTest:/'+(c.data("placeholder")||c.attr("data-placeholder")||g.filter_placeholder.select||"")+"":"",d=s,o=s,s.indexOf(g.filter_selectSourceSeparator)>=0&&(o=(d=s.split(g.filter_selectSourceSeparator))[1],d=d[0]),n+="");p.$table.find("thead").find("select."+l.filter+'[data-column="'+f+'"]').append(n),(u="function"==typeof(o=g.filter_selectSource)||i.getColumnData(a,o,f))&&t.buildSelect(p.table,f,"",!0,c.hasClass(g.filter_onlyAvail))}t.buildDefault(a,!0),t.bindSearch(a,p.$table.find("."+l.filter),!0),g.filter_external&&t.bindSearch(a,g.filter_external),g.filter_hideFilters&&t.hideFilters(p),p.showProcessing&&(o="filterStart filterEnd ".split(" ").join(p.namespace+"filter "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(t,r){c=r?p.$table.find("."+l.header).filter("[data-column]").filter(function(){return""!==r[e(this).data("column")]}):"",i.isProcessing(a,"filterStart"===t.type,r?c:"")})),p.filteredRows=p.totalRows,o="tablesorter-initialized pagerBeforeInitialized ".split(" ").join(p.namespace+"filter "),p.$table.unbind(o.replace(i.regex.spaces," ")).bind(o,function(){t.completeInit(this)}),p.pager&&p.pager.initialized&&!g.filter_initialized?(p.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){t.filterInitComplete(p)},100)):g.filter_initialized||t.completeInit(a)},completeInit:function(e){var r=e.config,l=r.widgetOptions,a=t.setDefaults(e,r,l)||[];a.length&&(r.delayInit&&""===a.join("")||i.setFilters(e,a,!0)),r.$table.triggerHandler("filterFomatterUpdate"),setTimeout(function(){l.filter_initialized||t.filterInitComplete(r)},100)},formatterUpdated:function(e,t){var r=e&&e.closest("table"),i=r.length&&r[0].config,l=i&&i.widgetOptions;l&&!l.filter_initialized&&(l.filter_formatterInit[t]=1)},filterInitComplete:function(r){var i,l,a=r.widgetOptions,n=0,s=function(){a.filter_initialized=!0,r.lastSearch=r.$table.data("lastSearch"),r.$table.triggerHandler("filterInit",r),t.findRows(r.table,r.lastSearch||[])};if(e.isEmptyObject(a.filter_formatter))s();else{for(l=a.filter_formatterInit.length,i=0;i';for(c=0;c<_;c++)a.$headerIndexed[c].length&&(F+=(g=a.$headerIndexed[c]&&a.$headerIndexed[c][0].colSpan||0)>1?'").appendTo(a.$table.children("thead").eq(0)).children("td"),c=0;c<_;c++)u=!1,(f=a.$headerIndexed[c])&&f.length&&(s=t.getColumnElm(a,a.$filters,c),p=i.getColumnData(r,n.filter_functions,c),d=n.filter_functions&&p&&"function"!=typeof p||f.hasClass("filter-select"),o=i.getColumnData(r,a.headers,c),u="false"===i.getData(f[0],o,"filter")||"false"===i.getData(f[0],o,"parser"),d?F=e("').appendTo(s),F&&(g=f.data("placeholder")||f.attr("data-placeholder")||n.filter_placeholder.search||"",F.attr("placeholder",g))),F&&(h=(e.isArray(n.filter_cssFilter)?void 0!==n.filter_cssFilter[c]?n.filter_cssFilter[c]||"":"":n.filter_cssFilter)||"",F.addClass(l.filter+" "+h),(g=(h=n.filter_filterLabel).match(/{{([^}]+?)}}/g))||(g=["{{label}}"]),e.each(g,function(t,r){var i=new RegExp(r,"g"),l=f.attr("data-"+r.replace(/{{|}}/g,"")),a=void 0===l?f.text():l;h=h.replace(i,e.trim(a))}),F.attr({"data-column":s.attr("data-column"),"aria-label":h}),u&&(F.attr("placeholder","").addClass(l.filterDisabled)[0].disabled=!0)))},bindSearch:function(r,l,n){if(r=e(r)[0],(l=e(l)).length){var s,o=r.config,c=o.widgetOptions,f=o.namespace+"filter",d=c.filter_$externalFilters;!0!==n&&(s=c.filter_anyColumnSelector+","+c.filter_multipleColumnSelector,c.filter_$anyMatch=l.filter(s),d&&d.length?c.filter_$externalFilters=c.filter_$externalFilters.add(l):c.filter_$externalFilters=l,i.setFilters(r,o.$table.data("lastSearch")||[],!1===n)),s="keypress keyup keydown search change input ".split(" ").join(f+" "),l.attr("data-lastSearchTime",(new Date).getTime()).unbind(s.replace(i.regex.spaces," ")).bind("keydown"+f,function(e){if(e.which===a.escape&&!r.config.widgetOptions.filter_resetOnEsc)return!1}).bind("keyup"+f,function(l){c=r.config.widgetOptions;var n=parseInt(e(this).attr("data-column"),10),s="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,n);if(void 0===s&&(s=c.filter_liveSearch.fallback||!1),e(this).attr("data-lastSearchTime",(new Date).getTime()),l.which===a.escape)this.value=c.filter_resetOnEsc?"":o.lastSearch[n];else{if(""!==this.value&&("number"==typeof s&&this.value.length=a.left&&l.which<=a.down)))return;if(!1===s&&""!==this.value&&l.which!==a.enter)return}t.searching(r,!0,!0,n)}).bind("search change keypress input blur ".split(" ").join(f+" "),function(l){var n=parseInt(e(this).attr("data-column"),10),s=l.type,f="boolean"==typeof c.filter_liveSearch?c.filter_liveSearch:i.getColumnData(r,c.filter_liveSearch,n);!r.config.widgetOptions.filter_initialized||l.which!==a.enter&&"search"!==s&&"blur"!==s&&("change"!==s&&"input"!==s||!0!==f&&(!0===f||"INPUT"===l.target.nodeName)||this.value===o.lastSearch[n])||(l.preventDefault(),e(this).attr("data-lastSearchTime",(new Date).getTime()),t.searching(r,"keypress"!==s,!0,n))})}},searching:function(e,r,l,a){var n,s=e.config.widgetOptions;void 0===a?n=!1:void 0===(n="boolean"==typeof s.filter_liveSearch?s.filter_liveSearch:i.getColumnData(e,s.filter_liveSearch,a))&&(n=s.filter_liveSearch.fallback||!1),clearTimeout(s.filter_searchTimer),void 0===r||!0===r?s.filter_searchTimer=setTimeout(function(){t.checkFilters(e,r,l)},n?s.filter_searchDelay:10):t.checkFilters(e,r,l)},equalFilters:function(t,r,i){var l,a=[],n=[],s=t.columns+1;for(r=e.isArray(r)?r:[],i=e.isArray(i)?i:[],l=0;l1?e.trim(t).split(/\s/):[e.trim(t)],s=n.length-1,o=0,c=i;for(s<1&&a>1&&(n[1]=n[0]);l.test(c);)c=c.replace(l,n[o++]||""),l.test(c)&&o(s=parseInt(a[1],10)||e.columns-1)&&(i=n,n=s,s=i),s>=e.columns&&(s=e.columns-1);n<=s;n++)u[u.length]=n;t=t.replace(l[f],"")}if(!r&&/,/.test(t))for(d=(o=t.split(/\s*,\s*/)).length,c=0;c-1})},multipleColumns:function(r,i){var l=r.widgetOptions,a=l.filter_initialized||!i.filter(l.filter_anyColumnSelector).length,n=e.trim(t.getLatestSearch(i).attr("data-column")||"");return t.findRange(r,n,!a)},processTypes:function(r,i,l){var a,n=null,s=null;for(a in t.types)e.inArray(a,l.excludeMatch)<0&&null===s&&null!==(s=t.types[a](r,i,l))&&(i.matchedOn=a,n=s);return n},matchType:function(e,t){var r,i=e.widgetOptions,a=e.$headerIndexed[t];return a.hasClass("filter-exact")?r=!1:a.hasClass("filter-match")?r=!0:(i.filter_columnFilters?a=e.$filters.find("."+l.filter).add(i.filter_$externalFilters).filter('[data-column="'+t+'"]'):i.filter_$externalFilters&&(a=i.filter_$externalFilters.filter('[data-column="'+t+'"]')),r=!!a.length&&"match"===e.widgetOptions.filter_matchType[(a[0].nodeName||"").toLowerCase()]),r},processRow:function(l,a,n){var s,o,c,f,d,u=l.widgetOptions,h=!0,p=u.filter_$anyMatch&&u.filter_$anyMatch.length,g=u.filter_$anyMatch&&u.filter_$anyMatch.length?t.multipleColumns(l,u.filter_$anyMatch):[];if(a.$cells=a.$row.children(),a.matchedOn=null,a.anyMatchFlag&&g.length>1||a.anyMatchFilter&&!p){if(a.anyMatch=!0,a.isMatch=!0,a.rowArray=a.$cells.map(function(t){if(e.inArray(t,g)>-1||a.anyMatchFilter&&!p)return a.parsed[t]?d=a.cacheArray[t]:(d=a.rawArray[t],d=e.trim(u.filter_ignoreCase?d.toLowerCase():d),l.sortLocaleCompare&&(d=i.replaceAccents(d))),d}).get(),a.filter=a.anyMatchFilter,a.iFilter=a.iAnyMatchFilter,a.exact=a.rowArray.join(" "),a.iExact=u.filter_ignoreCase?a.exact.toLowerCase():a.exact,a.cache=a.cacheArray.slice(0,-1).join(" "),n.excludeMatch=n.noAnyMatch,null!==(o=t.processTypes(l,a,n)))h=o;else if(u.filter_startsWith)for(h=!1,g=Math.min(l.columns,a.rowArray.length);!h&&g>0;)g--,h=h||0===a.rowArray[g].indexOf(a.iFilter);else h=(a.iExact+a.childRowText).indexOf(a.iFilter)>=0;if(a.anyMatch=!1,a.filters.join("")===a.filter)return h}for(g=0;g=0:a.filter===a.exact:(d=(a.iExact+a.childRowText).indexOf(t.parseFilter(l,a.iFilter,a)),s=!u.filter_startsWith&&d>=0||u.filter_startsWith&&0===d):s=o):s=o,h=!!s&&h);return h},findRows:function(l,a,n){if(!t.equalFilters(l.config,l.config.lastSearch,n)&&l.config.widgetOptions.filter_initialized){var s,o,c,f,d,u,h,p,g,m,_,y,F,w,x,b,C,v,$,S,R,T,A,O=e.extend([],a),E=l.config,M=E.widgetOptions,I={anyMatch:!1,filters:a,filter_regexCache:[]},D={noAnyMatch:["range","operators"],functions:[],excludeFilter:[],defaultColFilter:[],defaultAnyFilter:i.getColumnData(l,M.filter_defaultFilter,E.columns,!0)||""};for(I.parsed=[],g=0;g1&&(isNaN(R[0])?e.each(E.headerContent,function(e,t){t.toLowerCase().indexOf(R[0])>-1&&(a[T=e]=R[1])}):T=parseInt(R[0],10)-1,T>=0&&T")>=0)return f;if(e.isArray(f))s=f;else if("object"===e.type(o)&&f&&null===(s=f(r,l,a)))return null}return!1===s&&(s=t.getOptions(r,l,a)),t.processOptions(r,l,s)},processOptions:function(t,r,l){if(!e.isArray(l))return!1;var a,n,s,o,c,f,d=(t=e(t)[0]).config,u=void 0!==r&&null!==r&&r>=0&&r'+(y.data("placeholder")||y.attr("data-placeholder")||_.filter_placeholder.select||"")+"",w=m.$table.find("thead").find("select."+l.filter+'[data-column="'+a+'"]').val();if(void 0!==n&&""!==n||null!==(n=t.getOptionSource(i,a,o))){if(e.isArray(n)){for(c=0;c"}else""+g!="[object Object]"&&(f=d=g=(""+g).replace(r.quote,"""),d.indexOf(_.filter_selectSourceSeparator)>=0&&(f=(u=d.split(_.filter_selectSourceSeparator))[0],d=u[1]),F+=""!==g?"":"");n=[]}h=(m.$filters?m.$filters:m.$table.children("thead")).find("."+l.filter),_.filter_$externalFilters&&(h=h&&h.length?h.add(_.filter_$externalFilters):_.filter_$externalFilters),(p=h.filter('select[data-column="'+a+'"]')).length&&(p[s?"html":"append"](F),e.isArray(n)||p.append(n).val(w),p.val(w))}}},buildDefault:function(e,r){var l,a,n,s=e.config,o=s.widgetOptions,c=s.columns;for(l=0;l1&&(c=c.slice(1)),s===u.columns&&(c=(f=c.filter(h.filter_anyColumnSelector)).length?f:c),c.val(a[s]).trigger("change"+u.namespace)):(d[s]=c.val()||"",s===u.columns?c.slice(1).filter('[data-column*="'+c.attr("data-column")+'"]').val(d[s]):c.slice(1).val(d[s])),s===u.columns&&c.length&&(h.filter_$anyMatch=c));return d},i.setFilters=function(r,l,a,n){var s=r?e(r)[0].config:"",o=i.getFilters(r,!0,l,n);return void 0===a&&(a=!0),s&&a&&(s.lastCombinedFilter=null,s.lastSearch=[],t.searching(s.table,l,n),s.$table.triggerHandler("filterFomatterUpdate")),0!==o.length}}(jQuery); \ No newline at end of file diff --git a/docs/example-widget-filter.html b/docs/example-widget-filter.html index e495e12f..3db28858 100644 --- a/docs/example-widget-filter.html +++ b/docs/example-widget-filter.html @@ -83,6 +83,10 @@ // class added to filtered rows (rows that are not showing); needed by pager plugin filter_filteredRow : 'filtered', + // ARIA-label added to filter input/select; {{label}} is replaced by the column header + // "data-label" attribute, if it exists, or it uses the column header text + filter_filterLabel : 'Filter "{{label}}" column by...', + // add custom filter elements to the filter row // see the filter formatter demos for more specifics filter_formatter : null, @@ -251,6 +255,7 @@ $(function(){

Notes

    +
  • In v2.29.4, filter_filterLabel option was added to include an ARIA-label to the filter inputs and selects.
  • In v2.27.3, filter_liveSearch will now accept an object containing zero-based column indexes or header class names.
  • In v2.26.6, the hideFilters setting will now accept a function to determine when to hide the filter row.
  • In v2.25.6, added filterResetSaved method to clear stored filter values.
  • @@ -466,6 +471,20 @@ $(function(){ + + + 'Filter "{{label}}" column by...' + + This option contains the ARIA-label value to be added to the filter input or select (v2.29.4). +
    +

    + By default, a {{label}} is included in the setting to insert a column label. The content is obtained from the header cell's data-label attribute (do not include the data- prefix), if it exists, or the column header text. See the "First Name" column below for an example. +

    + Note See the main page documentation for more important details! +
    + + + null @@ -829,7 +848,7 @@ $.extend($.tablesorter.language, { Rank - First Name ( filter-match ) + First Name ( filter-match ) Last Name Age Total diff --git a/docs/index.html b/docs/index.html index 8fbc23c9..20bbdd5c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -465,9 +465,9 @@
  • Content editable widget (v2.9; v2.28.7).
  • Current Sort Widget (v2.27.0).
  • Beta Dragtable mod - (jQuery UI widget for column reordering [ref]; v2.24.0).
  • -
  • Filter widget (v2.29.2): +
  • Filter widget (v2.29.4):
      -
    • basic (v2.0.18; v2.26.6).
    • +
    • basic (v2.0.18; v2.29.4).
    • external option (match any column) (v2.13.3; v2.27.5).
    • external inputs (v2.14; v2.18.0).
    • custom filter functions (v2.3.6; v2.22.0).
    • @@ -1976,6 +1976,11 @@ $(function(){ // class added to filtered rows; needed by pager plugin filter_filteredRow: 'filtered', + // ARIA-label added to filter input/select; {{label}} is replaced by + // the column header "data-label" attribute, if it exists, or it uses the + // column header text + filter_filterLabel : 'Filter "{{label}}" column by...', + // add custom filter elements to the filter row filter_formatter: null, @@ -2833,6 +2838,36 @@ filter_cellFilter : [ '', 'hidden', '', 'hidden' ] + + + String + 'Filter "{{label}}" column by...' + + This option contains the ARIA-label value to be added to the filter input or select (v2.29.4). +
      +

      + By default, a {{label}} is included in the setting to insert a column label. The content is obtained from the header cell's data-label attribute (do not include the data- prefix), if it exists, or the column header text. See the "First Name" column on the example page. +

      +

      + More complex labels may be included by adding multiple "data-attributes". For example, the following option: +

      filter_filterLabel : 'Filter the {{column-name}}, the {{ordinal-number}} column{{label-extra}}{{default-filter}}'
      + with this header cell HTML +
      <th data-column-name="last name" data-ordinal-number="second" data-default-filter=", using a fuzzy search" data-label-extra="">
      +  Last
      +<th>
      + would result in an ARIA-label of 'Filter the last name, the second column, using a fuzzy search' +

      + Note: +
        +
      • The data- prefix must not be added in the placeholders.
      • +
      • The empty data-label-extra attribute did add any content to the resulting label.
      • +
      • If an included data-attribute does not exist on the header, it will be replaced by the header text.
      • +
      +
      + + Example + + Object diff --git a/js/widgets/widget-filter.js b/js/widgets/widget-filter.js index a1a4c039..60aeac52 100644 --- a/js/widgets/widget-filter.js +++ b/js/widgets/widget-filter.js @@ -40,6 +40,7 @@ filter_excludeFilter : {}, // filters to exclude, per column filter_external : '', // jQuery selector string ( or jQuery object ) of external filters filter_filteredRow : 'filtered', // class added to filtered rows; define in css with "display:none" to hide the filtered-out rows + filter_filterLabel : 'Filter "{{label}}" column by...', // Aria-label added to filter input/select; see #1495 filter_formatter : null, // add custom filter elements to the filter row filter_functions : null, // add custom filter functions using this option filter_hideEmpty : true, // hide filter row when table is empty @@ -696,7 +697,7 @@ cellFilter = wo.filter_cellFilter, columns = c.columns, arry = $.isArray( cellFilter ), - buildFilter = ''; + buildFilter = ''; for ( column = 0; column < columns; column++ ) { if ( c.$headerIndexed[ column ].length ) { // account for entire column set with colspan. See #1047 @@ -765,7 +766,22 @@ ( typeof wo.filter_cssFilter[column] !== 'undefined' ? wo.filter_cssFilter[column] || '' : '' ) : wo.filter_cssFilter ) || ''; // copy data-column from table cell (it will include colspan) - buildFilter.addClass( tscss.filter + ' ' + name ).attr( 'data-column', $filter.attr( 'data-column' ) ); + buildFilter.addClass( tscss.filter + ' ' + name ); + name = wo.filter_filterLabel; + tmp = name.match(/{{([^}]+?)}}/g); + if (!tmp) { + tmp = ['{{label}}']; + } + $.each(tmp, function(indx, attr) { + var regex = new RegExp(attr, 'g'), + data = $header.attr('data-' + attr.replace(/{{|}}/g, '')), + text = typeof data === 'undefined' ? $header.text() : data; + name = name.replace( regex, $.trim( text ) ); + }); + buildFilter.attr({ + 'data-column': $filter.attr( 'data-column' ), + 'aria-label': name + }); if ( disabled ) { buildFilter.attr( 'placeholder', '' ).addClass( tscss.filterDisabled )[0].disabled = true; }