Sha256: 89b1aa9368af0af4617206c793743e517c0b1a468068ddb3c4aec98a2806eb68
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
window.CMI or= {} class CMI.LoadingIndicator extends Backbone.View className: 'cmi-loading-indicator' initialize: (options = {}) -> @_options = _.extend(@_defaultOptions(), options) @render() render: -> @.$el.html(@_getInnerHtml()) if @_options.background == 'dark' @.$el.addClass('cmi-loading-indicator-background-dark') else if @_options.background == 'light' @.$el.addClass('cmi-loading-indicator-background-light') else if @_options.background? == true && @_options.background.length > 0 @.$el.addClass(@_options.background) @ domElement: -> @.$el fadeIn: -> @_attach() if @_isAttached() == false @.$el.addClass('cmi-loading-fade') @ fadeOut: -> @.$el.removeClass('cmi-loading-fade') _.delay($.proxy(@, '_detach'), 300) if @_options.detachAfterFadeOut @ # --------------------------------------------- # private methods _getInnerHtml: -> $('<div class="cmi-loading-indicator-inside"> <svg class="cmi-circular"> <circle class="cmi-path" cx="50" cy="50" fill="none" r="20" stroke-miterlimit="10" stroke-width="3"></circle> </svg> </div>') _detach: -> @.$el.detach() @_attached = false _attach: -> return if @_options.parent? == false @_options.parent.append(@.$el) @_attached = true _isAttached: -> @_attached or= false _defaultOptions: -> { background: null parent: null detachAfterFadeOut: true }
Version data entries
3 entries across 3 versions & 1 rubygems