Commit 46921e690ec95fdfb4c38ea1a2dd65261719ba23
1 parent
b1ef7d7a
Exists in
master
and in
4 other branches
cleanup main.coffee
Showing
1 changed file
with
16 additions
and
16 deletions
Show diff stats
app/assets/javascripts/main.js.coffee
| ... | ... | @@ -7,7 +7,7 @@ window.slugify = (text) -> |
| 7 | 7 | window.ajaxGet = (url) -> |
| 8 | 8 | $.ajax({type: "GET", url: url, dataType: "script"}) |
| 9 | 9 | |
| 10 | - # Disable button if text field is empty | |
| 10 | +# Disable button if text field is empty | |
| 11 | 11 | window.disableButtonIfEmptyField = (field_selector, button_selector) -> |
| 12 | 12 | field = $(field_selector) |
| 13 | 13 | closest_submit = field.closest("form").find(button_selector) |
| ... | ... | @@ -15,21 +15,21 @@ window.disableButtonIfEmptyField = (field_selector, button_selector) -> |
| 15 | 15 | closest_submit.disable() if field.val() is "" |
| 16 | 16 | |
| 17 | 17 | field.on "keyup", -> |
| 18 | - if $(this).val() is "" | |
| 18 | + if $(@).val() is "" | |
| 19 | 19 | closest_submit.disable() |
| 20 | 20 | else |
| 21 | 21 | closest_submit.enable() |
| 22 | 22 | |
| 23 | 23 | $ -> |
| 24 | 24 | # Click a .one_click_select field, select the contents |
| 25 | - $(".one_click_select").live 'click', -> $(this).select() | |
| 25 | + $(".one_click_select").on 'click', -> $(@).select() | |
| 26 | 26 | |
| 27 | 27 | # Initialize chosen selects |
| 28 | 28 | $('select.chosen').chosen() |
| 29 | 29 | |
| 30 | 30 | # Disable form buttons while a form is submitting |
| 31 | 31 | $('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) -> |
| 32 | - buttons = $('[type="submit"]', this) | |
| 32 | + buttons = $('[type="submit"]', @) | |
| 33 | 33 | |
| 34 | 34 | switch e.type |
| 35 | 35 | when 'ajax:beforeSend', 'submit' |
| ... | ... | @@ -38,7 +38,7 @@ $ -> |
| 38 | 38 | buttons.enable() |
| 39 | 39 | |
| 40 | 40 | # Show/Hide the profile menu when hovering the account box |
| 41 | - $('.account-box').hover -> $(this).toggleClass('hover') | |
| 41 | + $('.account-box').hover -> $(@).toggleClass('hover') | |
| 42 | 42 | |
| 43 | 43 | # Focus search field by pressing 's' key |
| 44 | 44 | $(document).keypress (e) -> |
| ... | ... | @@ -52,22 +52,22 @@ $ -> |
| 52 | 52 | |
| 53 | 53 | # Commit show suppressed diff |
| 54 | 54 | $(".supp_diff_link").bind "click", -> |
| 55 | - $(this).next('table').show() | |
| 56 | - $(this).remove() | |
| 55 | + $(@).next('table').show() | |
| 56 | + $(@).remove() | |
| 57 | 57 | |
| 58 | 58 | # Note markdown preview |
| 59 | 59 | $(document).on 'click', '#preview-link', (e) -> |
| 60 | - $('#preview-note').text('Loading...') | |
| 60 | + $('#preview-note').text 'Loading...' | |
| 61 | 61 | |
| 62 | - previewLinkText = if $(this).text() == 'Preview' then 'Edit' else 'Preview' | |
| 63 | - $(this).text(previewLinkText) | |
| 62 | + previewLinkText = if $(@).text() is 'Preview' then 'Edit' else 'Preview' | |
| 63 | + $(@).text previewLinkText | |
| 64 | 64 | |
| 65 | 65 | note = $('#note_note').val() |
| 66 | 66 | |
| 67 | - if note.trim().length == 0 | |
| 68 | - $('#preview-note').text("Nothing to preview.") | |
| 67 | + if note.trim().length is 0 | |
| 68 | + $('#preview-note').text 'Nothing to preview.' | |
| 69 | 69 | else |
| 70 | - $.post $(this).attr('href'), {note: note}, (data) -> | |
| 70 | + $.post $(@).attr('href'), {note: note}, (data) -> | |
| 71 | 71 | $('#preview-note').html(data) |
| 72 | 72 | |
| 73 | 73 | $('#preview-note, #note_note').toggle() |
| ... | ... | @@ -79,14 +79,14 @@ $ -> |
| 79 | 79 | $.fn.extend chosen: (options) -> |
| 80 | 80 | default_options = search_contains: "true" |
| 81 | 81 | $.extend default_options, options |
| 82 | - _chosen.apply this, [default_options] | |
| 82 | + _chosen.apply @, [default_options] | |
| 83 | 83 | |
| 84 | 84 | # Disable an element and add the 'disabled' Bootstrap class |
| 85 | 85 | $.fn.extend disable: -> |
| 86 | - $(this).attr('disabled', 'disabled').addClass('disabled') | |
| 86 | + $(@).attr('disabled', 'disabled').addClass('disabled') | |
| 87 | 87 | |
| 88 | 88 | # Enable an element and remove the 'disabled' Bootstrap class |
| 89 | 89 | $.fn.extend enable: -> |
| 90 | - $(this).removeAttr('disabled').removeClass('disabled') | |
| 90 | + $(@).removeAttr('disabled').removeClass('disabled') | |
| 91 | 91 | |
| 92 | 92 | )(jQuery) | ... | ... |