From 0bf3d54095cbd3503101233ac13a455cde73be21 Mon Sep 17 00:00:00 2001 From: Jared Tabor Date: Wed, 21 Jan 2015 18:00:25 -0500 Subject: [PATCH] JSHint errors fixed some JSHint errors from the prompt dialog commit --- awx/ui/static/lib/ansible/prompt-dialog.js | 31 ++++++++++------------ 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/awx/ui/static/lib/ansible/prompt-dialog.js b/awx/ui/static/lib/ansible/prompt-dialog.js index 0a2f715fbe..a0c7f3a064 100644 --- a/awx/ui/static/lib/ansible/prompt-dialog.js +++ b/awx/ui/static/lib/ansible/prompt-dialog.js @@ -47,24 +47,27 @@ angular.module('PromptDialog', ['Utilities']) // This will keep the tab indexing on the modal's focus. This is to fix an issue with tabbing working when // the user is attempting to delete something. Might need to be checked for other occurances of the bootstrap // modal other than deleting - function disableTabModalShown() { + function disableTabModalShown() { $('.modal').on('shown.bs.modal', function() { - var modal = $(this); - var focusableChildren = modal.find('a[href], a[data-dismiss], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]'); - var numElements = focusableChildren.length; - var currentIndex = 0; + var modal = $(this), + focusableChildren = modal.find('a[href], a[data-dismiss], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]'), + numElements = focusableChildren.length, + currentIndex = 0, + focus, + focusPrevious, + focusNext; $(document.activeElement).blur(); - var focus = function() { + focus = function() { var focusableElement = focusableChildren[currentIndex]; if (focusableElement) focusableElement.focus(); }; - var focusPrevious = function () { + focusPrevious = function () { currentIndex--; if (currentIndex < 0) currentIndex = numElements - 1; @@ -74,7 +77,7 @@ angular.module('PromptDialog', ['Utilities']) return false; }; - var focusNext = function () { + focusNext = function () { currentIndex++; if (currentIndex >= numElements) currentIndex = 0; @@ -86,11 +89,11 @@ angular.module('PromptDialog', ['Utilities']) $(document).on('keydown', function (e) { - if (e.keyCode == 9 && e.shiftKey) { + if (e.keyCode === 9 && e.shiftKey) { e.preventDefault(); focusPrevious(); } - else if (e.keyCode == 9) { + else if (e.keyCode === 9) { e.preventDefault(); focusNext(); } @@ -102,7 +105,7 @@ angular.module('PromptDialog', ['Utilities']) $('.modal').on('hidden.bs.modal', function() { $(document).unbind('keydown'); }); - }; + } $('#prompt-modal').off('hidden.bs.modal'); @@ -112,12 +115,6 @@ angular.module('PromptDialog', ['Utilities']) show: true }); disableTabModalShown(); - // $('#prompt-modal').on('shown.bs.modal', function (e) { - // if($('#prompt_action_btn')){ - // $('#prompt_action_btn').focus(); - // } - // }); - }; }