mirror of
https://github.com/dataarts/dat.gui.git
synced 2024-12-12 04:08:27 +00:00
3b4f6e3944
Included prettify.js in the repo so people checking the demo localy doesn't need the internets. Changed way of hidding the panel (controllerContainer.style.height rather than this.domElement.stylemarginTop).
57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
var Controller = function() {
|
|
|
|
var onChange = null;
|
|
|
|
this.parent = null;
|
|
|
|
this.setName = function(n) {
|
|
this.propertyNameElement.innerHTML = n;
|
|
return this;
|
|
}
|
|
|
|
this.setValue = function(n) {
|
|
this.object[this.propertyName] = n;
|
|
if (onChange != null) {
|
|
onChange.call(this, n);
|
|
}
|
|
return this;
|
|
}
|
|
|
|
this.getValue = function() {
|
|
return this.object[this.propertyName];
|
|
}
|
|
|
|
this.onChange = function(fnc) {
|
|
onChange = fnc;
|
|
return this;
|
|
}
|
|
|
|
this.makeUnselectable = function(elem) {
|
|
elem.onselectstart = function() { return false; };
|
|
elem.style.MozUserSelect = "none";
|
|
elem.style.KhtmlUserSelect = "none";
|
|
elem.unselectable = "on";
|
|
}
|
|
|
|
this.makeSelectable = function(elem) {
|
|
elem.onselectstart = function() { };
|
|
elem.style.MozUserSelect = "auto";
|
|
elem.style.KhtmlUserSelect = "auto";
|
|
elem.unselectable = "off";
|
|
}
|
|
|
|
this.domElement = document.createElement('div');
|
|
this.domElement.setAttribute('class', 'guidat-controller ' + this.type);
|
|
|
|
this.object = arguments[0];
|
|
this.propertyName = arguments[1];
|
|
|
|
this.propertyNameElement = document.createElement('span');
|
|
this.propertyNameElement.setAttribute('class', 'guidat-propertyname');
|
|
this.setName(this.propertyName);
|
|
this.domElement.appendChild(this.propertyNameElement);
|
|
|
|
this.makeUnselectable(this.domElement);
|
|
|
|
};
|