updated h1 to be html5 and hooked to the gui

This commit is contained in:
jonobr1 2011-01-25 16:10:56 -08:00
commit aeb24b86ae
5 changed files with 40 additions and 17 deletions

View File

@ -8,8 +8,9 @@ var NumberController = function() {
var _this = this; var _this = this;
// If we simply click and release a number field, we want to highlight it. // If we simply click and release a number field, we want to highlight it.
// This variable keeps track of whether or not we've draggedNumberField. // This variable keeps track of whether or not we've dragged
var draggedNumberField = false; var draggedNumberField = false;
var clickedNumberField = false; var clickedNumberField = false;
var y = py = 0; var y = py = 0;
@ -106,9 +107,9 @@ var NumberController = function() {
val = parseFloat(val); val = parseFloat(val);
if (min && val <= min) { if (min != undefined && val <= min) {
val = min; val = min;
} else if (max && val >= max) { } else if (max != undefined && val >= max) {
val = max; val = max;
} }
_this.setValue(val); _this.setValue(val);

View File

@ -13,15 +13,17 @@ var Slider = function(numberController, min, max, step, initValue) {
var x, px; var x, px;
this.domElement = document.createElement('div'); this.domElement = document.createElement('div');
this.domElement.setAttribute('class', 'guidat-slider-bg');
this.fg = document.createElement('div'); this.fg = document.createElement('div');
this.domElement.setAttribute('class', 'guidat-slider-bg');
this.fg.setAttribute('class', 'guidat-slider-fg'); this.fg.setAttribute('class', 'guidat-slider-fg');
this.domElement.appendChild(this.fg); this.domElement.appendChild(this.fg);
var map = function(v, i1, i2, o1, o2) { var map = function(v, i1, i2, o1, o2) {
return o1 + (o2 - o1) * ((v - i1) / (i2 - i1)); var v = o1 + (o2 - o1) * ((v - i1) / (i2 - i1));
if (v < o1) v = o1;
else if (v > o2) v = o2;
return v;
} }
var findPos = function(obj) { var findPos = function(obj) {
@ -53,11 +55,15 @@ var Slider = function(numberController, min, max, step, initValue) {
this.domElement.addEventListener('mousedown', function(e) { this.domElement.addEventListener('mousedown', function(e) {
clicked = true; clicked = true;
x = px = e.pageX; x = px = e.pageX;
_this.domElement.setAttribute('class', 'guidat-slider-bg active');
_this.fg.setAttribute('class', 'guidat-slider-fg active');
onDrag(e); onDrag(e);
}, false); }, false);
this.domElement.addEventListener('mouseup', function(e) { document.addEventListener('mouseup', function(e) {
_this.domElement.setAttribute('class', 'guidat-slider-bg');
_this.fg.setAttribute('class', 'guidat-slider-fg');
clicked = false; clicked = false;
}, false); }, false);

BIN
demo/assets/favicon.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 169 B

32
gui.css
View File

@ -1,12 +1,12 @@
#guidat { #guidat {
color: #fff; color: #fff;
position: fixed; position: fixed;
width: 320px; width: 280px;
z-index: 200; z-index: 200;
opacity: 0.97; opacity: 0.97;
top: 0; top: 0;
left: 100%; left: 100%;
margin-left: -340px; margin-left: -300px;
background-color: #fff; background-color: #fff;
-moz-transition: margin-top .2s ease-out; -moz-transition: margin-top .2s ease-out;
-webkit-transition: margin-top .2s ease-out; -webkit-transition: margin-top .2s ease-out;
@ -51,6 +51,15 @@
background-color: #111; background-color: #111;
} }
.guidat-controller,
.guidat-controller input,
.guidat-slider-bg,
.guidat-slider-fg {
-moz-transition: background-color 0.15s linear;
-webkit-transition: background-color 0.15s linear;
transition: background-color 0.15s linear;
}
.guidat-controller.boolean:hover, .guidat-controller.boolean:hover,
.guidat-controller.function:hover { .guidat-controller.function:hover {
background-color: #000; background-color: #000;
@ -85,7 +94,7 @@
border: 0; border: 0;
color: #1ed36f; color: #1ed36f;
margin-right: 2px; margin-right: 2px;
width: 170px; width: 53%;
} }
.guidat-controller.boolean { .guidat-controller.boolean {
@ -103,10 +112,6 @@ width: 170px;
color: #00aeff; color: #00aeff;
} }
.guidat-controller.number input[type=slider] {
width: 50%;
}
#guidat .guidat-controller.boolean input { #guidat .guidat-controller.boolean input {
margin-top: 6px; margin-top: 6px;
margin-right: 2px; margin-right: 2px;
@ -127,10 +132,21 @@ width: 170px;
display: inline-block; display: inline-block;
} }
.guidat-slider-bg:hover,
.guidat-slider-bg.active {
background-color: #444;
}
.guidat-slider-bg:hover .guidat-slider-fg,
.guidat-slider-bg.active .guidat-slider-fg {
background-color: #52c8ff;
}
.guidat-slider-bg { .guidat-slider-bg {
background-color: #222; background-color: #222;
cursor: ew-resize; cursor: ew-resize;
width: 130px; width: 40%;
margin-top: 2px; margin-top: 2px;
float: right; float: right;
height: 21px; height: 21px;

View File

@ -45,7 +45,7 @@
GUI.add(controllableObject, "constrainedNum", -100, 100) GUI.add(controllableObject, "constrainedNum", -100, 100)
// Creates a slider with notches // Creates a slider with notches
GUI.add(controllableObject, "notchedNum", 0, 800, 20) GUI.add(controllableObject, "notchedNum", 0, 800, 100)
// Creates a text field // Creates a text field
GUI.add(controllableObject, "pageTitle"); GUI.add(controllableObject, "pageTitle");
@ -93,7 +93,7 @@ window.onload = function() {
GUI.add(controllableObject, "constrainedNum", -100, 100) GUI.add(controllableObject, "constrainedNum", -100, 100)
// Creates a slider with notches // Creates a slider with notches
GUI.add(controllableObject, "notchedNum", 0, 800, 20) GUI.add(controllableObject, "notchedNum", 0, 800, 100)
// Creates a text field // Creates a text field
GUI.add(controllableObject, "textProperty"); GUI.add(controllableObject, "textProperty");