Add focus methods

This commit is contained in:
Ludovic Stephan 2017-04-04 20:18:53 -03:00
parent 9c559d9ec3
commit 3b9affb3f3

View file

@ -19,6 +19,17 @@ class KPsulManager {
} }
} }
focus() {
if (this.checkout_manager.is_empty())
this.checkout_manager.focus();
else if (this.account_manager.is_empty())
this.account_manager.focus();
else
this.article_manager.focus();
return this;
}
} }
@ -267,11 +278,7 @@ class CheckoutManager {
(data) => this._update_on_success(data), (data) => this._update_on_success(data),
() => this.reset_data()); () => this.reset_data());
if (kpsul.account_manager.is_empty()) { kpsul.focus();
kpsul.account_manager.focus();
} else {
kpsul.article_manager.focus();
}
} }
_update_on_success(data) { _update_on_success(data) {
@ -336,6 +343,11 @@ class CheckoutManager {
this.display(); this.display();
} }
focus() {
this.selection.focus();
return this;
}
} }
@ -368,6 +380,11 @@ class CheckoutSelection {
reset() { reset() {
this._$input.find('option:first').prop('selected', true); this._$input.find('option:first').prop('selected', true);
} }
focus() {
this._$input.focus();
return this;
}
} }
class ArticleManager { class ArticleManager {