pandora/static/js/loadingIcon.js

64 lines
1.4 KiB
JavaScript
Raw Normal View History

2013-07-28 09:52:13 +00:00
'use strict';
pandora.ui.loadingIcon = function() {
2013-07-29 09:47:25 +00:00
var self = {},
that = Ox.LoadingIcon({
2013-08-08 13:03:10 +00:00
tooltip: Ox._('Click to reload {0}', [pandora.site.site.name])
2013-07-29 09:47:25 +00:00
}, self)
.attr({
2014-09-26 12:30:51 +00:00
src: Ox.UI.getImageURL('symbolRedo')
2013-07-29 09:47:25 +00:00
})
.css(getCSS('stop'))
.bindEvent({
anyclick: function() {
pandora.$ui.appPanel.reload();
}
});
that.superStart = that.start;
that.superStop = that.stop;
that.start = function() {
if (!self.loadingInterval) {
that.css(getCSS('start'))
.attr({
2014-09-26 12:30:51 +00:00
src: Ox.UI.getImageURL('symbolLoading')
2013-07-29 09:47:25 +00:00
});
that.superStart();
}
};
that.stop = function() {
if (self.loadingInterval) {
that.superStop(function() {
2013-07-29 10:30:37 +00:00
that.css(getCSS('stop'))
.attr({
2014-09-26 12:30:51 +00:00
src: Ox.UI.getImageURL('symbolRedo')
2013-07-29 10:30:37 +00:00
});
2013-07-29 09:47:25 +00:00
});
}
};
2013-07-28 09:52:13 +00:00
that.update = function(requests) {
2013-07-29 09:47:25 +00:00
that[requests ? 'start' : 'stop']();
2013-07-28 09:52:13 +00:00
};
2013-07-29 09:47:25 +00:00
function getCSS(action) {
return action == 'start' ? {
width: '16px',
height: '16px',
margin: 0,
opacity: 0
} : {
width: '10px',
height: '10px',
margin: '3px',
opacity: 1
};
}
2013-07-28 09:52:13 +00:00
return that;
};