Client-Side menu separators with jquery

March 11th, 2007

Have you ever pulled your hair about separators between menu entries on websites? Or just plain fell asleep? The task is trivial, but it is boring. Depending on what server side solution you are using, you end up with 4 to twenty lines of code.

CSS3 would save us from that boredom, but there is almost no CSS3 support in today’s browsers. That is, there’s no native CSS3 support. We can do the same and more with jquery, which does have CSS3 support.

What I have is:
(this is the HTML as output to the browser).

<div id="mainmenu"><ul><li><a href="Impressum.html">Impressum</a></li><li><a href="UeberMich.html">Über Mich</a></li><li><a href="Moebel.html">Möbel</a></li><li><a href="Innenausbau.html">Innenausbau</a></li><li><a href="SonstigeLeistungen.html">Sonstige Leistungen</a></li></ul></div>

Which gives me this:

But what I want is:

I could inject conditions into my server-side code to insert the bullets after all but the last menu entry (or before all but the first). But this has many drawbacks: usually, there’s more conditions involved in such menus like considering hidden pages if I am working in a CMS or similar, navigation states (which is the current page, etc), and so on. Also, it makes the HTML cluttered and charges the server-side code with view-dependant details. The server-side code in this case would be considered UI-driven anyway, so this is not inherently bad. But it’s still nicer not to.

Anyway, there’s a rather easy way with jquery (if you are new to jquery, just grab jquery.js from jquery.com). The relevant code:

<script src="jquery.js" type="text/javascript"></script><script language="javascript" type="text/javascript">$(document).ready(function(){$("#mainmenu ul li:not(:last-child)").after("<li class='bull'><b>•</b></li>");});</script>

