[Pro] Best Way to Approach Multiple Rollovers

Hello all,

I’m a novice Freeway Pro user and after a couple of weeks of playing around with the software, watching tutorials, and forum browsing I think I’m ready to tackle my first Freeway project.

I want to create a color selector similar to the one in the link. Basically I want a larger swatch of the color, which would also include the color name/number, to appear as you mouse over it. I think it would be pretty straightforward creating this effect using the Rollover action, but as I plan to include approx. 500 colors I was hoping to get some suggestions describing the most efficient way of doing this. I have all the colors I will be using saved as 1 X 1 px PNG files. Should the larger swatch which includes the color name be created in Photoshop and imported as a graphic? Is there a better way?

I believe the Rollover 60 action should allow for up to 600 individual items. Is there a way of going beyond 600 items on a single page if I decide to include more colors? Should I use the iFrame action and target another page containing the additional items?

Thanks in advance and thanks to all the contributing members of this forum – I have found it to be an invaluable resource.

Cheers,
Roy


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

You are going to go nuts, or die of repetitive stress injury, before you get 500 color swatch rollovers to work long-hand like this. What I would do is name each of the 1x1 pngs to match the color name, using underscore characters to replace spaces. So your file would be called Butterfly_Bush.png if that was the color name. Then I would use a single JavaScript to trigger all of the rollovers on the page. I’ll see if I can knock something together for you this weekend. Get to work renaming all of your color image files!

Walter

On Nov 16, 2012, at 10:51 PM, Roy H wrote:

Hello all,

I’m a novice Freeway Pro user and after a couple of weeks of playing around with the software, watching tutorials, and forum browsing I think I’m ready to tackle my first Freeway project.

I want to create a color selector similar to the one in the link. Basically I want a larger swatch of the color, which would also include the color name/number, to appear as you mouse over it. I think it would be pretty straightforward creating this effect using the Rollover action, but as I plan to include approx. 500 colors I was hoping to get some suggestions describing the most efficient way of doing this. I have all the colors I will be using saved as 1 X 1 px PNG files. Should the larger swatch which includes the color name be created in Photoshop and imported as a graphic? Is there a better way?

I believe the Rollover 60 action should allow for up to 600 individual items. Is there a way of going beyond 600 items on a single page if I decide to include more colors? Should I use the iFrame action and target another page containing the additional items?

Thanks in advance and thanks to all the contributing members of this forum – I have found it to be an invaluable resource.

Cheers,
Roy

Wood Stain Colors - Find The Right Deck Stain Color For Your Project - Olympic


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


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

Thanks for your help Walter.

As it happens I’ve already named my color files in the format you suggested. I’ve written the color number followed by the name as in FF083_Vanilla_Cream.png. The longest name is 30 characters long.

Looking forward to any Javascript you can put together although I was already preparing myself mentally for the arduous task of duplicating a color swatch 499 times and adjusting all the individual parameters. Obviously not the most practical method, but it would’ve built some character I think.

Roy


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

The larger image can be created by using the small one as a bg image in an html container set to repeat - not sure that will give you the quality you want/need though. And 1 x 1 Pngs are a too small to use as a starter maybe 25 x 25 instead

David


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

Hi Roy,
As Walter suggests doing this sort of thing manually using the rollover Action (or similar) will drive you nuts and will take forever. Freeway is very good at allowing you to produce unique web designs but this, IMHO, is a job for an automated solution that will crack through the colours and add them to the page in a split second.

Personally I’d consider dumping the PNGs as well and create the colour swatches using background colours. The page will be smaller, faster to load and should be a lot easier to keep up to date as you won’t need to make new PNG files for any new colours.

It looks like you’d need a ‘database’ of colour values, the colour names, and maybe a link to the colour product page when the user wants to find out more about the colour. The ‘database’ doesn’t need to be a real database but can be an exported text file from a spreadsheet or even just your folder of PNG images.

I think an ideal solution would be to design your first colour swatch in Freeway and ‘tag’ the background colour, names and links with special tokens that is replaced when the page is published. The script or Action would dutifully step and repeat this master swatch replacing the tokens for the real colour values, names and links as it builds the page. Then if you wanted to update the design without changing the data you could quite easily or, alternatively, update the data and leave the design intact.
Regards,
Tim.

On 17 Nov 2012, at 03:51, Roy H wrote:

