int events again each time page changes

This commit is contained in:
Kyle Spearrin 2017-11-15 14:26:01 -05:00
parent 2f7b6790db
commit 3b6e9d7b0b
3 changed files with 28 additions and 3 deletions

View File

@ -47,6 +47,10 @@ angular
$scope.typeChanged = function () { $scope.typeChanged = function () {
$scope.cipher.type = parseInt($scope.selectedType); $scope.cipher.type = parseInt($scope.selectedType);
$timeout(function () {
utilsService.initListSectionItemListeners(document, angular);
}, 500);
}; };
$scope.savePromise = null; $scope.savePromise = null;
@ -95,6 +99,10 @@ angular
name: null, name: null,
value: null value: null
}); });
$timeout(function () {
utilsService.initListSectionItemListeners(document, angular);
}, 500);
}; };
$scope.removeField = function (field) { $scope.removeField = function (field) {

View File

@ -38,6 +38,10 @@ angular
$scope.typeChanged = function () { $scope.typeChanged = function () {
$scope.cipher.type = parseInt($scope.selectedType); $scope.cipher.type = parseInt($scope.selectedType);
$timeout(function () {
utilsService.initListSectionItemListeners(document, angular);
}, 500);
}; };
$scope.savePromise = null; $scope.savePromise = null;
@ -111,6 +115,10 @@ angular
name: null, name: null,
value: null value: null
}); });
$timeout(function () {
utilsService.initListSectionItemListeners(document, angular);
}, 500);
}; };
$scope.removeField = function (field) { $scope.removeField = function (field) {

View File

@ -299,8 +299,16 @@ export default class UtilsService implements UtilsServiceInterface {
throw new Error('doc parameter required'); 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) => { sectionItems.forEach((item) => {
(item as HTMLElement).dataset.bwEvents = '1';
item.addEventListener('click', (e) => { item.addEventListener('click', (e) => {
if (e.defaultPrevented) { if (e.defaultPrevented) {
return; return;
@ -342,9 +350,10 @@ export default class UtilsService implements UtilsServiceInterface {
}, false); }, false);
}); });
const sectionFormItems = doc.querySelectorAll(
'.list-section-item input, .list-section-item select, .list-section-item textarea');
sectionFormItems.forEach((item) => { sectionFormItems.forEach((item) => {
const itemCell = item.closest('.list-section-item');
(itemCell as HTMLElement).dataset.bwEvents = '1';
item.addEventListener('focus', (e: Event) => { item.addEventListener('focus', (e: Event) => {
const el = e.target as HTMLElement; const el = e.target as HTMLElement;
const cell = el.closest('.list-section-item'); const cell = el.closest('.list-section-item');