Sha256: 1507a55149b865f6b244ef0a824a82127d1096abcc12838050651884b925776f
Contents?: true
Size: 1.16 KB
Versions: 4
Compression:
Stored size: 1.16 KB
Contents
window.TableFilter = class TableFilter constructor: (@$form) -> @$table = $("table.#{$form.data('filter-for')}") @$form.find("input[type='text']").keyup (event) => Escape = 27 if event.keyCode is Escape @clearFilter() else @$form.submit() @$form.find("button.clear").click (event) => event?.preventDefault() @clearFilter() @$form.submit (event) => event?.preventDefault() filterVal = @getFilterInput() @filter(filterVal) @filter() filter: -> filterVal = @getFilterInput() @$table.find("tbody tr").each (index, row) => $row = $(row) name = $row.find("td:first").text() if filterVal is "" or name.match(new RegExp(filterVal)) $row.show() else $row.hide() @$table.show() if @$table.find("tbody tr:visible").size() == 0 @$table.hide() $(".filter.alert").show() else @$table.show() $(".filter.alert").hide() clearFilter: -> @setFilterInput('') @filter() setFilterInput: (value) -> @$form.find("input[type='text']").val(value) getFilterInput: -> @$form.find("input[type='text']").val()
Version data entries
4 entries across 4 versions & 1 rubygems