Skip to content

Commit

Permalink
CTRL+S triggers save click
Browse files Browse the repository at this point in the history
See #924
  • Loading branch information
bloatware committed Sep 5, 2017
1 parent 6d170b1 commit 642a221
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
5 changes: 2 additions & 3 deletions textpattern/include/txp_article.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 15 additions & 3 deletions textpattern/textpattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
});

Expand Down

0 comments on commit 642a221

Please sign in to comment.