Giter VIP home page Giter VIP logo

iris's Introduction

Iris

Iris uses CSS3 Gradients for everything, so it'll look awesome on HiDPI displays out of the box. Initially developed for Custom Colors on WordPress.com and shipping with WordPress 3.5+.

Documentation

See the Iris project page.

License

Copyright (c) 2012–2014 Automattic. Licensed under the GPLv2 license.

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.

Important notes

Please don't edit files in the dist subdirectory as they are generated via grunt. You'll find source code in the src subdirectory!

While grunt can run the included unit tests via PhantomJS, this shouldn't be considered a substitute for the real thing. Please be sure to test the test/*.html unit test file(s) in actual browsers.

Installing grunt

This assumes you have node.js and npm installed already.

  1. Test that grunt is installed globally by running grunt --version at the command-line.
  2. If grunt isn't installed globally, run npm install -g grunt-cli to install the latest version. You may need to run sudo npm install -g grunt-cli.
  3. From the root directory of this project, run npm install to install the project's dependencies.

iris's People

Contributors

alexyorke avatar clorith avatar evansolomon avatar llemurya avatar mattwiebe avatar umeshsingla 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  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

iris's Issues

Color picker should appear when clicking labels

I'm not sure if this is related to the wp-color-picker implementation, but that's where I've noticed this issue and placing this here just in case.

Default form behavior like clicking on labels to focus on an input does not work to pop up the Iris color picker.

Can be reproduced with the input either inside or outside the label.

Input inside label
<label for="color-picker">Color Picker <input type="text" id="color-picker" value="#000000"></label>

Input outside label
<label for="color-picker">Color Picker</label><input type="text" id="color-picker" value="#000000">

Farbtastic understood this and displayed the color picker. Iris should, too :)

Add events for show/hide

It seems the only event/callback is change. Having show/hide event callbacks/hooks would be very useful.

Add titles to palette, use palette only

I'd like the ability to add titles to the palette swatch (provided as a json array in palette: options)

Also I'd like the ability to use only the palette, removing the gradient color picker. This allows me to use the same tool for every color picking feature I want to implement.

HSL

Hi,
Devinsays added this colorpicker to Theme Options Framework & I'd like to use it because it's now included in Wordpress. Plus then I wouldn't have to use a fork off of Devin's code.

Can you tell me if I can retrieve HSL values, as I did with Farbtastic?
I was doing it like this: var hslcolor = $.farbtastic('#picker').hsl;

The reason why, is because I can choose a base color for my theme, and based on this, I can calculate a half dozen shades of color that are used throughout the site. I can't do that purely with CSS, because RGBA doesn't have some easy way to add lightness or change hue (that I know of).

Thanks.

Thanks.

Abrupt color changes when circle dragged outside

(This issue still exists after the bug fixes on June 8th by myself)

