dat.gui/controller.js

35 lines
1002 B
JavaScript
Raw Normal View History

var Controller = function() {
2011-01-24 02:59:29 +00:00
this.setName = function(n) {
2011-01-24 02:59:29 +00:00
this.propertyNameElement.innerHTML = n;
}
this.setValue = function(n) {
this.object[this.propertyName] = n;
}
this.getValue = function() {
return this.object[this.propertyName];
}
2011-01-24 21:45:31 +00:00
this.makeUnselectable = function(elem) {
elem.onselectstart = function() { return false; };
elem.style.MozUserSelect = "none";
elem.style.KhtmlUserSelect = "none";
elem.unselectable = "on";
}
2011-01-24 00:15:04 +00:00
this.domElement = document.createElement('div');
2011-01-24 02:59:29 +00:00
this.domElement.setAttribute('class', 'guidat-controller ' + this.type);
2011-01-24 00:50:14 +00:00
this.object = arguments[0];
this.propertyName = arguments[1];
2011-01-24 00:50:14 +00:00
this.propertyNameElement = document.createElement('span');
this.propertyNameElement.setAttribute('class', 'guidat-propertyname');
this.setName(this.propertyName);
2011-01-24 00:50:14 +00:00
this.domElement.appendChild(this.propertyNameElement);
2011-01-24 02:59:29 +00:00
2011-01-24 21:45:31 +00:00
this.makeUnselectable(this.domElement);
2011-01-24 02:59:29 +00:00
};