From 6c5626da43b77679e5acee552ca5b70f6f652130 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 18 May 2015 10:19:11 -0700 Subject: [PATCH] save input on enter or act on table --- domain-server/resources/web/js/settings.js | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/domain-server/resources/web/js/settings.js b/domain-server/resources/web/js/settings.js index a1b5383182..8e6587695e 100644 --- a/domain-server/resources/web/js/settings.js +++ b/domain-server/resources/web/js/settings.js @@ -158,26 +158,39 @@ $(document).ready(function(){ moveTableRow(this, false); }); - $('#' + Settings.FORM_ID).on('keypress', 'table input', function(e){ + $('#' + Settings.FORM_ID).on('keyup', function(e){ + var $target = $(e.target); if (e.keyCode == 13) { - // capture enter in table input - // if we have a sibling next to us that has an input, jump to it, otherwise check if we have a glyphicon for add to click - sibling = $(this).parent('td').next(); + if ($target.is('table input')) { + // capture enter in table input + // if we have a sibling next to us that has an input, jump to it, otherwise check if we have a glyphicon for add to click + sibling = $target.parent('td').next(); - if (sibling.hasClass(Settings.DATA_COL_CLASS)) { - // set focus to next input - sibling.find('input').focus() - } else if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) { - sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click() + if (sibling.hasClass(Settings.DATA_COL_CLASS)) { + // set focus to next input + sibling.find('input').focus() + } else if (sibling.hasClass(Settings.ADD_DEL_BUTTONS_CLASS)) { + sibling.find('.' + Settings.ADD_ROW_BUTTON_CLASS).click() - // set focus to the first input in the new row - $(this).closest('table').find('tr.inputs input:first').focus() + // set focus to the first input in the new row + $target.closest('table').find('tr.inputs input:first').focus() + } + + } else if ($target.is('input')) { + $target.change().blur(); } e.preventDefault(); } }); + $('#' + Settings.FORM_ID).on('keypress', function(e){ + if (e.keyCode == 13) { + + e.preventDefault(); + } + }); + $('#' + Settings.FORM_ID).on('change', '.' + Settings.TRIGGER_CHANGE_CLASS , function(){ // this input was changed, add the changed data attribute to it $(this).attr('data-changed', true) @@ -222,7 +235,6 @@ $(document).ready(function(){ $('#' + Settings.FORM_ID).on('click', '#' + Settings.DISCONNECT_ACCOUNT_BTN_ID, function(e){ disonnectHighFidelityAccount(); - e.preventDefault(); }); $('#' + Settings.FORM_ID).on('click', '#' + Settings.CONNECT_ACCOUNT_BTN_ID, function(e){