From 7c64ff4bd96fbac778404227f7f94c3ee20c5338 Mon Sep 17 00:00:00 2001 From: cristijora Date: Mon, 18 Sep 2017 19:31:31 +0300 Subject: [PATCH] Minor refactorings Simplify some code and extract some methods to a helpers file --- src/assets/form-wizard/_buttons.scss | 8 +--- src/components/FormWizard.vue | 59 ++++++++++------------------ src/components/WizardButton.vue | 4 +- src/components/helpers.js | 15 +++++++ 4 files changed, 38 insertions(+), 48 deletions(-) create mode 100644 src/components/helpers.js diff --git a/src/assets/form-wizard/_buttons.scss b/src/assets/form-wizard/_buttons.scss index d15610f..e0d35f8 100644 --- a/src/assets/form-wizard/_buttons.scss +++ b/src/assets/form-wizard/_buttons.scss @@ -6,15 +6,9 @@ font-size: $font-size-base; font-weight: $font-weight-bold; padding: $padding-base-vertical $padding-base-horizontal; + min-width: 140px; &:hover, &:focus { outline: 0 !important; } } - -.vue-form-wizard { - .navbar .navbar-nav > li > a.wizard-btn.wizard-btn-wd, - .wizard-btn-wd { - min-width: 140px; - } -} diff --git a/src/components/FormWizard.vue b/src/components/FormWizard.vue index 2844191..d412c92 100644 --- a/src/components/FormWizard.vue +++ b/src/components/FormWizard.vue @@ -74,6 +74,7 @@ diff --git a/src/components/helpers.js b/src/components/helpers.js new file mode 100644 index 0000000..cea815b --- /dev/null +++ b/src/components/helpers.js @@ -0,0 +1,15 @@ +export function getFocusedElementId () { + return document.activeElement.id +} +export function getFocusedTabIndex (tabs = []) { + let activeId = getFocusedElementId() + let tabIndex = tabs.findIndex(tab => tab.tabId === activeId) + return tabIndex +} +export function findElementAndFocus (elemId) { + let elem = document.getElementById(elemId) + elem.focus() +} +export function isPromise (func) { + return func.then && typeof func.then === 'function' +}