Explanations:
The $(document).ready function is executed after the DOM is completely available.
$(”#mainmenu ul li:not(:last-child)”) selects DOM elements with a CSS3 selector, in this case all li elements that have a ul as their parent and #mainmenu as their grandparent and that are not the last child of their parent.
after(”<li class=’bull’><b>•</b></li>”) simply injects the HTML after each element in the collection just selected.

The CSS, for completeness’ sake:

#mainmenu{width: 800px;border: 1px solid #006633;border-left: none;border-right: none;background-color: #e5e5e5;}#mainmenu ul{display: block;margin: 0;margin-left: auto;margin-right: auto;height: 18px;}#mainmenu ul li{display: block;float: left;margin-left: 10px;margin-right: 10px;}#mainmenu ul li.bull{margin-top: 2px;}#mainmenu ul li a{display: block;text-decoration: none;color: #006633;background-color: #e5e5e5;font-size: 14px;}

buy cheap abilify
perfect acai
cheap accutane online
buy aciphex
acomplia direct from india
order actonel
cheap actos no prescription
Mobic vs Aleve
buy allegra
discount alli
altace versus cozaar
Bone Meal Candida Antibiotics
aricept best price
arimidex fda
online ashwagandha
nasonex vs astelin
ATACAND 32 MG
atarax xr
feline dosage Augmentin
steve haffner avandia
avapro blood medicine pressure
avodart medicine
bactrim uti
is benadryl safe for dogs
benicar on line
biaxin information
Buspar Addictive
cardizem rx
celebrex contraindications
celadrin medicine
cephalexin on line
cialis coupon
Can I Give My Cat Cipro
generic cla online
taking both clarinex and xyzal
claritin 24 hour
clomid india
order clonidine
using polyploidy colchicine
cost of coreg
foods to avoid on coumadin
cozaar losartan
Top 10 Creatine Supplements
crestor attorney Columbus
cheap cymbalta online
cymbalta information
depakote price
diclofenac price
differin side effects
Diflucan For Yeast Infections Vaginal
diovan alternative
doxycycline calcium
side effects of effexor
Side Effects in Flagyl
medication called flomax
glucophage interaction insulin
Guinea Pig Hair loss
hangover rx
hoodia usa
keppra fda
no rx lamictal
generic lamisil
lasix
levaquin 250mg
levitra rx
lexapro and weight gain
lipitor xr
side effect of lisinopril
the effects of melatonin on dreams
cost of metformin
Methotrexate DOSAGE
Micardis HCT
buy mobic
motrin and ketorolac interaction
MSM Messenger
neurontin fda
How Long Do You Take Nexium
online nizoral
bodybuilding best place to buy nolvadex
omnicef stool
buy paxil
penis extender xr
Where Can I Purchase Phentermine
phosphatidylserine complex
plan b information
plavix canada
pravachol canada
prednisone reaction
premarin alternative
purchase prevacid online
order prometrium
cheap propecia online
cheap provera no prescription
prozac rx
Incidence of seizures with Reglan
reminyl medicine
determination of rimonabant
Psychotropic Drugs Risperdal
rogaine for facial hair
intensity of effects of seroquel
singulair weight gain
skelaxin usa
stop smoking pill
side effect of strattera
stress relief fda
synthroid medicine
tetracycline for staph
how long does it take for topamax to work
how long before a nuclear stress do you stop taking toprol
toradol information
Tramadol RX
trazodone withdrawl
TRICOR analog
trileptal india
ultracet getting high
buy cheap valtrex
Viagra Order Canada
voltaren description
side effects of vytorin
weight loss pictures
wellbutrin tablets
cheapest yohimbe
no rx zantac online
buy zetia online
buy cheap zestoretic
buy zithromax online
generic zoloft
zovirax
zyban and pregnancy
no rx zyprexa online
generic zyrtec online
buy zyvox

Isorecorder by Alex Feinman

March 9th, 2007

http://isorecorder.alexfeinman.com/isorecorder.htm

Isorecorder is a free tool for Windows XP and Vista that can perform the following transformations:

CD/DVD -> ISO Image
Directory Tree -> ISO Image
ISO Image -> CD/DVD (DVD only on Vista)

Especially  the latter is a great equivalent to the ease of use that dd brings on Unix.
I  like to just save an ISO image of CDs and trash them. I don’t much like those stacks of never-used driver CDs…

Isorecorder does not mount ISO images as virtual drives.You still need Microsoft’s Virtual CD-ROM Control Panel for Windows XP, which you can download from Microsoft. The only official link to this tool is found in the MSDN FAQ. There is no corresponding page on Microsoft Downloads.

Ströer has encountered a problem and needs to close

February 26th, 2007

Every day, I walk past several Ströer appliances, and more often than not, they show interesting error messages. This time, I couldn’t resist.

Using Word 2007 to Post to WordPress

February 24th, 2007

Word 2007 works well for posting to a WordPress blog. Here is a step-by-step description.

  1. Use any existing document or create a new one. Once you’re done, hit the Office Button -> Publish -> Blog
  2. You’ll be asked to set up a blog account. Select WordPress as the blog provider and enter the URL to xmlrpc.php, your user name and your password.
  3. Then, hit the Picture Options button and enter your FTP URL and the URL used in the Blog Posts.
    For WordPress, you’ll need to use “My own server” – “My blog provider” won’t do.
    The FTP URL is where your images will be stored. Source URL is what Word will prepend to the src= attribute of the img tag.
  4. You can now publish, publish as a draft, edit categories, and edit existing posts. Wow.

A draggable masked image behind transparent navigation

March 16th, 2006

A friend asked whether it would be possible to have an image that can be dragged behind a mask, with a transparent navigation in the upper part of the page. The images are too large to fit on the page, so you need to be able to move it. Yes, they could be resized, but it’s a wanted effect.

Making things transparent in the top part is easy. A little extra treatment for Internet Explorer, and a transparent PNG will do. Making the image draggable was a single line of JavaScript with prototype/scriptaculous. Below is an example in an iframe (i know, i know, but it’s so easy this way). I have added a Fade/Appear for the navigation while the image is dragged, but it leaves the navigation hidden if the drag ends while the navigation is still fading. There certainly are ways around this, but this is enough for a proof of concept.

here is the whole thing out of the iframe