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
--
Petr Vobornik
From cb89604fb89bc46a87de89bd35188d0e45d44f60 Mon Sep 17 00:00:00 2001
From: Petr Vobornik <pvobo...@redhat.com>
Date: Mon, 28 May 2012 13:24:54 +0200
Subject: [PATCH] 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 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/install/ui/widget.js b/install/ui/widget.js
index d3efe499b1d77602ad7f246d123a193815f56ea1..5bc4447d46ded9ce162dbd5059c305d2231b3e22 100644
--- a/install/ui/widget.js
+++ b/install/ui/widget.js
@@ -174,6 +174,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() {};
 
@@ -230,10 +235,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);
         }
@@ -933,10 +942,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);
         }
@@ -2091,6 +2104,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',
-- 
1.7.7.6

_______________________________________________
Freeipa-devel mailing list
Freeipa-devel@redhat.com
https://www.redhat.com/mailman/listinfo/freeipa-devel

Reply via email to