'use strict'; /*@ Ox.LoadingIcon Loading Icon Element () -> Loading Icon Element (options) -> Loading Icon Element (options, self) -> Loading Icon Element options Options object size size of icon self Shared private variable @*/ Ox.LoadingIcon = function(options, self) { self = self || {}; var that = Ox.Element('', self) .defaults({ size: 'medium' }) .options(options || {}) .attr({ src: Ox.UI.getImageURL('symbolLoading') }) .addClass( 'OxLoadingIcon Ox' + Ox.toTitleCase(self.options.size) ); /*@ start Start loading animation () -> Loading Icon Element @*/ 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); } return that; }; /*@ stop Stop loading animation () -> Loading Icon Element @*/ that.stop = function() { var loadingInterval = self.loadingInterval; if (self.loadingInterval) { self.loadingInterval = void 0; that.animate({opacity: 0}, 250, function() { clearInterval(loadingInterval); }); } return that; }; return that; };