Focus on all modal types by default [MAILPOET-724]
This commit is contained in:
@ -63,7 +63,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
overlay: false,
|
||||
|
||||
// focus upon displaying
|
||||
focus: false,
|
||||
focus: true,
|
||||
|
||||
// highlighted elements
|
||||
highlight: null,
|
||||
@ -91,11 +91,11 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
'</div>',
|
||||
panel: '<div id="mailpoet_panel">'+
|
||||
'<a href="javascript:;" id="mailpoet_modal_close"></a>'+
|
||||
'<div class="mailpoet_panel_wrapper">'+
|
||||
'<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
||||
'<div class="mailpoet_panel_body clearfix"></div>'+
|
||||
'</div>'+
|
||||
'</div>',
|
||||
subpanel: '<div class="mailpoet_panel_wrapper">'+
|
||||
subpanel: '<div class="mailpoet_panel_wrapper" tabindex="-1">'+
|
||||
'<div class="mailpoet_panel_body clearfix"></div>'+
|
||||
'</div>'
|
||||
},
|
||||
@ -257,6 +257,11 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
// add sub panel content
|
||||
jQuery('.mailpoet_'+this.options.type+'_body').last()
|
||||
.html(this.subpanels[(this.subpanels.length - 1)].element);
|
||||
|
||||
// focus on sub panel
|
||||
if(this.options.focus) {
|
||||
this.focus();
|
||||
}
|
||||
} else if (this.options.element) {
|
||||
jQuery('.mailpoet_'+this.options.type+'_body').empty();
|
||||
jQuery('.mailpoet_'+this.options.type+'_body')
|
||||
@ -398,7 +403,7 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
}
|
||||
|
||||
if(this.options.focus) {
|
||||
jQuery('#mailpoet_'+this.options.type).focus();
|
||||
this.focus();
|
||||
}
|
||||
|
||||
// set popup as opened
|
||||
@ -411,6 +416,16 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
|
||||
return this;
|
||||
},
|
||||
focus: function() {
|
||||
if(this.options.type == 'popup') {
|
||||
jQuery('#mailpoet_'+this.options.type).focus();
|
||||
} else {
|
||||
// panel and subpanel
|
||||
jQuery('#mailpoet_'+this.options.type+' .mailpoet_panel_wrapper')
|
||||
.filter(':visible').focus();
|
||||
}
|
||||
return this;
|
||||
},
|
||||
highlightOn: function(element) {
|
||||
jQuery(element).addClass('mailpoet_modal_highlight');
|
||||
return this;
|
||||
@ -450,8 +465,6 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
options.type = 'popup';
|
||||
// set overlay state
|
||||
options.overlay = options.overlay || true;
|
||||
// set focus state
|
||||
options.focus = options.focus || true;
|
||||
// initialize modal
|
||||
this.init(options);
|
||||
// open modal
|
||||
@ -594,6 +607,11 @@ define('modal', ['mailpoet', 'jquery'],
|
||||
// remove last subpanels
|
||||
this.subpanels.pop();
|
||||
|
||||
// focus on previous panel
|
||||
if(this.options.focus) {
|
||||
this.focus();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user