FreshBooks.rb now maintained by Ben Curren

I’ve been late to announce this, but Ben Curren (of Outright) has been maintaining the canonical copy of FreshBooks.rb for a few months now. He’s improved the library ten fold, so if you’re a FreshBooks/Ruby integrator, I encourage you to take a look.

Revised date, datetime helpers for Merb 1.x

I’ve expanded on both mine and Jamie Macey’s original date helper code to support Merb 1.x, and add a datetime helper to the mix.

Usage:

<%= form_for @person %>

  <%= date_field :birth_date :label => 'Birthdate' %>

  <%= datetime_field :birth_date_and_time, :label => 'Birthdate and time' %>

<% end =%>

You’ll find the code here, via GitHub. I generally name this file date_field.rb, and stick it in app/helpers.

GitHub Pages for project docs, demos

Have you seen GitHub Pages? As of mid-December, GitHub now hosts complete web pages that are backed onto GitHub-hosted Git repositories. To start, just define an alternate ‘gh-pages’ branch for your repo, add your web content and push, and it will appear at yourname.github.com/repo-name. It’s perfect for small one-off project pages, or even complete blogs.

I’ve already migrated my project documentation pages over (see: Abbreviator, Labelize). I like the idea that these pages are accessible at the same location as their corresponding source code, with complete revision history, even if my blog is down or – dare I say it – long defunct.

Abbreviator: a jQuery plugin for fitting chunky content

Inside FreshBooks (the application), there’s a few places where we abbreviate long-ish text with ellipses to make it fit inside small table cells. This is done in PHP by a single function, whose two parameters are a string and the desired character length.

Of course, not all characters are made equal. We estimate appropriate character lengths as best we can, but it doesn’t always work. If users have a penchant for typing in capital letters, or use text zoom, our little abbreviating function can fail. And of course, every design change to these areas require new character length settings – a task that is easily forgotten.

So, after some sanity checking/brainstorming with my co-workers Taavi and Justin, I put together a little jQuery library for accomplishing this feat in Javascript. It’s called Abbreviator, and it adjusts for font size, browser rendering differences, padding, and more. Take a look at the project page for more.

That’s it for me for the year – Happy holidays!

Labelize: a jQuery plugin for making big honking labels

Labelize is a handy jQuery plugin that lets you give input-containing elements <label/> like properties, so that clicking on the container activates the input inside. The goal? To improve usability by giving hard-to-click input elements like radio buttons and checkboxes generous target areas. Surprisingly, this can’t be done with a <label/> element alone—if you want it supported in IE6, that is.

Say we have the following markup:

<div class="myLabel">
  <input type="checkbox"/>
</div>

To make the “myLabel” div become a label-like container for the checkbox its holding, we simply do the following:

<script>
  $('.myLabel').labelize()
</script>

That’s it! Now if we click anywhere on “myLabel”, the checkbox is clicked—and its onclick() event is fired too. Huzzah.

If you’d like to see the plugin in action, I’ve whipped up a quick project page with some working examples. Please have a look and let me know what you think.