add loadingIcon.js

This commit is contained in:
rolux 2013-07-28 09:52:13 +00:00
parent 716a5a57a9
commit aeed539fe7
3 changed files with 18 additions and 11 deletions

15
static/js/loadingIcon.js Normal file
View file

@ -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;
};

View file

@ -9,9 +9,7 @@ pandora.ui.mainMenu = function() {
fullscreenState = Ox.Fullscreen.getState(), fullscreenState = Ox.Fullscreen.getState(),
that = Ox.MainMenu({ that = Ox.MainMenu({
extras: [ extras: [
pandora.$ui.loadingIcon = Ox.LoadingIcon({ pandora.$ui.loadingIcon = pandora.ui.loadingIcon()
size: 'medium'
})
], ],
id: 'mainMenu', id: 'mainMenu',
menus: [].concat( menus: [].concat(

View file

@ -366,17 +366,11 @@ appPanel
function initPandoraApp() { function initPandoraApp() {
pandora.$ui.appPanel = pandora.ui.appPanel().display(); pandora.$ui.appPanel = pandora.ui.appPanel().display();
Ox.Request.requests() && pandora.$ui.loadingIcon.start(); pandora.$ui.loadingIcon.update(Ox.Request.requests());
Ox.Request.bindEvent({ Ox.Request.bindEvent({
error: pandora.ui.errorDialog, error: pandora.ui.errorDialog,
request: function(data) { request: function(data) {
pandora.$ui.loadingIcon[ pandora.$ui.loadingIcon.update(data.requests);
data.requests ? 'start' : 'stop'
]().options({
tooltip: (data.requests || 'No')
+ ' request'
+ (data.requests == 1 ? '' : 's')
});
} }
}); });
pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8; pandora.site.sectionButtonsWidth = pandora.$ui.sectionButtons.width() + 8;