I want to create a color selector similar to the one in the link. Basically I want a larger swatch of the color, which would also include the color name/number, to appear as you mouse over it. I think it would be pretty straightforward creating this effect using the Rollover action, but as I plan to include approx. 500 colors I was hoping to get some suggestions describing the most efficient way of doing this. I have all the colors I will be using saved as 1 X 1 px PNG files. Should the larger swatch which includes the color name be created in Photoshop and imported as a graphic? Is there a better way?


FreewayActions.com - Freeware and commercial Actions for Freeway Express & Pro - http://www.freewayactions.com


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

Tim, that’s an excellent idea. Roy, if you don’t have a good programmer’s text editor, please get one. I personally use TextMate 1.5, but there is a free editor named TextWrangler that is a very solid tool for the occasional programmer. http://barebones.com

Once you have that in hand, open up a new file and start typing in this format:

var colors = {
	'ffffff' => 'Bright White',
	'ffffcc' => 'Pale Yellow',
	…
};

That is to say, make a JavaScript object where the keys are the hex color numbers and the values are the color names. After each color name EXCEPT the last, add a comma before the line-break. The goal is to have a long running comma-delimited set of color pairs, with no comma after the last pair.

You may find it helpful to use the Language picker in your editor (bottom left of the TextWrangler window, defaults to None in a blank file) to hint to the editor that you are writing JavaScript. What this will gain you is color-coded syntax highlighting, so you’ll see when you fail to close a quote or similar.

Once you’re done with this, come on back and I should have a script that can use this database to build the final page.

Walter

On Nov 17, 2012, at 7:15 AM, Tim Plumb wrote:

Personally I’d consider dumping the PNGs as well and create the colour swatches using background colours. The page will be smaller, faster to load and should be a lot easier to keep up to date as you won’t need to make new PNG files for any new colours.


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

Thanks a ton for your help guys.

I should note that the PNG color files I want to use aren’t random color values but colors that correlate to the collections we use in my paint business. The only way I can think of determining the hex values would be to hover over the file preview window in the finder with a color picker tool. This will probably take a couple hours but I have a picker tool app with a hotkey that allows you to cut and paste the hex values. As this will undoubtedly save me countless hours in the long run I’m only too happy to do it.

I will start working on the database but have a few questions. Does the order of the colors in the database matter at this point? Is there a way of later sorting the colors by color number so that if I add colors in the future they will be in the correct order? I will be including the color number as part of the color name value as in ‘FA103 Bright Yellow’ (unless you think it would be better to make the color number a separate value).

Cheers,
Roy


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

Hashes don’t respect order at all. Opening the same hash two different times and iterating over its members may result in a different order of operations two different times.

If you want to set a particular order, then you need to use an array instead of a hash for your data structure. Adding the colors in the order you want them to appear will be a manual task, as will inserting new colors later on. You will maintain the database within this text file, so that’s where you need to begin. Instead of one large object with all of the colors inside it, we will use an array of objects to maintain the structure:

var colors = [
	{'ffffff' => 'Bright White'},
	{'ffffcc' => 'Pale Yellow'},
	…
];

Again, you are using commas to delimit each element from the next, and you don’t add a trailing comma after the last object in the array.

Actually, now that I think about how this will get added to your page, it’s best if you start off at this level using the Prototype.js helper method $A():

var colors = $A([
	/*objects here, as above, comma-delimited  */
]);

Let me know when you have that together.

Walter

On Nov 17, 2012, at 12:24 PM, Roy H wrote:

Thanks a ton for your help guys.

I should note that the PNG color files I want to use aren’t random color values but colors that correlate to the collections we use in my paint business. The only way I can think of determining the hex values would be to hover over the file preview window in the finder with a color picker tool. This will probably take a couple hours but I have a picker tool app with a hotkey that allows you to cut and paste the hex values. As this will undoubtedly save me countless hours in the long run I’m only too happy to do it.

I will start working on the database but have a few questions. Does the order of the colors in the database matter at this point? Is there a way of later sorting the colors by color number so that if I add colors in the future they will be in the correct order? I will be including the color number as part of the color name value as in ‘FA103 Bright Yellow’ (unless you think it would be better to make the color number a separate value).

Cheers,
Roy


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


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

Typo in these instructions (I substituted Ruby hash syntax for JavaScript). Make it like this:

var colors = $A([
	{'ffffff': 'Bright White'},
	etc.
]);

Sorry for the mix-up, should be easy to find-and-replace if you have already begun.

Walter

On Nov 17, 2012, at 12:41 PM, Walter Lee Davis wrote:

