Add keyboard shortcut to all views with Save command

This commit is contained in:
Giuseppe Criscione 2018-09-06 18:40:52 +02:00
parent ef3f738bb3
commit bebc4244d8
7 changed files with 28 additions and 10 deletions

15
admin/assets/js/app.js Executable file → Normal file
View File

@ -20,6 +20,18 @@ var Formwork = {
new Formwork.Notification($this.attr('content'), $this.data('type'), $this.data('interval'));
$this.remove();
});
if ($('[data-command=save]').length > 0) {
$(document).keydown(function() {
if (!event.altKey && (event.ctrlKey || event.metaKey)) {
if (event.which == 83) { // ctrl/cmd + S
$('[data-command=save]').click();
return false;
}
}
});
}
}
};
@ -167,9 +179,6 @@ Formwork.Editor = function(id) {
case 73: // ctrl/cmd + I
$('[data-command=italic]', $toolbar).click();
return false;
case 83: // ctrl/cmd + S
$('[data-command=save]').click();
return false;
case 89: //ctrl/cmd + Y
case 90: // ctrl/cmd + Z
return false;

2
admin/assets/js/app.min.js vendored Executable file → Normal file

File diff suppressed because one or more lines are too long

View File

@ -85,9 +85,6 @@ Formwork.Editor = function(id) {
case 73: // ctrl/cmd + I
$('[data-command=italic]', $toolbar).click();
return false;
case 83: // ctrl/cmd + S
$('[data-command=save]').click();
return false;
case 89: //ctrl/cmd + Y
case 90: // ctrl/cmd + Z
return false;

View File

@ -20,6 +20,18 @@ var Formwork = {
new Formwork.Notification($this.attr('content'), $this.data('type'), $this.data('interval'));
$this.remove();
});
if ($('[data-command=save]').length > 0) {
$(document).keydown(function() {
if (!event.altKey && (event.ctrlKey || event.metaKey)) {
if (event.which == 83) { // ctrl/cmd + S
$('[data-command=save]').click();
return false;
}
}
});
}
}
};

View File

@ -5,6 +5,6 @@
<?= $fields ?>
<div class="separator-l"></div>
<input type="hidden" name="csrf-token" value="<?= $csrfToken ?>">
<button class="button-accent button-save button-right" type="submit" tabindex="4"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
<button class="button-accent button-save button-right" type="submit" tabindex="4" data-command="save"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
</form>
</div>

View File

@ -5,6 +5,6 @@
<?= $fields ?>
<div class="separator-l"></div>
<input type="hidden" name="csrf-token" value="<?= $csrfToken ?>">
<button class="button-accent button-save button-right" type="submit" tabindex="4"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
<button class="button-accent button-save button-right" type="submit" tabindex="4" data-command="save"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
</form>
</div>

View File

@ -68,7 +68,7 @@
</div>
</div>
<input type="hidden" name="csrf-token" value="<?= $csrfToken ?>">
<button class="button-accent button-save button-right" type="submit" tabindex="4"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
<button class="button-accent button-save button-right" type="submit" tabindex="4" data-command="save"><i class="i-check"></i> <?= $this->label('modal.action.save') ?></button>
</div>
</form>
</div>