// Generated by github.com/steida/coffee2closure 0.1.12 goog.provide('spark.components.Loader'); goog.require('spark.core.View'); /** Loader component for Spark Framework. There are six different type of loader is implemented right now. Ported from tobiasahlin.com/spinkit Loader size can be configurable. With current implementation background color customization is missing. However you can customize your loader's background color using CSS. @constructor @export @param {Object=} options Class options. @param {*=} data Class data @extends {spark.core.View} */ spark.components.Loader = function(options, data) { var loaderEl, size; if (options == null) { options = {}; } options.type || (options.type = spark.components.Loader.LoaderTypes.CIRCLE); if (options.size == null) { options.size = 50; } options.template = this.getLoaderTemplate_(options); this.getCssClass(options, 'loader'); spark.components.Loader.superClass_.constructor.call(this, options, data); loaderEl = this.getElement().firstChild; size = "" + (this.getOptions().size) + "px"; loaderEl.style.width = size; loaderEl.style.height = size; } goog.inherits(spark.components.Loader, spark.core.View); /** Creates and returns loader template. @param {Object} options Options object for loader template @private */ spark.components.Loader.prototype.getLoaderTemplate_ = function(options) { var base, baseClass, configs, i, itemCount, type, _i, _ref; configs = spark.components.Loader.TemplateConfigs; type = spark.components.Loader.LoaderTypes[options.type]; if (!type) { throw new Error("Invalid loader type, " + options.type); } _ref = configs[type], baseClass = _ref.baseClass, itemCount = _ref.itemCount; base = "<div class=\"" + baseClass + "\">"; if (itemCount) { for (i = _i = 1; 1 <= itemCount ? _i <= itemCount : _i >= itemCount; i = 1 <= itemCount ? ++_i : --_i) { base += "<div class=\"item item" + i + "\"></div>"; } } return "" + base + "</div>"; }; /** Enum for template configs. @enum {Object} @export */ spark.components.Loader.TemplateConfigs = { 'CIRCLE': { baseClass: 'circle', itemCount: 3 }, 'SPINNER': { baseClass: 'spinner', itemCount: 12 }, 'BOUNCE': { baseClass: 'bounce', itemCount: 2 }, 'BAR': { baseClass: 'bar', itemCount: 5 }, 'PULSE': { baseClass: 'pulse' }, 'SQUARE': { baseClass: 'square' } }; /** Enum for loader types. @enum {string} @export */ spark.components.Loader.LoaderTypes = { 'CIRCLE': 'CIRCLE', 'SPINNER': 'SPINNER', 'PULSE': 'PULSE', 'SQUARE': 'SQUARE', 'BOUNCE': 'BOUNCE', 'BAR': 'BAR' };