var colors = [
{‘ffffff’ => ‘Bright White’},
{‘ffffcc’ => ‘Pale Yellow’},

];


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

Hey Walter - Just wanted to make sure I’ve got the format correct before I jump into it…

var colors = $A([
{‘84472F’: ‘BH005 Fall Back’},
{‘AF694B’: ‘BH107 Cream soda’},
{‘873A26’: ‘FC063 Western Setting’} ]);

So if I understand you correctly, if I wanted “Cream Soda” to be the first color in the series I would reorganize the database like this:

var colors = $A([
{‘AF694B’: ‘BH107 Cream soda’},
{‘84472F’: ‘BH005 Fall Back’},
{‘873A26’: ‘FC063 Western Setting’} ]);

Also, I don’t have all the colors I want to use ready yet but I should be able to add or remove colors from the database at any point, no?

This is incredibly helpful.

Thanks,
Roy


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

Yes. I have the rest of it working here:

http://scripty.walterdavisstudio.com/mr-chips.html

This is just using the same five colors over and over, but it’s working in terms of layout.

About that layout: this page is currently hand-coded, but in a way that resembles how Freeway would draw a page. I have to run out right now, but I’ll try to get you some instructions for threading this all together in Freeway later today.

Walter

On Nov 17, 2012, at 1:14 PM, Roy H wrote:

Hey Walter - Just wanted to make sure I’ve got the format correct before I jump into it…

var colors = $A([
{‘84472F’: ‘BH005 Fall Back’},
{‘AF694B’: ‘BH107 Cream soda’},
{‘873A26’: ‘FC063 Western Setting’} ]);

So if I understand you correctly, if I wanted “Cream Soda” to be the first color in the series I would reorganize the database like this:

var colors = $A([
{‘AF694B’: ‘BH107 Cream soda’},
{‘84472F’: ‘BH005 Fall Back’},
{‘873A26’: ‘FC063 Western Setting’} ]);

Also, I don’t have all the colors I want to use ready yet but I should be able to add or remove colors from the database at any point, no?

This is incredibly helpful.

Thanks,
Roy


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


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

Looks really good!

Roy


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

I’ve updated this to use a list of named HTML colors I found on the Web. They’re in alphabetical order, so they don’t look all that coherent. I’ve also tightened up the code to make it run faster.

Here’s how to thread this into Freeway (version 5.6.2 or newer). You will need the Protaculous and External JavaScript Actions, both available at ActionsForge. (Download the latest of each, unless you already have the latest version installed.)

Start with a blank page to begin, and make sure that the CSS Layout button is on. You can style up this page with additional elements after you have gone through these basic steps, but I want you to succeed at first, so you know it works, before you start mixing in other Actions and confusing the issue.

  1. Apply the External JavaScript Action to the page, use it to link your colors file (which you should name colors.js) to the page, in the Before position.
  2. Apply Protaculous to the page. Set the Library picker to prototype-packed.
  3. Somewhere off-screen (like above the visible page on the pasteboard) draw an HTML box to be your large “popover” swatch. (The script will move it into place, you just have to make it look the way you want it to look.) Be sure to give it a solid background color. Use the Padding control in the Inspector to create the amount of inset you want (if you’re trying to copy my example, that’s 5px). Name this box ‘popover’.
  4. Double-click inside that box and choose Insert / HTML Item from the main menu. Drag the bottom of the inline HTML box to be the size you want the color swatch to be. You can set a color for design purposes, it will be overridden by the script later.
  5. Click elsewhere, then double-click in your example swatch again and type a return followed by a line of placeholder text for your color name. Be sure to style this text using a paragraph style that you make yourself in the Styles palette. It has to be a paragraph style so it won’t have any inline tags in it (these would get wiped out by the script, leaving unstyled text).
  6. Draw another HTML box on the page that is large enough to hold your swatches. You don’t need to actually create the swatches inside it, the script will do that. Name this box ‘swatches’. In the Inspector, set the Overflow attribute for this box to Hidden.
  7. Use the Page / HTML Markup dialog in the Before section to add the following CSS to the page:
<style type="text/css">
#swatches div {
  width: 64px;
  height: 64px;
  float: left;
  border: 1px solid #ccc;
  margin: 0 5px 5px 0;
  padding: 0;
}
</style>
  1. Click on the Protaculous tab in the Actions palette, and click on the top Function Body button. Paste in the following script:
