diff options
author | Petr Vobornik <pvoborni@redhat.com> | 2012-09-03 16:43:13 +0200 |
---|---|---|
committer | Petr Vobornik <pvoborni@redhat.com> | 2012-09-06 17:36:29 +0200 |
commit | 835c7859c5c31807b9f46cf79462459238571f5e (patch) | |
tree | f6c338cc023d95bb80057de46b71fbddedfcd561 /install/ui/dialog.js | |
parent | a01fbb91e88918ead456ae85e886e975f29dc1be (diff) | |
download | freeipa-835c7859c5c31807b9f46cf79462459238571f5e.tar.gz freeipa-835c7859c5c31807b9f46cf79462459238571f5e.tar.xz freeipa-835c7859c5c31807b9f46cf79462459238571f5e.zip |
Update of confirmation of actions
This patch is changing confirmation of actions according to ticket #3035, see the ticket description.
It does following changes:
* Confirmation of update action was removed.
* Action lists resets to first action (which is usually a NOP: '-- select action --') on change of displayed entry.
* New confirmation dialog was implemented. It is used for action confirmation. It is used in IPA.action to replace the call of window.confirm(message). The old call is a modal window which blocks all JS functionality and has different style than other dialogs in Web UI. The new one has same design and doesn't block background operations.
https://fedorahosted.org/freeipa/ticket/3035
Diffstat (limited to 'install/ui/dialog.js')
-rw-r--r-- | install/ui/dialog.js | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/install/ui/dialog.js b/install/ui/dialog.js index 878218419..e3d3395f9 100644 --- a/install/ui/dialog.js +++ b/install/ui/dialog.js @@ -671,7 +671,7 @@ IPA.message_dialog = function(spec) { label: IPA.messages.buttons.ok, click: function() { that.close(); - if(that.on_ok) { + if (that.on_ok) { that.on_ok(); } } @@ -681,3 +681,79 @@ IPA.message_dialog = function(spec) { return that; }; + +IPA.confirm_dialog = function(spec) { + + spec = spec || {}; + spec.message = spec.message || IPA.messages.actions.confirm; + spec.title = spec.title || IPA.messages.dialogs.confirmation; + + var that = IPA.message_dialog(spec); + that.on_cancel = spec.on_cancel; + that.ok_label = spec.ok_label || IPA.messages.buttons.ok; + that.cancel_label = spec.cancel_label || IPA.messages.buttons.cancel; + that.confirmed = false; + that.confirm_on_enter = spec.confirm_on_enter !== undefined ? spec.confirm_on_enter : true; + + that.close = function() { + + that.dialog_close(); + $(document).unbind('keyup', that.on_key_up); + + if (that.confirmed) { + if (that.on_ok) { + that.on_ok(); + } + } else { + if (that.on_cancel) { + that.on_cancel(); + } + } + }; + + that.open = function(container) { + + that.confirmed = false; + that.dialog_open(container); + $(document).bind('keyup', that.on_key_up); + }; + + that.on_key_up = function(event) { + + if (event.keyCode === $.ui.keyCode.ENTER) { + event.preventDefault(); + that.confirmed = true; + that.close(); + } + }; + + that.create_buttons = function() { + + that.buttons.empty(); + + that.create_button({ + name: 'ok', + label: that.ok_label, + click: function() { + that.confirmed = true; + that.close(); + } + }); + + that.create_button({ + name: 'cancel', + label: that.cancel_label, + click: function() { + that.confirmed = false; + that.close(); + } + }); + }; + + that.create_buttons(); + + that.confirm_dialog_close = that.close; + that.confirm_dialog_open = that.open; + + return that; +}; |