From 7d9abecbb6b2779e074616ca5563714d165bb49b Mon Sep 17 00:00:00 2001 From: Petr Vobornik Date: Mon, 28 May 2012 13:24:54 +0200 Subject: Text widget's dirty state is changed on various input methods on_value_changed event in textboxes and textareas was raised only on keyboard input. If user used different input method such as paste or browser undo and redo functions widget's on_value_changed event wasn't raised and so dirty state wasn't changed as well. This patch adds listener to text's and textarea's 'input' event. Input is a HTML 5 event which is raises on user initiated action. Some of user initiated actions : * Cut * Copy * Paste * Undo * Redo * Clear * Typing (like keyup) * Form AutoFill * User-invoked spellcheck corrections * Input from Input Method Editor It should be supported by all recent versions of major browsers. IE doesn't support it up to version 8. Listener for 'keyup' event was left in implementation for backward compatibility with older browsers. This may cause firing on_value_change twice but so far it shouldn't cause troubles. https://fedorahosted.org/freeipa/ticket/2647 --- install/ui/widget.js | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'install') diff --git a/install/ui/widget.js b/install/ui/widget.js index e7a837f99..d3dbd4c37 100644 --- a/install/ui/widget.js +++ b/install/ui/widget.js @@ -193,6 +193,11 @@ IPA.input_widget = function(spec) { } }; + that.on_value_changed = function() { + var value = that.save(); + that.value_changed.notify([value], that); + }; + that.focus_input = function() {}; that.set_deleted = function() {}; @@ -249,10 +254,14 @@ IPA.text_widget = function(spec) { size: that.size, title: that.tooltip, keyup: function() { - that.value_changed.notify([], that); + that.on_value_changed(); } }).appendTo(container); + that.input.bind('input', function() { + that.on_value_changed(); + }); + if (that.undo) { that.create_undo(container); } @@ -970,10 +979,14 @@ IPA.textarea_widget = function (spec) { disabled: that.disabled, title: that.tooltip, keyup: function() { - that.value_changed.notify([], that); + that.on_value_changed(); } }).appendTo(container); + that.input.bind('input', function() { + that.on_value_changed(); + }); + if (that.undo) { that.create_undo(container); } @@ -2128,6 +2141,10 @@ IPA.combobox_widget = function(spec) { } }).appendTo(that.input_container); + that.input.bind('input', function() { + that.input_field_changed.notify([], that); + }); + that.open_button = IPA.action_button({ name: 'open', icon: 'combobox-icon', -- cgit