Skip to content
This repository has been archived by the owner on Jul 9, 2020. It is now read-only.

Commit

Permalink
[config-UI] Preview: wait when keyboard shortcut is used
Browse files Browse the repository at this point in the history
Give some extra time to jsonschema-editor to update the corresponding
raw config value. This avoids outdated previews.
  • Loading branch information
nemesifier committed Apr 13, 2016
1 parent d061f0c commit 751e24e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ django.jQuery(function($) {
inner = overlay.find('.inner'),
preview_url = $('.previewlink').attr('data-url');
var openPreview = function() {
// gather data to send in POST
var data = {
'name': $('#id_name').val(),
'backend': $('#id_backend').val(),
Expand Down Expand Up @@ -43,9 +44,13 @@ django.jQuery(function($) {
openPreview();
});
$(document).keyup(function(e) {
// CTRL+SHIFT+P
// ALT+P
if (e.altKey && e.which == 80) {
openPreview();
// unfocus any active input before proceeding
$(document.activeElement).trigger('blur');
// wait for JSON editor to update the
// corresonding raw value before proceding
setTimeout(openPreview, 15);
}
// ESC
else if (!e.ctrlKey && e.which == 27) {
Expand Down

0 comments on commit 751e24e

Please sign in to comment.