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

jquery-hslpicker

v0.0.5

Published

hsl color picker

Downloads

20

Readme

jQuery HSL Color Picker

A css and javascript driven HSL picker. Made to be small, styleable and easy to use.

Example

$('input[type="color"]').hslPicker({
    color: 'orange'
});

Config

color : string

A hex string (e.g. '#ff0000') or named color to set the initial color. If no initial color is defined, the value of the input will be used. If no color is associated with the picker or 'random' is passed as a color, the picker will select a random color.

hsl : array|object

Define an hsl color as [0, 0.25, 0.5] or [ h: 0, s: 0.25: l: 0.5 ] with percentages as the values. If this color is defined, it will override the color configuration.

disabled : bool

Whether to disable the picker. Initializing with a disabled input will also disable the picker. Disabling the picker overrides disabled inputs.

disableInputs : string|array|object

Prevent specific values from being changed. Passing 'h' would disable the hue; 'hs' would prevent hue and saturation. Can be passed as 'h', ['h'], or { h: true }.

alwaysOpen : bool

Whether to keep the picker modal always open.

Methods

The picker instance can be retrieved by passing 'picker':

var picker = $('input').hslPicker('picker');

.disable()


Disable the picker. Disabling the picker overrides disabled inputs. Can also be triggered via the input.

$('input').trigger('disable');

.enable()


Enable the picker. Enabling the picker overrides disabled inputs. Can also be triggered via the input.

$('input').trigger('enable');

.disableInput(opts)


Disable specific values from being changed.

.enableInputs(opts)


Enable specific values to be changed.

.refresh()


Refresh the picker with the current hsl value on the picker instance. Use this if the hsl values have been changed manually:

var picker = $('input').hslPicker('picker');
picker.h = 0.5;
picker.refresh();

Can also be triggered via the input.

$('input').trigger('refresh');

.open()


Open the picker. Can also be triggered via the input.

$('input').trigger('open');

.close()


Close the picker. Can also be triggered via the input.

$('input').trigger('close');

.update()


Update the value of the color picker. Can be passed a valid color or hsl value. The picker can also be updated by updating the input:

$('input').trigger('update', { color: '#000000' });

.val()


Set or retrieve the hex value of the picker.

.destroy()


Destroy the picker. This will remove all bindings and inputs generated by the picker. Can also be triggered by passing 'destroy' or triggering the input:

$('input').hslPicker('destroy');
// or
$('input').trigger('destroy');

Extending

$.hslPicker is the picker object that can be extened. $.hslPicker also contains helpful color manipulation methods:

  • .hslToRgb(h, s, l)
  • .rgbToHsl(r, g, b)
  • .hexToRgb(hex)
  • .rgbToHex(r, g, b)
  • .hexToHsl(hex)
  • .random()

Styles

Include the jquery.hsl-picker.css file. The styles rely on the border-box model which is used by bootstrap by default:

* {
    box-sizing: border-box;
}

Support

Modern browsers and IE9+

#License

The MIT License (MIT)

Copyright (c) 2014 Joseph Clay

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.