Commit 3551df8e authored by Robert Speicher's avatar Robert Speicher

Minor main.js refactor and docs

parent ad1aa517
...@@ -21,8 +21,8 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> ...@@ -21,8 +21,8 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) ->
closest_submit.enable() closest_submit.enable()
$ -> $ ->
$(".one_click_select").live 'click', -> # Click a .one_click_select field, select the contents
$(this).select() $(".one_click_select").live 'click', -> $(this).select()
# Disable form buttons while a form is submitting # Disable form buttons while a form is submitting
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
...@@ -66,10 +66,12 @@ $ -> ...@@ -66,10 +66,12 @@ $ ->
$(this).text(previewLinkText) $(this).text(previewLinkText)
note = $('#note_note').val() note = $('#note_note').val()
note = 'Nothing to preview' if note.trim().length is 0
$.post($(this).attr('href'), {note: note}, (data) -> if note.trim().length == 0
$('#preview-note').text("Nothing to preview.")
else
$.post $(this).attr('href'), {note: note}, (data) ->
$('#preview-note').html(data) $('#preview-note').html(data)
)
$('#preview-note, #note_note').toggle() $('#preview-note, #note_note').toggle()
e.preventDefault() e.preventDefault()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment