refactorizacion popover

This commit is contained in:
Dani Herrero 2017-07-05 14:41:10 +02:00
parent 53af148def
commit 81749e906d
1 changed files with 6 additions and 8 deletions

View File

@ -141,8 +141,7 @@ export class Popover {
let idNumber = parseInt(id.split('-')[1], 10);
popovers.forEach(
val => {
let valId = angular.element(val).attr('id');
if (parseInt(valId.split('-')[1], 10) > idNumber)
if (parseInt(val.id.split('-')[1], 10) > idNumber)
this._removeElement(val);
}
);
@ -157,18 +156,17 @@ export class Popover {
);
this._checkOpens();
}
_findParent(node) {
_findPopOver(node) {
while (node != null) {
if ((node.className && node.className.indexOf('vn-popover') !== -1) ||
(node.id && node.id.indexOf('popover-') !== -1)) {
return angular.element(node).attr('id');
if (node.id && node.id.indexOf('popover-') !== -1) {
return node.id;
}
node = node.parentNode;
}
return null;
}
onDocMouseDown(event) {
let targetId = this._findParent(event.target);
let targetId = this._findPopOver(event.target);
if (targetId) {
this.hideChilds(targetId);
} else {
@ -177,7 +175,7 @@ export class Popover {
}
onDocKeyDown(event) {
if (event.keyCode === 27) {
let targetId = this._findParent(this.latTarget);
let targetId = this._findPopOver(this.latTarget);
if (targetId) {
this.hideChilds(targetId);
} else {