tablesorter/dist/js/jquery.tablesorter.widgets.min.js

3 lines
50 KiB
JavaScript
Raw Normal View History

2016-09-01 16:46:28 +00:00
/*! tablesorter (FORK) - updated 09-01-2016 (v2.27.6)*/
2016-08-22 15:41:07 +00:00
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof module&&"object"==typeof module.exports?module.exports=a(require("jquery")):a(jQuery)}(function(a){return function(a,b,c){"use strict";var d=a.tablesorter||{};d.storage=function(d,e,f,g){d=a(d)[0];var h,i,j,k=!1,l={},m=d.config,n=m&&m.widgetOptions,o=g&&g.useSessionStorage||n&&n.storage_useSessionStorage?"sessionStorage":"localStorage",p=a(d),q=g&&g.id||p.attr(g&&g.group||n&&n.storage_group||"data-table-group")||n&&n.storage_tableId||d.id||a(".tablesorter").index(p),r=g&&g.url||p.attr(g&&g.page||n&&n.storage_page||"data-table-page")||n&&n.storage_fixedUrl||m&&m.fixedUrl||b.location.pathname;if(o in b)try{b[o].setItem("_tmptest","temp"),k=!0,b[o].removeItem("_tmptest")}catch(a){m&&m.debug&&console.warn(o+" is not supported in this browser")}return a.parseJSON&&(k?l=a.parseJSON(b[o][e]||"null")||{}:(i=c.cookie.split(/[;\s|=]/),h=a.inArray(e,i)+1,l=0!==h?a.parseJSON(i[h]||"null")||{}:{})),"undefined"!=typeof f&&b.JSON&&JSON.hasOwnProperty("stringify")?(l[r]||(l[r]={}),l[r][q]=f,k?b[o][e]=JSON.stringify(l):(j=new Date,j.setTime(j.getTime()+31536e6),c.cookie=e+"="+JSON.stringify(l).replace(/\"/g,'"')+"; expires="+j.toGMTString()+"; path=/"),void 0):l&&l[r]?l[r][q]:""}}(a,window,document),function(a){"use strict";var b=a.tablesorter||{};b.themes={bootstrap:{table:"table table-bordered table-striped",caption:"caption",header:"bootstrap-header",sortNone:"",sortAsc:"",sortDesc:"",active:"",hover:"",icons:"",iconSortNone:"bootstrap-icon-unsorted",iconSortAsc:"icon-chevron-up glyphicon glyphicon-chevron-up",iconSortDesc:"icon-chevron-down glyphicon glyphicon-chevron-down",filterRow:"",footerRow:"",footerCells:"",even:"",odd:""},jui:{table:"ui-widget ui-widget-content ui-corner-all",caption:"ui-widget-content",header:"ui-widget-header ui-corner-all ui-state-default",sortNone:"",sortAsc:"",sortDesc:"",active:"ui-state-active",hover:"ui-state-hover",icons:"ui-icon",iconSortNone:"ui-icon-carat-2-n-s ui-icon-caret-2-n-s",iconSortAsc:"ui-icon-carat-1-n ui-icon-caret-1-n",iconSortDesc:"ui-icon-carat-1-s ui-icon-caret-1-s",filterRow:"",footerRow:"",footerCells:"",even:"ui-widget-content",odd:"ui-state-default"}},a.extend(b.css,{wrapper:"tablesorter-wrapper"}),b.addWidget({id:"uitheme",priority:10,format:function(c,d,e){var f,g,h,i,j,k,l,m,n,o,p,q,r,s=b.themes,t=d.$table.add(a(d.namespace+"_extra_table")),u=d.$headers.add(a(d.namespace+"_extra_headers")),v=d.theme||"jui",w=s[v]||{},x=a.trim([w.sortNone,w.sortDesc,w.sortAsc,w.active].join(" ")),y=a.trim([w.iconSortNone,w.iconSortDesc,w.iconSortAsc].join(" "));for(d.debug&&(j=new Date),t.hasClass("tablesorter-"+v)&&d.theme===d.appliedTheme&&e.uitheme_applied||(e.uitheme_applied=!0,o=s[d.appliedTheme]||{},r=!a.isEmptyObject(o),p=r?[o.sortNone,o.sortDesc,o.sortAsc,o.active].join(" "):"",q=r?[o.iconSortNone,o.iconSortDesc,o.iconSortAsc].join(" "):"",r&&(e.zebra[0]=a.trim(" "+e.zebra[0].replace(" "+o.even,"")),e.zebra[1]=a.trim(" "+e.zebra[1].replace(" "+o.odd,"")),d.$tbodies.children().removeClass([o.even,o.odd].join(" "))),w.even&&(e.zebra[0]+=" "+w.even),w.odd&&(e.zebra[1]+=" "+w.odd),t.children("caption").removeClass(o.caption||"").addClass(w.caption),m=t.removeClass((d.appliedTheme?"tablesorter-"+(d.appliedTheme||""):"")+" "+(o.table||"")).addClass("tablesorter-"+v+" "+(w.table||"")).children("tfoot"),d.appliedTheme=d.theme,m.length&&m.children("tr").removeClass(o.footerRow||"").addClass(w.footerRow).children("th, td").removeClass(o.footerCells||"").addClass(w.footerCells),u.removeClass((r?[o.header,o.hover,p].join(" "):"")||"").addClass(w.header).not(".sorter-false").unbind("mouseenter.tsuitheme mouseleave.tsuitheme").bind("mouseenter.tsuitheme mouseleave.tsuitheme",function(b){a(this)["mouseenter"===b.type?"addClass":"removeClass"](w.hover||"")}),u.each(function(){var c=a(this);c.find("."+b.css.wrapper).length||c.wrapInner('<div class="'+b.css.wrapper+'" style="position:relative;height:100%;width:100%"></div>')}),d.cssIcon&&u.find("."+b.css.icon).removeClass(r?[o.icons,q].join(" "):"").addClass(w.icon
}return i===!1&&(i=b.getOptions(c,e,f)),b.processOptions(c,e,i)},processOptions:function(b,c,e){if(!a.isArray(e))return!1;b=a(b)[0];var f,g,h,i,j,k,l=b.config,m="undefined"!=typeof c&&null!==c&&c>=0&&c<l.columns,n=[];if(e=a.grep(e,function(b,c){return!!b.text||a.inArray(b,e)===c}),m&&l.$headerIndexed[c].hasClass("filter-select-nosort"))return e;for(i=e.length,h=0;h<i;h++)g=e[h],k=g.text?g.text:g,j=(m&&l.parsers&&l.parsers.length&&l.parsers[c].format(k,b,[],c)||k).toString(),j=l.widgetOptions.filter_ignoreCase?j.toLowerCase():j,g.text?(g.parsed=j,n[n.length]=g):n[n.length]={text:g,parsed:j};for(f=l.textSorter||"",n.sort(function(a,e){var g=a.parsed,h=e.parsed;return m&&"function"==typeof f?f(g,h,!0,c,b):m&&"object"==typeof f&&f.hasOwnProperty(c)?f[c](g,h,!0,c,b):!d.sortNatural||d.sortNatural(g,h)}),e=[],i=n.length,h=0;h<i;h++)e[e.length]=n[h];return e},getOptions:function(b,c,e){b=a(b)[0];var f,g,h,i,j,k,l,m,n=b.config,o=n.widgetOptions,p=[];for(g=0;g<n.$tbodies.length;g++)for(j=n.cache[g],h=n.cache[g].normalized.length,f=0;f<h;f++)if(i=j.row?j.row[f]:j.normalized[f][n.columns].$row[0],!e||!i.className.match(o.filter_filteredRow))if(o.filter_useParsedData||n.parsers[c].parsed||n.$headerIndexed[c].hasClass("filter-parsed")){if(p[p.length]=""+j.normalized[f][c],o.filter_childRows&&o.filter_childByColumn)for(m=j.normalized[f][n.columns].$row.length-1,k=0;k<m;k++)p[p.length]=""+j.normalized[f][n.columns].child[k][c]}else if(p[p.length]=j.normalized[f][n.columns].raw[c],o.filter_childRows&&o.filter_childByColumn)for(m=j.normalized[f][n.columns].$row.length,k=1;k<m;k++)l=j.normalized[f][n.columns].$row.eq(k).children().eq(c),p[p.length]=""+d.getElementText(n,l,c);return p},buildSelect:function(d,f,g,h,i){if(d=a(d)[0],f=parseInt(f,10),d.config.cache&&!a.isEmptyObject(d.config.cache)){var j,k,l,m,n,o,p,q=d.config,r=q.widgetOptions,s=q.$headerIndexed[f],t='<option value="">'+(s.data("placeholder")||s.attr("data-placeholder")||r.filter_placeholder.select||"")+"</option>",u=q.$table.find("thead").find("select."+e.filter+'[data-column="'+f+'"]').val();if("undefined"!=typeof g&&""!==g||(g=b.getOptionSource(d,f,i)),a.isArray(g)){for(j=0;j<g.length;j++)if(p=g[j],p.text){p["data-function-name"]="undefined"==typeof p.value?p.text:p.value,t+="<option";for(k in p)p.hasOwnProperty(k)&&"text"!==k&&(t+=" "+k+'="'+p[k]+'"');p.value||(t+=' value="'+p.text+'"'),t+=">"+p.text+"</option>"}else""+p!="[object Object]"&&(l=p=(""+p).replace(c.quote,"&quot;"),k=l,l.indexOf(r.filter_selectSourceSeparator)>=0&&(m=l.split(r.filter_selectSourceSeparator),k=m[0],l=m[1]),t+=""!==p?"<option "+(k===l?"":'data-function-name="'+p+'" ')+'value="'+k+'">'+l+"</option>":"");g=[]}n=(q.$filters?q.$filters:q.$table.children("thead")).find("."+e.filter),r.filter_$externalFilters&&(n=n&&n.length?n.add(r.filter_$externalFilters):r.filter_$externalFilters),o=n.filter('select[data-column="'+f+'"]'),o.length&&(o[h?"html":"append"](t),a.isArray(g)||o.append(g).val(u),o.val(u))}},buildDefault:function(a,c){var e,f,g,h=a.config,i=h.widgetOptions,j=h.columns;for(e=0;e<j;e++)f=h.$headerIndexed[e],g=!(f.hasClass("filter-false")||f.hasClass("parser-false")),(f.hasClass("filter-select")||d.getColumnData(a,i.filter_functions,e)===!0)&&g&&b.buildSelect(a,e,"",c,f.hasClass(i.filter_onlyAvail))}},c=b.regex,d.getFilters=function(c,d,f,g){var h,i,j,k,l=[],m=c?a(c)[0].config:"",n=m?m.widgetOptions:"";if(d!==!0&&n&&!n.filter_columnFilters||a.isArray(f)&&f.join("")===m.lastCombinedFilter)return a(c).data("lastSearch");if(m&&(m.$filters&&(i=m.$filters.find("."+e.filter)),n.filter_$externalFilters&&(i=i&&i.length?i.add(n.filter_$externalFilters):n.filter_$externalFilters),i&&i.length))for(l=f||[],h=0;h<m.columns+1;h++)k=h===m.columns?n.filter_anyColumnSelector+","+n.filter_multipleColumnSelector:'[data-column="'+h+'"]',j=i.filter(k),j.length&&(j=b.getLatestSearch(j),a.isArray(f)?(g&&j.length>1&&(j=j.slice(1)),h===m.columns&&(k=j.filter(n.filter_anyColumnSelector),j=k.length?k:j),j.val(f[h]).trigger("change"+m.namespace)):(l[h]=j.val()||"",h===m.columns?j.slice(1).filter('[data-column*="'+j.att