Friday, February 13, 2009

Opening links in a new window

Like it or not, people often expect certain documents (i.e. PDFs) to open in a tab or window. Often enough, the ugly solution of target="top" or similar is used otherwise JavaScript is employed to redirect links. Both methods are a wonderful source of confusion and annoyance.


With this in mind, I cobbled together my own solution employing the wonders of jQuery to handle the selectors:


$(function(){
$("a[href$='.pdf']").click(function(e){
//don't interfere with modifier keys
if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) {
return true;
}
window.open($(this).attr("href"));
return false;
}).attr("title", function(){
return this.title + " (Opens in a new window)"
});
});

Two key things happen here: modifier keys are left alone so power users are happy and the anchor”s title is altered to give users a hint of what’s going on.

Sunday, January 4, 2009

Portugal and beyond

We are now in warm Portugal (compared to the rest of the trip, it is really warm!)

But first, a little recap as we were last in Berlin.

For those who aren´t aware, we spent a white Christmas in Levi, Finland. It´s the home of crazy reindeer, lots of snow and Santa!!! We had the most fantastic time in which we got pulled around by reindeer in sleds, rode snowmobiles at fantastic speeds (sort of), met some huskies who enjoyed eating people´s hands, elf-skippd in the snow-covered forest at night and caught some fish on a lake that had 30cm of frozen ice. It was incredible - photos will come later.

Berlin was also a fantastic experience. It involved eating and sampling lots of the local delicasies which were generally Berliners or gummy bears. Saw lots of the local historical areas - museums of ancient Egypt and Babylonian times (the Pokemon museum!) and staying in Checkpoint Charlie, saw that important area. New Year´s was an amazing experience in which we were packed into the Tiergarten with stages, food, fireworks and 1 million people. The fireworks were the most interesting as people are allowed to set them off everywhere, including in the street right next to you.
We ended our time in Berlin with some snowfall and maybe a couple of snowballs being thrown..

We are now in Portugal, staying about an hour out of Lisbon with Sarah´s aunt and cousins. Today we went to Obidos - a castle (a real castle) which still had its wall and village inside the wall intact and functioning. An amazing sight for people who come from a country that definately doesn´t have any castles. We will be staying in Lisbon on Tuesday and Wednesday and then we start our journey home.

Saturday, December 27, 2008

Ich bin ein Berliner

We've made it this far to Berlin.

Christmas in Levi was cold but incredible.

Running out of time... until next time!

Wednesday, November 26, 2008

Pattern Recognition

AVA7 Patterns is an interesting site with hundreds of patterns with a friendly licence. The only problem I see is finding a pattern you like means crawling through the lot. While it's technically impossible to search abstract images, perhaps some tags on the site might add helpful metadata. (Via Veerle)

Monday, November 24, 2008

Packing it in

Having finally tackled the relatively complex art of compressing JavaScript and CSS in ASP.NET, I found most of the work had already been done in the form of Packer for .NET. As I found it, Packer featured methods to compress via Dean Edward's Packer and and Doug Crockford's JSMin.


Since I wanted to combine and minify my CSS, a hunt around revealed an efficient method written by Isaac Schlueter which was incorporated into the YUI Compressor. Working from two C# ports of Isaac's code, I added CSSMinify to the pot and the result is now available.


Want more? Send a request or, even better, fetch the source and contribute your own magic.

Monday, September 15, 2008