Skip to content

Commit

Permalink
Draw metric divs via unify rather than a list comprehension so that e…
Browse files Browse the repository at this point in the history
…vent handlers have easy access to metric data.
  • Loading branch information
lynaghk committed Aug 18, 2012
1 parent 3f23551 commit c9c54c9
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/cljs/vcfvis/controls.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,31 @@


;;;;;;;;;;;;;;;;;;;;;;;
;;Metrics radio buttons
;;Metrics mini-hists
(bind! "#metrics"
(let [shared (set (map :id @core/!shared-metrics))]
(let [shared (set (map :id @core/!shared-metrics))
selected-metric @core/!metric
metrics (for [[id m] (@core/!context :metrics)]
(assoc m :id id
:selected? (= m selected-metric)
:shared? (contains? shared id)))]
[:div#metrics
(doall (for [[id {:keys [desc] :as metric}] (@core/!context :metrics)]
(unify metrics
(fn [{:keys [id desc selected? shared?]}]
[:div.metric {:id (str "metric-" id)
:class (str (when (= @core/!metric metric) "selected")
" " (when-not (shared id) "disabled"))}
:class (str (when selected? "selected")
" " (when-not shared? "disabled"))}
[:h2 id]
[:span desc]
[:div.mini-hist]]))]))

(event/on "#metrics" :click core/select-metric!)






;;;;;;;;;;;;;;;;;;;;;;;
;;TODO: download button

Expand Down

0 comments on commit c9c54c9

Please sign in to comment.