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);
var _this = this;
this.isClicked = false; 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() { };
document.onmouseup = function(e) {
this.onmousedown = function(e) { _this.isClicked = false;
this.isClicked = true; };
}; document.onmousemove = function(e) {
document.onmouseup = function(e) {
this.isClicked = false; if(_this.isClicked) {
};
document.onmousemove = function(e) { _this.py = _this.y;
if(this.isClicked) { _this.y = e.offsetY;
this.py = this.y; var dy = _this.y - _this.py;
var dy = this.y - this.py;
if(dy > 0) if(dy > 0)
this.button.setAttribute('value', this.inc++); _this.button.setAttribute('value', _this.inc++);
else else
this.button.setAttribute('value', this.inc--); _this.button.setAttribute('value', _this.inc--);
this.y = e.offsetY; }
}
};
}; };
this.__defineGetter__("button", function(){
return this.button;
});
}; };
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() {