Commit 3551df8eb1c1bfe3a4cef532ddab1cbdcdd96a11
1 parent
ad1aa517
Exists in
master
and in
4 other branches
Minor main.js refactor and docs
Showing
1 changed file
with
8 additions
and
6 deletions
Show diff stats
app/assets/javascripts/main.js.coffee
@@ -21,8 +21,8 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> | @@ -21,8 +21,8 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> | ||
21 | closest_submit.enable() | 21 | closest_submit.enable() |
22 | 22 | ||
23 | $ -> | 23 | $ -> |
24 | - $(".one_click_select").live 'click', -> | ||
25 | - $(this).select() | 24 | + # Click a .one_click_select field, select the contents |
25 | + $(".one_click_select").live 'click', -> $(this).select() | ||
26 | 26 | ||
27 | # Disable form buttons while a form is submitting | 27 | # Disable form buttons while a form is submitting |
28 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> | 28 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> |
@@ -66,10 +66,12 @@ $ -> | @@ -66,10 +66,12 @@ $ -> | ||
66 | $(this).text(previewLinkText) | 66 | $(this).text(previewLinkText) |
67 | 67 | ||
68 | note = $('#note_note').val() | 68 | note = $('#note_note').val() |
69 | - note = 'Nothing to preview' if note.trim().length is 0 | ||
70 | - $.post($(this).attr('href'), {note: note}, (data) -> | ||
71 | - $('#preview-note').html(data) | ||
72 | - ) | 69 | + |
70 | + if note.trim().length == 0 | ||
71 | + $('#preview-note').text("Nothing to preview.") | ||
72 | + else | ||
73 | + $.post $(this).attr('href'), {note: note}, (data) -> | ||
74 | + $('#preview-note').html(data) | ||
73 | 75 | ||
74 | $('#preview-note, #note_note').toggle() | 76 | $('#preview-note, #note_note').toggle() |
75 | e.preventDefault() | 77 | e.preventDefault() |