Skip to content
Permalink
Browse files

CTRL+S triggers save click

See #924
  • Loading branch information...
bloatware committed Sep 5, 2017
1 parent 6d170b1 commit 642a2214734ea442f1a5871aba704addc50ce1e6
Showing with 17 additions and 6 deletions.
  1. +2 −3 textpattern/include/txp_article.php
  2. +15 −3 textpattern/textpattern.js
@@ -727,12 +727,11 @@ function article_edit($message = '', $concurrent = false, $refresh_partials = fa
$response[] = '$("#article_form").addClass("published").removeClass("saved")';
}
$response = array_merge($response, updateVolatilePartials($partials));
if (!empty($GLOBALS['ID'])) {
$response[] = "if (typeof window.history.pushState == 'function') {history.replaceState({}, '', '?event=article&step=edit&ID=$ID')}";
$response[] = "if (typeof window.history.replaceState == 'function') {history.replaceState({}, '', '?event=article&ID=$ID')}";
}
$response = array_merge($response, updateVolatilePartials($partials));
send_script_response(join(";\n", $response));
// Bail out.
@@ -1479,13 +1479,25 @@ jQuery.fn.gTxt = function (opts, tags, escape) {

/**
* ESC button closes alert messages.
* CTRL+S triggers Save buttons click.
*
* @since 4.5.0
* @since 4.7
*/

$(document).keyup(function (e) {
if (e.keyCode == 27) {
$(document).keydown(function (e) {
var key = e.which || e.keyCode;

if (key === 27) {
$('.close').parent().remove();
} else if (key === 19 || (String.fromCharCode(key).toLowerCase() === 's' && (e.metaKey || e.ctrlKey)))
{
var obj = $('input.publish');

if (obj.length)
{
e.preventDefault();
obj.eq(0).click();
}
}
});

0 comments on commit 642a221

Please sign in to comment.
You can’t perform that action at this time.