Animating table rows in the browser is problematic. You see, they aren’t block elements and as such don’t have a height or width property. Instead they take their constraints from the content inside them, and the elements that contain them. For rows this typically means they’re constrained by the containing table, and filled by the contained columns.
Today I wanted to slide a row up, and then when it had finished sliding I wanted to remove it from the DOM. Essentially giving it a nice effect when something is deleted.
Given that the height of a row is controlled by it’s content, I figured the easiest way to do this would be to wrap all of the content inside each column with a block element, in this case a div, and then resize those.
jQuery makes this extremely easy :
var el = $(options.element_prefix + id);
el.children("td").each(function() {
$(this).wrapInner("< div />").children("div").slideUp(function() {el.remove();})
});
NOTE : The div tag in the wrapInner() is malformed because it won’t display properly otherwise. Please remove the space between the opening bracket and ‘div’.
It’s all pretty easy to understand. Essentially my root element is a row, and so for each td in that row wrap it’s content in a div. Then for the child divs in each td, run the slideUp() method. The callback in the slideUp() method says after the animation is done, remove the row. Given the speed of computers these days, no one will notice that the last few columns quite likely just vanish instead of complete their animation.
Further to my previous foray into the world of Applescript, I’ve modified my server management script to now prompt me for a sudo password. Previously I would have to tab between each Terminal window and enter my sudo password, but now I enter it once and a dynamic command is generated that looks like this:
I don’t like that my sudo password is displayed on the screen. I could get around this by manually editing /etc/sudoers to allow for password-less aptitude. Alternatively, perhaps I could encrypt my password inside the Applescript and send it, pre-encrypted, to sudo. They’re options I guess.
You’ll notice that the first thing I do is clear the screen, but when there’s a second or so lag it means my password is bare for all to see. I’ll consider that when I run the script.
Below is an Applescript snippet which shows you how to open a dialog box and take some simple text input:
set my_password to display dialog "Please enter your password:" ¬
with title "Password" ¬
with icon caution ¬
default answer "" ¬
buttons {"Cancel", "OK"} default button 2 ¬
giving up after 295 ¬
with hidden answer
if length of (text returned of my_password) is not 0 then
display dialog "Running the application!" buttons ["OK"] default button 1
else
display dialog "You didn't enter a sudo password!" buttons ["OK"] default button 1
end if
Having spent a bit of time with Ruby lately, I don’t like the syntax of Applescript very much, though it gets the job done.
I’ve written about Rails Rumble previously, the 48 hour event where teams turn an idea into a web application using Ruby on Rails. I was surprised to see the completeness of some of the applications that were developed this year as well as the utility of the ideas they implemented.
One of the more interesting articles I’ve seen in relation to Rails Rumble analysed the prevalence of various plug-ins and gems that teams utilised.
After a quick look there are a few points that specifically interest me :
jQuery is the most used Javascript library, even though it isn’t the default included with Rails. I think this says a lot about where jQuery fits in the client side coding space these days. Under further scrutiny it seems clear that jQuery had an even larger base of use than shown in that graph, as explained here.
1 in 3 teams used a skeleton application. All of those teams used Bort. That’s a pretty overwhelming statistic for two reasons. Firstly it means you should be looking at using skeleton applications if you aren’t already. Secondly anything that you develop that could be used in other applications should possibly be a gem or plug-in. Reuse doesn’t seem to be something you just talk about anymore.
Over 50% of people wrote tests as part of their application, and the majority of people used a Behaviour Driven Development framework such as Shoulda or rSpec (they got rSpec!). Keep in mind that even on a tight schedule most people using Rails are writing tests!
Over a third of applications offered OpenID support for authentication. Given I don’t even remember where I signed up for OpenID this surprises me. Maybe it’s time to join this bandwagon?
I think the article gives a good indicator where you should look to implement certain parts of your application. Generally speaking, if a lot of passionate developers are using a particular library or piece of code then you’d be wise to make the same choice.
I have recently seen two examples of product / image rebranding that have caught my attention. Both for completely different reasons.
The first one is Coca-Cola‘s “Mother“. About a year ago when the drink was first introduced, I decided to buy one and see what it was like. My taste buds rejected it immediately. And not in a “Oh that’s bad, but maybe in a few months I’ll forget how bad and try again” way. It was possibly one of the most horrid flavoured drinks this side of Sarsaparilla.
It got me wondering how on earth Coca-Cola let this slip through the taste-testing cracks. Given their massive customer base, well established other flavours and an already saturated energy drink market, I expected much better. I expected this drink to disappear from shelves as fast as it had appeared.
I was close. Not long after, a “new formula” was announced. Massive advertising and money spent to show that indeed their first attempt was a failure and now it’s much better. But for me, the damage was already done. After both literally and figuratively leaving a bad taste in my mouth, this is one cat who won’t be willing to give it a try again. I’m sure Coca-Cola have picked up plenty of “new recipe” Mother lovers, but I’m not going to be one of them. While you were out, I found Rockstar, and that’s where I will stay.
Note: If your sting loyal customers with a Z-grade product, you’ll probably lose them.
The second re-branding exercise I have witnessed is that of City Farmers. I remember their cringe-worthy song, their cheap looking ads and their country bumpkin image.
However this image proved successful. They are popular, and have found a great market over the last few years. I’ve become a loyal customer of theirs, and have no need to shop elsewhere for any pet related products. They are like Bunnings for pets.
However, It shocked me to drive past the massive warehouse for the second time that week, to see that it was no longer green. It was bright orange, with a brand-spanking new logo. And a much better one at that. I figured their web site would have been updated too, so I checked. It’s one of the better looking ones I’ve seen in a while.
City Farmers, you won me as a customer with your cheap and tacky image, and then you cemented me as a customer with your willingness to adapt and somehow completely change your image better than most companies ever do it. I’m not sure who has designed the web site, but they’ve certainly done well.
Note: Use the right professionals for the job and listen to their advice. Remember, they’re the ones with the expertise.