How do they do this?

On 14 Jun 2007, 11:55 am, waltd wrote:

The quick and easy way to do it is to make a text field, and with that
field selected, open the Item/Extended dialog and add the name/value
pair:

Name: type
Value: search

I just tried this. It doesn’t work at all. It just puts “search” inside a normal, square field in Safari.

And as to Tim’s comments about a “Safari Search” action, I have searched and Googled for that in vain. I simply cannot find it anywhere.

There is a wonderful search field at the top right of this site. It only looks lovely in Safari. It turns square in Firefox (Mac) and MSIE (Win), and the text is no longer light gray. But at least there is text in the field and when you click in the field the text goes away. I want to do that in Freeway, but how?


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

Hi James,
Did you not get the file attachment that I sent with that mail? If not I’ll
upload it later tonight.
Regards,
Tim.

Quoting JDW email@hidden:

And as to Tim’s comments about a “Safari Search” action, I have searched and
Googled for that in vain. I simply cannot find it anywhere.


Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


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

First off… Tim, I wrote you an email offline to say I don’t know what you are talking about. You never wrote back.

Back to Safari-style search fields…
My goal is to get a nice looking rounded search field to work in Safari (Mac/Win), Firefox (Mac/Win) and MSIE (6/7 Win). The following is required:

  1. Search field with predictable/consistent height and width

  2. Text in the search field (lt.gry, if possible) that vanishes when you click in the field.

  3. Looks the same in almost any browser.

Walter Davis kindly offered me some detailed guidance offline, which accomplishes (1) & (2) of my aim. I have compiled the steps for the benefit of all Freeway users, as follows:

Step-1: Insert > Text Field. Size it to your liking and then apply the Freeze Form Item action to it – make sure only “Activate” and “Width” checkboxes are ticked in the Actions palette.

Step-2: Insert > Button. Size it to your liking. Click the “Item Output Settings” tab in the Inspector. Type “SEARCH” for the Name. The text you want to appear on the button goes in the Value field. Make sure its a “Submit” button.

Step-3: With your button still selected, choose Item > Extended… Within the tab, Click New and type “onClick” for the Name and type “checkform(); return false;” for the Value (without the quotes). OK that and then click New again. Type “onKeyUp” for the Name and “checkform(); return false;” for the Value (without the quotes). OK the dialog, then OK the Extended Attributes dialog.

Step-4: Select your field and then choose Item > Extended… Within the tab, Click New and type “class” for the Name and type “search” for the Value (without the quotes). OK that and then click New again. Type “type” for the Name and “text” for the Value (without the quotes). OK the dialog, then OK the Extended Attributes dialog.

Step-5: Fill out Page > Form Setup in accordance with whatever search engine you wish to use. There is guidance on the SoftPress website for Atomz:
http://www.softpress.com/kb/questions/131/

Step-6: Download the Protaculous Action from ActionsForge:
http://www.actionsforge.com/actions/view/18-protaculous
(Yes, I know there are two version 0.5’s shown at ActionsForge but with two different dates! I do not know why! I downloaded the one showing 5 Nov, 2008.)

Step-7: Add Protaculous to Freeway by double-clicking it.

Step-8: Apply Protaculous to your page in Freeway.

Step-9: Open the Actions palette and adjust the settings as follows:

• Use Library: prototype-packed

• Click the upper “Function Body” button and then copy/paste in this code:

