Code Monkey home page Code Monkey logo

jquery-minicolors's Introduction

jQuery MiniColors: A tiny color picker built on jQuery

Developed by Cory LaViska for A Beautiful Site, LLC

Licensed under the MIT license: http://opensource.org/licenses/MIT

Install via NPM

This is the official NPM version of MiniColors:

npm install --save @claviska/jquery-minicolors

Note: There is another version on NPM without the namespace that is out of date and not supported. I did not create it nor do I have control of it. Please use the official NPM version to ensure you have the latest updates.

jquery-minicolors's People

Contributors

alextk avatar andypandy avatar asgeo1 avatar baggachipz avatar bronson avatar brunoais avatar bytestream avatar claviska avatar cyrezdev avatar dependabot[bot] avatar dzafel avatar gggritso avatar gyopiazza avatar ibobo avatar jberryman avatar jgasiorowski avatar lumbendil avatar luukvdo avatar majko96 avatar markvantilburg avatar mshiltonj avatar onassar avatar otanistudio avatar pablorecio avatar phawk avatar rchavik avatar sg5 avatar sneetsher avatar stevehorn avatar ycintre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-minicolors's Issues

Close swatch via API

I want to dynamically close the swatch once it is opened. I could not find such method in the API. Is this posible?

Best,
Roel

INPUT selector usage

Hi,

I was customizing the widget by injecting additional input inside the created structure of spans.
There are 2 places at least (maybe more) where jquery selector contains INPUT, such as:
var input = $(this).parent().find('INPUT').
This will select wrong input and... I don't need to tell you the rest

I patched my copy with .find('INPUT.minicolors-input') to only target the "original" input.

Thank you for well written plugin.

Custom palette functionality request

Hi,
Your plugin is really the best i found on internet!
Just, could you add a custom palette functionality, to allow selection of preset colors?
(cf. Iris by Automattic plugin)
It would be really great!!
Thanks

how to re-position miniColors-selector popup panel

Thanks for a great piece of work....

Got this working in no time... but I have an right side installation and need to move the miniColors-selector popup panel position -150px to the left ....

I tried adjusting the js scripts, but could not find the magic buttons....

What's the best way to accomplish this ??

Thanks.
Bill

Option for explicit instantiation

I would love an option for explicitly constructing the controls rather than the auto constructor based on the "type=minicolors" attribute. For one thing, a custom type attribute is not valid HTML (or HTML5), and explicit construction would also make setting up controls with different options a bit more straightforward and flexible in my opinion.

afterChange event

A lot of users require an efficient way of updating something within a specified timeframe after a change has occurred, but not on every single change event (because it fires very rapidly when dragging). This issue is a reminder for me to add this functionality into MiniColors.

The concept is a callback that fires at a configurable amount of time after the change event, but gets deferred on subsequent change events that fire before it is executed. This will be achieved with a setTimeout/clearTimeout to handle the delay. The options I'm proposing are:

$('input').minicolors({

    // delay the afterChange callback by half a second
    afterChangeDelay: 500

    // the callback function to execute
    afterChange: function() { ... }

});

If anyone has alternative suggestions for the callback name then please submit them here. I'm going to try to work this feature into the plugin this week if time permits.

No Show/Hide Event Callback

In the documentation you note that theres a hide/show event callback, which I've tested but doesn't seem to exist. As a quick hack this is what I've done for the show/hide event callbacks:

Show callback: Append to the show(input) function:
input.trigger('show', input);

Hide callback: Append to the hide() function:
$("input[type='minicolors']").trigger('hide');

Like I said, this was a quick hack for me and I don't pass back an event for the hide function.

Recent change breaks on create for inputs that don't have a data-opacity attribute

There's some code change (very recent) in the create method which will leave one of the local variables (alpha) undefined. Here, you have:

var hex = input.val() ? '#' + cleanHex(expandHex(input.val())) : '#ffffff',
    rgb = hex2rgb(hex),
    opacity = false,
    alpha,
    trigger;

// Handle opacity
if( input.attr('data-opacity') !== undefined ) {
    opacity = true;
    alpha = input.attr('data-opacity');
    if( alpha === '' ) {
        alpha = 1;
    } else {
        alpha = parseFloat(alpha).toFixed(2);
    }
    if( alpha > 1 ) alpha = 1;
    if( alpha < 0 ) alpha = 0;
    input.attr('data-opacity', alpha);
}

...