When dragging the circle to the bottom of the color palette, the color changes to almost black. Repeat this process two times, dragging it further and further down to the black area. Then, adjust the hue slider. The colors will not change nicely (it's very discrete) but when the circle is restored to a position in the middle of the color pallette, the problem disappears. The following screen capture may help:

http://cl.ly/2A023B3P2K1j

No palette change at runtime

Hi,
I would like to change the preset colors dynamically, but it doesn't seem to work with jQuery('.color-picker').iris('option','palettes',['#aaa','#bbb','#ccc']);
Is there a way to make it work?
Thanks

Documentation Discrepancy

The documentation for the target option at http://automattic.github.io/Iris/ incorrectly states that the option will be ignored for <input> elements, however, it's the exact opposite, it is only honored if Iris is applied to an <input> element. Inline documentation in iris.js is correct however.

Double-click issue affecting window location by appending #

I've noticed that double-clicking on a color picker to select a color also seems to affect the browser's address bar, specifically, by appending a # character. This can actually be re-created on the project homepage at http://automattic.github.io/Iris/.

This causes serious problems for single page apps. Right now it makes Iris unsuitable for the BackboneJS app I'm working on. Can anything be done?

Add init method

It would be great if there was an init method for wpColorPicker so that I can, for instance change the background image of the .wp-color-result element that gets prepended to the initialized input field.

I know I can change the background with css, but for some reason, when I do that, the selected color gets written to the element as background-color and that won't overwrite my default background inside the css. With init method I'd be able to append the background as an inline style, then remove it on change and add the color.

adding trigger to change

//Color picker
( function( $ ){

$('.of-color').wpColorPicker({

    change: _.throttle( function( event , ui) { 
        console.log( ui.color.toRgb() );
        $(this).trigger( 'change' );
    }, 2000 )
});

})(jQuery);

When using the code above I can't add direct function with $(this).trigger( 'change' ); without use of _.throttle because it causes the script to stop working. Even when I use _.throttle and try to use ui firebug sometimes but not always shows that it doesn't exist. Is there a way to add trigger other than above ( note that when I set delay to anything under 2000 it causes incorrect behaviour )

While selecting a color input value isn't changed.

Screen Shot 2013-03-21 at 6 05 47 PM
I am using Iris using the most simple call:
$(".popup-colorpicker").iris();
When any color is selected the value of the input type text isn't changed, so when my other scripts grab the value of the input field they show the default value.
Can we include a stop function, so when color selecting is done I can change the value of the input field?

Transparency

Hi, it's possible to add transparency support in color picker box?
Thanks

SetDefault option

I have number of form fields. I reset all the form fields value but color picker is not showing the default color.

Does this plugin support this feature or not ?

    var background_color = jQuery('#background_color');
        background_color.val(background_color.attr('data-real')).wpColorPicker({color:background_color.attr('data-real')});

I thought color option will do that, but it doesn't

Clicking palette color or any color on first click doesn't trigger change callback.

I am using this inside a plugin and have seen the following issue. Since iris doesn't do alpha channels I have a range input below for opacity. When there is no color selected I want to hide that field. Also on color change I update a live view of the element being styled.

Here is the code currently being used.

PUMColorPickers = {
    init: function () {
        $('.color-picker').filter(':not(.initialized)')
            .addClass('initialized')
            .wpColorPicker({
                change: function (e) {
                    var $input = $(e.currentTarget);
                    if ($input.hasClass('background-color')) {
                        $input.parents('table').find('.background-opacity').show();
                    }

                    $(this).trigger('change.update');

                    PopMakeAdmin.update_theme();
                },
                clear: function (e) {
                    var $input = $(e.currentTarget).prev();
                    if ($input.hasClass('background-color')) {
                        $input.parents('table').find('.background-opacity').hide();
                    }

                    $(this).prev('input').trigger('change.clear').wpColorPicker('close');

                    PopMakeAdmin.update_theme();
                }
            });
    }
};

As you can see it should show / hide the opacity input when a color is chosen or cleared. Here is how it is working / not working.

Click clear - Works perfect, field hides.

With clear field, open picker and click once(no drag) on the color chart - Updates the color fields value, but does not trigger the change callback function or hide the opacity input. Also the theme update isn't triggered.

With clear field, open picker and click any paletted color - Same result as above. Color field shows new value but change event never fires.

With existing color, single click any color on palette or color chart(no drag) - Same as above, but if you click a second color in the palette, then the change callback is fired, but not for the newly selected color, but rather the last one picked. You always have to double click in order to update the opacity field and rerender the theme.

EX of that.
Current color: #fffffff
Open iris, click the red color palette. Field updates to red hex code, but the live preview still shows white.
Now click yellow in the palette and the field updates to yellow, but the live preview now shows red.

I have tried everything from using _.throttle and _.debounce to setting a timeout on the theme update and show/hide function, nothing seems to fix this glitch for me or my users. Been there since v1.0 of Popup Maker even though I have rewritten that entire section of JS multiple times over the last 16 months.

Allow hue-only slider to be updated from its input field

See https://core.trac.wordpress.org/ticket/42078

In order to be fully accessible, the hue-only control used, for example, in Twenty Seventeen would need to display the underlying input field as an alternative input source. A native input field is the only guarantee the hue control can be used by everyone, with any device and ability. Worth noting the full color picker already allows to manually update the value form the input field and see the color palette and slider updating on the fly.

However, in the hue control moving the slider updates the value in the input field, but the other way around doesn't work. For example, manually changing the input value from 250 to 240 passes an hex color to _setOption () because of color.toString() so what gets passed is actually #224400 and nothing happens.

I've played a bit with the Iris version used in core, and passing the hue value with some adjustments seems to work. However, I'm really not an expert and I'm sure there are better ways to do it.

Issues I've identified so far:

  • when the type ie hue, then _addInputListeners() should pass a hue value (number from 0 to 359) or the value should be converted to something Iris can use to update the slider later on
  • not sure if the regex in _addInputListeners() should be adjusted
  • color.js may return an error when changing the input to a value under 100 because the current error checking expects a hex string with at list 3 chars
  • performance: since the input field used in core is of type number, it's possible to keep the Up or Down arrow keys pressed to change its value. Keeping the key pressed continuously triggers the change event so lots of code is continuously running. Even on a modern macbook pro this makes the CPU go over 100% after a few seconds. The simplest solution I can think of is to debounce also the change callback.

Horizontal Hue Slider

I'm interested in restricting users access to the light/dark spectrum, so I'd love to have a horizontal slider-only UI element that only enables adjustment of the hue value. I was playing around a bit and I think this is already close-to-possible and I'll enable this in my WordPress environment by extending WP_Customize_Color_Control and messing around with a bit of the output HTML, etc. I just figured I would open it as an idea in case you had any thought on enabling it as an easily enabled option for the library.

A few suggestions

From the most important to me to the least important:

  1. Having alpha or rgba() would make it complete.
  2. I'm not sure if this is possible or not but absolute positioning of color picker would be a cool improvement (so that it can float above elements like in Photoshop).
  3. Maybe no message "pick a color" at all? It is quite clear anyway. I would add an alternative mode where upon initialization it still shows old input field and to the right of that input field you see a solid little square - exactly like this person did: http://dribbble.com/shots/232627-Custom-colour-picker (it's probably Iris).
  4. Additional controls (at least as an option) where user can manually put R, G, B or H, L, S numbers is sometimes useful to me in Photoshop as well.

Basically, I think that companies like Adobe or Autodesk deliver nice colorpickers in their products that can be used for further improvements. And for a person that is half-wordpress-user-half-designer (like a person setting up unified brand color for entire WordPress website through admin panel) some more options like number (4) might be useful.

I hope that some of my ideas will help make it better :)

