Last active
December 10, 2015 14:58
-
-
Save joshdover/4451013 to your computer and use it in GitHub Desktop.
GaugeView for Batman using JustGage
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Albedo.GaugeView extends Batman.View | |
@option 'title', 'max', 'min', 'value', 'better' | |
@::on 'appear', -> | |
@makeGauge() | |
makeGauge: -> | |
node = $(@get('node')) | |
node.attr 'id', @get('title') | |
# Add a new gauge using the prescribed options | |
new JustGage( | |
id: node.attr 'id' | |
value: Math.round(@get('value') * 10) / 10 | |
min: @get('min') || 0 | |
max: @get('max') || 100 | |
title: @get('title').replace '_', ' ' | |
gaugeWidthScale: 0.1 | |
startAnimationType: 'bounce' | |
startAnimationTime: 1500 | |
levelColors: @getColors() | |
) | |
getColors: -> | |
colors = ["#D60000", "#F57A00", "#FADA28", "#52D138"] | |
if @get('better') is 'min' | |
colors = colors.reverse() | |
return colors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.row | |
.span12 | |
.row.gauges | |
.span4{"data-foreach-gauge" => "gauges"} | |
%div{"data-view" => "GaugeView", "data-view-value" => "gauge.average", "data-view-title" => "gauge.title", "data-view-max" => "5", "data-view-min" => "1"} | |
.center | |
%a.btn.disabled | |
%span{"data-bind" => "gauge.count"} | |
responses |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment