I am primarily a Ruby on Rails developer now, but even before that I had began to leverage Prototype into my PHP applications to make UI design easier. One of the things that bugs me about the Prototype library is that if you load an element with the default CSS ‘display’ value of ‘none’, you have to use the hide/show functions to toggle it’s display. That means finding some way to conditionally determine the state and choose which function to call. Who has time for that? Not me, enter my little addition to Protype toggleDisplay:

  1. toggleDisplay: function() {
  2.     for (var i = 0; i < arguments.length; i++) {
  3.         var element = $(arguments[i]);
  4.         element.style.display = (element.style.display != 'none') ? 'none' : 'block';
  5.     }
  6. },

I entered this code in directly between “toggle:” and “hide:” in “Object.extend”, around line 860. This was done in Prototype version 1.4.0.

Man, I need a better code highlighting formatting widget thingy. I guess I should upgrade this old and busted installation of WordPress to Version 2. I’ll do that now!