mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
42 lines
1021 B
JavaScript
42 lines
1021 B
JavaScript
(function(ionic) {
|
|
'use strict';
|
|
|
|
ionic.views.Modal = ionic.views.View.inherit({
|
|
initialize: function(opts) {
|
|
opts = ionic.extend({
|
|
focusFirstInput: false,
|
|
unfocusOnHide: true,
|
|
focusFirstDelay: 600
|
|
}, opts);
|
|
|
|
ionic.extend(this, opts);
|
|
|
|
this.el = opts.el;
|
|
},
|
|
show: function() {
|
|
var self = this;
|
|
|
|
if(self.focusFirstInput) {
|
|
// Let any animations run first
|
|
window.setTimeout(function() {
|
|
var input = self.el.querySelector('input, textarea');
|
|
input && input.focus && input.focus();
|
|
}, self.focusFirstDelay);
|
|
}
|
|
},
|
|
hide: function() {
|
|
// Unfocus all elements
|
|
if(this.unfocusOnHide) {
|
|
var inputs = this.el.querySelectorAll('input, textarea');
|
|
// Let any animations run first
|
|
window.setTimeout(function() {
|
|
for(var i = 0; i < inputs.length; i++) {
|
|
inputs[i].blur && inputs[i].blur();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
});
|
|
|
|
})(ionic);
|