From d11f1a0b2bf7df45e4400f50ed271d1021626f29 Mon Sep 17 00:00:00 2001 From: Robert Dampilon Date: Thu, 31 Aug 2017 11:03:16 +0700 Subject: [PATCH 1/2] feat(tooltip): Prevent close tooltip with 'esc' key --- src/stackedMap/stackedMap.js | 7 ++++--- src/tooltip/tooltip.js | 14 ++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/stackedMap/stackedMap.js b/src/stackedMap/stackedMap.js index f1f4d857b4..765e53c825 100644 --- a/src/stackedMap/stackedMap.js +++ b/src/stackedMap/stackedMap.js @@ -9,10 +9,11 @@ angular.module('ui.bootstrap.stackedMap', []) var stack = []; return { - add: function(key, value) { + add: function(key, value, options) { stack.push({ key: key, - value: value + value: value, + options: options }); }, get: function(key) { @@ -51,4 +52,4 @@ angular.module('ui.bootstrap.stackedMap', []) }; } }; - }); \ No newline at end of file + }); diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index dd02a077a1..65a931cd54 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -80,7 +80,8 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s function keypressListener(e) { if (e.which === 27) { var last = openedTooltips.top(); - if (last) { + var enableEsc = last.options.enableEsc; + if (last && enableEsc) { last.value.close(); last = null; } @@ -146,6 +147,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s var positionTimeout; var adjustmentTimeout; var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false; + var enableEsc = !angular.isDefined(attrs[prefix + 'EnableEsc']); var triggers = getTriggers(undefined); var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']); var ttScope = scope.$new(true); @@ -334,9 +336,9 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s } }); - openedTooltips.add(ttScope, { - close: hide - }); + openedTooltips.add(ttScope, + { close: hide }, + { enableEsc: enableEsc }); prepObservers(); } @@ -348,7 +350,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s if (tooltip) { tooltip.remove(); - + tooltip = null; if (adjustmentTimeout) { $timeout.cancel(adjustmentTimeout); @@ -356,7 +358,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s } openedTooltips.remove(ttScope); - + if (tooltipLinkedScope) { tooltipLinkedScope.$destroy(); tooltipLinkedScope = null; From 10adc97ca7f79cf5a468fc3a69f4ac7f47198386 Mon Sep 17 00:00:00 2001 From: RDD2017 Date: Fri, 1 Sep 2017 12:18:28 +0700 Subject: [PATCH 2/2] feat(tooltip): check. last tooltip must exist --- src/tooltip/tooltip.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tooltip/tooltip.js b/src/tooltip/tooltip.js index 65a931cd54..dea385088b 100644 --- a/src/tooltip/tooltip.js +++ b/src/tooltip/tooltip.js @@ -80,7 +80,7 @@ angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.s function keypressListener(e) { if (e.which === 27) { var last = openedTooltips.top(); - var enableEsc = last.options.enableEsc; + var enableEsc = last ? last.options.enableEsc : true; if (last && enableEsc) { last.value.close(); last = null;