mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 23:16:52 +08:00
FIxed #109 - modal auto focus and unfocus on close
This commit is contained in:
@ -3,13 +3,30 @@
|
||||
|
||||
ionic.views.Modal = ionic.views.View.inherit({
|
||||
initialize: function(opts) {
|
||||
opts = ionic.extend({
|
||||
focusFirstInput: true
|
||||
}, opts);
|
||||
|
||||
ionic.extend(this, opts);
|
||||
|
||||
this.el = opts.el;
|
||||
},
|
||||
show: function() {
|
||||
this.el.classList.add('active');
|
||||
|
||||
if(this.focusFirstInput) {
|
||||
var input = this.el.querySelector('input, textarea');
|
||||
input && input.focus && input.focus();
|
||||
}
|
||||
},
|
||||
hide: function() {
|
||||
this.el.classList.remove('active');
|
||||
|
||||
// Unfocus all elements
|
||||
var inputs = this.el.querySelectorAll('input, textarea');
|
||||
for(var i = 0; i < inputs.length; i++) {
|
||||
inputs[i].blur && inputs[i].blur();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user