Skip to content

Commit

Permalink
fix text pane
Browse files Browse the repository at this point in the history
  • Loading branch information
hofmeister committed Mar 30, 2013
1 parent f989ebc commit 1e37d22
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions js/lib/widget.js
Expand Up @@ -1366,6 +1366,7 @@ $wb.ui.Html = $wb.Class('Html',{
$wb.ui.TextPane = $wb.Class('Html',{
__extends:[$wb.ui.Widget],
_text:'',
_maxLength:15000,
__construct:function() {
this.__super({
tmpl:function() {return '<pre class="wb-pane wb-textpane" />';}
Expand All @@ -1374,9 +1375,19 @@ $wb.ui.TextPane = $wb.Class('Html',{
prepend:function(text) {
this._text = text+"\n"+this._text;
this.elm().text(this._text);
this.elm().enableMarking();
},
append:function(text) {
this._text += text+"\n"
if (this._text.length > this._maxLength) {
var startOffset = this._text.length - this._maxLength;
var firstLineOffset = this._text.indexOf("\n",startOffset);
if (firstLineOffset < 0) {
firstLineOffset = Math.max(0,startOffset);
}
this._text = '....\n' + this._text.substr(firstLineOffset);
}

this.elm().text(this._text);
}
});
Expand Down

0 comments on commit 1e37d22

Please sign in to comment.