This commit is contained in:
Hannes Mannerheim 2016-09-07 17:56:29 +02:00
parent b9877c8b93
commit 3d447e43e8
10 changed files with 87 additions and 8 deletions

View File

@ -374,6 +374,21 @@ class QvitterAction extends ApiAction
print 'window.qvitterProfilePrefs = false;'; print 'window.qvitterProfilePrefs = false;';
} }
} }
// keyboard shortcuts can be disabled
$disable_keyboard_shortcuts = false;
if($logged_in_user) {
try {
$disable_keyboard_shortcuts = Profile_prefs::getData($logged_in_user->getProfile(), 'qvitter', 'disable_keyboard_shortcuts');
if($disable_keyboard_shortcuts == '1' || $disable_keyboard_shortcuts == 1) {
$disable_keyboard_shortcuts = true;
}
} catch (Exception $e) {
//
}
}
print 'window.disableKeyboardShortcuts = '.var_export($disable_keyboard_shortcuts, true).';';
?> ?>
// available language files and their last update time // available language files and their last update time
@ -485,8 +500,16 @@ class QvitterAction extends ApiAction
<li class="fullwidth dropdown-divider"></li> <li class="fullwidth dropdown-divider"></li>
<li class="fullwidth"><a id="faq-link"></a></li> <li class="fullwidth"><a id="faq-link"></a></li>
<li class="fullwidth"><a id="tou-link"></a></li> <li class="fullwidth"><a id="tou-link"></a></li>
<li class="fullwidth"><a id="shortcuts-link"></a></li> <?php
<?php if (common_config('invite', 'enabled') && !common_config('site', 'closed')) { ?>
if($disable_keyboard_shortcuts === true) {
print '<li class="fullwidth"><a id="shortcuts-link" class="disabled" href="'.$instanceurl.'settings/qvitter"></a></li>';
}
else {
print '<li class="fullwidth"><a id="shortcuts-link"></a></li>';
}
if (common_config('invite', 'enabled') && !common_config('site', 'closed')) { ?>
<li class="fullwidth"><a id="invite-link" href="<?php print $instanceurl; ?>main/invite"></a></li> <li class="fullwidth"><a id="invite-link" href="<?php print $instanceurl; ?>main/invite"></a></li>
<?php } ?> <?php } ?>
<li class="fullwidth"><a id="classic-link"></a></li> <li class="fullwidth"><a id="classic-link"></a></li>

View File