var popover = $('popover').hide().observe(
  'mouseleave',
  function(){ this.hide(); }
);
var example = popover.down('div');
var caption = popover.down('p');
var box = $('swatches');
colors.each(function(color){
  var swatch = new Element('div');
  swatch.setStyle('background-color: #' + $H(color).keys().first());
  swatch.store('caption', $H(color).values().first());
  box.insert(swatch);
});
box.on('mouseover','#swatches > div', function(evt, elm){
  example.setStyle('background-color: ' + elm.getStyle('background-color'));
  caption.update(elm.retrieve('caption'));
  popover.clonePosition(elm, {
    offsetTop: -25,
    offsetLeft: -22,
    setWidth: false,
    setHeight: false
  }).show();      
});

Preview into a browser, and see what happens. If you’ve followed these directions closely, you should see something similar to my example. Things you can start tinkering with after the page works:

  • The size of the swatches. Remember that they have to be large enough to “peek out” from the left and right of the popover overlay, so you can switch from one color to the next by swiping the cursor over the grid.
  • The amount of the offsetTop and offsetLeft attributes in the JavaScript. This is related to the size of your swatches, and the size of your popover. Fiddle with these values, which are the number of pixels up and to the left of the top-left corner of the swatch that the popover is related to. I fiddled to get these, based on the dimensions in my example, so that the popover would be visually centered over its parent swatch.
  • Add the CSS3 Shadow Action to the popover to give it some lift above the grid.

Walter

On Nov 17, 2012, at 1:41 PM, Walter Lee Davis wrote:

Yes. I have the rest of it working here:

Mr. Chips

This is just using the same five colors over and over, but it’s working in terms of layout.

About that layout: this page is currently hand-coded, but in a way that resembles how Freeway would draw a page. I have to run out right now, but I’ll try to get you some instructions for threading this all together in Freeway later today.

Walter

On Nov 17, 2012, at 1:14 PM, Roy H wrote:

Hey Walter - Just wanted to make sure I’ve got the format correct before I jump into it…

var colors = $A([
{‘84472F’: ‘BH005 Fall Back’},
{‘AF694B’: ‘BH107 Cream soda’},
{‘873A26’: ‘FC063 Western Setting’} ]);

So if I understand you correctly, if I wanted “Cream Soda” to be the first color in the series I would reorganize the database like this:

var colors = $A([
{‘AF694B’: ‘BH107 Cream soda’},
{‘84472F’: ‘BH005 Fall Back’},
{‘873A26’: ‘FC063 Western Setting’} ]);

Also, I don’t have all the colors I want to use ready yet but I should be able to add or remove colors from the database at any point, no?

This is incredibly helpful.

Thanks,
Roy


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


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


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

At 23:15 -0500 17/11/12, Walter Lee Davis wrote:

I’ve updated this to use a list of named HTML colors I found on the
Web. They’re in alphabetical order, so they don’t look all that
coherent. I’ve also tightened up the code to make it run faster.

There’s a list of 752 colour names on your Mac if you have X Windows
installed. A lot are space/capitalisation/spelling duplicates such as

211 211 211 light grey
211 211 211 LightGrey
211 211 211 light gray
211 211 211 LightGray
25 25 112 midnight blue
25 25 112 MidnightBlue
0 0 128 navy
0 0 128 navy blue
0 0 128 NavyBlue

but it’s a well established list going back 25-30 years to my
knowledge. It’s at

/usr/X11/share/X11/rgb.txt

David


David Ledger - Freelance Unix Sysadmin in the UK.
email@hidden
www.ivdcs.co.uk


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

It works great Walter. I still have to play around with formatting but it is exactly what I was after.

At the risk of wearing out my welcome early, could you tell me how I would go about adding a hyperlink to the swatches? I could create a page for each color and give it a page title based on the color name, number, or hex value (whichever database value would be most convenient for the script to refer to).

Thanks again,
Roy


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

If you make all of those pages before-hand in Freeway, you could use the color value as the page file name, then it would be easy to add that link to the script. Let’s say you are hovered over the white chip. The color of that chip is coded as #ffffff, so your page would be named ffffff.html. It doesn’t matter whether you used FFFFFF or ffffff, we will just convert it to lower-case to fix that.

Then, in the JavaScript you pasted into the Protaculous Action, you would add a bit of code after the first four lines (the fourth line is modified slightly, too – remove the trailing semi-colon).

var popover = $('popover').hide().observe(
  'mouseleave',
  function(){ this.hide(); }
).observe('click', function(evt){
  var color = this.getStyle('background-color').sub('#', '').toLowerCase();
  window.location.href = color + '.html';
});

