60 lines
No EOL
1.5 KiB
JavaScript
60 lines
No EOL
1.5 KiB
JavaScript
'use strict';
|
|
|
|
Ox.LoadingScreen = function(options, self) {
|
|
|
|
self = self || {};
|
|
var that = Ox.Element({}, self)
|
|
.defaults({
|
|
height: 256,
|
|
size: 32,
|
|
text: '',
|
|
width: 256
|
|
})
|
|
.options(options || {})
|
|
.update({
|
|
height: setSizes,
|
|
text: function() {
|
|
self.$text && self.$text.html(self.options.text);
|
|
},
|
|
width: setSizes
|
|
})
|
|
.addClass('OxLoadingScreen');
|
|
|
|
self.$box = $('<div>').appendTo(that);
|
|
|
|
setSizes();
|
|
|
|
$('<img>')
|
|
.attr({src: Ox.UI.getImageURL('symbolLoadingAnimated')})
|
|
.css({
|
|
width: self.options.size + 'px',
|
|
height: self.options.size + 'px'
|
|
})
|
|
.appendTo(self.$box);
|
|
|
|
if (self.options.text) {
|
|
self.$text = $('<div>')
|
|
.html(self.options.text)
|
|
.appendTo(self.$box);
|
|
}
|
|
|
|
function setSizes() {
|
|
var css = {
|
|
width: (self.options.text ? 256 : self.options.size),
|
|
height: self.options.size + (self.options.text ? 24 : 0)
|
|
};
|
|
css.left = Math.floor((self.options.width - css.width) / 2);
|
|
css.top = Math.floor((self.options.height - css.height) / 2);
|
|
css = Ox.map(css, function(value) {
|
|
return value + 'px';
|
|
});
|
|
that.css({
|
|
width: self.options.width + 'px',
|
|
height: self.options.height + 'px'
|
|
});
|
|
self.$box.css(css);
|
|
}
|
|
|
|
return that;
|
|
|
|
}; |