consolidating Value and ValueMeter

This commit is contained in:
Yotam Mann 2014-08-27 13:15:24 -04:00
parent a2166ccc91
commit 3361fbd87d
2 changed files with 9 additions and 27 deletions

View file

@ -166,7 +166,10 @@ GUI.Value = function(container, initial, label, units){
};
GUI.Value.prototype.setValue = function(val){
this.value.text(val.toFixed(2) + " " + this.units);
if (typeof val === "number"){
val = val.toFixed(2);
}
this.value.text(val + " " + this.units);
};
/**
@ -176,17 +179,12 @@ GUI.ValueMeter = function(container, meter, label){
this.meter = meter;
this.element = $("<div>", {"class" : "ValueMeter"})
.appendTo(container);
this.label = $("<div>", {"id" : "Label"})
.appendTo(this.element)
.text(label);
this.value = $("<div>", {"id" : "Value"})
.appendTo(this.element)
.text(0);
this.value = new GUI.Value(this.element, 0, label);
GUI.onupdate(this.update.bind(this));
};
GUI.ValueMeter.prototype.update = function(){
this.value.text(this.meter.getValue().toFixed(2));
this.value.setValue(this.meter.getValue().toFixed(2));
};
/**

View file

@ -187,29 +187,13 @@
.ValueMeter {
width: auto;
height: 20px;
border: 1px solid black;
display: inline-block;
line-height: 20px;
}
.ValueMeter #Label {
margin-left: 10px;
margin-right: 5px;
position: relative;
float: left;
.ValueMeter .Value {
width: 100%;
height: 100%;
font-size: 12px;
}
.ValueMeter #Value {
padding-right: 10px;
padding-left: 10px;
background-color: #8d8d8d;
color: white;
position: relative;
float: right;
height: 100%;
font-size: 12px;
}
/* LEVEL METER */
@ -272,6 +256,6 @@
top: 0px;
width: 100%;
left: 0px;
transition: height 0.1s;
/*transition: height 0.1s;*/
}