October 13, 2008

Pages


Search Site


Topics



Archives

HTML/CSS Tip: Specifying Multiple Classes

October 06 2008 by Adam

Since CFML developers are essentially very specialized web developers, I feel that it's important to continually learn and improve my skills not only with CFML, but also with HTML and CSS. Here's a trick I picked up earlier this year that I think could benefit a lot of people.

The beauty of CSS is that you can write simple, reusable rules that can be applied throughout your site to provide a consistent look and feel without setting individual display properties on every object on the page. You already knew that.

But let's say that you want all of your site's button elements to have the same overall style: a specific font, a background and border color, and maybe a set of color changes for hover (not displayed in IE). But on certain pages, you want all buttons to have a fixed width so that their edges line up when stacked vertically, and on other pages you want widths to be automatic so that you can fit more in a single horizontal row. This is a great case for multiple classes.

Take these two HTML samples (from different pages) for example. We'll start with our set of vertically stacked buttons:

<div id="buttons">
<button class="standard" onclick="doStuff1();">1</button><br />
<button class="standard" onclick="doStuff2();">2</button><br />
<button class="standard" onclick="doStuff3();">3</button>
</div>

And now our single row of horizontal buttons:

<div id="buttons">
<button class="standard" onclick="doFoo();">Foo</button>
<button class="standard" onclick="doBar();">Bar</button>
<button class="standard" onclick="doFooBar();">Foo & Bar</button>
</div>

Let's make them flat, with a light shade of gray for their background, and a darker shade of gray for their border. Add some font styling and a hover style, and they start to look pretty decent:

button.standard{
background-color: #eee;
border: 1px solid #bbb;
text-align: center;
color: #666;
font-family: Tahoma, Verdana, Helvetica;
font-weight: bold;
}
button.standard:hover{
background-color: #935232;
color: #fff;
}

Now, here are the two classes that we'll use to specify widths:

button.autoW{
width: auto;
}
button.fixedW{
width: 200px;
}

To apply these size style classes without losing our other styles, we can add them to the class attribute, as if it were a space-delimited list, like so:

<button class="standard fixedW">...</button>

Now, we can have consistent color & hover styles for our site, and be able to specify either a fixed or automatic width for it. Using this method, if you decide later that you want your button hover color to be something different, you only have to change it in one place.

I've tested this with IE6 and 7, Safari, and Firefox 1-3. I presume Opera and other modern browsers also support this functionality.

Posted in HTML/CSS | 7 comments

Announcing my Twitter Bot: TwitMeBack

September 28 2008 by Adam

Over a few evenings last week and over the weekend I wrote a twitter bot. It's not a client or a mashup. It simply looks for you to say certain things and replies later. It's basically a glorified alarm clock — one that you can set and receive via text message (if you have twitter setup for mobile updates).

The syntax is pretty simple:

@twitmeback in 15 time to make the donuts

or

@twitmeback in 1:45 check parking meter

You can specify the duration until you're reminded in either [hours]:[minutes] or just in a count of minutes.

Where I think this really gets useful is that it can do direct messages, too. Personally I prefer to keep mobile updates to directs only, so if I want a text message reminder, it needs to be in the form of a direct message. The bot will automatically follow you back if you follow it (it checks every half hour). Then, you can set reminders via direct message, like so:

d twitmeback in 30 don't forget to submit your time sheet

or

d twitmeback in 4:00 lunch time!

If your reminder is received via DM, it will remind you via DM. This way, your reminders can be totally private (if that's what you want), or work totally from text message.

Lastly, you can also specify a DM reminder by starting your message with "d", like so:

@twitmeback d in 90 is the pizza here yet?

Now go forth, and be reminded.

Posted in My projects | 2 comments

Windows Tip: No to All

September 20 2008 by Adam

Everyone agrees that Microsoft is not the really best when it comes to usability, right?

We've probably all looked at this dialogue at some point during our lives and said, "How about a No to All button, Microsoft?"

No To All, where are you?

But did you know it's possible? Hold the shift key while you click the "No" button, and Windows will act as if there were a "No to All" button and you clicked it.

You're welcome.

Posted in Misc | 3 comments

Ask a Grokker: Why can't I activate an inactive Plugin in Mango?

September 15 2008 by Adam

Hey, everyone else is doing it. Why not me?

Mark asks,

I have been getting a lot of comment spam on one of my mango installs. I took a look and the captcha is not showing up anymore. The plug in's page says it's deactivated, however trying to activate it says it's already active? Have you see this before?

In fact, I have seen this before. I'm not sure what causes it, but what happens is somehow one of Mango's preferences files gets out of sync. Luckily, it's fairly easy to fix.

Open up the file pluginprefs.cfm, which should be in the root of your Mango install. Look (or search) for:

<entry key="userPlugins" ...

…and take a look at the value. There, you'll find the plugin listed that you're having difficulty activating. Remove it from the list, save the file, and try again to activate the plugin. In this case, the value to remove is "LylaCaptcha", as this is the plugin that can't be activated.

Posted in Ask a Grokker | Mango | 0 comments

ColdSpring 1.2 released, website updated

September 12 2008 by Adam

Along with the long awaited 1.2 release of ColdSpring, the worlds best CFC IoC/AOP framework has a brand spanking new website, which looks great; and includes a total overhaul of the online documentation.

Congratulations to Chris Scott — manager of the Philadelphia CFUG, and project lead for ColdSpring — and the rest of the ColdSpring team. Looks like a job well done!

Posted in Frameworks | 0 comments