     _.compact _.flatten(links)
 
   similarity_exclusions = ->
-    $.makeArray( ScholarMapViz.$similarity_types.find('button:not(.active)') ).map (type) ->
-      $(type).data 'similarity-type'
+    $.makeArray( ScholarMapViz.$similarity_types.find('input[type="checkbox"]:not(:checked)') ).map (type) ->
+      type.value
 
   active_similarity_types = ->
     similarity_types().filter (type) ->

    d.name

  draw_link_by_buttons = (links) ->
    return if ScholarMapViz.$similarity_types.data('links-for') == @type

    ScholarMapViz.$similarity_types.css 'display', 'none'

    similarity_types = []
    for link in links
      for similarity in link.similarities
        similarity_types.push(similarity.type) unless similarity_types.indexOf(similarity.type) > -1

    ScholarMapViz.$similarity_types.html ''

    for type in similarity_types
      formatted_type = type[0].toUpperCase() + type[1..-1]
      ScholarMapViz.$similarity_types.data 'links-for', type
      ScholarMapViz.$similarity_types.append """
        <button class="btn btn-default btn-block active" data-similarity-type="#{type}">#{formatted_type}</button>
      """

    ScholarMapViz.$similarity_types.fadeIn 500

class ScholarMapViz.LinkTypeToggles

  constructor: ->
    ScholarMapViz.$similarity_types.on 'click', 'input[type="checkbox"]', ->
      $this = $(@)
      if ScholarMapViz.$similarity_types.find('input:checked').length == 1 && $this.prop('checked')
        $this.prop 'checked', !$this.prop('checked')
      else
        ScholarMapViz.current_map.link_weight_cache = {}
        ScholarMapViz.current_map.draw()

