Adding the tt bbcode via the button is broken in Chrome Version 39.0.2171.71 m after a quote, see this example:
Although, is this intended to be done directly from the database class? You used $this, which implies that you're inside a class.
Read up on object-oriented programming, and you wouldn't have this question.
$this denotes the scope of
Marking $this above and clicking the button for the tt-bbcode results in it being inserted at seemingly random locations.