Add this to the bottom of /admin/themes/default/includes/standard.js
Code: Select all
function getCharTab(e) {
// IE and Firefox
// tab => 9
// return => 13
// up => 38
// down => 40
if (window.event)
{
e = window.event;
}
var charCode = (!e.which || e.which == 0) ? e.keyCode : e.which;
if (charCode != 9) return true;
addTab();
return false;
}
function addTab()
{
var theField = document.getElementById('content');
var theInsert = "\t";
// Is this a Windows user? If so, add tags around selection
if (document.selection)
{
theField.focus();
document.selection.createRange().text = theInsert;
theField.blur();
theField.focus();
}
else if ( ! isNaN(theField.selectionEnd))
{
var selLength = theField.textLength;
var selStart = theField.selectionStart;
var selEnd = theField.selectionEnd;
if (selEnd <= 2)
selEnd = selLength;
var s1 = (theField.value).substring(0,selStart);
var s2 = (theField.value).substring(selStart, selEnd)
var s3 = (theField.value).substring(selEnd, selLength);
var newStart = selStart + theInsert.length;
theField.value = s1 + theInsert + s3;
theField.focus();
theField.selectionStart = newStart;
theField.selectionEnd = newStart;
}
}
document.onkeypress = getCharTab;
Code: Select all
<textarea class="pagebigtextarea" name="css_text" cols="" rows="" id="content"><?php echo $css_text?></textarea>
Forgot to add that the javascript is from http://www.pmachine.com/developers/blog/1048/