From 09864f330e4da8f63b609a49632eec6d65c3b922 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Tue, 27 Nov 2012 19:58:00 +0100 Subject: [PATCH] Only show ajax spinner if data is sent. Disabled spinner for long polling. --- .../app/lib/app_post/ajax.js.coffee | 3 ++ .../app/lib/app_post/websocket.js.coffee | 28 +++++++++++++------ 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee index 5d33741d8..7e747fd33 100644 --- a/app/assets/javascripts/app/lib/app_post/ajax.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/ajax.js.coffee @@ -92,3 +92,6 @@ class _Singleton if @count == 0 $('.spinner').hide() + else if App.WebSocket.channel() is 'ajax' + if @count == 1 + $('.spinner').hide() diff --git a/app/assets/javascripts/app/lib/app_post/websocket.js.coffee b/app/assets/javascripts/app/lib/app_post/websocket.js.coffee index 5522590f6..d2c97a5c3 100644 --- a/app/assets/javascripts/app/lib/app_post/websocket.js.coffee +++ b/app/assets/javascripts/app/lib/app_post/websocket.js.coffee @@ -7,20 +7,29 @@ class App.WebSocket _instance ?= new _Singleton _instance - @close: (args) -> # Must be a static method - if _instance isnt undefined - _instance.close(args) + @close: (args) -> + if _instance == undefined + _instance ?= new _Singleton + _instance.close(args) - @send: (args) -> # Must be a static method - @connect() + @send: (args) -> + if _instance == undefined + _instance ?= new _Singleton _instance.send(args) - @auth: (args) -> # Must be a static method - @connect() + @auth: (args) -> + if _instance == undefined + _instance ?= new _Singleton _instance.auth(args) + @channel: -> + if _instance == undefined + _instance ?= new _Singleton + _instance.channel() + @_spool: -> - @connect() + if _instance == undefined + _instance ?= new _Singleton _instance.spool() # The actual Singleton class @@ -49,6 +58,9 @@ class _Singleton extends App.Controller # inital connect @connect() + channel: -> + @backend + send: (data) => if @backend is 'ajax' @_ajaxSend(data)