// Set input data and update attributes
input
    .addClass('miniColors')
    .data('original-maxlength', input.attr('maxlength') || null)
    .data('original-autocomplete', input.attr('autocomplete') || null)
    .data('letterCase', o.letterCase === 'uppercase' ? 'uppercase' : 'lowercase')
    .data('opacity', opacity)
    .data('alpha', alpha)
    .data('trigger', trigger)
    .data('hex', hex)
    .data('change', o.change ? o.change : null)
    .data('close', o.close ? o.close : null)
    .data('open', o.open ? o.open : null)
    .attr('maxlength', 7)
    .attr('autocomplete', 'off')
    .val(convertCase('#' + cleanHex(hex), o.letterCase));

If data-opacity isn't an attribute of the input, then alpha will be undefined when you run the .data method for it. When that happens, it returns undefined, which then causes everything to break. Our code using this library had been working fine yesterday, and after no change on our part, it began to break today, so I suspect like this is probably an issue within the library alone.

Reading & writing RGBA colors

Any chance of setting the RGBA color? rgbString & rgbaString are only for getting a value if I understood correctly.

Nice looking plugin, btw 👍

using method

i would to preset value using of method is like that? But it doesnt work

    $('.color-picker').miniColors({'value','#C307ED'});

jQuery UI Issue

I found that when I have jQuery UI installed, the color picker would not work correctly and would stay on #000000.

class .minicolors-swatch span doesn't change color

Sorry for my english, I am a Brazilian guy who used miniColors =D.

When I loaded the data with hex and put on input that I used the miniColors, the class '.minicolors-swatch span' doesn't change the color that came from the data.

My solution for this bug was this:

$('.minicolors-swatch span').css('background', $('#my-selector').minicolors('rgbString'));

allow blank value

any chance a blank value can be allowed/supported?

currently, if the html form field for the colorpicker is blank (by default or if the user clears the colorpicker field), it defaults to #FFFFFF

Initilisation time change

