Only show ajax spinner if data is sent. Disabled spinner for long polling.

This commit is contained in:
Martin Edenhofer 2012-11-27 19:58:00 +01:00
parent 5ac6c06dc2
commit 09864f330e
2 changed files with 23 additions and 8 deletions

View file

@ -92,3 +92,6 @@ class _Singleton
if @count == 0 if @count == 0
$('.spinner').hide() $('.spinner').hide()
else if App.WebSocket.channel() is 'ajax'
if @count == 1
$('.spinner').hide()

View file

@ -7,20 +7,29 @@ class App.WebSocket
_instance ?= new _Singleton _instance ?= new _Singleton
_instance _instance
@close: (args) -> # Must be a static method @close: (args) ->
if _instance isnt undefined if _instance == undefined
_instance.close(args) _instance ?= new _Singleton
_instance.close(args)
@send: (args) -> # Must be a static method @send: (args) ->
@connect() if _instance == undefined
_instance ?= new _Singleton
_instance.send(args) _instance.send(args)
@auth: (args) -> # Must be a static method @auth: (args) ->
@connect() if _instance == undefined
_instance ?= new _Singleton
_instance.auth(args) _instance.auth(args)
@channel: ->
if _instance == undefined
_instance ?= new _Singleton
_instance.channel()
@_spool: -> @_spool: ->
@connect() if _instance == undefined
_instance ?= new _Singleton
_instance.spool() _instance.spool()
# The actual Singleton class # The actual Singleton class
@ -49,6 +58,9 @@ class _Singleton extends App.Controller
# inital connect # inital connect
@connect() @connect()
channel: ->
@backend
send: (data) => send: (data) =>
if @backend is 'ajax' if @backend is 'ajax'
@_ajaxSend(data) @_ajaxSend(data)