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