From 77d51b77c28d0363f6f97422fdcf33788cac0dab Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Wed, 3 Feb 2016 01:39:35 +0500 Subject: [PATCH] fix join-group-import-key inputs via slight rewriting of importSecretKeypress(), move last one to js/interface_common.js --- js/interface_common.js | 12 ++++++++++++ js/twister_user.js | 17 ++--------------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 0f9a78c..28f135e 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -2096,6 +2096,18 @@ function inputEnterActivator(event) { .attr('disabled', elemEvent.val().trim() === ''); } +function importSecretKeypress(event) { // FIXME rename + var elemModule = $(event.target).closest('.module'); + var elemEnter = elemModule.find('.import-secret-key'); + var secretKey = elemModule.find('.secret-key-import').val(); + var peerAlias = elemModule.find('.username-import').val().toLowerCase(); + + if (secretKey.length === 52 && peerAlias.length) + $.MAL.enableButton(elemEnter); + else + $.MAL.disableButton(elemEnter); +} + function setTextcompleteOnEventTarget(event) { // cursor has not set yet and we need to wait 100ms to skip global click event setTimeout(setTextcompleteOnElement, 100, event.target, diff --git a/js/twister_user.js b/js/twister_user.js index c0b5b73..bf439f5 100644 --- a/js/twister_user.js +++ b/js/twister_user.js @@ -174,19 +174,6 @@ function sendNewUserTransaction(username, cbFunc) { }, {}); } - -function importSecretKeypress() { - var secretKey = $(".secret-key-import").val(); - var username = $(".username-import").val().toLowerCase(); - var $importButton = $(".import-secret-key"); - - if( secretKey.length == 52 && username.length ) { - $.MAL.enableButton( $importButton ); - } else { - $.MAL.disableButton( $importButton ); - } -} - function importSecretKeyClick() { var secretKey = $(".secret-key-import").val(); var username = $(".username-import").val().toLowerCase(); @@ -214,8 +201,8 @@ function interfaceCommonLoginHandlers() { /* must specialize: $( ".create-user").bind( "click", function() { createUserClick( processCreateUser ); } ); */ /* must specialize: $( ".login-created-user").bind( "click", loginCreatedUser ); */ $( ".new-username" ).keyup( newUserNameKeypress ); - $( ".secret-key-import" ).keyup( importSecretKeypress ); - $( ".username-import" ).keyup( importSecretKeypress ); + $('.secret-key-import').on('input', importSecretKeypress); + $('.username-import').on('input', importSecretKeypress); $( ".import-secret-key").bind( "click", importSecretKeyClick ); }