implement #61
This commit is contained in:
parent
b9877c8b93
commit
3d447e43e8
|
@ -374,6 +374,21 @@ class QvitterAction extends ApiAction
|
|||
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
|
||||
|
@ -485,8 +500,16 @@ class QvitterAction extends ApiAction
|
|||
<li class="fullwidth dropdown-divider"></li>
|
||||
<li class="fullwidth"><a id="faq-link"></a></li>
|
||||
<li class="fullwidth"><a id="tou-link"></a></li>
|
||||
<li class="fullwidth"><a id="shortcuts-link"></a></li>
|
||||
<?php if (common_config('invite', 'enabled') && !common_config('site', 'closed')) { ?>
|
||||
<?php
|
||||
|
||||
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>
|
||||
<?php } ?>
|
||||
<li class="fullwidth"><a id="classic-link"></a></li>
|
||||
|
|
|
@ -93,7 +93,13 @@ class QvitterSettingsAction extends SettingsAction
|
|||
$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();
|
||||
}
|
||||
|
@ -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', 'disable_keyboard_shortcuts', $this->boolean('disable_keyboard_shortcuts'));
|
||||
|
||||
// TRANS: Confirmation shown when user profile settings are saved.
|
||||
$this->showForm(_('Settings saved.'), true);
|
||||
|
||||
|
@ -130,12 +138,14 @@ class QvitterPrefsForm extends Form
|
|||
{
|
||||
var $disable_enable_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);
|
||||
$this->disable_enable_prefs = $disable_enable_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('ul');
|
||||
$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');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5343,6 +5343,10 @@ content:"\f068";
|
|||
/* Keyboard shortcuts
|
||||
-----------*/
|
||||
|
||||
#shortcuts-link.disabled {
|
||||
color:#eee;
|
||||
}
|
||||
|
||||
#popup-shortcuts #shortcuts-container {
|
||||
padding:0 20px 20px 20px;
|
||||
font-size:13px;
|
||||
|
|
|
@ -11,3 +11,6 @@
|
|||
<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">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>
|
||||
|
|
|
@ -11,3 +11,6 @@
|
|||
<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">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>
|
||||
|
|
|
@ -11,3 +11,6 @@
|
|||
<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">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>
|
||||
|
|
|
@ -11,3 +11,6 @@
|
|||
<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">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>
|
||||
|
|
|
@ -11,3 +11,6 @@
|
|||
<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">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>
|
||||
|
|
|
@ -47,11 +47,11 @@
|
|||
· · · · · · · · · */
|
||||
|
||||
function triggerClickOnInputFile(inputFile) {
|
||||
if(bowser != 'undefined') {
|
||||
if(typeof bowser != 'undefined') {
|
||||
var bowserIntVersion = parseInt(bowser.version,10);
|
||||
if(bowser.chrome != 'undefined' && bowser.chrome === true && bowserIntVersion < 53
|
||||
|| bowser.opera != 'undefined' && bowser.opera === true && bowserIntVersion < 39
|
||||
|| bowser.safari != 'undefined' && bowser.safari === true && bowserIntVersion < 9) {
|
||||
if(typeof bowser.chrome != 'undefined' && bowser.chrome === true && bowserIntVersion < 53
|
||||
|| typeof bowser.opera != 'undefined' && bowser.opera === true && bowserIntVersion < 39
|
||||
|| typeof bowser.safari != 'undefined' && bowser.safari === true && bowserIntVersion < 9) {
|
||||
var evt = document.createEvent("HTMLEvents");
|
||||
evt.initEvent("click", true, true);
|
||||
inputFile[0].dispatchEvent(evt);
|
||||
|
|
|
@ -3475,6 +3475,12 @@ $('body').on('keyup', 'div.queet-box-syntax', function(e) {
|
|||
|
||||
// menu
|
||||
$('#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);
|
||||
getDoc('shortcuts',function(html){
|
||||
$('#shortcuts-container').html(html);
|
||||
|
@ -3484,6 +3490,12 @@ $('#shortcuts-link').click(function(){
|
|||
|
||||
// send queet on ctrl+enter or ⌘+enter (mac)
|
||||
$('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)
|
||||
|| (e.metaKey && e.which == 13)) {
|
||||
e.preventDefault();
|
||||
|
@ -3495,6 +3507,11 @@ $('body').on('keydown','.queet-box-syntax',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
|
||||
if($('.queet-box-syntax[contenteditable="true"]').length == 0
|
||||
&& $(":focus").length == 0
|
||||
|
|
Loading…
Reference in New Issue
Block a user