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

tips.js

v1.2.0

Published

jQuery plugin for writing dynamic tooltips

Downloads

5

Readme

Description

npm

tips.js is a simple jQuery tooltip plugin.

Demo

A demo of the functionality and implementation can be found here

Installation

Install via npm:

npm install tips.js

Install via bower:

bower install tips.js

Or download the zip.

Getting Started

If using CommonJS:

var tips = require('tips.js');

If using AMD:

require(['tips.js'], function () {});

If using normal browser include:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js" type="text/javascipt"></script>
<script src="js/tips.js" type="text/javascript"></script>

Note: This plugin utilizes the jQuery "on" method, and therefore requires jQuery 1.7 or newer.

Styling

To use the pre-built CSS add the tips.css stylesheet in the head of your view:

<link href="css/tips.css" media="screen" rel="stylesheet" type="text/css" />

Using tips.js

All of the files for the plugin can be found in the build directory. Add a data-tooltip attribute with the content of the tooltip.

<input type="email" id="email" data-tooltip="Please enter an email address" />

Text can be formatted within the data-tooltip attribute via special characters.

^heading^       :   <h1>Heading</h1>
*bold*          :   <strong>bold</strong>
~italic~        :   <em>italic</em>
Line | Break    :   Line <br /> Break

{`item one `item two `item three} :
<ul>
    <li>item one</li>
    <li>item two</li>
    <li>item three</li>
</ul>

Specify the optional direction of the tooltip by adding the data-tooltip-direction attribute with the direction you'd like. The default is right, however acceptable values are top, bottom, left, and right.

<input type="email" id="email" data-tooltip="Please enter an email address" data-tooltip-direction="top" />

Then invoke $.tips passing the selectors(s) you'd like to show tooltips.

$.tips({
    element: '.error'
});

Specific tooltip bindings can be removed using the removeSpecific option. This required both an element and an action to be specified, otherwise the default .error class and focus action will be removed.

$.tips({
    action: 'hover'
    element: '.info'
    removeSpecific: true
});

All tooltips binding can be removed by using the removeAll option.

$.tips({
    removeAll: true
});

You can also specify a callback to fire after the tooltip has been instantiated as well.


// named

$.tips({
    element: '.error'
}, callback());

// anonymous

$.tips({
    element: '.error'
}, function(){
    // some logic here
});

Options

Below are the supported options and their default values:

settings = {
    action: 'focus',            // tooltip display event (click, focus, hover)
    debug: false,               // debug console
    element: '.error'           // selector to run the tooltip on
    fadeSpeed: 200,             // fade speed
    html5: true,                // uses aside for tooltip instead of div for html5 supported browsers
    preventDefault: false,      // prevent default event when element is clicked on
    removeAll: false,           // removes all tooltip bindings
    removeSpecific: false,      // removes specific tooltip binding (requires element and action)
    tailLength: 14,             // width/length of the tooltip tail for positioning
    tooltipClass: ''            // class to add to tooltip
}

There are several built in CSS styles for the tooltips. Currently there are styles for error, warning, and informational tooltips. Utilize the tooltipClass option to set one of the aforementioned classes. You can also add or modify styles in the CSS to file to tailor the tooltips to your site.

Contributing and Updates

I would definitely appreciate any feedback. I'm working on some ideas for the next release:

  1. Detecting edge of screen and repositioning tooltips
  2. Support for window resizing
  3. Adding formatting for links in tooltips
  4. Adding more pre-defined CSS tooltip colors and classes

Please fork and send pull requests, or create an issue.

License (MIT)

tips.js is distributed under the MIT License:

Copyright (c) 2016 Scott Lanning

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.