Sha256: eeef02c12837356745d35d341cb9437c4fa37f4e5839e83b40ad8a8d2de9a5e5

Contents?: true

Size: 1.17 KB

Versions: 33

Compression:

Stored size: 1.17 KB

Contents

class Quby.Models.Panel extends Backbone.Model
  defaults: ->
    questions: new Quby.Collections.Questions
    view: new Quby.Views.PanelView(model: @)
    panelId: null
    initedShowsHidesCalled: false
  initialize: ->
    panelId = @get('panelId')
    viewSelector = "##{panelId}"
    if panelId
      @get("view").setElement $(viewSelector)[0]

    hidePanelTrigger = ->
      @trigger "hidePanelCheck"
    @get("questions").on "hide", hidePanelTrigger, @
    @get("questions").on "unhide", hidePanelTrigger, @
    @get("questions").on "show", hidePanelTrigger, @
    @get("questions").on "unshow", hidePanelTrigger, @
    @on "hidePanelCheck", @hidePanelCheck, @
    @trigger "hidePanelCheck"

  initShowsHides: (allQuestions) ->
    unless @get 'initedShowsHidesCalled'
      @set('initedShowsHidesCalled', true)
      @get("questions").each (question) ->
        options = question.get("options")
        options.each (option) ->
          option.initShowsHides allQuestions

  hidePanelCheck: ->
    if @hidden()
      if !@get("questions").noneVisible()
        @trigger "unhide"
    else
      if @get("questions").noneVisible()
        @trigger "hide"

  hidden: ->
    @get("view").hidden()

Version data entries

33 entries across 33 versions & 1 rubygems

Version Path
quby-5.6.5 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.6.3 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.6.2 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.6.1 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.6.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.5.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.4.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.3.1 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.3.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.2.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.1.3 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.1.2 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.1.1 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.1.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.5 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.4 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.3 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.2 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.1 app/assets/javascripts/quby/backbone/models/panel.js.coffee
quby-5.0.0 app/assets/javascripts/quby/backbone/models/panel.js.coffee