Sha256: 5709e42346ee02f84c5abdfc04720e27e1c49317bb2ee2d49696578e6d405384

Contents?: true

Size: 1.34 KB

Versions: 58

Compression:

Stored size: 1.34 KB

Contents

define ['view_hier_model'],(ViewHierModel)->

  TreeNodeView = Backbone.View.extend
    tagName: 'li'

    initialize: ->
      @model.on 'change:selected', _.bind( @refreshSelectedness, @ ) 

    $a: -> @$( '> a' )

    render: ->
      $childList = $("<ul/>")

      for child in @model.get('children')
        childView = new TreeNodeView( model: child )
        $childList.append( childView.render().el )

      @$el.append("<a>#{@model.getDesc()}</a>").append($childList)

      # have to do this by hand rather than with events property
      # because BB doesn't appear to let you bind to just immediate
      # descendants using e.g. "mouseenter > a"
      @$a()
        .on( 'mouseenter', => @model.setActive() )
        .on( 'mouseleave', => @model.unsetActive() )
        .on( 'click', => @model.trigger('selected',@model) )

      @refreshSelectedness()
      @

    refreshSelectedness: ->
      if @model.get('selected')
        @$a().addClass('selected')
      else
        @$a().removeClass('selected')





  TreeView = Backbone.View.extend
    el: $('#dom-dump > ul')

    initialize: ->
      @model = new ViewHierModel()
      @model.on 'change', _.bind(@refresh,@)

    refresh: ->
      @$el.empty()
      rootNodeView = new TreeNodeView(model: @model.get('root'))
      @$el.append( rootNodeView.render().el )
      @$el.treeview( collapsed: false )

Version data entries

58 entries across 41 versions & 5 rubygems

Version Path
sc-frank-ios-1.2.3 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-cucumber-1.2.5 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-cucumber-1.2.4.pre1 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.3.0.pre.2 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.bba52d7.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.e1e3ccb.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.1a856ca.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.3.0.pre.1 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.2.4 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.2.3.pre.2 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.2.3.pre.1 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
frank-pivotal-1.2.3 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.b7791c5.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.b7791c5.debug frank-skeleton/frank_static_resources.bundle/bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.b7791c5.debug frank-skeleton/frank_static_resources.bundle/bundle/bundle/js/tree_view.coffee
frank-cucumber-1.2.3 frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.3256dc1.debug frank-skeleton/frank_static_resources.bundle/bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.3256dc1.debug frank-skeleton/frank_static_resources.bundle/bundle/bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.3256dc1.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee
sc-frank-cucumber-1.2.1.9c95c03.debug frank-skeleton/frank_static_resources.bundle/js/tree_view.coffee