mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-06 22:29:44 +08:00
FIxed #109 - modal auto focus and unfocus on close
This commit is contained in:
4
dist/js/ionic-angular.js
vendored
4
dist/js/ionic-angular.js
vendored
@ -167,11 +167,15 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
$animate.enter(element, angular.element($document[0].body));
|
||||
}
|
||||
$animate.addClass(element, this.animation);
|
||||
|
||||
ionic.views.Modal.prototype.show.call(this);
|
||||
},
|
||||
// Hide the modal
|
||||
hide: function() {
|
||||
var element = angular.element(this.el);
|
||||
$animate.removeClass(element, this.animation);
|
||||
|
||||
ionic.views.Modal.prototype.hide.call(this);
|
||||
},
|
||||
|
||||
// Remove and destroy the modal scope
|
||||
|
||||
17
dist/js/ionic.js
vendored
17
dist/js/ionic.js
vendored
@ -3318,13 +3318,30 @@ window.ionic = {
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
4
js/ext/angular/src/service/ionicModal.js
vendored
4
js/ext/angular/src/service/ionicModal.js
vendored
@ -14,11 +14,15 @@ angular.module('ionic.service.modal', ['ionic.service.templateLoad'])
|
||||
$animate.enter(element, angular.element($document[0].body));
|
||||
}
|
||||
$animate.addClass(element, this.animation);
|
||||
|
||||
ionic.views.Modal.prototype.show.call(this);
|
||||
},
|
||||
// Hide the modal
|
||||
hide: function() {
|
||||
var element = angular.element(this.el);
|
||||
$animate.removeClass(element, this.animation);
|
||||
|
||||
ionic.views.Modal.prototype.hide.call(this);
|
||||
},
|
||||
|
||||
// Remove and destroy the modal scope
|
||||
|
||||
@ -25,6 +25,7 @@
|
||||
</header>
|
||||
<content>
|
||||
Realllllyyy long content
|
||||
<input type="text">
|
||||
<div style="height: 2000px; background-color: red;"></div>
|
||||
</content>
|
||||
</div>
|
||||
|
||||
@ -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