summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorPetr Vobornik <pvoborni@redhat.com>2012-10-25 10:40:11 +0200
committerPetr Vobornik <pvoborni@redhat.com>2013-02-21 13:03:23 +0100
commit69185978eb8b9b206fda13af49e9885cc4a150b7 (patch)
tree0530e7845edc5319576ca7945040aaf8bb4cb5c1 /install
parent40a5d90cfe2077d847841ce46a859ca9ade97a61 (diff)
downloadfreeipa.git-69185978eb8b9b206fda13af49e9885cc4a150b7.tar.gz
freeipa.git-69185978eb8b9b206fda13af49e9885cc4a150b7.tar.xz
freeipa.git-69185978eb8b9b206fda13af49e9885cc4a150b7.zip
Confirm error dialog by enter
Refactored error dialog and unauthorized dialog to support confirm mixin. https://fedorahosted.org/freeipa/ticket/3200
Diffstat (limited to 'install')
-rw-r--r--install/ui/ipa.js90
1 files changed, 45 insertions, 45 deletions
diff --git a/install/ui/ipa.js b/install/ui/ipa.js
index a33fbfd5..fa26a2ad 100644
--- a/install/ui/ipa.js
+++ b/install/ui/ipa.js
@@ -1404,20 +1404,22 @@ IPA.dirty_dialog = function(spec) {
IPA.error_dialog = function(spec) {
+ spec = spec || {};
+
+ spec.id = spec.id || 'error_dialog';
+ spec.title = spec.error_thrown.name;
+
var that = IPA.dialog(spec);
- var init = function() {
- spec = spec || {};
+ IPA.confirm_mixin().apply(that);
+
+ that.xhr = spec.xhr || {};
+ that.text_status = spec.text_status || '';
+ that.error_thrown = spec.error_thrown || {};
+ that.command = spec.command;
+ that.errors = spec.errors;
+ that.visible_buttons = spec.visible_buttons || ['retry', 'cancel'];
- that.id = spec.id || 'error_dialog';
- that.xhr = spec.xhr || {};
- that.text_status = spec.text_status || '';
- that.error_thrown = spec.error_thrown || {};
- that.command = spec.command;
- that.title = spec.error_thrown.name;
- that.errors = spec.errors;
- that.visible_buttons = spec.visible_buttons || ['retry', 'cancel'];
- };
that.beautify_message = function(container, message) {
var lines = message.split(/\n/g);
@@ -1552,7 +1554,11 @@ IPA.error_dialog = function(spec) {
that.close();
};
- init();
+ that.on_confirm = function() {
+ if (that.visible_buttons.indexOf('retry') > -1) that.on_retry();
+ else that.on_ok();
+ };
+
that.create_buttons();
return that;
@@ -1710,9 +1716,7 @@ IPA.unauthorized_dialog = function(spec) {
};
that.session_expired_form = function() {
- that.session_form = $('<div\>', {
- keyup: that.on_login_keyup
- }).appendTo(that.container);
+ that.session_form = $('<div\>').appendTo(that.container);
that.login_error_box = $('<div/>', {
'class': 'error-box',
@@ -1753,7 +1757,6 @@ IPA.unauthorized_dialog = function(spec) {
that.create_reset_form = function() {
that.reset_form = $('<div\>', {
- keyup: that.on_reset_keyup,
style: 'display:none'
}).appendTo(that.container);
@@ -1851,6 +1854,7 @@ IPA.unauthorized_dialog = function(spec) {
that.show_session_form = function() {
+ that.current_view = 'session';
that.enable_fields(['username', 'password']);
that.session_form.css('display', 'block');
that.reset_form.css('display', 'none');
@@ -1860,6 +1864,7 @@ IPA.unauthorized_dialog = function(spec) {
that.show_reset_form = function() {
+ that.current_view = 'reset';
that.enable_fields(['new_password', 'verify_password']);
that.session_form.css('display', 'none');
that.reset_form.css('display', 'block');
@@ -1884,19 +1889,6 @@ IPA.unauthorized_dialog = function(spec) {
}
};
- that.on_login_keyup = function(event) {
-
- if (that.switching) {
- that.switching = false;
- return;
- }
-
- if (event.keyCode === 13) { // enter
- that.on_login();
- event.preventDefault();
- }
- };
-
that.on_cancel = function() {
that.username_widget.clear();
@@ -1946,22 +1938,6 @@ IPA.unauthorized_dialog = function(spec) {
that.on_retry();
};
- that.on_reset_keyup = function(event) {
-
- if (that.switching) {
- that.switching = false;
- return;
- }
-
- if (event.keyCode === 13) { // enter
- that.on_reset();
- event.preventDefault();
- } else if (event.keyCode === 27) { // escape
- that.on_cancel();
- event.preventDefault();
- }
- };
-
that.on_reset = function() {
if (!that.validate()) return;
@@ -2012,6 +1988,30 @@ IPA.unauthorized_dialog = function(spec) {
that.on_login();
};
+ //replaces confirm_mixin method
+ that.on_key_up = function(event) {
+
+ if (that.switching) {
+ that.switching = false;
+ return;
+ }
+
+ if (that.current_view === 'session') {
+ if (event.keyCode === $.ui.keyCode.ENTER && !this.test_ignore(event)) {
+ that.on_login();
+ event.preventDefault();
+ }
+ } else {
+ if (event.keyCode === $.ui.keyCode.ENTER && !this.test_ignore(event)) {
+ that.on_reset();
+ event.preventDefault();
+ } else if (event.keyCode === $.ui.ESCAPE) {
+ that.on_cancel();
+ event.preventDefault();
+ }
+ }
+ };
+
that.create_buttons();
return that;