Skip to content

Commit fa3a211

Browse files
committed
Merge pull request #5 from HubSpot/configurable
Make the selector configurable
2 parents 860ff27 + b1d9a38 commit fa3a211

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

coffee/sortable.coffee

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ touchDevice = 'ontouchstart' of document.documentElement
77
clickEvent = if touchDevice then 'touchstart' else 'click'
88

99
sortable =
10-
init: ->
11-
tables = document.querySelectorAll SELECTOR
10+
init: (options={}) ->
11+
options.selector ?= SELECTOR
12+
13+
tables = document.querySelectorAll options.selector
1214
sortable.initTable table for table in tables
1315

1416
initTable: (table) ->
15-
return if table.tHead.rows.length isnt 1
17+
return if table.tHead?.rows.length isnt 1
1618
return if table.getAttribute('data-sortable-initialized') is 'true'
1719

1820
table.setAttribute 'data-sortable-initialized', 'true'

js/sortable.js

Lines changed: 10 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

js/sortable.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)