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
This commit is contained in:
Petr Vobornik
2012-05-28 13:24:54 +02:00
parent 664d33cef6
commit 7d9abecbb6

View File

@@ -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',