1
0
Fork 0
forked from 0x2620/oxjs
oxjs/source/Ox.UI/js/Core/Ox.LoadingIcon.js

65 lines
1.7 KiB
JavaScript
Raw Normal View History

2011-11-05 17:46:53 +01:00
'use strict';
2012-05-21 12:38:18 +02:00
2011-05-16 10:24:46 +02:00
/*@
Ox.LoadingIcon <f:Ox.Element> Loading Icon Element
() -> <f> Loading Icon Element
(options) -> <f> Loading Icon Element
(options, self) -> <f> Loading Icon Element
options <o> Options object
size <s|medium> size of icon
self <o> Shared private variable
@*/
2011-04-23 00:03:10 +02:00
Ox.LoadingIcon = function(options, self) {
2012-01-27 19:59:11 +05:30
self = self || {};
var that = Ox.Element('<img>', self)
2012-01-17 23:04:33 +05:30
.defaults({
size: 'medium'
})
.options(options || {})
.attr({
src: Ox.UI.getImageURL('symbolLoading')
})
.addClass(
'OxLoadingIcon Ox' + Ox.toTitleCase(self.options.size)
);
2012-01-27 19:59:11 +05:30
2011-05-16 10:24:46 +02:00
/*@
start <f> Start loading animation
() -> <f> Loading Icon Element
@*/
2011-04-23 00:03:10 +02:00
that.start = function() {
var deg = 0;
if (!self.loadingInterval) {
self.loadingInterval = setInterval(function() {
deg = (deg + 30) % 360;
that.css({
OTransform: 'rotate(' + deg + 'deg)',
MozTransform: 'rotate(' + deg + 'deg)',
WebkitTransform: 'rotate(' + deg + 'deg)'
});
}, 83)
that.animate({opacity: 1}, 250);
}
2011-04-23 00:03:10 +02:00
return that;
};
2012-01-27 19:59:11 +05:30
2011-05-16 10:24:46 +02:00
/*@
stop <f> Stop loading animation
() -> <f> Loading Icon Element
@*/
2011-04-23 00:03:10 +02:00
that.stop = function() {
var loadingInterval = self.loadingInterval;
if (self.loadingInterval) {
self.loadingInterval = void 0;
that.animate({opacity: 0}, 250, function() {
clearInterval(loadingInterval);
2012-01-17 23:04:33 +05:30
});
}
2011-04-23 00:03:10 +02:00
return that;
};
2012-01-27 19:59:11 +05:30
2011-04-23 00:03:10 +02:00
return that;
2012-01-27 19:59:11 +05:30
};