implemented tab input support from #40, thank you azlux!

pull/17/head
El RIDO 2015-10-15 22:06:01 +02:00
parent 2e3bacb699
commit 87b41a0c3d
2 changed files with 28 additions and 2 deletions

View File

@ -8,6 +8,7 @@ MrKooky - HTML5 markup, CSS cleanup
Simon Rupf - MVC refactoring, configuration, i18n and unit tests
Hexalyse - Password protection
Viktor Stanchev - File upload support
azlux - Tab character input support
Translations:
Hexalyse - French

View File

@ -1073,7 +1073,7 @@ $(function() {
},
/**
* Reload the page
* Reload the page.
*
* @param Event event
*/
@ -1084,7 +1084,7 @@ $(function() {
},
/**
* Return raw text
* Return raw text.
*
* @param Event event
*/
@ -1120,6 +1120,30 @@ $(function() {
$('.navbar-toggle').click();
},
/**
* Support input of tab character.
*
* @param Event event
*/
supportTabs: function(event)
{
var keyCode = event.keyCode || event.which;
// tab was pressed
if (keyCode === 9)
{
// prevent the textarea to lose focus
event.preventDefault();
// get caret position & selection
var val = this.value,
start = this.selectionStart,
end = this.selectionEnd;
// set textarea value to: text before caret + tab + text after caret
this.value = val.substring(0, start) + '\t' + val.substring(end);
// put caret at right position again
this.selectionStart = this.selectionEnd = start + 1;
}
},
/**
* Create a new paste.
*/
@ -1203,6 +1227,7 @@ $(function() {
this.rawTextButton.click($.proxy(this.rawText, this));
this.fileRemoveButton.click($.proxy(this.removeAttachment, this));
$('.reloadlink').click($.proxy(this.reloadPage, this));
this.message.keydown(this.supportTabs);
},
/**