Make the loading spinner toggle more explicit

Occasionally the loading spinner would stay visible after the tab
finished loading. This change makes the toggle explicit so that it's
always shown on `beforeSend`, and always hidden on `complete`.

Plus a bonus semi-colon eradication! 💥
This commit is contained in:
Robert Speicher 2015-10-08 20:53:29 -04:00
parent 680b6d88a5
commit 29fe488b0c
1 changed files with 8 additions and 5 deletions

View File

@ -69,7 +69,7 @@ class @MergeRequestTabs
scrollToElement: (container) ->
if window.location.hash
top = $(container + " " + window.location.hash).offset().top
$('body').scrollTo(top);
$('body').scrollTo(top)
# Activate a tab based on the current action
activateTab: (action) ->
@ -139,13 +139,16 @@ class @MergeRequestTabs
@diffsLoaded = true
@scrollToElement(".diffs")
toggleLoading: ->
$('.mr-loading-status .loading').toggle()
# Show or hide the loading spinner
#
# status - Boolean, true to show, false to hide
toggleLoading: (status) ->
$('.mr-loading-status .loading').toggle(status)
_get: (options) ->
defaults = {
beforeSend: @toggleLoading
complete: @toggleLoading
beforeSend: => @toggleLoading(true)
complete: => @toggleLoading(false)
dataType: 'json'
type: 'GET'
}