From c101e6b7b939822f29e237e60bf0a2896d5c3831 Mon Sep 17 00:00:00 2001 From: Ben Paddock Date: Mon, 21 Apr 2014 20:30:46 +0100 Subject: Add hide-on-click option (defaults to true) --- README.md | 4 ++++ src/nsPopover.js | 13 ++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 6179ed6..ce385d7 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,10 @@ the possible combinations of [position] and [alignment]. * right|bottom - The popover will be positioned on the right side of the triggering element and its bottom will be aligned with the bottom of the triggering element. +### ``ns-popover-hide-on-click {Boolean}`` + +Whether or not to hide the popover when it is clicked on, default: ``true``. + ### Themes diff --git a/src/nsPopover.js b/src/nsPopover.js index b3c9ab5..96a1652 100644 --- a/src/nsPopover.js +++ b/src/nsPopover.js @@ -19,7 +19,8 @@ trigger: attrs.nsPopoverTrigger || 'click', container: attrs.nsPopoverContainer, placement: attrs.nsPopoverPlacement || 'bottom|left', - timeout: attrs.nsPopoverTimeout || 1.5 + timeout: attrs.nsPopoverTimeout || 1.5, + hideOnClick: attrs.nsPopoverHideOnClick === 'true' || attrs.nsPopoverHideOnClick === undefined }; var hider_ = { @@ -140,10 +141,12 @@ // |elm|. move($popover, placement_, align_, getBoundingClientRect(elm[0]), $triangle); - // Hide the popover without delay on click events. - $popover.on('click', function() { - hider_.hide($popover, 0); - }); + if (options.hideOnClick) { + // Hide the popover without delay on click events. + $popover.on('click', function () { + hider_.hide($popover, 0); + }); + } }); elm -- cgit v1.2.3