diff --git a/static/js/loadingIcon.js b/static/js/loadingIcon.js new file mode 100644 index 000000000..141c0ba70 --- /dev/null +++ b/static/js/loadingIcon.js @@ -0,0 +1,15 @@ +'use strict'; + +pandora.ui.loadingIcon = function() { + + var that = Ox.LoadingIcon({size: 'medium'}); + + that.update = function(requests) { + that[requests ? 'start' : 'stop']().options({ + tooltip: (requests || 'No') + ' request' + (requests == 1 ? '' : 's') + }); + }; + + return that; + +}; diff --git a/static/js/mainMenu.js b/static/js/mainMenu.js index 5e67c69df..a234a0404 100644 --- a/static/js/mainMenu.js +++ b/static/js/mainMenu.js @@ -9,9 +9,7 @@ pandora.ui.mainMenu = function() { fullscreenState = Ox.Fullscreen.getState(), that = Ox.MainMenu({ extras: [ - pandora.$ui.loadingIcon = Ox.LoadingIcon({ - size: 'medium' - }) + pandora.$ui.loadingIcon = pandora.ui.loadingIcon() ], id: 'mainMenu', menus: [].concat( diff --git a/static/js/pandora.js b/static/js/pandora.js index 52d393851..113a91da9 100644 --- a/static/js/pandora.js +++ b/static/js/pandora.js @@ -366,17 +366,11 @@ appPanel function initPandoraApp() { pandora.$ui.appPanel = pandora.ui.appPanel().display(); - Ox.Request.requests() && pandora.$ui.loadingIcon.start(); + pandora.$ui.loadingIcon.update(Ox.Request.requests()); Ox.Request.bindEvent({ error: pandora.ui.errorDialog, request: function(data) { - pandora.$ui.loadingIcon[ - data.requests ? 'start' : 'stop' - ]().options({ - tooltip: (data.requests || 'No') - + ' request' - + (data.requests == 1 ? '' : 's') - }); + pandora.$ui.loadingIcon.update(data.requests); } }); pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;