# \[Pro\] Best Way to Approach Multiple Rollovers

**URL:** <https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655>\
**Category:** Freeway\
**Created:** [November 17, 2012, 3:51am UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655 "2012-11-17T03:51:56Z")\
**Posts on this page:** 10\
**Page:** 2

<div class="post-metadata">

**Author:** ![David\_McCallum](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@David\_McCallum](https://discourse.softpress.com/u/David_McCallum)\
**Post date:** [November 19, 2012, 9:22pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/21 "2012-11-19T21:22:44Z")

</div>

Walter - how would you go about adding the Hex value to the colour name on the swatch ie Alice Blue #F0F8FF

I see caption.update(elm.retrieve(‘caption’)); but cant seem to get the colour value in there.

David

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [November 19, 2012, 9:27pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/22 "2012-11-19T21:27:35Z")

</div>

You would do that in the “database” array:

```auto
...
{'f0f8ff': 'Alice Blue #F0F8FF'},
…

```

Whatever you add in the value part of the object will become the caption, while the key will become the background color.

Walter

On Nov 19, 2012, at 4:22 PM, DeltaDave wrote:

> Walter - how would you go about adding the Hex value to the colour name on the swatch ie Alice Blue #F0F8FF
> 
> I see caption.update(elm.retrieve(‘caption’)); but cant seem to get the colour value in there.
> 
> David
> 
> * * *
> 
> freewaytalk mailing list  
> email@hidden  
> Update your subscriptions at:  
> [http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![David\_McCallum](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@David\_McCallum](https://discourse.softpress.com/u/David_McCallum)\
**Post date:** [November 19, 2012, 9:33pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/23 "2012-11-19T21:33:48Z")

</div>

I thought you could maybe pull it from the JS using something like elm.retrieve(‘caption’ + ‘background-color’) or create a new variable first from the bg color and then include the variable.

D

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [November 19, 2012, 9:40pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/24 "2012-11-19T21:40:19Z")

</div>

You could, but I wanted to keep the logic simple in the JavaScript.

The database holds matched pairs of colors and captions. Whatever you put in the database is shown on the page.

Now if you already had your database populated, you could use find-and-replace in TextMate/TextWrangler/BBEdit to automatically update the caption with the color value.

Or you could hack the script with something like `swatch.store('caption', $H(color).values().first() + ' #' + $H(color).keys().first());` up in the `colors.each()` block. That would keep you from having to edit the database if you didn’t want to do that, at the expense of making the example less clear.

Walter

On Nov 19, 2012, at 4:33 PM, DeltaDave wrote:

> I thought you could maybe pull it from the JS using something like elm.retrieve(‘caption’ + ‘background-color’) or create a new variable first from the bg color and then include the variable.
> 
> D
> 
> * * *
> 
> freewaytalk mailing list  
> email@hidden  
> Update your subscriptions at:  
> [http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![David\_McCallum](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@David\_McCallum](https://discourse.softpress.com/u/David_McCallum)\
**Post date:** [November 19, 2012, 9:47pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/25 "2012-11-19T21:47:36Z")

</div>

> I wanted to keep the logic simple in the JavaScript

Understood - I was really just fiddling to try a bit of enhancement.

I will fiddle some more.

Thanks

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![David\_McCallum](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@David\_McCallum](https://discourse.softpress.com/u/David_McCallum)\
**Post date:** [November 19, 2012, 10:01pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/26 "2012-11-19T22:01:04Z")

</div>

That worked.

My thinking was to create a page that has all those common colours with their Hex values that I can use for my own reference.

Done!

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![Tim3](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/t/f14d63/32.png) [@Tim3](https://discourse.softpress.com/u/Tim3)\
**Post date:** [November 21, 2012, 3:03pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/27 "2012-11-21T15:03:48Z")

</div>

## This appears to have worked out really well. One of the benefits of holding the colours in an object like this is that you could sort the image swatches based on name, hue, tone, popularity or any other variables. Regards, Tim.

Experienced Freeway designer for hire - [http://www.freewayactions.com](http://www.freewayactions.com)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [November 21, 2012, 4:18pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/28 "2012-11-21T16:18:31Z")

</div>

And nobody has tried to spot the difference? I’ll give you a hint: “quantity of anonymous functions”.

Walter

On Nov 18, 2012, at 3:24 PM, Walter Lee Davis wrote:

> Bonus points for anyone who can tell me what the difference is, and why it matters.

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![David\_McCallum](https://discourse.softpress.com/letter_avatar_proxy/v4/letter/d/ec9cab/32.png) [@David\_McCallum](https://discourse.softpress.com/u/David_McCallum)\
**Post date:** [November 21, 2012, 5:23pm UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/29 "2012-11-21T17:23:34Z")

</div>

> And nobody has tried to spot the difference?

Oh we have seen the differences but need your superior intellect to make sense of them!

😉

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

---

<div class="post-metadata">

**Author:** ![waltd](https://discourse.softpress.com/user_avatar/discourse.softpress.com/waltd/32/2720_2.png) [@waltd](https://discourse.softpress.com/u/waltd)\
**Post date:** [November 22, 2012, 5:41am UTC](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655/30 "2012-11-22T05:41:17Z")

</div>

Pshaw!

In my first attempt at this, I created the click observer within in the mouseover observer that showed the popup. What this meant was that each time the mouseover fired, a new handler was created for the click event, which was a waste. Changing it the way I did in the second example put a single click handler on the popup at the beginning of the page load, and never varied it. The only thing that changed was the address – the value of the go variable. By not creating a new handler at each show of the popup, the whole script runs quite a lot faster and that makes the page run better over time. (It also won’t leak a bunch of memory in IE \< 10.)

Walter

On Nov 21, 2012, at 12:23 PM, DeltaDave wrote:

> > And nobody has tried to spot the difference?
> 
> Oh we have seen the differences but need your superior intellect to make sense of them!
> 
> 😉
> 
> * * *
> 
> freewaytalk mailing list  
> email@hidden  
> Update your subscriptions at:  
> [http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

* * *

freewaytalk mailing list  
email@hidden  
Update your subscriptions at:  
[http://freewaytalk.net/person/options](http://freewaytalk.net/person/options)

[Previous page](https://discourse.softpress.com/t/pro-best-way-to-approach-multiple-rollovers/15655.md?page=1)
