Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate application.js into separate initializers
- Loading branch information
1 parent
c6510db
commit 01ad42f
Showing
6 changed files
with
36 additions
and
38 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
app/assets/javascripts/active_admin/initializers/batch_actions.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
$(document).on 'ready page:load', -> | ||
# In order for index scopes to overflow properly onto the next line, we have | ||
# to manually set its width based on the width of the batch action button. | ||
if (batch_actions_selector = $('.table_tools .batch_actions_selector')).length | ||
batch_actions_selector.next().css | ||
width: "calc(100% - 10px - #{batch_actions_selector.outerWidth()}px)" | ||
'float': 'right' |
10 changes: 10 additions & 0 deletions
10
app/assets/javascripts/active_admin/initializers/datepicker.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
$(document).on 'ready page:load', -> | ||
$(document).on 'focus', 'input.datepicker:not(.hasDatepicker)', -> | ||
input = $(@) | ||
|
||
# Only create datepickers in compatible browsers | ||
return if input[0].type is 'date' | ||
|
||
defaults = dateFormat: 'yy-mm-dd' | ||
options = input.data 'datepicker-options' | ||
input.datepicker $.extend(defaults, options) |
15 changes: 15 additions & 0 deletions
15
app/assets/javascripts/active_admin/initializers/filters.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$(document).on 'ready page:load', -> | ||
# Clear Filters button | ||
$('.clear_filters_btn').click -> | ||
params = window.location.search.slice(1).split('&') | ||
regex = /^(q\[|q%5B|q%5b|page|commit)/ | ||
window.location.search = (param for param in params when not param.match(regex)).join('&') | ||
|
||
# Filter form: don't send any inputs that are empty | ||
$('.filter_form').submit -> | ||
$(@).find(':input').filter(-> @value is '').prop 'disabled', true | ||
|
||
# Filter form: for filters that let you choose the query method from | ||
# a dropdown, apply that choice to the filter input field. | ||
$('.filter_form_field.select_and_search select').change -> | ||
$(@).siblings('input').prop name: "q[#{@value}]" |
3 changes: 3 additions & 0 deletions
3
app/assets/javascripts/active_admin/initializers/tabs.js.coffee
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$(document).on 'ready page:load', -> | ||
# Tab navigation | ||
$('#active_admin_content .tabs').tabs() |