remove old code. comments.

This commit is contained in:
Christopher Jeffrey 2013-06-11 13:57:06 -05:00
parent 02c57a34ce
commit 94426dfd79

View File

@ -679,6 +679,7 @@ Element.prototype.__defineGetter__('width', function() {
}
if (!width) {
// Problem if .left is 'center', we can't calculate the width
// NOTE: This assume `right` cannot be a string.
var left = this.position.left;
if (typeof left === 'string') {
if (left === 'center') left = '50%';
@ -699,6 +700,7 @@ Element.prototype.__defineGetter__('height', function() {
}
if (!height) {
// Problem if .top is 'center', we can't calculate the height
// NOTE: This assume `bottom` cannot be a string.
var top = this.position.top;
if (typeof top === 'string') {
if (top === 'center') top = '50%';
@ -771,21 +773,12 @@ Element.prototype.__defineSetter__('left', function(val) {
if (val === 'center') val = '50%';
val = +val.slice(0, -1) / 100;
val = this.screen.width * val | 0;
//val = val - this.parent.left;
}
this.emit('move');
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
//var left = this.left;
//return this.options.left = this.position.left = left + (val - left);
return this.options.left = this.position.left = val - this.parent.left;
// More efficient clearing:
// if (left > this.left) {
// this.screen.clearRegion(this.left + this.width, left + this.width, this.top, this.top + this.height);
// } else {
// this.screen.clearRegion(left, this.left, this.top, this.top + this.height);
// }
});
Element.prototype.__defineSetter__('right', function(val) {
@ -793,14 +786,11 @@ Element.prototype.__defineSetter__('right', function(val) {
if (val === 'center') val = '50%';
val = +val.slice(0, -1) / 100;
val = this.screen.width * val | 0;
//val = val - this.parent.right;
}
this.emit('move');
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
//var right = this.right;
//return this.options.right = this.position.right = right + (val - right);
return this.options.right = this.position.right = val - this.parent.right;
});
@ -809,14 +799,11 @@ Element.prototype.__defineSetter__('top', function(val) {
if (val === 'center') val = '50%';
val = +val.slice(0, -1) / 100;
val = this.screen.height * val | 0;
//val = val - this.parent.top;
}
this.emit('move');
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
//var top = this.top;
//return this.options.top = this.position.top = top + (val - top);
return this.options.top = this.position.top = val - this.parent.top;
});
@ -825,20 +812,16 @@ Element.prototype.__defineSetter__('bottom', function(val) {
if (val === 'center') val = '50%';
val = +val.slice(0, -1) / 100;
val = this.screen.height * val | 0;
//val = val - this.parent.bottom;
}
this.emit('move');
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
//var bottom = this.bottom;
//return this.options.bottom = this.position.bottom = bottom + (val - bottom);
return this.options.bottom = this.position.bottom = val - this.parent.bottom;
});
Element.prototype.__defineSetter__('width', function(val) {
this.emit('resize');
//if (this.width < width)
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
@ -847,7 +830,6 @@ Element.prototype.__defineSetter__('width', function(val) {
Element.prototype.__defineSetter__('height', function(val) {
this.emit('resize');
//if (this.height < height)
this.screen.clearRegion(
this.left, this.left + this.width,
this.top, this.top + this.height);
@ -1440,15 +1422,13 @@ ScrollableText.prototype.scroll = function(offset) {
// and put it in a scrollable text box.
// TODO: Move this into a separate function and call it from the constructor
// and setContent.
// TODO: Possibly map _content into line lengths only to save memory.
if (this.content != null) {
w = this.width - (this.border ? 2 : 0);
if (this.__content == null) this.__content = this.content;
if (this._content == null || this._content.width !== w) {
this._content = wrapContent(this.__content, w);
this.content = this._content.join('\n');
// this._content = this._content.map(function(line) {
// return line.length;
// });
}
max = this._content.length - 1 - (this.height - (this.border ? 2 : 0));
@ -1468,24 +1448,15 @@ ScrollableText.prototype._setContent = ScrollableText.prototype.setContent;
ScrollableText.prototype.setContent = function(content) {
var ret = this._setContent(content);
// delete this.__content;
// delete this._content;
this.__content = this.content;
this._content = wrapContent(this.__content, this.width - (this.border ? 2 : 0));
this.content = this._content.join('\n');
// this._content = this._content.map(function(line) {
// return line.length;
// });
for (var i = 0, t = 0; i < this.childBase; i++) {
t += this._content[i].length + 1;
}
this.contentIndex = t;
// this.childBase = 0;
// this.contentIndex = 0;
if (this.parent) this.scroll(0);
return ret;