{"version":3,"file":"excel-bootstrap-table-filter-bundle.js","sources":["../src/FilterMenu.ts","../src/FilterCollection.ts","../src/excel-bootstrap-table-filter.ts"],"sourcesContent":["export class FilterMenu {\n\n th: HTMLElement;\n tds: Array;\n column: number;\n index: number;\n menu: HTMLElement;\n inputs: Array;\n selectAllCheckbox: Element;\n searchFilter: Element;\n options: Options;\n target: JQuery;\n\n constructor (target: JQuery, th: HTMLElement, column: number, index: number, options: Options) {\n this.options = options;\n this.th = th;\n this.column = column;\n this.index = index;\n this.tds = target.find('tbody tr td:nth-child(' + (this.column + 1) + ')').toArray();\n }\n\n public initialize(): void {\n this.menu = this.dropdownFilterDropdown();\n this.th.appendChild(this.menu);\n\n // variables for click handlers\n let $trigger = $(this.menu.children[0]);\n let $content = $(this.menu.children[1]);\n let $menu = $(this.menu);\n\n // toggle hide/show when the trigger is clicked\n $trigger.click(() => $content.toggle());\n\n $(document).click(function(el) {\n // hide the content if the user clicks outside of the menu\n if (!$menu.is(el.target) && $menu.has(el.target).length === 0) {\n $content.hide();\n }\n });\n }\n\n public searchToggle(value: string): void {\n if (this.selectAllCheckbox instanceof HTMLInputElement) this.selectAllCheckbox.checked = false;\n if (value.length === 0){\n this.toggleAll(true);\n if (this.selectAllCheckbox instanceof HTMLInputElement) this.selectAllCheckbox.checked = true;\n return;\n }\n // deselect all checkboxes initially\n this.toggleAll(false);\n // select checkboxes that match the search parameter\n this.inputs.filter(function(input: HTMLInputElement) {\n return input.value.toLowerCase().indexOf(value.toLowerCase()) > -1;\n }).forEach(function(input: HTMLInputElement) {\n input.checked = true;\n });\n }\n\n\n public updateSelectAll(): void {\n if (this.selectAllCheckbox instanceof HTMLInputElement) {\n // clear search parameters, if any\n $(this.searchFilter).val('');\n // Check if all inputs are selected\n this.selectAllCheckbox.checked = (this.inputs.length === this.inputs.filter(function(input: HTMLInputElement) {\n return input.checked;\n }).length);\n }\n }\n\n public selectAllUpdate(checked: boolean): void {\n // clear search parameters, if any\n $(this.searchFilter).val('');\n this.toggleAll(checked);\n }\n\n private toggleAll(checked: boolean): void {\n // loop through all inputs and check or uncheck each\n for (var i=0; i < this.inputs.length; i++) {\n let input = this.inputs[i];\n if (input instanceof HTMLInputElement) input.checked = checked;\n }\n }\n\n private dropdownFilterItem(td: HTMLElement, self: any): HTMLElement {\n // build holder div\n let value = td.innerText;\n let dropdownFilterItem = document.createElement('div');\n dropdownFilterItem.className = 'dropdown-filter-item';\n // build input\n let input = document.createElement('input');\n input.type = 'checkbox';\n input.value = value.trim().replace(/ +(?= )/g,'');\n input.setAttribute('checked','checked');\n input.className = 'dropdown-filter-menu-item item';\n // get index of td element\n input.setAttribute('data-column', self.column.toString());\n input.setAttribute('data-index', self.index.toString());\n // append input to holding div\n dropdownFilterItem.appendChild(input);\n dropdownFilterItem.innerHTML = dropdownFilterItem.innerHTML.trim() + ' ' + value;\n return dropdownFilterItem;\n }\n\n private dropdownFilterItemSelectAll(): HTMLElement {\n // build holder div\n let value = this.options.captions.select_all;\n let dropdownFilterItemSelectAll = document.createElement('div');\n dropdownFilterItemSelectAll.className = 'dropdown-filter-item';\n // build input\n let input = document.createElement('input');\n input.type = 'checkbox';\n input.value = this.options.captions.select_all;\n input.setAttribute('checked','checked');\n input.className = 'dropdown-filter-menu-item select-all';\n input.setAttribute('data-column', this.column.toString());\n input.setAttribute('data-index', this.index.toString());\n // append input to holding div\n dropdownFilterItemSelectAll.appendChild(input);\n dropdownFilterItemSelectAll.innerHTML = dropdownFilterItemSelectAll.innerHTML + ' ' + value;\n return dropdownFilterItemSelectAll;\n }\n\n private dropdownFilterSearch(): HTMLElement {\n // build holder div\n let dropdownFilterItem = document.createElement('div');\n dropdownFilterItem.className = 'dropdown-filter-search';\n // build input\n let input = document.createElement('input');\n input.type = 'text';\n input.className = 'dropdown-filter-menu-search form-control';\n input.setAttribute('data-column', this.column.toString());\n input.setAttribute('data-index', this.index.toString());\n input.setAttribute('placeholder', this.options.captions.search);\n // append input to holding div\n dropdownFilterItem.appendChild(input);\n return dropdownFilterItem;\n }\n\n private dropdownFilterSort(direction: string): HTMLElement {\n // build holder div\n let dropdownFilterItem = document.createElement('div');\n dropdownFilterItem.className = 'dropdown-filter-sort';\n // build span\n let span = document.createElement('span');\n span.className = direction.toLowerCase().split(' ').join('-');\n span.setAttribute('data-column', this.column.toString());\n span.setAttribute('data-index', this.index.toString());\n span.innerText = direction;\n // append input to holding div\n dropdownFilterItem.appendChild(span);\n return dropdownFilterItem;\n }\n\n private dropdownFilterContent(): HTMLElement {\n let self = this;\n // build holder div\n let dropdownFilterContent = document.createElement('div');\n dropdownFilterContent.className = 'dropdown-filter-content';\n\n let innerDivs = this.tds.reduce(function(arr, el) {\n // get unique values in column\n let values = arr.map((el) => el.innerText.trim());\n if (values.indexOf(el.innerText.trim()) < 0) arr.push(el);\n // return unique values\n return arr;\n }, [])\n .sort(function(a, b) {\n // sort values for display in dropdown\n var A = a.innerText.toLowerCase();\n var B = b.innerText.toLowerCase();\n\n if (!isNaN(Number(A)) && !isNaN(Number(B))) {\n\n // handle numbers\n if(Number(A) < Number(B)) return -1;\n if(Number(A) > Number(B)) return 1;\n\n } else {\n\n // handle strings\n if(A < B) return -1;\n if(A > B) return 1;\n\n }\n //return a.innerText.toLowerCase() > b.innerText.toLowerCase() ? 1 : -1;\n return 0;\n })\n // create dropdown filter items out of each value\n .map( (td) => {\n return this.dropdownFilterItem(td, self);\n })\n\n // map inputs to instance, we will need these later\n this.inputs = innerDivs.map((div) => div.firstElementChild);\n\n // add a select all checkbox\n let selectAllCheckboxDiv = this.dropdownFilterItemSelectAll();\n // map the select all checkbox to the instance, we will need it later\n this.selectAllCheckbox = selectAllCheckboxDiv.firstElementChild;\n // the checkbox will precede the other inputs\n innerDivs.unshift(selectAllCheckboxDiv);\n\n let searchFilterDiv = this.dropdownFilterSearch();\n this.searchFilter = searchFilterDiv.firstElementChild;\n\n // create outer div, and place all inner divs within it\n let outerDiv = innerDivs.reduce(function(outerDiv, innerDiv) {\n outerDiv.appendChild(innerDiv);\n return outerDiv;\n }, document.createElement('div'));\n outerDiv.className = 'checkbox-container';\n\n let elements: Array = [];\n if (this.options.sort ) elements= elements.concat([\n this.dropdownFilterSort(this.options.captions.a_to_z),\n this.dropdownFilterSort(this.options.captions.z_to_a)\n ]);\n if (this.options.search) elements.push(searchFilterDiv);\n\n return elements.concat(outerDiv).reduce(function(html, el) {\n html.appendChild(el);\n return html;\n }, dropdownFilterContent);\n }\n\n private dropdownFilterDropdown(): HTMLElement {\n // build holder div\n let dropdownFilterDropdown = document.createElement('div');\n dropdownFilterDropdown.className = 'dropdown-filter-dropdown';\n let arrow = document.createElement('span');\n arrow.className = 'glyphicon glyphicon-arrow-down dropdown-filter-icon';\n let icon = document.createElement('i');\n icon.className = 'arrow-down';\n arrow.appendChild(icon);\n dropdownFilterDropdown.appendChild(arrow);\n dropdownFilterDropdown.appendChild(this.dropdownFilterContent());\n\n if ($(this.th).hasClass('no-sort')) {\n $(dropdownFilterDropdown).find('.dropdown-filter-sort').remove();\n }\n if ($(this.th).hasClass('no-filter')) {\n $(dropdownFilterDropdown).find('.checkbox-container').remove();\n }\n if ($(this.th).hasClass('no-search')) {\n $(dropdownFilterDropdown).find('.dropdown-filter-search').remove();\n }\n return dropdownFilterDropdown;\n }\n\n}\n","import { FilterMenu } from './FilterMenu'\n\nexport class FilterCollection {\n\n filterMenus: Array;\n rows: Array;\n ths: Array;\n table: HTMLElement;\n options: Options;\n target: JQuery;\n\n constructor (target: JQuery, options: Options) {\n this.target = target;\n this.options = options;\n this.ths = target.find('th' + options.columnSelector).toArray()\n this.filterMenus = this.ths.map(function(th: HTMLElement, index: number) {\n let column = $(th).index();\n return new FilterMenu(target, th, column, index, options);\n });\n this.rows = target.find('tbody').find('tr').toArray();\n this.table = target.get(0);\n }\n\n public initialize(): void {\n this.filterMenus.forEach(function(filterMenu) {\n filterMenu.initialize();\n });\n this.bindCheckboxes();\n this.bindSelectAllCheckboxes();\n this.bindSort();\n this.bindSearch();\n }\n\n private bindCheckboxes(): void {\n let filterMenus = this.filterMenus;\n let rows = this.rows;\n let ths = this.ths;\n let updateRowVisibility = this.updateRowVisibility;\n this.target.find('.dropdown-filter-menu-item.item').change(function() {\n let index = $(this).data('index');\n let value = $(this).val();\n filterMenus[index].updateSelectAll();\n updateRowVisibility(filterMenus, rows, ths);\n });\n }\n\n private bindSelectAllCheckboxes(): void {\n let filterMenus = this.filterMenus;\n let rows = this.rows;\n let ths = this.ths;\n let updateRowVisibility = this.updateRowVisibility;\n this.target.find('.dropdown-filter-menu-item.select-all').change(function() {\n let index = $(this).data('index');\n let value = this.checked;\n filterMenus[index].selectAllUpdate(value);\n updateRowVisibility(filterMenus, rows, ths);\n });\n }\n\n private bindSort(): void {\n let filterMenus = this.filterMenus;\n let rows = this.rows;\n let ths = this.ths;\n let sort = this.sort;\n let table = this.table;\n let options = this.options;\n let updateRowVisibility = this.updateRowVisibility;\n this.target.find('.dropdown-filter-sort').click(function() {\n let $sortElement = $(this).find('span');\n let column = $sortElement.data('column');\n let order = $sortElement.attr('class');\n sort(column, order, table, options);\n updateRowVisibility(filterMenus, rows, ths);\n });\n }\n\n private bindSearch(): void {\n let filterMenus = this.filterMenus;\n let rows = this.rows;\n let ths = this.ths;\n let updateRowVisibility = this.updateRowVisibility;\n this.target.find('.dropdown-filter-search').keyup(function() {\n let $input = $(this).find('input');\n let index = $input.data('index');\n let value = $input.val();\n filterMenus[index].searchToggle(value);\n updateRowVisibility(filterMenus, rows, ths);\n });\n }\n\n private updateRowVisibility(filterMenus: Array, rows: Array, ths: Array): void {\n let showRows = rows;\n let hideRows: Array = [];\n let selectedLists = filterMenus.map(function(filterMenu) {\n return {\n column: filterMenu.column,\n selected: filterMenu.inputs\n .filter(function(input: HTMLInputElement) {\n return input.checked\n }).map(function(input: HTMLInputElement) {\n return input.value.trim().replace(/ +(?= )/g,'');\n })\n };\n });\n for (let i=0; i < rows.length; i++) {\n let tds = rows[i].children;\n for (let j=0; j < selectedLists.length; j++) {\n let content = (tds[selectedLists[j].column] as HTMLElement).innerText.trim().replace(/ +(?= )/g,'')\n if (selectedLists[j].selected.indexOf(content) === -1 ) {\n $(rows[i]).hide();\n break;\n }\n $(rows[i]).show();\n }\n }\n }\n\n private sort(column: number, order: string, table: HTMLElement, options: Options): void {\n let flip = 1;\n if (order === options.captions.z_to_a.toLowerCase().split(' ').join('-')) flip = -1;\n let tbody = $(table).find('tbody').get(0);\n let rows = $(tbody).find('tr').get();\n\n rows.sort(function(a, b) {\n var A = (a.children[column] as HTMLElement).innerText.toUpperCase();\n var B = (b.children[column] as HTMLElement).innerText.toUpperCase();\n\n if (!isNaN(Number(A)) && !isNaN(Number(B))) {\n // handle numbers\n if(Number(A) < Number(B)) return -1*flip;\n if(Number(A) > Number(B)) return 1*flip;\n } else {\n // handle strings\n if(A < B) return -1*flip;\n if(A > B) return 1*flip;\n }\n return 0;\n });\n\n for (var i=0; i < rows.length; i++) {\n tbody.appendChild(rows[i]);\n }\n }\n\n\n}\n","import $ from 'jquery';\nimport { FilterCollection } from './FilterCollection'\n\n// Define the plugin function on the jQuery extension point.\n($.fn as any).excelTableFilter = function (this: JQuery, options: Options) {\n let target = this;\n // Merge the global options with the per-call options.\n options = $.extend({}, ($.fn as any).excelTableFilter.options, options);\n\n if (typeof options.columnSelector === 'undefined') options.columnSelector = '';\n if (typeof options.sort === 'undefined') options.sort = true;\n if (typeof options.search === 'undefined') options.search = true;\n\n if (typeof options.captions === 'undefined') options.captions = {\n a_to_z: 'A to Z',\n z_to_a: 'Z to A',\n search: 'Search',\n select_all: 'Select All'\n }\n\n let filterCollection = new FilterCollection(target, options);\n filterCollection.initialize();\n\n // Return the jQuery object for chaining.\n return target;\n};\n\n// Define the plugin's global default options.\n($.fn as any).excelTableFilter.options = {};\n"],"names":["target","th","column","index","options","tds","find","toArray","menu","dropdownFilterDropdown","appendChild","$trigger","$","children","$content","$menu","click","toggle","document","el","is","has","length","hide","value","selectAllCheckbox","HTMLInputElement","checked","toggleAll","inputs","filter","input","toLowerCase","indexOf","forEach","searchFilter","val","i","td","self","innerText","dropdownFilterItem","createElement","className","type","trim","replace","setAttribute","toString","innerHTML","captions","select_all","dropdownFilterItemSelectAll","search","direction","span","split","join","dropdownFilterContent","innerDivs","reduce","arr","values","map","push","sort","a","b","A","B","isNaN","Number","_this","div","firstElementChild","selectAllCheckboxDiv","unshift","searchFilterDiv","dropdownFilterSearch","outerDiv","innerDiv","elements","concat","dropdownFilterSort","a_to_z","z_to_a","html","arrow","icon","hasClass","remove","ths","columnSelector","filterMenus","FilterMenu","rows","table","get","filterMenu","initialize","bindCheckboxes","bindSelectAllCheckboxes","bindSort","bindSearch","updateRowVisibility","change","data","updateSelectAll","selectAllUpdate","$sortElement","order","attr","keyup","$input","searchToggle","showRows","hideRows","selectedLists","j","content","selected","show","flip","tbody","toUpperCase","fn","excelTableFilter","extend","filterCollection","FilterCollection"],"mappings":";;;;;AAAA;uBAaE,CAAaA,MAAb,EAA6BC,EAA7B,EAA8CC,MAA9C,EAA8DC,KAA9D,EAA6EC,OAA7E;aACOA,OAAL,GAAeA,OAAf;aACKH,EAAL,GAAUA,EAAV;aACKC,MAAL,GAAcA,MAAd;aACKC,KAAL,GAAaA,KAAb;aACKE,GAAL,GAAWL,OAAOM,IAAP,CAAY,4BAA4B,KAAKJ,MAAL,GAAc,CAA1C,IAA+C,GAA3D,EAAgEK,OAAhE,EAAX;;wBAGK,WAAA,GAAP;aACOC,IAAL,GAAY,KAAKC,sBAAL,EAAZ;aACKR,EAAL,CAAQS,WAAR,CAAoB,KAAKF,IAAzB;YAGIG,WAAWC,EAAE,KAAKJ,IAAL,CAAUK,QAAV,CAAmB,CAAnB,CAAF,CAAf;YACIC,WAAWF,EAAE,KAAKJ,IAAL,CAAUK,QAAV,CAAmB,CAAnB,CAAF,CAAf;YACIE,QAAQH,EAAE,KAAKJ,IAAP,CAAZ;iBAGSQ,KAAT,CAAe;mBAAMF,SAASG,MAAT,EAAA;SAArB;UAEEC,QAAF,EAAYF,KA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