src/core/panel.coffee in luca-0.9.2 vs src/core/panel.coffee in luca-0.9.4
- old
+ new
@@ -41,60 +41,17 @@
# upon submission, with a moving progress bar which will be
# hidden upon successful response
loadMask: false
loadMaskTemplate: ["components/load_mask"]
loadMaskTimeout: 3000
+
+ mixins:["LoadMaskable"]
initialize: (@options={})->
Luca.View::initialize.apply(@, arguments)
+
- _.bindAll @, "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 "enable:loadmask", @applyLoadMask
- @on "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()
-
applyStyles: (styles={},body=false)->
target = if body then @$bodyEl() else @$el
for setting, value of styles
@@ -135,9 +92,12 @@
@$el.wrap( wrapper )
$template: (template, variables={})->
@$html( Luca.template(template,variables) )
+ $empty: ()->
+ @$bodyEl().empty()
+
$html: (content)->
@$bodyEl().html( content )
$append: (content)->
@$bodyEl().append(content)
\ No newline at end of file