%META:TOPICINFO{author="TWikiContributor" date="1290815722" format="1.1" version="$Rev$"}%
---+!! Color Picker Contrib
<!--
   Contributions to this contrib package are appreciated. Please update this page at
   http://twiki.org/cgi-bin/view/Plugins/ColorPickerContrib or provide feedback at
   http://twiki.org/cgi-bin/view/Plugins/ColorPickerContribDev.
   If you are a TWiki contributor please update the extension in the SVN repository.
-->
<sticky>
<div style="float:right; background-color:#EBEEF0; margin:0 0 20px 20px; padding: 0 10px 0 10px;">
%TOC{title="Page contents"}%
</div>
<img src="%ATTACHURLPATH%/screenshot-edit.png" alt="screenshot-edit.png" width="201" height="227" style="float:right" />
</sticky>
%SHORTDESCRIPTION%

---++ Introduction

This module packages the [[http://acko.net/dev/farbtastic][Farbtastic color picker]], which is a jQuery plugin developed by Steven Wittens of Acko.net. The package adds a color picker to TWiki forms and TWiki applications.

---++ Using the color picker in !TWikiForms

This package adds a =color= type to %SYSTEMWEB%.TWikiForms:

| *Type* | *Description* | *Size* | *Value* |
| =color= | Single-line text box and a color picker to pick a color. The color can also be typed into the text box, such as =#123456=. %IF{ "'%BASETOPIC%'='TWikiForms'" then="[[ColorPickerContrib][See details]]." }% | Text box width in number of characters | Initial (default) color |

Example form definition:

| *Name:* | *Type:* | *Size* | *Values:* | *Tooltip message:* |
| Background color | color | 12 | | Select color |

---++ Using the color picker in an HTML form

You can also use the color picker directly in your HTML forms, without having to write any code. Just include this in the topic text:
<verbatim>
%INCLUDE{ "%SYSTEMWEB%.ColorPickerContrib" section="code" }%
%INCLUDE{ "%SYSTEMWEB%.ColorPickerContrib" section="picker" NAME="text_color" SIZE="12" VALUE="#123456" EXTRA="class=\"twikiInputField\"" }%
</verbatim>
This will show an HTML input field named "text_color" and a color picker tied to it. The ="code"= section should be included once per topic, the ="picker"= section can be included as many times as needed. The =size=, =value= and =extra= parameters are optional. Use the =extra= parameter to add additional parameters to the HTML input field.

Test: (this works only if the !ColorPickerContrib is installed)

<!--
%STARTSECTION{code}%<script type="text/javascript" src="%PUBURL%/%SYSTEMWEB%/ColorPickerContrib/farbtastic.js"></script> <link rel="stylesheet" href="%PUBURL%/%SYSTEMWEB%/ColorPickerContrib/farbtastic.css" type="text/css" />%ENDSECTION{code}%
<form>
%STARTSECTION{picker}%<input type="text" id="%NAME%" name="%NAME%" value="%IF{ "defined VALUE" then="$percntVALUE$percnt" else="#808080" }%" size="%IF{ "defined SIZE" then="$percntSIZE$percnt" else="12" }%" %IF{ "defined EXTRA" then="$percntEXTRA$percnt" }% /> <div id="%NAME%picker"></div> <script type="text/javascript"> $(document).ready(function() { $('#%NAME%picker').farbtastic('#%NAME%'); }); </script>%ENDSECTION{picker}%
</form>
-->
%INCLUDE{ "%TOPIC%" section="code" }%
%INCLUDE{ "%TOPIC%" section="picker" NAME="text_color" SIZE="12" VALUE="#123456" EXTRA="class=\"twikiInputField\"" }%

---++ Detailed Documentation


This package includes a small Perl module to make it easier to use the 
color picker from TWiki plugins. This module includes the functions:


---+++ renderForEdit

TWiki::Contrib::ColorPickerContrib::renderForEdit($name, $value, [, \%options]) -> $html

This is the simplest way to use the color picker from a plugin.

   * =$name= is the name of the CGI parameter for the calendar
     (it should be unique),
   * =$value= is the color such as '#8899aa' (may be empty)
   * =\%options= is an optional hash containing base options for
     the textfield.
Example:
<verbatim>
use TWiki::Contrib::ColorPickerContrib;
my $html = "<form>\n";
$html .= TWiki::Contrib::ColorPickerContrib::renderForEdit( 'webcolor'i, $value );
...
</verbatim>


---+++ addHEAD

TWiki::Contrib::ColorPickerContrib::addHEAD( )

=addHEAD= can be called from =commonTagsHandler= for adding the header to 
all pages, or from =beforeEditHandler= just for edit pages.



---++ Installation Instructions

You do not need to install anything in the browser to use this extension. The following instructions are for the administrator who installs the extension on the server where TWiki is running.

Like many other TWiki extensions, this module is shipped with a fully
automatic installer script written using the Build<nop>Contrib.
   * If you have TWiki 4.2 or later, you can install from the =configure= interface (Go to Plugins->Find More Extensions)
      * See the [[http://twiki.org/cgi-bin/view/Plugins/BuildContribInstallationSupplement][installation supplement]] on TWiki.org for more information.
   * If you have any problems, then you can still install manually from the command-line:
      1 Download one of the =.zip= or =.tgz= archives
      1 Unpack the archive in the root directory of your TWiki installation.
      1 Run the installer script ( =perl &lt;module&gt;_installer= )
      1 Run =configure= and enable the module, if it is a plugin.
      1 Repeat for any missing dependencies.
   * If you are *still* having problems, then instead of running the installer script:
      1 Make sure that the file permissions allow the webserver user to access all files.
      1 Check in any installed files that have existing =,v= files in your existing install (take care *not* to lock the files when you check in)
      1 Manually edit !LocalSite.cfg to set any configuration variables.

%IF{"defined 'SYSTEMWEB'" else="<div class='twikiAlert'>%X% WARNING: SYSTEMWEB is not defined in this TWiki. Please add these definitions to your %MAINWEB%.TWikiPreferences, if they are not already there:<br><pre>   * <nop>Set SYSTEMWEB = %<nop>TWIKIWEB%<br>   * <nop>Set USERSWEB = %<nop>MAINWEB%</pre></div>"}%


---++ Contrib Info

   * Set SHORTDESCRIPTION = Color picker for use in TWiki forms and TWiki applications

|  Author: | TWiki:Main.PeterThoeny, [[http://twiki.net][Twiki Inc]] |
|  Copyright: | &copy; 2007 [[http://acko.net/about][Steven Wittens]], Acko.net for Farbtastic jQuery plugin %BR% &copy; 2010 TWiki:Main.PeterThoeny and TWiki:TWiki.TWikiContributor for TWiki !ColorPickerContrib |
|  License: | GPL ([[http://www.gnu.org/copyleft/gpl.html][GNU General Public License]]) |
|  Dependencies: | None |
|  Version: | 19885 (2010-11-26) |
|  Change History: | <!-- versions below in reverse order -->&nbsp; |
|  2010-11-27: | TWikibug:Item6609: In %SYSTEMWEB%.TWikiForms type table, automatically list the =color= form field type defined in this contrib -- TWiki:Main.PeterThoeny |
|  2010-11-26: | TWikibug:Item6606: Complete rewrite of contrib using [[http://acko.net/dev/farbtastic][Farbtastic color picker]] -- TWiki:Main.PeterThoeny |
|  2006-10-27: | Initial version by TWiki:Main.FlavioCurti using Colorpicker by Norman Timmler (inlet media e.K., Hamburg, Germany) |
|  Home: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC% |
|  Feedback: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Dev |
|  Appraisal: | http://TWiki.org/cgi-bin/view/Plugins/%TOPIC%Appraisal |

__Related Topics:__ %SYSTEMWEB%.TWikiPreferences, %SYSTEMWEB%.TWikiForms, %SYSTEMWEB%.TWikiContribs

%META:FILEATTACHMENT{name="screenshot-edit.png" attachment="screenshot-edit.png" attr="h" comment="" date="1290756224" path="screenshot-edit.png" size="29633" user="TWikiContributor" version="1"}%
