npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nowzoo/ngx-bootstrap-popup

v8.0.1

Published

A minimal library for implementing Bootstrap 4 popovers and tooltips in Angular

Downloads

4

Readme

@nowzoo/ngx-bootstrap-popup

A minimal library for implementing Bootstrap 4 popovers and tooltips in Angular. The library depends on native Bootstrap and jQuery code.

Quick Start

Install the library and its dependencies...

npm i -S @nowzoo/ngx-bootstrap-popup jquery bootstrap

Include the dependencies in some way in your build, for example via angular.json...

"styles": [
  "node_modules/bootstrap/dist/css/bootstrap.min.css"
],
"scripts": [
  "node_modules/jquery/dist/jquery.slim.min.js",
  "node_modules/bootstrap/dist/js/bootstrap.bundle.min.js"
],

Note: In the above example we use bootstrap.bundle.min.js, which includes popper.js. If you don't use the bundle version you have to install and add popper.js.

Import the module...

//...
import { 
  NgxBootstrapPopupModule 
} from '@nowzoo/ngx-bootstrap-popup';

@NgModule({
  //...
  imports: [
    NgxBootstrapPopupModule
  ]
})
export class MyModule { }

The module provides two directives, NgxBootstrapTooltipDirective and NgxBootstrapPopoverDirective. Both work with either plain strings or ng-templates.

<!-- basic tooltip -->
<button class="btn btn-primary" 
  ngxBootstrapTooltip tooltipTitle="Tooltip Title as String">
  Basic Tooltip
</button>

<!-- tooltip with template-->
<button class="btn btn-primary" 
  ngxBootstrapTooltip [tooltipTitle]="tooltipTitle" 
  (tooltipEvents)="onTooltipEvent($event)">
  Tooltip from Template
</button>
<ng-template #tooltipTitle>
  <div class="d-flex justify-content-between align-items-center">
    Opened {{counter}} times.
    <span class="badge badge-primary ml-2">
      open for
      {{timer}}s
    </span>
  </div>
</ng-template>

<!-- basic popover -->
<button class="btn btn-primary" 
    ngxBootstrapPopover 
    popoverTitle="Popover Title as String" 
    popoverContent="Lorem ipsum dolor sit, amet consectetur adipisicing elit. Eius repellat officiis, harum hic ea voluptate voluptatum.">
  Basic Popover
</button>

<!-- more complex popover example, with templates -->
<button class="btn btn-primary" 
    ngxBootstrapPopover [popoverTitle]="popoverTitle" 
    [popoverContent]="popoverContent"
    (popoverEvents)="onPopoverEvent($event)">
  Popover from Template
</button>
<ng-template #popoverTitle>
  <div class="d-flex justify-content-between align-items-center">
    <h5 class="m-0">
      Popover from Template
    </h5>
    
    <span class="badge badge-primary">
      {{timer}}s
    </span>
  </div>
  
  
</ng-template>
<ng-template #popoverContent>
  <p>
    Opened {{counter}} time(s).
  </p>
  <p>
    Open for {{timer}} second(s).
  </p>
  
  <p>
    Lorem ipsum dolor sit, amet consectetur adipisicing elit. 
    Eius repellat officiis, harum hic ea voluptate voluptatum 
    amet inventore placeat explicabo magni, ducimus provident 
    iste. Sed possimus provident ullam nostrum ea!
  </p>
  
  <p>
    <a href="#" (click)="$event.preventDefault()">Click Me</a>
  </p>
</ng-template>

API

interface IPopupOptions

An optional object that you can pass to an individual directive or set globally by providing a value for NGX_BOOTSTRAP_POPUP_OPTIONS. All fields are optional, and hew to the native Bootstrap options. Also note that for most of the options you can use data- attributes instead.

  • animation?: boolean
  • html?: boolean
    Note this will always be set to true if you use templates.
  • delay?: number | {show: number, hide: number}
  • container?: string | HTMLElement | false
  • placement?: string | ((popupEl: HTMLElement, triggerEl: HTMLElement) => string)
  • template?: string
  • offset?: number | string
  • fallbackPlacement?: string | string[]
  • boundary?: string | HTMLElement
  • trigger?: string
  • sanitize?: boolean
  • sanitizeFn?: (content: string) => string
    Note that if you do not provide a function, the directives will use DomSanitizer.sanitize by default.

const NGX_BOOTSTRAP_POPUP_OPTIONS: InjectionToken

The injection token for providing a set of default options for all popups in a module or component. Example...

import { 
  NgxBootstrapPopupModule, 
  NGX_BOOTSTRAP_POPUP_OPTIONS 
} from '@nowzoo/ngx-bootstrap-popup';

@NgModule({
  //...
  imports: [
    NgxBootstrapPopupModule
  ],
  providers: [
    { provide: NGX_BOOTSTRAP_POPUP_OPTIONS, useValue: {container: 'body'} }
  ]
})
export class MyModule { }

NgxBootstrapPopoverDirective

The directive for popovers.

  • selector: '[ngxBootstrapPopover]',
  • exportAs: 'ngxBootstrapPopover'
  • Inputs:
    • popoverTitle: string | TemplateRef<any>
    • popoverContent: string | TemplateRef<any>
    • popoverEnabled: boolean
      Optional. Default true.
    • popoverDismissOnClickOutside
      Optional. Default true.
    • popoverOptions: IPopupOptions
      Optional. Note that most options can also be set with data- attributes.
  • Outputs:
    • popoverEvents: EventEmitter<Event>
      The native Bootstrap events.
  • Properties:
    • bsInstance: any
      The native popover data provided by Bootstrap.
    • tip: HTMLElement
      The HTML Element of the popover.
  • Methods:
    • show(): void
    • hide(): void
    • toggle(): void
    • enable(): void
    • disable(): void
    • toggleEnabled(): void
    • update(): void

NgxBootstrapTooltipDirective

The directive for tooltips.

  • selector: '[ngxBootstrapTooltip]',
  • exportAs: 'ngxBootstrapTooltip'
  • Inputs:
    • tooltipTitle: string | TemplateRef<any>
    • tooltipEnabled: boolean
      Optional. Default true.
    • tooltipDismissOnClickOutside
      Optional. Default true.
    • tooltipOptions: IPopupOptions
      Optional. Note that most options can also be set with data- attributes.
  • Outputs:
    • tooltipEvents: EventEmitter<Event>
      The native Bootstrap tooltip events.
  • Properties:
    • bsInstance: any
      The native tooltip data provided by Bootstrap.
    • tip: HTMLElement
      The HTML Element of the tooltip.
  • Methods:
    • show(): void
    • hide(): void
    • toggle(): void
    • enable(): void
    • disable(): void
    • toggleEnabled(): void
    • update(): void

Development

Contributions are welcome.

git clone https://github.com/nowzoo/ngx.git
npm i

The library code is located in projects/ngx-bootstrap-popup.

To run tests:

  • ng test ngx-bootstrap-popup
  • or use the wallaby.js file at projects/ngx-bootstrap-popup/wallaby.js

Build the library with ng build ngx-bootstrap-popup.

License

MIT