Merge branch 'master' of github.com:jonobr1/GUI-DAT

This commit is contained in:
George Michael Brower 2011-01-23 17:21:44 -07:00
commit 506d5b597c
3 changed files with 27 additions and 31 deletions

View File

@ -1,5 +1,6 @@
var Controller = function() { var Controller = function() {
this.domElement; this.domElement = document.createElement('div');
this.domElement.setAttribute('class', 'guidat-controller');
this.object = arguments[0]; this.object = arguments[0];
this.propertyName = arguments[1]; this.propertyName = arguments[1];
@ -8,8 +9,10 @@ var Controller = function() {
var NumberController = function() { var NumberController = function() {
Controller.apply(this, arguments); Controller.apply(this, arguments);
this.isClicked = false;
var _this = this;
this.isClicked = false;
this.py = this.y = 0; this.py = this.y = 0;
// TODO pass argument to inc // TODO pass argument to inc
this.inc = 0; this.inc = 0;
@ -19,33 +22,28 @@ var NumberController = function() {
this.button.setAttribute('id', this.propertyName); this.button.setAttribute('id', this.propertyName);
this.button.setAttribute('type', 'number'); this.button.setAttribute('type', 'number');
this.button.setAttribute('value', this.y); this.button.setAttribute('value', this.y);
this.domElement.appendChild(this.button);
// return this.button; this.button.onmousedown = function(e) {
_this.isClicked = true;
this.addListeners = function() {
this.onmousedown = function(e) {
this.isClicked = true;
};
document.onmouseup = function(e) {
this.isClicked = false;
};
document.onmousemove = function(e) {
if(this.isClicked) {
this.py = this.y;
var dy = this.y - this.py;
if(dy > 0)
this.button.setAttribute('value', this.inc++);
else
this.button.setAttribute('value', this.inc--);
this.y = e.offsetY;
}
};
}; };
document.onmouseup = function(e) {
_this.isClicked = false;
};
document.onmousemove = function(e) {
this.__defineGetter__("button", function(){ if(_this.isClicked) {
return this.button;
}); _this.py = _this.y;
_this.y = e.offsetY;
var dy = _this.y - _this.py;
if(dy > 0)
_this.button.setAttribute('value', _this.inc++);
else
_this.button.setAttribute('value', _this.inc--);
}
};
}; };
NumberController.prototype = new Controller(); NumberController.prototype = new Controller();

View File

@ -1,6 +1,7 @@
<html> <html>
<head> <head>
<link href="gui.css" media="screen" rel="stylesheet" type="text/css" /> <link href="gui.css" media="screen" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="controller.js"></script>
<script type="text/javascript" src="gui.js"></script> <script type="text/javascript" src="gui.js"></script>
<script type="text/javascript"> <script type="text/javascript">

5
gui.js
View File

@ -57,11 +57,8 @@ var GUI = new function() {
var addHandlers = { var addHandlers = {
"number": function() { "number": function() {
var n = new NumberController(arguments); var n = new NumberController(arguments);
n.addListeners(); return n;
return n.button;
// return n.button;
}, },
"string": function() { "string": function() {