about summary refs log tree commit diff stats
path: root/app/assets/javascripts/admin/records.coffee
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/admin/records.coffee')
-rw-r--r--app/assets/javascripts/admin/records.coffee24
1 files changed, 20 insertions, 4 deletions
diff --git a/app/assets/javascripts/admin/records.coffee b/app/assets/javascripts/admin/records.coffee index 69cd471..3a1ed51 100644 --- a/app/assets/javascripts/admin/records.coffee +++ b/app/assets/javascripts/admin/records.coffee
@@ -1,9 +1,25 @@
1# Place all the behaviors and hooks related to the matching controller here. 1# Place all the behaviors and hooks related to the matching controller here.
2# All this logic will automatically be available in application.js. 2# All this logic will automatically be available in application.js.
3# You can use CoffeeScript in this file: http://coffeescript.org/ 3# You can use CoffeeScript in this file: http://coffeescript.org/
4
5create_record_toggle = (checked) ->
6 if checked
7 $(".record-description-field").show()
8 else
9 $(".record-description-field").hide()
10
11published_field_toggle = (checked) ->
12 if checked
13 $(".should-create-record-field input[type=checkbox]").prop("disabled", false)
14 else
15 $(".should-create-record-field input[type=checkbox]").prop("disabled", true)
16 $(".should-create-record-field input[type=checkbox]").prop("checked", false)
17 create_record_toggle(false)
18
4$(document).on "turbolinks:load", -> 19$(document).on "turbolinks:load", ->
20 if $(".published-field").length > 0
21 published_field_toggle($(".published-field input[type=checkbox]").prop("checked"))
5 $(".should-create-record-field input[type=checkbox]").change -> 22 $(".should-create-record-field input[type=checkbox]").change ->
6 if $(".should-create-record-field input[type=checkbox]").prop("checked") 23 create_record_toggle($(this).prop("checked"))
7 $(".record-description-field").show() 24 $(".published-field input[type=checkbox]").change ->
8 else 25 published_field_toggle($(this).prop("checked"))
9 $(".record-description-field").hide()