Set color palette after instantiation?

Is it possible to set a color palette after the color picker has been instantiated? Advanced Custom Fields uses the Iris color picker as one of the available fields, and I'd like to be able to set the color palette without having to edit the ACF files.

Thanks!

Multiple lines palettes container

Hi!
Instead of having very little squares when setting a lot of palettes, it could be great to display them on several lines above ~ 8 / 10 palettes.
Thanks!

Setting to close Iris when you click off of it

I'm trying to use Iris for multiple text inputs on a page. However, whenever you open an instance of Iris, it does not close.

In this example - http://jsfiddle.net/sFnsB/1/ - you can see that there are 2x text inputs. I've styled Iris so it displays absolutely on top of the form (another feature I'd love to see out of the box), but as you'll see, it's pretty much impossible for me to use Iris in this scenario.

It would be great to have a 'close when you click away' setting for Iris. Or even an setting to add a close button, if desired.

Here is an image showing the current impracticalities of using Iris for my scenario -
iris-fail

wpColorPicker options and Iris options

I'm under the impression that all the options in Iris are not available to wpColorPicker.

In particular

var irisOnlyOptions = {
// the following option are available to iris not wpColorPicker
  color: false,
  mode: 'hsl',
  controls: {
    horiz: 's', // horizontal defaults to saturation
    vert: 'l', // vertical defaults to lightness
    strip: 'h' // right strip defaults to hue
    },
  border: true, // draw a border around the collection of UI elements
  target: false, // a DOM element / jQuery selector that the element will be appended within. Only used when called on an input.
  width: 150,
};

