Home

Farbtastic 1.2 out

Jan 09, 2007

I've released a new version of Farbtastic which fixes a bug with multiple fields that have the same value.

Get it from the Farbtastic page.

Thanks!

Jan 10, 2007 Torsten

Great news! Thanks.

Issues with jQuery 1.1

Jan 15, 2007 David

First off, Great piece of code. It is a really awesome asset that I am truly looking forward to using in my CMS.

I am working to integrate the new jQuery 1.1 release into my development process and have noticed that there are issues with Farbtastic in the new release. For example, the selector will follow the cursor when any area of the document window is clicked. Also, I can't select the input field I am linking to via the linkTo() function to manual entre the color.

Thanks again for your contribution!

David

Cool! But I'm stymied.

Feb 19, 2007 Eric Meyer

I was looking around for a tool like this one, and I really like your implementation. Thanks! I was wondering something, and I suspect this is pretty much entirely based on my limited JS skills and total lack of understanding of OO principles: how do I get the picker to update the color of one element while dumping the color value to another element entirely? If you just say "use .color()" I'll be no better off, since my attempts along those lines failed.

Here's what I'm trying to do in a nutshell:

1. Have a picker that's pre-set to the color value of a div; let's call it #one.
2. Changing the picker changes the color of #one.
3. As the color of #one is updated via the picker, the value of #two (another div) is set to the newly picked color in hex form.

I've managed to do #2. #1 and #3 are beyond me, it would seem. Even if you just created a quick demo file showing how to do that, I'm pretty sure I could take it from there.

Thanks again for the nice tool, and I hope you'll show pity on a poor OOJS newbie!

Custom callback

Feb 19, 2007 Steven

Instead of tying farbtastic directly to some elements, you can specify a callback function for linkTo / callback and do whatever you want. You can look at farbtastic's internal callback to see how it does things by default.

For your problem, something like this should work (where f is a farbtastic object).

f.linkTo(function () {
  $('#one').css('backgroundColor', f.color);
  $('#two').attr('value', f.color);
});

I don't have time for hand-holding, sorry. Farbtastic is documented, and there are plenty of resources online that explain JS, closures and OO.

Thanks anyway

Feb 20, 2007 Eric Meyer

Yeah, I've read quite a few resources on those topics. So far, none of them make sense to me-- I grew up in a procedural era, and haven't been able to make the conceptual leap. Which would most likely be why I didn't really understand what you posted, though I picked up a few more glimmerings of possible understanding. (Maybe.)

Sorry to have troubled you.

Be nice with dean edwards' packer

May 21, 2007 Rodrigo Moraes

Hi, Steven. Thank you very much for this plugin. It's awesome.

I just ask you to be nice with dean edwards' packer (http://dean.edwards.name/packer/) in future versions. Farbtastic currently misses semi-colons to make the packer work nice. But it is really easy to make it 'packable': just add a semi-colon to the end of all assignments and functions.

Patch to make color picker work within scrolling element

Jan 04, 2008 phred

What a wonderful plugin! The only thing lacking is support for hosting the color picker within a scrollable element; here's my patch which allows just that:

diff -u farbtastic.js ~fred/js/farbtastic.js
--- farbtastic.js 2007-01-09 22:53:11.000000000 -0800
+++ js/farbtastic.js 2008-01-04 08:31:50.000000000 -0800
@@ -108,6 +108,7 @@
     if (typeof event.offsetX != 'undefined') {
       // Use offset coordinates and find common offsetParent
       var pos = { x: event.offsetX, y: event.offsetY };
+      var scrollTop = 0, scrollLeft = 0;

       // Send the coordinates upwards through the offsetParent chain.
       var e = el;
@@ -116,12 +117,14 @@
         e.mouseY = pos.y;
         pos.x += e.offsetLeft;
         pos.y += e.offsetTop;
+        scrollTop += e.scrollTop;
+        scrollLeft += e.scrollLeft;
         e = e.offsetParent;
       }

       // Look for the coordinates starting from the wheel widget.
       var e = reference;
-      var offset = { x: 0, y: 0 }
+      var offset = { x: 0 - scrollLeft, y: 0 - scrollTop }
       while (e) {
         if (typeof e.mouseX != 'undefined') {
           x = e.mouseX - offset.x;

Post new comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <b> <dd> <dl> <dt> <i> <li> <ol> <u> <ul> <img> <em> <p> <br> <span> <div> <h2> <h3> <abbr> <small> <table> <tr> <td> <strong> <acronym> <th> <blockquote>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

Recent comments

Images