Skip to contentSkip to conversation

bitbake: toaster: Use on input event for validation rather than keyup

PATCH Superseded Michael Wood 2 participants 3 messages Feb 6, 2015 – Feb 13, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: toaster: Use on input event for validation rather than keyup

Avoid using keyup event to trigger form validation as this won't fire for events such as pasting or autofill from the browser.

[YOCTO #7292]

---
 bitbake/lib/toaster/toastergui/static/js/importlayer.js   | 6 +++---
 bitbake/lib/toaster/toastergui/static/js/layerdetails.js  | 2 +-
 bitbake/lib/toaster/toastergui/templates/newproject.html  | 2 +-
 bitbake/lib/toaster/toastergui/templates/projectconf.html | 8 ++++----
 4 files changed, 9 insertions(+), 9 deletions(-)
bitbake/lib/toaster/toastergui/static/js/importlayer.js +3 -3
index d6e140f..e782bda 100644
@@ -245,15 +245,15 @@ function importLayerPageInit (ctx) {
       enable_import_btn(true);
   }
 
-  vcsURLInput.keyup(function() {
+  vcsURLInput.on('input', function() {
     check_form();
   });
 
-  gitRefInput.keyup(function() {
+  gitRefInput.on('input', function() {
     check_form();
   });
 
-  layerNameInput.keyup(function() {
+  layerNameInput.on('input', function() {
     if ($(this).val() && !validLayerName.test($(this).val())){
       layerNameCtrl.addClass("error")
       $("#invalid-layer-name-hint").show();
bitbake/lib/toaster/toastergui/static/js/layerdetails.js +1 -1
index 2793225..3e64d4a 100644
@@ -351,7 +351,7 @@ function layerDetailsPageInit (ctx) {
   });
 
   /* Disable the change button when we have no data in the input */
-  $("dl input, dl textarea").keyup(function() {
+  $("dl input, dl textarea").on("input",function() {
     if ($(this).val().length == 0)
       $(this).parent().children(".change-btn").attr("disabled", "disabled");
     else
bitbake/lib/toaster/toastergui/templates/newproject.html +1 -1
index 0265564..dcb6590 100644
@@ -72,7 +72,7 @@
             $('.btn-primary').attr('disabled', 'disabled');
 
             // enable submit button when all required fields are populated
-            $("input#new-project-name").keyup(function() {
+            $("input#new-project-name").on('input', function() {
                 if ($("input#new-project-name").val().length > 0 ){
                     $('.btn-primary').removeAttr('disabled');
                     $(".help-inline").css('visibility','hidden');
bitbake/lib/toaster/toastergui/templates/projectconf.html +4 -4
index edcad18..0d38a92 100644
@@ -269,7 +269,7 @@
                 });
             });
 
-            $(".js-new-config_var").keyup(function(){
+            $(".js-new-config_var").on('input', function(){
                 if ($(this).val().length == 0) {
                     $(".js-apply-change-config_var").attr("disabled","disabled");
                 }
@@ -386,7 +386,7 @@
                 });
             });
 
-            $("#new-distro").keyup(function(){
+            $("#new-distro").on('input', function(){
                 if ($(this).val().length == 0) {
                     $("#apply-change-distro").attr("disabled","disabled");
                 }
@@ -469,7 +469,7 @@
                 });
             });
 
-            $("#new-image_install").keyup(function(){
+            $("#new-image_install").on('input', function(){
                 if ($(this).val().length == 0) {
                     $("#apply-change-image_install").attr("disabled","disabled");
                 }
@@ -629,7 +629,7 @@
             });
 
             //activate / deactivate save added variable button
-            $("#variable, #value").keyup(function() {
+            $("#variable, #value").on('input', function() {
                 if ( $("#variable").val().length > 0  && $("#value").val().trim().length > 0 ) {
                     $(".save").removeAttr("disabled");
                 }
Signature · 1 line
2.1.0
#1 lore raw

PATCH v2 1/1 bitbake: toaster: Use on input event for validation rather than keyup

Avoid using keyup event to trigger form validation as this won't fire for events such as pasting or autofill from the browser.

[YOCTO #7292]

---
 bitbake/lib/toaster/toastergui/static/js/base.js          | 4 ++--
 bitbake/lib/toaster/toastergui/static/js/importlayer.js   | 6 +++---
 bitbake/lib/toaster/toastergui/static/js/layerdetails.js  | 2 +-
 bitbake/lib/toaster/toastergui/templates/newproject.html  | 2 +-
 bitbake/lib/toaster/toastergui/templates/projectconf.html | 8 ++++----
 5 files changed, 11 insertions(+), 11 deletions(-)
bitbake/lib/toaster/toastergui/static/js/base.js +2 -2
index 619ad28..0302b80 100644
@@ -71,13 +71,13 @@ function basePageInit (ctx) {
     /* Any typing in the input apart from enter key is going to invalidate
      * the value that has been set by selecting a suggestion from the typeahead
      */
-    newBuildProjectInput.keyup(function(event) {
+    newBuildProjectInput.on('input', function(event) {
         if (event.keyCode == 13)
           return;
         newBuildProjectSaveBtn.attr("disabled", "disabled");
     });
 
-    newBuildTargetInput.keyup(function() {
+    newBuildTargetInput.on('input', function() {
       if ($(this).val().length == 0)
         newBuildTargetBuildBtn.attr("disabled", "disabled");
       else
bitbake/lib/toaster/toastergui/static/js/importlayer.js +3 -3
index d6e140f..e782bda 100644
@@ -245,15 +245,15 @@ function importLayerPageInit (ctx) {
       enable_import_btn(true);
   }
 
-  vcsURLInput.keyup(function() {
+  vcsURLInput.on('input', function() {
     check_form();
   });
 
-  gitRefInput.keyup(function() {
+  gitRefInput.on('input', function() {
     check_form();
   });
 
-  layerNameInput.keyup(function() {
+  layerNameInput.on('input', function() {
     if ($(this).val() && !validLayerName.test($(this).val())){
       layerNameCtrl.addClass("error")
       $("#invalid-layer-name-hint").show();
bitbake/lib/toaster/toastergui/static/js/layerdetails.js +1 -1
index 2793225..3e64d4a 100644
@@ -351,7 +351,7 @@ function layerDetailsPageInit (ctx) {
   });
 
   /* Disable the change button when we have no data in the input */
-  $("dl input, dl textarea").keyup(function() {
+  $("dl input, dl textarea").on("input",function() {
     if ($(this).val().length == 0)
       $(this).parent().children(".change-btn").attr("disabled", "disabled");
     else
bitbake/lib/toaster/toastergui/templates/newproject.html +1 -1
index 0265564..dcb6590 100644
@@ -72,7 +72,7 @@
             $('.btn-primary').attr('disabled', 'disabled');
 
             // enable submit button when all required fields are populated
-            $("input#new-project-name").keyup(function() {
+            $("input#new-project-name").on('input', function() {
                 if ($("input#new-project-name").val().length > 0 ){
                     $('.btn-primary').removeAttr('disabled');
                     $(".help-inline").css('visibility','hidden');
bitbake/lib/toaster/toastergui/templates/projectconf.html +4 -4
index edcad18..0d38a92 100644
@@ -269,7 +269,7 @@
                 });
             });
 
-            $(".js-new-config_var").keyup(function(){
+            $(".js-new-config_var").on('input', function(){
                 if ($(this).val().length == 0) {
                     $(".js-apply-change-config_var").attr("disabled","disabled");
                 }
@@ -386,7 +386,7 @@
                 });
             });
 
-            $("#new-distro").keyup(function(){
+            $("#new-distro").on('input', function(){
                 if ($(this).val().length == 0) {
                     $("#apply-change-distro").attr("disabled","disabled");
                 }
@@ -469,7 +469,7 @@
                 });
             });
 
-            $("#new-image_install").keyup(function(){
+            $("#new-image_install").on('input', function(){
                 if ($(this).val().length == 0) {
                     $("#apply-change-image_install").attr("disabled","disabled");
                 }
@@ -629,7 +629,7 @@
             });
 
             //activate / deactivate save added variable button
-            $("#variable, #value").keyup(function() {
+            $("#variable, #value").on('input', function() {
                 if ( $("#variable").val().length > 0  && $("#value").val().trim().length > 0 ) {
                     $(".save").removeAttr("disabled");
                 }
Signature · 1 line
2.1.0
#2 lore raw

Taken for submission,

Thank you,
Alex

Quoted 142 lines · Michael Wood

Avoid using keyup event to trigger form validation as this won't fire for events such as pasting or autofill from the browser.

[YOCTO #7292]

---
 bitbake/lib/toaster/toastergui/static/js/base.js          | 4 ++--
 bitbake/lib/toaster/toastergui/static/js/importlayer.js   | 6 +++---
 bitbake/lib/toaster/toastergui/static/js/layerdetails.js  | 2 +-
 bitbake/lib/toaster/toastergui/templates/newproject.html  | 2 +-
 bitbake/lib/toaster/toastergui/templates/projectconf.html | 8 ++++----
 5 files changed, 11 insertions(+), 11 deletions(-)
bitbake/lib/toaster/toastergui/static/js/base.js +0 -0
index 619ad28..0302b80 100644
@@ -71,13 +71,13 @@ function basePageInit (ctx) {
     /* Any typing in the input apart from enter key is going to invalidate
      * the value that has been set by selecting a suggestion from the

typeahead

      */
bitbake/lib/toaster/toastergui/static/js/base.js +2 -2
-    newBuildProjectInput.keyup(function(event) {
+    newBuildProjectInput.on('input', function(event) {
         if (event.keyCode == 13)
           return;
         newBuildProjectSaveBtn.attr("disabled", "disabled");
     });
 
-    newBuildTargetInput.keyup(function() {
+    newBuildTargetInput.on('input', function() {
       if ($(this).val().length == 0)
         newBuildTargetBuildBtn.attr("disabled", "disabled");
       else
bitbake/lib/toaster/toastergui/static/js/importlayer.js +3 -3
index d6e140f..e782bda 100644
@@ -245,15 +245,15 @@ function importLayerPageInit (ctx) {
       enable_import_btn(true);
   }
 
-  vcsURLInput.keyup(function() {
+  vcsURLInput.on('input', function() {
     check_form();
   });
 
-  gitRefInput.keyup(function() {
+  gitRefInput.on('input', function() {
     check_form();
   });
 
-  layerNameInput.keyup(function() {
+  layerNameInput.on('input', function() {
     if ($(this).val() && !validLayerName.test($(this).val())){
       layerNameCtrl.addClass("error")
       $("#invalid-layer-name-hint").show();
bitbake/lib/toaster/toastergui/static/js/layerdetails.js +1 -1
index 2793225..3e64d4a 100644
@@ -351,7 +351,7 @@ function layerDetailsPageInit (ctx) {
   });
 
   /* Disable the change button when we have no data in the input */
-  $("dl input, dl textarea").keyup(function() {
+  $("dl input, dl textarea").on("input",function() {
     if ($(this).val().length == 0)
       $(this).parent().children(".change-btn").attr("disabled",
 "disabled");

else

bitbake/lib/toaster/toastergui/templates/newproject.html +1 -1
index 0265564..dcb6590 100644
@@ -72,7 +72,7 @@
             $('.btn-primary').attr('disabled', 'disabled');
 
             // enable submit button when all required fields are populated
-            $("input#new-project-name").keyup(function() {
+            $("input#new-project-name").on('input', function() {
                 if ($("input#new-project-name").val().length > 0 ){
                     $('.btn-primary').removeAttr('disabled');
                     $(".help-inline").css('visibility','hidden');
bitbake/lib/toaster/toastergui/templates/projectconf.html +1 -1
index edcad18..0d38a92 100644
@@ -269,7 +269,7 @@
                 });
             });
 
-            $(".js-new-config_var").keyup(function(){
+            $(".js-new-config_var").on('input', function(){
                 if ($(this).val().length == 0) {
 
 $(".js-apply-change-config_var").attr("disabled","disabled");
                 }
bitbake/lib/toaster/toastergui/templates/projectconf.html +2 -2
@@ -386,7 +386,7 @@
                 });
             });
 
-            $("#new-distro").keyup(function(){
+            $("#new-distro").on('input', function(){
                 if ($(this).val().length == 0) {
                     $("#apply-change-distro").attr("disabled","disabled");
                 }
@@ -469,7 +469,7 @@
                 });
             });
 
-            $("#new-image_install").keyup(function(){
+            $("#new-image_install").on('input', function(){
                 if ($(this).val().length == 0) {
 
 $("#apply-change-image_install").attr("disabled","disabled");
                 }
bitbake/lib/toaster/toastergui/templates/projectconf.html +1 -1
@@ -629,7 +629,7 @@
             });
 
             //activate / deactivate save added variable button
-            $("#variable, #value").keyup(function() {
+            $("#variable, #value").on('input', function() {
                 if ( $("#variable").val().length > 0  &&
 $("#value").val().trim().length > 0 ) {
                     $(".save").removeAttr("disabled");
                 }

--
2.1.0

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Alex Damian
Yocto Project
SSG / OTC