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

View File

@ -1,6 +1,7 @@
<html>
<head>
<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">

5
gui.js
View File

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