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

lintel-contrib-tooltips

v0.1.3

Published

Tooltips for lintel.

Downloads

1

Readme

lintel-contrib-tooltips

Tooltips for lintel.

npm Bower

Getting Started

This module requires Lintel.

If you haven't used Lintel before, be sure to check out the Getting Started guide, as it explains how to install and use this module. Once you're familiar with that process, you may install this module with this command:

bower install lintel-contrib-tooltips --save

Once the module has been installed, you will have to load it in your main SASS file:

@import "bower_components/lintel-contrib-tooltips/sass/tooltips.scss"

This module also includes a JavaScript component, which you will have to load separately.

<script src="bower_components/lintel-contrib-tooltips/dist/tooltips.min.js" type="text/javascript"></script>

You can use wiredep or grunt-wiredep to automatically inject files in your build process.

Variables

Check the vars file in the sass folder to see the full list of variables you can customize.

$tooltip-padding-y

Default value: 3px

Tooltip padding-top and padding-bottom.

$tooltip-padding-x

Default value: 6px

Tooltip padding-left and padding-right.

$tooltip-arrow-width

Default value: 10px

$tooltip-border-radius

Default value: $border-radius-base

$tooltip-font-size

Default value: $font-size-xs

$tooltip-include-states

Default value: true

Enable or disable styles for the default states.

$tooltip-base-bg

Default value: rgba(0,0,0,.9)

$tooltip-base-border

Default value: $tooltip-base-bg

$tooltip-base-text

Default value: #fff

$tooltip-*-bg

Default value: transparentize($state-*, 0.1)

$tooltip-*-border

Default value: $tooltip-*-bg

$tooltip-*-text

Default value: null

Inherits from $tooltip-base-text.

Mixins

Check the mixins file in the sass folder to see how you can extend this module.

tooltip-state($bg, $border, $text)

Creates a new tooltip state, including arrow colors for each placement.

.tooltip-primary {
  @include tooltip-state(
    $bg: $tooltip-primary-bg,
    $border: $tooltip-primary-border,
    $text: $tooltip-primary-text
  );
}

JavaScript

You will have to call the jQuery plugin on each element you want to have a tooltip.

One way to do that would be to add data-toggle="tooltip" to all elements that should have a tooltip and call the following from your javascript:

$('[data-toggle="tooltip"]').tooltip();

Methods

Name | Type | Default | Description --------- | ------------------------------ | ------------------- | ----------- onShow | function | | Callback function to execute every time tooltip is shown. onHide | function | | Callback function to execute every time tooltip is hidden. html | Boolean | false | Display HTML content. Note: you must sanitize user input. state | string | | Tooltip type (ex. primary, error, success). placement | string | 'top' | Top, right, bottom, or left. title | string, function, $.Deferred() | | Can be a string, function, function that returns a deferred, or a deferred. If using a function, result will be cached. To run function again, reset this.options.title to the same function in onShow. See test/fixtures/tooltip.html for example. template | string | see js/tooltip.js | Template must contain these elements: .tooltip > .tooltip-content. The content of .tooltip-content will only be visible if a promise is used.

Examples

String Title

$('#myButton').tooltip({
  title: 'Tooltip Title'
});

Placement and State

$('#myButton').tooltip({
  title: 'Tooltip Title',
  placement: 'right',
  state: 'success'
});

HTML Content

NOTE: You must sanitize user input.

$('#myButton').tooltip({
  title: '<h1>Big Title</h1>',
  html: true
});

Function

$('#myButton').tooltip({
  title: function() {
    return 'Tooltip Title';
  }
});

Async Function

$('#myButton').tooltip({
  title: function() {
    var deferred = $.Deferred();

    // Async action...
    setTimeout(function() {
      deferred.resolve({
        title: 'Tooltip Title',
        state: 'success'
      });
    }, 500);

    return deferred;
  }
});

Async Function without Cache

var myTooltipGetter = function(tooltip, button) {
  var deferred = $.Deferred();

  setTimeout(function() {
    deferred.resolve({
      title: 'Tooltip Title',
      state: 'success',
      onShow: function() {
        // reset state
        this.options.state = null;
        // reset title after displaying tooltip
        this.options.title = myTooltipGetter;
      }
    });
  }.bind(this), 500);

  return deferred;
};

$('#myButton').tooltip({
  title: myTooltipGetter
});

Deferred

var deferred = $.Deferred();

$('#myButton').tooltip({
  title: deferred
});

setTimeout(function() {
  deferred.resolve({
    title: 'Deferred Success',
    state: 'success'
  });
}.bind(this), 1000);

Font Awesome Loading Icon

$('#myButton').tooltip({
  title: deferred,
  template: `<div class="tooltip"><div class="tooltip-content"><i class="fa-li fa fa-spinner fa-spin"></i></div></div>`
});

Data-Attributes

<button data-title="Tooltip Title" data-placement="bottom" data-state="warning" data-toggle="tooltip" type="button">I have a tooltip.</button>
$('[data-toggle="tooltip"]').tooltip();

Title Attribute

<button title="Tooltip Title" type="button">I have a tooltip.</button>
$('[data-toggle="tooltip"]').tooltip();

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

License

Copyright (c) 2015 Marius Craciunoiu. Licensed under the MIT license.