mirror of
https://github.com/PrivateBin/PrivateBin.git
synced 2026-04-19 21:58:08 -04:00
prototype keyboard trap toggle
- needs updating all language files - replicate changes to all templates
This commit is contained in:
+24
-5
@@ -2092,7 +2092,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
{
|
||||
I18n._(
|
||||
$('#pastelink'),
|
||||
'Your paste is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit [Ctrl]+[c] to copy)</span>',
|
||||
'Your paste is <a id="pasteurl" href="%s">%s</a> <span id="copyhint">(Hit <kbd>Ctrl</kbd>+<kbd>c</kbd> to copy)</span>',
|
||||
url, url
|
||||
);
|
||||
// save newly created element
|
||||
@@ -2394,7 +2394,8 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
$messagePreview,
|
||||
$messagePreviewParent,
|
||||
$message,
|
||||
isPreview = false;
|
||||
isPreview = false,
|
||||
isTabSupported = true;
|
||||
|
||||
/**
|
||||
* support input of tab character
|
||||
@@ -2406,9 +2407,14 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
*/
|
||||
function supportTabs(event)
|
||||
{
|
||||
const keyCode = event.keyCode || event.which;
|
||||
// support disabling tab support using [Esc] and [Ctrl]+[m]
|
||||
if (event.key === 'Escape' || (event.ctrlKey && event.key === 'm')) {
|
||||
toggleTabSupport();
|
||||
document.getElementById('message-tab').checked = isTabSupported;
|
||||
event.preventDefault();
|
||||
}
|
||||
// tab was pressed
|
||||
if (keyCode === 9) {
|
||||
else if (isTabSupported && event.key === 'Tab') {
|
||||
// get caret position & selection
|
||||
const val = this.value,
|
||||
start = this.selectionStart,
|
||||
@@ -2422,6 +2428,18 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* toggle tab support in message textarea
|
||||
*
|
||||
* @name Editor.toggleTabSupport
|
||||
* @private
|
||||
* @function
|
||||
*/
|
||||
function toggleTabSupport()
|
||||
{
|
||||
isTabSupported = !isTabSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
* view the Editor tab
|
||||
*
|
||||
@@ -2599,6 +2617,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
|
||||
// bind events
|
||||
$message.keydown(supportTabs);
|
||||
$('#message-tab').change(toggleTabSupport);
|
||||
|
||||
// bind click events to tab switchers (a), and save parents (li)
|
||||
$messageEdit = $('#messageedit').click(viewEditor);
|
||||
@@ -3768,7 +3787,7 @@ jQuery.PrivateBin = (function($, RawDeflate) {
|
||||
|
||||
/**
|
||||
* Clear the password input in the top navigation
|
||||
*
|
||||
*
|
||||
* @name TopNav.clearPasswordInput
|
||||
* @function
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user