@ -93,7 +93,13 @@ class QvitterSettingsAction extends SettingsAction
$hide_replies_prefs = false; $hide_replies_prefs = false;
} }
$form = new QvitterPrefsForm($this, $disable_enable_prefs, $hide_replies_prefs); try {
$disable_keyboard_shortcuts = Profile_prefs::getData($user->getProfile(), 'qvitter', 'disable_keyboard_shortcuts');
} catch (NoResultException $e) {
$disable_keyboard_shortcuts = false;
}
$form = new QvitterPrefsForm($this, $disable_enable_prefs, $hide_replies_prefs, $disable_keyboard_shortcuts);
$form->show(); $form->show();
} }
@ -119,6 +125,8 @@ class QvitterSettingsAction extends SettingsAction
Profile_prefs::setData($user->getProfile(), 'qvitter', 'hide_replies', $this->boolean('hide_replies')); Profile_prefs::setData($user->getProfile(), 'qvitter', 'hide_replies', $this->boolean('hide_replies'));
Profile_prefs::setData($user->getProfile(), 'qvitter', 'disable_keyboard_shortcuts', $this->boolean('disable_keyboard_shortcuts'));
// TRANS: Confirmation shown when user profile settings are saved. // TRANS: Confirmation shown when user profile settings are saved.
$this->showForm(_('Settings saved.'), true); $this->showForm(_('Settings saved.'), true);
@ -130,12 +138,14 @@ class QvitterPrefsForm extends Form
{ {
var $disable_enable_prefs; var $disable_enable_prefs;
var $hide_replies_prefs; var $hide_replies_prefs;
var $disable_keyboard_shortcuts;
function __construct($out, $disable_enable_prefs, $hide_replies_prefs) function __construct($out, $disable_enable_prefs, $hide_replies_prefs, $disable_keyboard_shortcuts)
{ {
parent::__construct($out); parent::__construct($out);
$this->disable_enable_prefs = $disable_enable_prefs; $this->disable_enable_prefs = $disable_enable_prefs;
$this->hide_replies_prefs = $hide_replies_prefs; $this->hide_replies_prefs = $hide_replies_prefs;
$this->disable_keyboard_shortcuts = $disable_keyboard_shortcuts;
} }
/** /**
@ -177,6 +187,16 @@ class QvitterPrefsForm extends Form
$this->elementEnd('li'); $this->elementEnd('li');
$this->elementEnd('ul'); $this->elementEnd('ul');
$this->elementEnd('fieldset'); $this->elementEnd('fieldset');
$this->elementStart('fieldset');
$this->elementStart('ul', 'form_data');
$this->elementStart('li');
$this->checkbox('disable_keyboard_shortcuts',
_('Disable keyboard shortcuts'),
(!empty($this->disable_keyboard_shortcuts)));
$this->elementEnd('li');
$this->elementEnd('ul');
$this->elementEnd('fieldset');
} }
/** /**

View File

@ -5343,6 +5343,10 @@ content:"\f068";
/* Keyboard shortcuts /* Keyboard shortcuts
-----------*/ -----------*/
#shortcuts-link.disabled {
color:#eee;
}
#popup-shortcuts #shortcuts-container { #popup-shortcuts #shortcuts-container {
padding:0 20px 20px 20px; padding:0 20px 20px 20px;
font-size:13px; font-size:13px;

View File

@ -11,3 +11,6 @@
<p><span class="shortcut">?</span><span class="description">Dieses Menu</span></p> <p><span class="shortcut">?</span><span class="description">Dieses Menu</span></p>
<p><span class="shortcut">j</span><span class="description">Nächster Queet</span></p> <p><span class="shortcut">j</span><span class="description">Nächster Queet</span></p>
<p><span class="shortcut">k</span><span class="description">Vorheriger Queet</span></p> <p><span class="shortcut">k</span><span class="description">Vorheriger Queet</span></p>
<h3>Disable</h3>
<p>Keyboard shortcuts can be turned off on <a href="{instance-url-with-protocol}settings/qvitter">the Qvitter settings page</a>.</p>

View File

@ -11,3 +11,6 @@
<p><span class="shortcut">?</span><span class="description">This menu</span></p> <p><span class="shortcut">?</span><span class="description">This menu</span></p>
<p><span class="shortcut">j</span><span class="description">Next Queet</span></p> <p><span class="shortcut">j</span><span class="description">Next Queet</span></p>
<p><span class="shortcut">k</span><span class="description">Previous Queet</span></p> <p><span class="shortcut">k</span><span class="description">Previous Queet</span></p>
<h3>Disable</h3>
<p>Keyboard shortcuts can be turned off on <a href="{instance-url-with-protocol}settings/qvitter">the Qvitter settings page</a>.</p>

View File

@ -11,3 +11,6 @@
<p><span class="shortcut">?</span><span class="description">Ica menuo</span></p> <p><span class="shortcut">?</span><span class="description">Ica menuo</span></p>
<p><span class="shortcut">j</span><span class="description">Sequanta mesajo</span></p> <p><span class="shortcut">j</span><span class="description">Sequanta mesajo</span></p>
<p><span class="shortcut">k</span><span class="description">Preiranta mesajo</span></p> <p><span class="shortcut">k</span><span class="description">Preiranta mesajo</span></p>
<h3>Disable</h3>
<p>Keyboard shortcuts can be turned off on <a href="{instance-url-with-protocol}settings/qvitter">the Qvitter settings page</a>.</p>

View File

@ -11,3 +11,6 @@
<p><span class="shortcut">?</span><span class="description">Denne menyen</span></p> <p><span class="shortcut">?</span><span class="description">Denne menyen</span></p>
<p><span class="shortcut">j</span><span class="description">Neste melding</span></p> <p><span class="shortcut">j</span><span class="description">Neste melding</span></p>
<p><span class="shortcut">k</span><span class="description">Forrige melding</span></p> <p><span class="shortcut">k</span><span class="description">Forrige melding</span></p>
<h3>Disable</h3>
<p>Keyboard shortcuts can be turned off on <a href="{instance-url-with-protocol}settings/qvitter">the Qvitter settings page</a>.</p>

View File

@ -11,3 +11,6 @@
<p><span class="shortcut">?</span><span class="description">Denna meny</span></p> <p><span class="shortcut">?</span><span class="description">Denna meny</span></p>
<p><span class="shortcut">j</span><span class="description">Nästa qvitter</span></p> <p><span class="shortcut">j</span><span class="description">Nästa qvitter</span></p>
<p><span class="shortcut">k</span><span class="description">Föregående qvitter</span></p> <p><span class="shortcut">k</span><span class="description">Föregående qvitter</span></p>
<h3>Stäng av</h3>
<p>Kortkommandon kan avaktiveras på <a href="{instance-url-with-protocol}settings/qvitter">Qvitters inställningssida</a>.</p>

View File

@ -47,11 +47,11 @@
· · · · · · · · · */ · · · · · · · · · */
function triggerClickOnInputFile(inputFile) { function triggerClickOnInputFile(inputFile) {
if(bowser != 'undefined') { if(typeof bowser != 'undefined') {
var bowserIntVersion = parseInt(bowser.version,10); var bowserIntVersion = parseInt(bowser.version,10);
if(bowser.chrome != 'undefined' && bowser.chrome === true && bowserIntVersion < 53 if(typeof bowser.chrome != 'undefined' && bowser.chrome === true && bowserIntVersion < 53
|| bowser.opera != 'undefined' && bowser.opera === true && bowserIntVersion < 39 || typeof bowser.opera != 'undefined' && bowser.opera === true && bowserIntVersion < 39
|| bowser.safari != 'undefined' && bowser.safari === true && bowserIntVersion < 9) { || typeof bowser.safari != 'undefined' && bowser.safari === true && bowserIntVersion < 9) {
var evt = document.createEvent("HTMLEvents"); var evt = document.createEvent("HTMLEvents");
evt.initEvent("click", true, true); evt.initEvent("click", true, true);
inputFile[0].dispatchEvent(evt); inputFile[0].dispatchEvent(evt);

View File

@ -3475,6 +3475,12 @@ $('body').on('keyup', 'div.queet-box-syntax', function(e) {
// menu // menu
$('#shortcuts-link').click(function(){ $('#shortcuts-link').click(function(){
// not if disabled
if($(this).hasClass('disabled')) {
return true;
}
popUpAction('popup-shortcuts', window.sL.keyboardShortcuts,'<div id="shortcuts-container"></div>',false); popUpAction('popup-shortcuts', window.sL.keyboardShortcuts,'<div id="shortcuts-container"></div>',false);
getDoc('shortcuts',function(html){ getDoc('shortcuts',function(html){
$('#shortcuts-container').html(html); $('#shortcuts-container').html(html);
@ -3484,6 +3490,12 @@ $('#shortcuts-link').click(function(){
// send queet on ctrl+enter or ⌘+enter (mac) // send queet on ctrl+enter or ⌘+enter (mac)
$('body').on('keydown','.queet-box-syntax',function (e) { $('body').on('keydown','.queet-box-syntax',function (e) {
// do nothing if shortcuts are disabled
if(window.disableKeyboardShortcuts === true) {
return true;
}
if((e.ctrlKey && e.which == 13) if((e.ctrlKey && e.which == 13)
|| (e.metaKey && e.which == 13)) { || (e.metaKey && e.which == 13)) {
e.preventDefault(); e.preventDefault();
@ -3495,6 +3507,11 @@ $('body').on('keydown','.queet-box-syntax',function (e) {
$('body').keyup(function (e) { $('body').keyup(function (e) {
// do nothing if shortcuts are disabled
if(window.disableKeyboardShortcuts === true) {
return true;
}
// only if queetbox is blurred, and we're not typing in any input, and we're logged in // only if queetbox is blurred, and we're not typing in any input, and we're logged in
if($('.queet-box-syntax[contenteditable="true"]').length == 0 if($('.queet-box-syntax[contenteditable="true"]').length == 0
&& $(":focus").length == 0 && $(":focus").length == 0