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

farbstastic

v1.3.0

Published

farbstastic

Downloads

2,321

Readme

Farbtastic: jQuery color picker plug-in

Farbtastic is a jQuery plug-in that can add one or more color picker widgets into a page. Each widget is then linked to an existing element (e.g. a text field) and will update the element's value when a color is selected.

Farbtastic uses layered transparent PNGs to render a saturation/luminance gradient inside of a hue circle. No Flash or pixel-sized divs are used.

Farbtastic was originally written by Steven Wittens and is licensed under the GPL.

Basic Usage

  1. Include farbtastic.js and farbtastic.css in your HTML:

  2. Add a placeholder div and a text field to your HTML, and give each an ID:

  3. Add a ready() handler to the document which initializes the color picker and link it to the text field with the following syntax:

See demo1.html and demo2.html for an example.

Styling

The color picker is a block-level element and is 195x195 pixels large. You can control the position by styling your placeholder (e.g. floating it). Note that the black/white gradients inside wheel.png and mask.png were generated programmatically and cannot be recreated easily in an image editing program.

Advanced Usage

###jQuery Method

$(...).farbtastic()
$(...).farbtastic(callback)

This creates color pickers in the selected objects. callback is optional and can be a:

  • DOM Node, jQuery object or jQuery selector: the color picker will be linked to the selected element(s) by syncing the value (for form elements) and color (all elements).
  • Function: this function will be called whenever the user chooses a different color.

Object

$.farbtastic(placeholder)
$.farbtastic(placeholder, callback)

Invoking $.farbtastic(placeholder) is the same as using $(placeholder).farbtastic() except that the Farbtastic object is returned instead of the jQuery object. This allows you to use the Farbtastic methods and properties below.

Note that there is only one Farbtastic object per placeholder. If you call $.farbtastic(placeholder) twice with the same placeholder, you will get the same object back each time.

The optional callback argument behaves exactly as for the jQuery method.

Methods

.linkTo(callback) - Allows you to set a new callback. Any existing callbacks are removed. See above for the meaning of callback.

.setColor(string) - Sets the picker color to the given color in hex representation.

.setColor([h, s, l]) - Sets the picker color to the given color in normalized HSL (0..1 scale).

Properties

.linked - The elements (jQuery object) or callback function this picker is linked to.

.color - Current color in hex representation.

.hsl - Current color in normalized HSL.

Changelog

1.3u (unofficial) - 2010/2/17

  • Updated style to use anonymous function wrapper per http://docs.jquery.com/Plugins/Authoring#Custom_Alias.
  • Now it uses the .offset() method available as of jQuery 1.2.x.
  • Works with JavaScript aggregators and compressors.

1.2 - 2007/01/08

  • Fixed bug with linking multiple fields with the same value.

1.1 - 2006/10/27

  • Work around for the transparent PNGs in Internet Explorer.
  • Better mouse handling code to accomodate CSS-based layouts better.

1.0 - 2006/07/14

  • Initial release.