claviska/jquery-miniColors — pull request #18 by cbosco (2012-06-27 21:10:02+00:00)
Title: Decouple selector widget from input field $.fn API

First off, I love your plugin!

I know this looks like a huge change so I wanted to completely explain.

I'd like to use this color picker on our [photo editor](http://www.aviary.com/web). We don't use input fields for color in the editor (it's not altogether accessibility-friendly if I'm being honest) but I still want to use the color picker itself.

Most of this code actually seems to handle the input field API and I thought I could apply the jquery plugin pattern where you have a library on the `$` namespace and then your DOM API on the `$.fn` one to this plugin and thus have to use far less code in my project.

## changes

* Looser coupling of the input field API (`$.fn`) from the color picker widget itself.
* Input field DOM API communicates directly with the color picker widget API via 4 simple functions -

api.setSelectorColor = setSelectorColor;
api.buildSelector = buildSelector;
api.bindSelectorEvents = bindSelectorEvents;
api.unBindSelectorEvents = unBindSelectorEvents;

* This library (`$`) communicates back by publishing a couple custom jQuery events and does not have a reference back to the input field
* With that decoupling I was able to remove some "extra" `data()` splats properties that you were using to keep track of mouse state on the widget.
* Finally, I re-generated the minified output but used uglify.js. I'm not sure what was originally used so it doesn't look exactly the same but seems to work fine in practice

I ended up with two files (not crazy about file names) but the `$` library is *miniColors.js*, while your original API is *jquery.miniColors.js* and it depends on the former file.