Giter VIP home page Giter VIP logo

jquery-simplecolorpicker's Introduction

Very simple jQuery color picker

Yet another jQuery color picker. This plugin is unobtrusive and integrates well with Twitter Bootstrap (it works just fine without). The source code only requires jQuery and is about 200 lines of JavaScript and 100 lines of CSS.

See the online demo.

simplecolorpicker-inline.png

simplecolorpicker-picker.png

How to use

Create a HTML select:

<select name="colorpicker">
  <option value="#7bd148">Green</option>
  <option value="#5484ed">Bold blue</option>
  <option value="#a4bdfc">Blue</option>
  <option value="#46d6db">Turquoise</option>
  <option value="#7ae7bf">Light green</option>
  <option value="#51b749">Bold green</option>
  <option value="#fbd75b">Yellow</option>
  <option value="#ffb878">Orange</option>
  <option value="#ff887c">Red</option>
  <option value="#dc2127">Bold red</option>
  <option value="#dbadff">Purple</option>
  <option value="#e1e1e1">Gray</option>
</select>

add the plugin files:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.js"></script>
<script src="jquery.simplecolorpicker.js"></script>

<link rel="stylesheet" href="jquery.simplecolorpicker.css">

then call the plugin:

$('select[name="colorpicker"]').simplecolorpicker();
$('select[name="colorpicker"]').simplecolorpicker('selectColor', '#7bd148');
$('select[name="colorpicker"]').simplecolorpicker('destroy');

and pass some options if needed:

$('select[name="colorpicker"]').simplecolorpicker({
  picker: true
}).on('change', function() {
  $(document.body).css('background-color', $('select[name="colorpicker"]').val());
});

Options

  • theme: font to use for the ok/check mark (default: ''), available themes: regularfont, fontawesome, glyphicons
  • picker: show the colors inside a picker instead of inline (default: false)
  • pickerDelay: show and hide animation delay in milliseconds (default: 0)

Browser support

Simplecolorpicker supports all modern browsers starting with Internet Explorer 8 included. It is recommended to not use any font theme with IE8.

HTML5 new color input

HTML5 provides a new input to select colors. Its implementation inside modern browsers is still lacking. The new color input does not provide any option to customize the color list and most of the time the widget is less user-friendly than the one provided by simplecolorpicker.

See http://slides.html5rocks.com/#new-form-types

See http://dev.w3.org/html5/markup/input.color.html#input.color

Bower

bower install jquery-simplecolorpicker

AngularJS directive

See simplecolorpicker directive. If you find a solution for the setTimeout() hack, please tell me.

Here another directive written by KGZM that re-implements simplecolorpicker. For the explanations, read this Google Groups discussion.

Ruby on Rails

A gem is available at https://github.com/tkrotoff/jquery-simplecolorpicker-rails

Copyright and license

Licensed under the MIT license. Copyright (C) 2012-2013 Tanguy Krotoff

jquery-simplecolorpicker's People

Contributors

tkrotoff avatar powerbuoy avatar dotjoel avatar

Watchers

James Cloos avatar Boris avatar

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.