Fixed focus on show modal

This commit is contained in:
benweet 2014-08-31 18:24:35 +01:00
parent ab49793420
commit 3381f17330
2 changed files with 15 additions and 15 deletions

View File

@ -378,7 +378,7 @@ define([
// Other initialization that are not prioritary
eventMgr.addListener("onReady", function() {
$('.modal').on('shown.bs.modal', function() {
$(document.body).on('shown.bs.modal', '.modal', function() {
var $elt = $(this);
setTimeout(function() {
// When modal opens focus on the first button
@ -388,12 +388,12 @@ define([
// Or on the first input if any
$elt.find("input:enabled:visible:first").focus();
}, 50);
}).on('hidden.bs.modal', function() {
}).on('hidden.bs.modal', '.modal', function() {
// Focus on the editor when modal is gone
editor.focus();
// Revert to current theme when settings modal is closed
applyTheme(window.theme);
}).keyup(function(e) {
}).on('keyup', '.modal', function(e) {
// Handle enter key in modals
if(e.which == 13 && !$(e.target).is("textarea")) {
$(this).find(".modal-footer a:last").click();

View File

@ -387,6 +387,16 @@ define([
layout.init = function() {
var isModalShown = false;
$(document.body).on('show.bs.modal', '.modal', function() {
// Close panel if open
menuPanel.toggle(false);
documentPanel.toggle(false);
isModalShown = true;
}).on('hidden.bs.modal', '.modal', function() {
isModalShown = false;
});
// Tweak the body element
(function(bodyStyle) {
bodyStyle.position = 'absolute';
@ -464,7 +474,7 @@ define([
// Focus on editor when document panel is closed
documentPanel.$elt.on('hidden.layout.toggle', function() {
editor.elt.focus();
isModalShown || editor.elt.focus();
});
menuPanel.isOpen = false;
@ -482,7 +492,7 @@ define([
// Focus on editor when menu panel is closed
menuPanel.$elt.on('hidden.layout.toggle', function() {
editor.elt.focus();
isModalShown || editor.elt.focus();
});
// Gesture
@ -558,16 +568,6 @@ define([
previewButtons.$elt.find('.btn-group').toggleClass('dropup', windowSize.height / 2 > -previewButtons.y);
});
var isModalShown = false;
$('.modal').on('show.bs.modal', function() {
// Close panel if open
menuPanel.toggle(false);
documentPanel.toggle(false);
isModalShown = true;
}).on('hidden.bs.modal', function() {
isModalShown = false;
});
// Configure Mousetrap
mousetrap.stopCallback = function() {
return menuPanel.isOpen || documentPanel.isOpen || isModalShown;