Sha256: 06fb16b14fc47c0a802dbb4b05a56ba698a941a95accdd9b3e70570f1200eaef

Contents?: true

Size: 1.34 KB

Versions: 2

Compression:

Stored size: 1.34 KB

Contents

Luca.modules.LoadMaskable = 
  _included: (self, module)->
    _.bindAll self, "applyLoadMask", "disableLoadMask"

    if @loadMask is true
      @defer ()=>
        @$el.addClass('with-mask')

        if @$('.load-mask').length is 0
          @loadMaskTarget().prepend Luca.template(@loadMaskTemplate, @)
          @$('.load-mask').hide()
      .until("after:render")

      @on (@loadmaskEnableEvent || "enable:loadmask"), @applyLoadMask
      @on (@loadmaskDisableEvent || "disable:loadmask"), @applyLoadMask

  loadMaskTarget: ()->
    if @loadMaskEl? then @$(@loadMaskEl) else @$bodyEl()

  disableLoadMask: ()->
    @$('.load-mask .bar').css("width","100%")
    @$('.load-mask').hide()
    clearInterval(@loadMaskInterval)

  enableLoadMask: ()->
    @$('.load-mask').show().find('.bar').css("width","0%")
    maxWidth = @$('.load-mask .progress').width()
    if maxWidth < 20 and (maxWidth = @$el.width()) < 20
      maxWidth = @$el.parent().width()

    @loadMaskInterval = setInterval ()=>
      currentWidth = @$('.load-mask .bar').width()
      newWidth = currentWidth + 12
      @$('.load-mask .bar').css('width', newWidth)
    , 200

    return unless @loadMaskTimeout?

    _.delay ()=>
      @disableLoadMask()
    , @loadMaskTimeout

  applyLoadMask: ()->
    if @$('.load-mask').is(":visible")
      @disableLoadMask()
    else
      @enableLoadMask()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
luca-0.9.42 src/modules/load_mask.coffee
luca-0.9.4 src/modules/load_mask.coffee