Sha256: 0aca1db17a1c0a4f3ee56f390db86d88287b494d3eb7727644646182146db0f5

Contents?: true

Size: 1.08 KB

Versions: 34

Compression:

Stored size: 1.08 KB

Contents

class Quby.Models.Flag extends Backbone.Model
  defaults: ->
    key: ""
    value: null
    hidesQuestions: new Quby.Collections.Questions
    showsQuestions: new Quby.Collections.Questions
    hidesQuestionsKeys: []
    showsQuestionsKeys: []
    triggerOn: true

  initShowsHides: (allQuestions)->
    showsQuestionsKeys = @get("showsQuestionsKeys")
    showsQuestions = allQuestions.select( (question) ->
      _.contains(showsQuestionsKeys, question.get("key"))
    )
    @get("showsQuestions").add(showsQuestions)

    hidesQuestionsKeys = @get("hidesQuestionsKeys")
    hidesQuestions = allQuestions.select( (question) ->
      _.contains(hidesQuestionsKeys, question.get("key"))
    )
    @get("hidesQuestions").add(hidesQuestions)
    @doHiding()

  doHiding: ->
    value = @get("value")
    if value == @get("triggerOn")
      @hideQuestions()
      @showQuestions()

  hideQuestions: ->
    flag = @
    @get("hidesQuestions").each (question) ->
      question.trigger "hide", flag
  showQuestions: ->
    flag = @
    @get("showsQuestions").each (question) ->
      question.trigger "show", flag

Version data entries

34 entries across 34 versions & 1 rubygems

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