$$(‘input.search’).each(function(elm){
var def = ‘Site Search…’;
if(!Prototype.Browser.WebKit){
if($F(elm).empty()) elm.setStyle({‘color’:‘#888’}).value = def;
elm.observe(‘focus’,function(evt){
if($F(elm) == def) elm.setStyle({‘color’:‘#000’}).clear().focus();
});
elm.observe(‘blur’,function(evt){
if($F(elm).empty()) elm.setStyle({‘color’:‘#888’}).value = def;
});
}else{
elm.setAttribute(‘type’,‘search’);
elm.setAttribute(‘autosave’,‘saved.data’);
elm.setAttribute(‘results’,‘5’);
elm.setAttribute(‘placeholder’,def);
}
});

(NOTE: You can change “Site Search…” to whatever you like.)

OK that dialog, and don’t worry about adding code via the lower “Function Body” button.

Step-10: Preview and assuming your Form Setup was correct, you will be enjoying a Safari style curved search field in Safari, with light gray text inside! Sadly, the curves are gone in Firefox and MSIE Windows.

Walter Davis informed me that he did some extra work to get that same curved search field to work in FireFox and MSIE on ActionsForge.com. Walter said that he “Applied styling and background images to make the search field appear exactly the same as Safari’s. (Took screenshots of the field in its two states in Safari, and used that for the field’s background image, hid all borders and selection rectangles and used padding to force the text into the available space.)”

So far, I’ve not been able to figure out this last part on my own, but perhaps some of you can and will then share the detailed steps with us.

I hope this is helpful.

James Wages


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

On Jan 20, 2009, at 1:57 AM, JDW wrote:

Walter Davis informed me that he did some extra work to get that
same curved search field to work in FireFox and MSIE on
ActionsForge.com. Walter said that he “Applied styling and
background images to make the search field appear exactly the same
as Safari’s. (Took screenshots of the field in its two states in
Safari, and used that for the field’s background image, hid all
borders and selection rectangles and used padding to force the text
into the available space.)”

So far, I’ve not been able to figure out this last part on my own,
but perhaps some of you can and will then share the detailed steps
with us.

I hope this is helpful.

Given your preference (noted, and approved) for visual design, this
last bit is going to be a more difficult climb. In order to get the
rounded end effect in non-WebKit browsers, I ended up making two new
styles: safari and safari:focus:

input.safari {
	width: 92px;
	font: 11px "Lucida Grande", Lucida, Verdana, sans-serif;
	border: none;
	padding: 6px 20px 6px 24px;
	background: url(../Resources/safari_search.gif) no-repeat left top;
	height: 14px;
}

input.safari:focus {
	overflow: visible;
	background: url(../Resources/safari_search.gif) 0 -26px;
}

The image that both styles reference is a screenshot of the form field
in Safari, doctored to remove the downward facing triangle (recent
searches) menu widget (which won’t work in anything besides Safari.
This image contains both the normal and the focused variant of the
field in one image (CSS Sprite technique) so there is no flicker when
changing states. The only difference between the two styles is that
the position of the background is shifted 26px up.

The JavaScript is modified to add this new CSS class to the form
element if the browser is not Safari:

$$('input.search').each(function(elm){
	var def = 'Site Search...';
	if(!Prototype.Browser.WebKit){

		elm.addClassName('safari'); // <-- new line

		if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
		elm.observe('focus',function(evt){
			if($F(elm) == def) elm.setStyle({'color':'#000'}).clear().focus();
		});
		elm.observe('blur',function(evt){
			if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
		});
	}else{
		elm.setAttribute('type','search');
		elm.setAttribute('autosave','saved.data');
		elm.setAttribute('results','5');
		elm.setAttribute('placeholder',def);
	}
});

Now if you’ve followed all the way to this point and tested in IE,
you’ll find that (surprise!) the :focus ‘pseudoclass’ doesn’t work
reliably in that attempt of a browser. So if that’s a big part of your
audience, you’ll probably want to make the following changes.

CSS:

input.safari, input.safari_focus {
	width: 92px;
	font: 11px "Lucida Grande", Lucida, Verdana, sans-serif;
	border: none;
	padding: 6px 20px 6px 24px;
	background: url(../Resources/safari_search.gif) no-repeat left top;
	height: 14px;
}

input.safari_focus {
	overflow: visible;
	background: url(../Resources/safari_search.gif) 0 -26px;
}

JavaScript:

$$('input.search').each(function(elm){
	var def = 'Site Search...';
	if(!Prototype.Browser.WebKit){
		elm.addClassName('safari');
		if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
		elm.observe('focus',function(evt){
			if($F(elm) == def) elm.setStyle({'color':'#000'}).clear().focus();
			elm.removeClassName('safari');
			elm.addClassName('safari_focus');
		});
		elm.observe('blur',function(evt){
			if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
			elm.removeClassName('safari_focus');
			elm.addClassName('safari');
		});
	}else{
		elm.setAttribute('type','search');
		elm.setAttribute('autosave','saved.data');
		elm.setAttribute('results','5');
		elm.setAttribute('placeholder',def);
	}
});

And that, I am afraid, is that. Quite a long row to hoe for a simple
form input. My own inclination is to keep it simpler. Optimize the
experience for those who have the sense to use a modern browser, and
try not to mess things up too horribly for those who are mired in the
past. It’s a subtle goad, intended to prod those forward who have the
taste level to appreciate the difference.

Walter


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

Walter, many thanks for sharing these details. Sorry for the bother, but I need a few more hints to get it to work.

To begin, I assumed your procedure was incompatible with the Freeze Form Item action, so started by disabling that action on my field. Next, I decided that I really do need to support those ever so commonly used “attempts at a browser,” which means my focus is on your last two blocks of code. (Walter, the same mentality that blinds the masses from seeing the subtle yet bright light of your search field “goad” is what will ultimately bring those same people back to Windows 7 even while the bitter taste of Vista lingers in their mouths.)

With this being the first I’ve heard of CSS sprites, I decided to read up a little (not “a lot” though since I am not a web coder):

Pretty amazing stuff, especially the part about reducing the HTTP request burden on the server. I also like this this concept for rollovers because I find Photoshop does a better job of creating outstanding looking GIF and JPEG images (versus Freeway’s internal engine) and would like to keep such images pass-thru. You can’t do that for Freeway style rollovers that have to be graphic boxes that combine. But CSS Rollovers open a new door of opportunity to rollovers involving my beloved pass-thru graphics!

Getting back to the story…

I am guessing that I need to put these two blocks of code in page Markup. And I also know that some extra tags are required to do that. So here is exactly what I dumped into “Before ” within the HTML Markup dialog:

<SCRIPT LANGUAGE="javascript" TYPE="text/javascript"><!--
    $$('input.search').each(function(elm){
    var def = 'Site Search...';
    if(!Prototype.Browser.WebKit){
        elm.addClassName('safari');
        if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
        elm.observe('focus',function(evt){
            if($F(elm) == def) elm.setStyle({'color':'#000'}).clear().focus();
            elm.removeClassName('safari');
            elm.addClassName('safari_focus');
        });
        elm.observe('blur',function(evt){
            if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
            elm.removeClassName('safari_focus');
            elm.addClassName('safari');
        });
    }else{
        elm.setAttribute('type','search');
        elm.setAttribute('autosave','saved.data');
        elm.setAttribute('results','5');
        elm.setAttribute('placeholder',def);
    }
});
//-->
</SCRIPT>

<style type="text/css">
input.safari, input.safari_focus {
    width: 92px;
    font: 11px "Lucida Grande", Lucida, Verdana, sans-serif;
    border: none;
    padding: 6px 20px 6px 24px;
    background: url(../Resources/safari_search.gif) no-repeat left top;
    height: 14px;
}

input.safari_focus {
    overflow: visible;
    background: url(../Resources/safari_search.gif) 0 -26px;
}
</style>

Note: For some reason FreewayTalk is putting almost all the JS part all on a single line in the code segment above. But in the HTML Markup dialog, it is in fact spaced and indented properly.

With that done, I then clicked once on my field and then applied the Extra Resources action so I could drop your “safari_search.gif” into the “Resources” folder.

I then Previewed in FireFox (Mac) and found the field was still rectangular. I went back to Freeway and deleted off the “Protaculous” action (and the code used inside it), and then previewed in FireFox again. But I still get the rectangular search field.

Clearly, I must not be dropping your code in the correct place(s) in Freeway, and/or the tags I added are wrong.

Please advise.

Thank you,

James Wages


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

JDW, if you do a search on this site you will find a large amount of threads dealing with creating css menus that do NOT utilize the CSS Menu action. Basically you can utilize all the CSS tricks you find in searching around the web or from the many books on CSS, but you also have to learn to use the Styles Editor in Freeway Pro. The editor is not perfect by any means, and many people don’t like having to use the Extended button to add the css options that Freeway does not include, which is necessary, but if you can get past that you can do just about anything with CSS.


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

JDW, here is a link to a related css menu thread. Pay particular attention to the looooong response from The Big Erns. The link associated with that response also has a sample file to download where you can look at how the styles were set up in the editor.

http://freewaytalk.net/thread/view/32203#m_32401


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

Chuck, you’re 2 posts appear to have gone Amuck because I cannot draw a direct correlation with what you wrote and the central them of this thread. (Nor do I see any relevance of Mr. Erns long post, which I read from top to bottom.) Perhaps you intended to put your two posts in the following thread, where myself and others are in fact talking about “CSS Menus”?

http://freewaytalk.net/thread/view/34889

But this particular thread centers on “Search Fields.” And unless you can offer more direct guidance on that, as my post above seeks, I await hearing more from others who can.

I also take tremendous offense at your insinuation that I lack the capability to conduct a search on this site. Indeed I have been doing just that, spending a lot of time doing so, in fact. And it was my searching of this site which led me to this thread. I most often search for several variations of keywords, and then compare no less than 4 different threads in the results that follow, to ensure that I get the most complete picture and most up to date information.

Lastly, concerning your personal feeling that we must learn the Styles Editor in Freeway, I will say this. Freeway 4 and 5 have opened doors that have ushered into the fold a number of users who get significant enjoyment from coding. More power to them and I hope that sells more copies of Freeway, but I am not among them. What led me to Freeway 2.0 in 1999 is the same thing that keeps me in Freeway today – WYSIWYG (for the most part) design for folks who are not coders. And before you try to take issue with me on this, consider the block of text sitting prominently in the right side of softpress.com, which reads:

Why Freeway?

You can create stunning, interactive, standards-compliant web-sites on your Mac without having to write any code.

In all my posts here on FreewayTalk, I am determined to accomplish just that. Even so, after reading Walter’s post above, I felt that copying and pasting in couple code segments to get a search field to look pretty in most any browser is something that even I, being brain dead to code, could accomplish. I simply have done something wrong and need a few hints to get it straight. And to use the words of Mr. Davis, “That is that.”


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

You are nearly there. But the fact that you were putting the $$
(‘input.search’)… part in the Page / HTML Markup meant that it was
running before the elements it referenced were loaded. This blob of
code needs to be added through the Protaculous Action, in one of the
Function Body popups (I would suggest the first one, although some
people have reported that IE has issues with that event, and prefer
the second one when IE is large in your sights).

So add Protaculous to the page, choose prototype-packed from the
Library picker, and then click on Function Body (either one) and paste
all that code in.

By the way, if you’re not seeing the code the way you expect in
FreewayTalk.net, try using four tildes instead of three to set off
your code block.

//this is code, and it doesn't matter how long it gets
//or how many lines you have
     or how it's indented

Walter

On Jan 20, 2009, at 9:29 PM, JDW wrote:

Clearly, I must not be dropping your code in the correct place(s) in
Freeway, and/or the tags I added are wrong.


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

Sometime around 21/1/09 (at 10:24 -0500) Walter Lee Davis said:

when IE is large in your sights)

When IE is large in your sights… shoot, shoot!

k


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

Walter, you ARE the man! A thousand thanks for holding my hand through all this. I have now seen the light, so to speak!

When I first tried your advice today, I was not seeing the curved Safari box in FireFox. I then went back to Freeway and deleted out one of the “.” symbols in 2 places in your CSS code, resulted in the following:

url(./Resources/safari_search.gif)

I then Previewed in FireFox and the GIF is now loading just fine!

For others following in my footsteps, here are some additional notes:

  1. The Freeze Form Action still works to make the field look great in Safari, but it messes up the appearance in Firefox and other browsers. The sad part is, if you are like me an you want to made the search field wider, you really need to use the Freeze Form Action. By reviewing the page source, I see there are only 2 things it changes: (1) adds “#item2 { width:191px; }” into the CSS styles, and (2) adds "id=“item2” to your field. (191px is the width I set in Freeze Form Action.) It’s easy to manually add that ID to the field in Freeway via the Extended dialog. But since I have zero knowledge of JS programming, I for the life of me cannot add the “#item2 { width:191px; }” part into Walter’s JS code (which has a browser sniffer). I think it would work if you could just add that line of code IF the browser was Safari (Webkit). That would basically give you the power of the Freeze Form Action on the field only in Safari but not other browsers. And that’s what you want, since the FF Action works fine in Safari, and other browsers work fine with the FF Action disabled.

  2. If you use a different background than what Walter does (like I do), you will need to view the field in Safari, then take the screen shots there, and then build both screen shot states into a single GIF file as Walter did. But when editing the GIF, don’t forget to erase off that little triangle, as only Safari uses that to produce a popup menu.

  3. Put Walter’s CSS code into the HTML Markup dialog, in the “before ” section, and be sure to add the following tags before and after:

<style type="text/css">
   Walter's CSS code here...
</style>

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

Supplementary info:

  1. On big reason to even use the Freeze Form action is to keep the Search button (usually sitting to the right of the field) next to the right edge of the field. When you draw fields in Freeway, I find they are almost always more narrow than in Safari, which leaves your poor Search button stranded to the far right of the field (a big gap between the field and the button). Freeze Form fixed the width of the field to bring WYSIWYG back to Freeway. However, in this particular case, as mentioned above, we cannot use the Freeze Form action. But you can sketch a single cell “table” as a solution. Just create the table cell, then copy/paste in your field and button. Make everything align to the left inside that cell, and then your button will never get stranded, and you don’t need the Freeze Form action!

  2. Walter’s technique above gives you a curved Safari-style search field in most modern browsers, including MSIE6 for Windows. But if you create a normal Freeway form button, the button will look great in Mac browsers (and Safari 3 for Windows), but suck rotten eggs in other Windows browsers. Sit an elegant Safari style search field next to a rectangular butt-ugly Windows search button and you will understand what I mean. Hence, the solution here is to make a graphic button. But the problem is, what if I find a rollover to mimic the button in Safari for the Mac? I believe a CSS Rollover would work wonderfully here. But alas, there is no easy means of adding this as I had hoped, as we are talking about in this thread:
    http://freewaytalk.net/thread/view/2010
    Having an update to Paul’s CSS Rollover action to make it work as expected in FW5 just may allow us to have a rollover Search button inside a table cell. (This is because CSS rollovers use a single graphic – you cannot have 2 graphics sitting atop each other inside a table cell.)


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

Have you tried switching to the Parameters side of the Action
interface, and adding the second image “old-school” using an optimized
image that you select through the MouseOver picker? (Change it to
Select… and choose a second image. This must be a pass-through
image, so the usual rules apply – actual size, compressed, Web-format.)

I haven’t tried this in the CSS Rollover Action, but this is how the
Rollover has worked since the beginning, if you’ll recall. When
Softpress introduced the ability to make a rollover out of a pair of
stacked images, that was in addition to the original working
technique, which didn’t go anywhere.

Walter

On Jan 22, 2009, at 1:51 AM, JDW wrote:

Hence, the solution here is to make a graphic button. But the
problem is, what if I find a rollover to mimic the button in Safari
for the Mac? I believe a CSS Rollover would work wonderfully here.
But alas, there is no easy means of adding this as I had hoped, as
we are talking about in this thread:
http://freewaytalk.net/thread/view/2010
Having an update to Paul’s CSS Rollover action to make it work as
expected in FW5 just may allow us to have a rollover Search button
inside a table cell. (This is because CSS rollovers use a single
graphic – you cannot have 2 graphics sitting atop each other inside
a table cell.)


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

Walter, to be absolutely honest with you, I didn’t try selecting the “image” the legacy Rollover MouseOver picker in the Actions palette. But thank you for the suggestion.

What I ultimately ended up doing is precisely what you did on ActionsForge; namely, you get rid of the button altogether. And truly, there is no real need for a button anyway. No button means no MSIE button shape headaches. And less content and code on the page too.

Many thanks,

James Wages


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

(I’m about to scream over not being able to edit posts here! Ack!)

I would like to add that for those of you really wanting a button next to your search field, you will likely find this action useful:

http://www.easibase.com/Resources/Form_Element_Styler.zip

It allows you to change the shape of the button itself, which is helpful in MSIE 6/7 for Windows. I tried it myself and it works great, even in MSIE. But in my application, even when I used a table to hold everything together, the button would shift down in MSIE, below the field. Tried everything to fix that but I couldn’t. So I gave up and deleted the button altogether. I’m pleased with the result though, so the missing button is not a big loss to me.


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

One thing I’ve noticed after a couple days of checking in various browsers, is that there is a slight vertical shift going on in my footer – where my search field is located. I created a detailed browser comparison among Safari, FireFox and MSIE 7 here:

The odd thing is that my Freeway graphic logo in the very center is vertically centered in all browsers. But the search field at left and the HTML box at right are shifted badly in MSIE 6/7, slightly in FireFox Mac, and not at all in Safari.

The black footer background is just a layered HTML item with a black fill. And none of the three objects inside it are child items.

Is there any trick to keep things from shifting?


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

Either people posting on FreewayTalk are not active of late, or my last post managed to baffle even the experts among us. :slight_smile: In any case, I have found a reasonable solution to the problem.

I switched on CSS and sketched a 1x1 table cell. I made the cell the exact same height as my footer container box. I then grabbed the table, hit the spacebar to highlight my footer container box, then dragged in the table. I then copied my HTML “copyright” item and pasted that inside the table cell, with the cell set to vertically center. I repeated this for my text field at left.

This works perfectly to eliminate the 1px shift I was seeing in FireFox Mac, and it still centers perfectly in Safari3 too (WinXP & Mac). In MSIE 6/7, my table cell scheme results in the search field being shifted up slightly. But that slight shift up looks far better than the huge shift down I had been seeing before. And the copyright text to the right of my footer is perfectly centered now in all browsers, so I am 99% happy with this.

Hope this helps others following in my footsteps.

Best,

James Wages


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

The code Walter Davis kindly created for us in this thread has worked wonderfully on my sites for a year and a half now. Unfortunately, things changed a bit when Apple released Safari 4; namely, the Windows version of Safari 4, Safari 5 and Chrome all use rectangular search fields (i.e., no curves) by default.

Walter’s code was intended to be used on Safari/Webkit browsers with the understanding that those browsers would all curve the search field corners automatically. Walter then added other code to slide a graphic around and work the same curved-corner trick in browsers like IE6/7/8 and FireFox.

Seeking 100% consistency across all browsers and OS platforms, I experimented today with some edits to Walter’s original code. I am by no means a coder though. I discovered a solution by trial and error. But what I have come up with seems to work fine in all browsers I tested on the Mac and Windows.

You need to start by adding the “Protaculous” action to your Freeway page. Then Use Library “prototype-packed”. Click the upper “Function Body” button, and paste in the following code:

$$('input.search').each(function(elm){
    var def = 'Site Search...';
    {
        elm.addClassName('safari');
        if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
        elm.observe('focus',function(evt){
            if($F(elm) == def) elm.setStyle({'color':'#000'}).clear().focus();
            elm.removeClassName('safari');
            elm.addClassName('safari_focus');
        });
        elm.observe('blur',function(evt){
            if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
            elm.removeClassName('safari_focus');
            elm.addClassName('safari');
        });
    }
});

The base code is still what Walter originally gave us, I just deleted out some parts to ensure that every browser uses the little curved corner graphic. We lose the clickable magnifying glass functionality on Webkit browsers, but honestly, I am happy with that so long as I get curved corners in every browser on both Mac and Windows.

Now go to the “Page” menu and select “HTML Markup…” When the Markup dialog appears, paste in the following code:

<style type="text/css">
input.safari, input.safari_focus {
    width: 152px;
    font: 12px MS PGothic, MS Serif, Sans-serif;
    border: none;
    padding: 6px 20px 6px 24px;
    background: url(./Resources/safari_search.gif) no-repeat left top;
    height: 14px;
}

input.safari_focus {
    overflow: visible;
    background: url(./Resources/safari_search.gif) 0 -26px;
}
*:focus { outline: 0; }
</style>

I did this on a Japanese language web page, so be sure to edit the “font” part to your own liking. Also edit “width” in accordance with the width of your search field. And ensure the two URLs are correct for your web server.

Note that the code I added at bottom (*:focus {outline: 0;}) is used to kill the blue highlight that Webkit browsers case around the search area. Without that code, there would be a rectangular blue outline surrounding your GIF graphic which has its own blue outline, resulting in two blue outlines! I don’t know if that code is best. I just found it on the web, dropped it in, and found it worked.

I would be happy to hear any comments you might have.

Best,

James Wages


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

Walter,

I am still using your code, in Protaculous2 now, to display my search field the way I like it:

$$('input.search').each(function(elm){
    var def = 'Search this site...';
    {
        elm.addClassName('safari');
        if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
        elm.observe('focus',function(evt){
            if($F(elm) == def) elm.setStyle({'color':'#000'}).clear().focus();
            elm.removeClassName('safari');
            elm.addClassName('safari_focus');
        });
        elm.observe('blur',function(evt){
            if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;
            elm.removeClassName('safari_focus');
            elm.addClassName('safari');
        });
    }
});

But there is one minor problem that, until now anyway, I have been ignoring all these years. Rather than coloring the proxy text inside the search field gray, FireFox and all flavors of IE running under WinXP to Win8 color the text BLACK. Yes, I verified this occurs even in IE10 running under Win8. Interestingly though, if I click inside the field and then click outside the field ONLY THEN the text turns gray!

So my question is, is there a way to improve the above code, such that Firefox and IE running under Windows (FF on OS X is ok) will display the gray text inside the field from when the page first loads?

Thank you,

James Wages

P.S. Just scroll down and view the bottom left corner of any page in my site to see the search field I am talking about:


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

Try taking the F out of this line, and in the other line where it appears. Make them both read if( $(elm).empty() ). That’s the only thing I see wrong here.

Walter

On Apr 11, 2013, at 4:33 AM, JDW wrote:

   if($F(elm).empty()) elm.setStyle({'color':'#888'}).value = def;

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