Is there some way to include these in wpColorPicker or am I out of luck?

Thanks.

Add simple touch capability

It seems like it would be fairly simple to add touch support to your control by changing:

line 556 from:

}).on( 'mousedown mouseup', function( event ) {

to:

}).on( 'mousedown mouseup touchmove touchend', function( event ) {

and line 594 from:

square.mousedown( function( event ) {

to:

square.on('mousedown touchmove', function( event ) {

btw, very nice plugin!

Value in field not updating

Hi,
I am trying to make a function that is called on color change... But the value in the input doesn't update. The text updates, but value stays the same. So I have some trouble calling my function.

Advice?
Thanks!

Refresh handle position when text input is changed via jquery

Hi there!

I am using WP Customizer to allow users configure my plugin. There are two color settings I would like to "sync", so changing the color from "color 1" makes "color 2" setting have the same value.

To achieve a full "sync", it is needed to achieve 3 things: update input value, button color and handle position.

So far, I have been able to make "color 2" have the same value and "button color" than "color 1" (with jQuery)... but I'm not able to make the iris handle to position where it should be. See screenshot below.

Anyone could tell how to force the handle to update its position accordingly to the inputted value?

image

Many thanks in advance!

Docs inaccessible????

Hi. It's my internet connection failing miserably or is there a problem with the url http://automattic.github.io/Iris/?
My browser say "waiting for response from ajax.googleapis.com..." and it stays there forever.
What's happening? How do I access the docs?

Set color to empty

Hey there,
it's not possible to reset color of the iris color picker to an empty value:
jQuery( element ).wpColorPicker( 'color', '' ); is not working here.
I solved it in following way:
jQuery( this ).find( '.wp-color-result' ).css( 'background-color', '' );

On initialization it works fine.

PS: I know it's the wp-color-picker, in iris it would be something like that:
jQuery( element ).iris( 'color', '' );
jQuery( this ).find( '.iris-result' ).css( 'background-color', '' );

Allways display `label` and `description` text above color-picker button

Hi there,
When I use the default WP_Customize_Color_Control Class the labeland descirption are displayed above the color-picker, but when I use the WP_Customize_Color_Control Class the labeland descriptiontext is shown after clicking on the color picker button, so the text is hidden.

See on the picture. The first picker is the WP_Customize_Color_Control, the rest is the WP_Customize_Color_Control Class.
bildschirmfoto 2018-04-17 um 11 52 19

The Code looks like that:

<?php
    // Text Color
    $wp_customize->add_setting( 'nav_text_color', array(
      'default'           => '',
    ) );
    $wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'nav_text_color', array(
      'label'    => esc_html__( 'Custom Style Options', 'onedrop_template' ),
      'description' => esc_html__( 'Text Color', 'onedropTemplate' ),
      'section'  => 'header_menulayout_section',
      'settings' => 'nav_text_color',
      'show_opacity' => true, // Optional.
      'priority' => 10
    ) ) );

    // Background Nav Color
    $wp_customize->add_setting( 'nav_background_color', array(
      'default'           => '',
    ) );
    $wp_customize->add_control( new Customize_Alpha_Color_Control( $wp_customize, 'nav_background_color', array(
      'description' => esc_html__( 'Background Color', 'onedropTemplate' ),
      'section'  => 'header_menulayout_section',
      'settings' => 'nav_background_color',
      'priority' => 10
    ) ) );
?>

Any Ideas? Thanks :))

Single click on Color Selector Appends # to URL

If you just Click the circle selector instead of Dragging it, it will append a # to the URL, causing the page to jump to the top.

Temporary fix until it's fixed in the repo:

jQuery(document).ready(function($){
    $('#color-picker').iris();

   // after initializing iris on your element(s)
   $('.iris-square-value').click(function(e) {
       e.preventDefault();
   });
});

No slider handle focus outlines in WordPress 4.3.1

The slider handles do not have focus outlines for accessibility when clicking or tabbing on a clean install of WordPress 4.3.1. I tried adjusting the CSS outline property with no success. You can see somewhat of a blue square in the middle of the center handle when clicked or focused using the tab key.

Reproduced issue in the latest versions of Chrome, Safari, Firefox, and Edge with a clean install of WordPress 4.3.1 and enqueuing the script using the 'iris' handle.

iristest

Recently used colors

It would be great if the box below the colorpicker displayed recently picked colors. Or if there was at least an option to include that.

Disable/Destroy methods

I'll try to add this in a pull request, but essentially from a development perspective, there should be a way to destroy and/or disable the colorpicker. If the colorpicker is instantiated on an input with a disabled property, the button should be disabled, which could be re-enabled by changing the input's disabled property and/or using a dedicated method of $.wpColorPicker.

Multiple color pickers on the page

How to use multiple color pickers on the page? I tried this

<input type="text" class='color-picker' value="#bada55" />
<input type="text" class='color-picker' value="#bada55" />

<script type="text/javascript">
jQuery(document).ready(function($){
    $('.color-picker').iris();
});
</script>

but it seems it doesn't work correctly, when I dragging the circle over the field with colors
23453245345345

Add new colors to palette without overwriting the previous colors?

I am using iris color picker (wordpress to exac) with a few preset color palettes. Now I want to add more colors, however I don't want to touch the previous code. I need a solution to extend the color palettes without touching the original code.

The problem I have, is that if I use the palette parameter again, it simply overwrites the previous selected palettes.

jQuery(document).ready(function($){
    $('#color-picker').iris({
        hide: false,
         palettes: ['#125', '#459', '#78b'],
    });
    
     $('#color-picker').iris({
         palettes: ['#000', '#000', '#000'],
    });
});

Here is my fiddle: http://jsfiddle.net/8ctrmsyx/

I also can't just add the previous color palettes, since there are dozens of different color pickers across the site, each with their own color palettes.

The easiest solution would be to somehow have a function to extend the palettes, rather than overwriting them.

How could I do that?

Require underscore?

Since underscore is bundled with WordPress 3.5, would it make sense to make it a dependency of Iris and use its native debounce() instead of recreating it? If we do use it, there are probably some other places where we could take advantage of its utility functions, this is just an obvious one I noticed.

Gradient selector and color links lack ARIA labels

We recently worked with the Inclusive Design Research Centre to conduct an accessibility audit on our WordPress-based software backend (for Pressbooks). In the course of that audit, the auditor indicated that the content of the color picker is not communicated to users of assistive technologies. For example, the selector within the gradient is communicated as link, and the various colors (black, white, red, etc.) are announced as group.
Screen Shot 2019-04-29 at 1 13 03 PM

Our auditors indicated that this can be fixed by adding an ARIA label to each color so that it says something other than 'group' (i.e. the color's name or hex value).

Enable rgba Colors

It'd be great if the color picker could output a rgba color and offer users an opacity option.

Cheers,

Sean.

Option to use as "overlay" over text instead inline

It would be awsome to have an option to use it more or less as a tooltip-style colorpicker instead of adding it inline to the input field.

On focus/enter the overlay opens, on exit/out of focus it closes.

Really like the plugin. Neat and simple layout.

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.