All the rest of the script stays the same. In your CSS style, you can add a new line to make the pointer cursor appear, so your visitors know that the big swatch is clickable:

#popover { cursor: pointer }

That should complete the illusion.

One last note – this whole thing is not very mobile-friendly. It will work just as advertised on anything with a mouse, since it uses mouseovers, but iOS and Android do not have any notion of a mouse or cursor, so they won’t see the effect at all, and are effectively locked out. You might want to think about that a bit, given that mobile is the fastest-growing segment of the browser pie.

Walter

On Nov 18, 2012, at 10:38 AM, Roy H wrote:

It works great Walter. I still have to play around with formatting but it is exactly what I was after.

At the risk of wearing out my welcome early, could you tell me how I would go about adding a hyperlink to the swatches? I could create a page for each color and give it a page title based on the color name, number, or hex value (whichever database value would be most convenient for the script to refer to).

Thanks again,
Roy


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


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

Hi Walter,

The only issue I’m having is instead of looking for FFFFFF.html (which I have created) it is looking for, and obviously not finding, rgb(255,%20255,%20255).html

I have tried a few different colors and it always looks for the rgb(255,%20255,%20255).html page regardless of the color value.

Also, it seems to me the only trade-off for using a mobile device is that you have to press on a chip to reveal the popover, and once you do, the popover stays stuck until you select another one. I can very much live with that as I don’t think it affects functionality all that much.

Roy


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

Oh. Okay, that’s an easy fix.

    var go;
    var popover = $('popover').hide().observe(
      'mouseleave',
      function(){ this.hide(); }
    );
    var example = popover.down('div');
    var caption = popover.down('p');
    var box = $('swatches');
    colors.each(function(color){
      var swatch = new Element('div');
      swatch.setStyle('background-color: #' + $H(color).keys().first());
      swatch.store('caption', $H(color).values().first());
      swatch.store('url', $H(color).keys().first().toLowerCase() + '.html');
      box.insert(swatch);
    });
    box.on('mouseover','#swatches > div', function(evt, elm){
      example.setStyle('background-color: ' + elm.getStyle('background-color'));
      caption.update(elm.retrieve('caption'));
      go = elm.retrieve('url');
      popover.clonePosition(elm, {
        offsetTop: -25,
        offsetLeft: -22,
        setWidth: false,
        setHeight: false
      }).show().observe('click', function(evt){
        window.location.href = go;
      });    
    });

Give that a try.

Walter

On Nov 18, 2012, at 1:05 PM, Roy H wrote:

Hi Walter,

The only issue I’m having is instead of looking for FFFFFF.html (which I have created) it is looking for, and obviously not finding, rgb(255,%20255,%20255).html

I have tried a few different colors and it always looks for the rgb(255,%20255,%20255).html page regardless of the color value.

Also, it seems to me the only trade-off for using a mobile device is that you have to press on a chip to reveal the popover, and once you do, the popover stays stuck until you select another one. I can very much live with that as I don’t think it affects functionality all that much.

Roy


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


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

Actually, try this one:

    var go;
    var popover = $('popover').hide().observe(
      'mouseleave',
      function(){ this.hide(); }
    ).observe('click', function(evt){
      window.location.href = go;
    });
    var example = popover.down('div');
    var caption = popover.down('p');
    var box = $('swatches');
    colors.each(function(color){
      var swatch = new Element('div');
      swatch.setStyle('background-color: #' + $H(color).keys().first());
      swatch.store('caption', $H(color).values().first());
      swatch.store('url', $H(color).keys().first().toLowerCase() + '.html');
      box.insert(swatch);
    });
    box.on('mouseover','#swatches > div', function(evt, elm){
      example.setStyle('background-color: ' + elm.getStyle('background-color'));
      caption.update(elm.retrieve('caption'));
      go = elm.retrieve('url');
      popover.clonePosition(elm, {
        offsetTop: -25,
        offsetLeft: -22,
        setWidth: false,
        setHeight: false
      }).show();
    });

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

Walter

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

Oh. Okay, that’s an easy fix.


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

I’m the last person on this forum who could tell you the difference.

They both worked but at your suggestion I have applied the second one.

I think now I’m gonna head over to Lynda.com and learn some Javascript. It’s funny, Freeway advertises itself as an alternative to coding when in fact I think it’s a gateway drug to coding.

Thanks a million Walter.

Roy


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