I found I had to change when all the controls are initialised to,

  1. $(document).ready(
    as opposed to
  2. $(window).on('load',

Option 1 will fire as soon as the DOM is ready, whereas option 2 will wait until everything is ready (including third party content).

I was finding that I had some third party content that was taking a few seconds to load, and was thus delaying the initialisation of miniColors.

Posting The Hex Value

Hi guys,

Nice Color picker I must say.
However, I am finding that I can not POST the selected color value.
The picker is inside a form and once posted I do not get the element in the posted element array even if i do a print_r($_POST).
Probably doing something crazy, but any help is appreciated.
I just opened up a form in the original source doc and tried posting, but the picker's text box value does not appear.

Cheers,
D

Reaction time noticeable slower

Hello!

The last change increased reaction times to where it's pretty unusable on mobiles. Right now I'm working an inline-show into the old version, but that's not the way to go. Can you please look into why it got so laggy? ;)

Thanks, Manuel

IE7-8 Issue with Swatch Trigger

There seems to be an issue in IE7-8 which is preventing the onClick event from working correctly on the a.miniColor-trigger element.

More Adaptive Formatting

From @dlong500:

"While this implementation is my favorite colorpicker so far, it still suffers from the same issue that so many javascript "controls" do: that is, the formatting doesn't match up with existing form elements (height, margins, not lined up, etc). It would be awesome if somehow the constructor could use the existing CSS of the base input element and just "attach" the colorpicker to it (as well as increasing the right margin) so that no existing formatting is lost. This way the control could be adapted to many different scenarios without have to hack the CSS or even JS files."

Allow transparent as value

One example for my app, this would be especially useful on setting background color. That is having a setting that controls background color.

Feedback of testing for 2.0.0-beta3

Hey, i just tested the new version of the colorpicker, the initialization now works perfectly with the new selector, that great!
I also like the settings to pass as an argument, perfect for configuration.

I just bumped into one drawback, when i'm picking a new color the color selection isn't smooth at all, it's laggy, ~20-50ms of lag i would say, is there anything you can do about that?

Optional Close Button

It has been mentioned that an optional close button at the top-right of the control would be helpful in certain cases. This would be relatively easy to implement, so I've placed it here as a to-do item for discussion.

Position: absolute doesn't work properly with jQuery 1.8.2

I just tried to use your plugin, but unfortunately the position: absolute attribute doesn't work like it should. The selector image is shown at the bottom of the page and the top attribute isn't set.
When i change the jQuery version to 1.7.1 everything works fine for me.

Add option to leave color field empty

Hi,

It can be really helpful if the users could leave the value of the color empty (delete the value from the text box or click a "clear" button).

right now i'm changing the code myself every time i want to upgrade and it's not very fun...

Thanks!
Roey

Color value without hashtag ?

Is there a way to having this plugin work without hashtag # prefix on the input value ?
I would like to replace my current color picker with this one but currently the colorpicker value does not stored with # tag.

allow for underlying input control change to update swatch value

If the underlying input control of a minicolor control gets its value updated via code like such:

$("#colorpicker").val("#AAAAAA");

then the swatch does not update it's color. It requires editing the text manually to get the color to show up. While using the minicolors value method can workaround this issue, it is less than ideal to require a custom function for something as basic as setting an input value programatically, and also makes would require editing every instance of value setting in an existing project when switching to miniColors from a different colorpicker control.

Thanks so much for your active development on this great control!

Hide method went missing

Hi,

the hide method is not available from outside (anymore?), it's not being handled by the switch for calls to $([selector]).miniColors().

Cheers,
Jonas

Layout broken when inside a container with text-align:center

The color-box is offset like seen in the picture if the control is inside a container with text-align: center. This is easy to test, just change a <p></p> in index.html to
<p style="text-align:center"></p>.

The control still works fine but looks like that:
Screen Shot 2013-02-14 at 11 23 39 AM

Edit: happens in FF and Chrome, latest.

RGBA Support

I'm not sure if there would be any immediate demand for this, but I was working on some mockups of transparency support and came up with the idea of an opacity slider.

RGBA slider

Anyone have any thoughts on this? Of course, it would be optional and disabled by default. The only issue is, due to the width being 128px, you'd only be able to select evens or odds from 0-255.

window scrolled down bug

if the window scrolled down the selection circle sticks at the bottom doesn't follow the mouse. Same thing happens with the selection bar on the right.

How to change value returned

I'm having a problem in figuring out how to change for format of the returned value.

If opacity: true how can I get a return value for rgba(255, 255, 255, 0.5) or whatever value is now selected.

What I find is that the hex color is always returned and I really don't know how to get at the opacity or rgba values.

Is there some setting I'm not understanding for how to return a value in a specific format? I would think being able to specify the returned value as hex, rga or rgba would be ideal.

Help.

option to separate display from data input

Hi,

Below I'm describing the use case that made me mess with created span structure.

I wanted to use the original input as toolbar button without textfield, just for display.
Then after widget opens in its full glory, I still needed an input so user can specify exact hex value if he knows one without any dependency on current hex value.

I think this can be a useful feature.

Color displayed is actually 2 colors

I've noticed that swatch with color is displayed with two variants: lighter on top and darker on bottom.

Can this be turned off and whole swatch area be displayed with one color only?

how to hide on mouse up

Hey I'm just curious if you guys know the best way to hide the color sampler on mouse up? Thanks.

Roadmap?

Hey there, do you have a roadmap of what you plan to include in the new release and a calendar?

I'm considering including the 2.0 release before tagging a stable release of my drupal module and would like to know if i will have to switch to version 1.0 if it's not going to happen in the next weeks.

No pressure there, it's just for my organisation. Thanks and keep the good work!

Uncaught TypeError: Object # has no method ‘refresh’

Hello, Very awesome plugin.

I am changing the value programatically but it would seem “$.minicolors.refresh();” does not work, I get this error:

Uncaught TypeError: Object # has no method ‘refresh’


I modified the index.html file that is in the repository and placing:

<script> $.minicolors.refresh(); </script>

At the bottom, will also cause the same error message
Uncaught TypeError: Object # has no method 'refresh'

I couldn't get it working no matter what I tried!

Change event not firing on paste/keypress

This was brought to my attention and needs to be fixed. The change event doesn't get fired when values are pasted or typed in. I'll get to this as soon as I can, just putting it here for my own memory.

Color slider on the right not updating when dragged up and down

Loving this color picker. However, this issue has stumped me. When I specify the Value property as a hard coded string e.g. '#ffffff' I have no problems. Everything works as it should. However, when I set the Value property equal to a dynamic value in my data model (using MVC razor view), this is what happens:

  • color picker is visible with all elements apparently working (grey color #666666 visible and color gradient square shows grey shades)
  • If I then slide the color slider on the left up and down the color gradient square changes to red and the color slider sticks on the red color.
  • starts working again as soon as there is a click event in the color gradient square ie. colours start changing again when I use the color slider.

Has someone come across this before?

Alignment options

it would be nice to have some options for the alignement of the color picker window. currently it is aligned below the input field, to the left. but sometimes it is handy to align it on the right or even above the input field. or maybe an automatic alignment, that is aware of the browser viewport, would be even better.

data-opacity doesn't work at all

Tried to set it from jquery before calling the plugin: firebug shows that my value is added like opacity=.39, but there is an attribute in the tag: data-opacity="1"

Destroy not removing change event?

When I pass in some code like so:

$('#color').miniColors({
change : function( hex_value, rgb_value)
{
... run some code ...
}
})

and then later call $('color').miniColors( 'destroy' ), the 'change' event never gets unbound. Thoughts?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.