From 3b6e9d7b0b1616a2f3853f63d493c0c3740ae35e Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 15 Nov 2017 14:26:01 -0500 Subject: [PATCH] int events again each time page changes --- src/popup/app/vault/vaultAddCipherController.js | 8 ++++++++ src/popup/app/vault/vaultEditCipherController.js | 8 ++++++++ src/services/utils.service.ts | 15 ++++++++++++--- 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/src/popup/app/vault/vaultAddCipherController.js b/src/popup/app/vault/vaultAddCipherController.js index 0f420f2b87..6808b5dd7c 100644 --- a/src/popup/app/vault/vaultAddCipherController.js +++ b/src/popup/app/vault/vaultAddCipherController.js @@ -47,6 +47,10 @@ angular $scope.typeChanged = function () { $scope.cipher.type = parseInt($scope.selectedType); + + $timeout(function () { + utilsService.initListSectionItemListeners(document, angular); + }, 500); }; $scope.savePromise = null; @@ -95,6 +99,10 @@ angular name: null, value: null }); + + $timeout(function () { + utilsService.initListSectionItemListeners(document, angular); + }, 500); }; $scope.removeField = function (field) { diff --git a/src/popup/app/vault/vaultEditCipherController.js b/src/popup/app/vault/vaultEditCipherController.js index 7c9d88a1d9..d77a8640b3 100644 --- a/src/popup/app/vault/vaultEditCipherController.js +++ b/src/popup/app/vault/vaultEditCipherController.js @@ -38,6 +38,10 @@ angular $scope.typeChanged = function () { $scope.cipher.type = parseInt($scope.selectedType); + + $timeout(function () { + utilsService.initListSectionItemListeners(document, angular); + }, 500); }; $scope.savePromise = null; @@ -111,6 +115,10 @@ angular name: null, value: null }); + + $timeout(function () { + utilsService.initListSectionItemListeners(document, angular); + }, 500); }; $scope.removeField = function (field) { diff --git a/src/services/utils.service.ts b/src/services/utils.service.ts index 03f09376a7..abe45c3d44 100644 --- a/src/services/utils.service.ts +++ b/src/services/utils.service.ts @@ -299,8 +299,16 @@ export default class UtilsService implements UtilsServiceInterface { throw new Error('doc parameter required'); } - const sectionItems = doc.querySelectorAll('.list-section-item'); + const sectionItems = doc.querySelectorAll( + '.list-section-item:not([data-bw-events="1"])'); + const sectionFormItems = doc.querySelectorAll( + '.list-section-item:not([data-bw-events="1"]) input, ' + + '.list-section-item:not([data-bw-events="1"]) select, ' + + '.list-section-item:not([data-bw-events="1"]) textarea'); + sectionItems.forEach((item) => { + (item as HTMLElement).dataset.bwEvents = '1'; + item.addEventListener('click', (e) => { if (e.defaultPrevented) { return; @@ -342,9 +350,10 @@ export default class UtilsService implements UtilsServiceInterface { }, false); }); - const sectionFormItems = doc.querySelectorAll( - '.list-section-item input, .list-section-item select, .list-section-item textarea'); sectionFormItems.forEach((item) => { + const itemCell = item.closest('.list-section-item'); + (itemCell as HTMLElement).dataset.bwEvents = '1'; + item.addEventListener('focus', (e: Event) => { const el = e.target as HTMLElement; const cell = el.closest('.list-section-item');