Opening a new tab using Ctrl+Click on Opera

One thing that bugs me everytime I use Opera are the weird keyboard shortcuts. You open link in a new tab by using the middle mouse button (classic) or Shift+click (less classic, we are accustomed to use the Ctrl+Click, Shift+Click being used to open in a new window).

Today it was bugging me one too many times, so I decided to use the power of AutoHotKey to help fix this.

Here is the little snippet I added to my default AutoHotKey script :

;        Open page in new tab in Opera using Ctrl + Click
#ifWinActive, ahk_class OpWindow
^LButton::Send +{LButton}
#IfWinActive

It basically catch every Shift+Click in Opera and return a Ctrl+Click instead, allowing me to finally open tabs the way I'm used to.

Knowing if an element is in the DOM using jQuery

If you ever need to know if the element you have a reference to is really in your page (or if it is an old reference to an element you've already replaced), you can use the $.contains(container, contained) method.

I was just working on an AJAX paginated list of elements and I kept references to my table in vars to avoid re-querying it each time. But this reference where still 'correct' (ie. not null) even after having replaced the element with a new one (using .replaceWith() and even .empty() and .remove())

I added a check to see if the element was really in the DOM before using it, and if not requerying it and re-saving it in var

missing data in jQuery Ajax event ajaxSuccess

jQuery provides a nifty set of Ajax events that one could define to fire methods whenever an ajax request starts, stop, failed or succeed. It is quite useful actually, to display visual indicator once and for all without having to define the various callback on each ajax call.

But it has one flaw. The ajaxSuccesscallback only give access to the event, XMLHttpRequestobject and the option object. There is no direct way to get the return data from the call.

Well, you can still access it from the XMLHttpRequest responseText attribute but it is then your job to parse it according to its type, duplicating some of the code already called in the jQuery core.

You can use the $.httpData to directly parse it, giving the XHR as first argument and the data type as the second one.

$('#ajaxIndicator').bind('ajaxSuccess', function(event, xhr, options) {
  var data = $.httpData(xhr, options.dataType);
}

CSS rule to target only Firefox

I just found (via enure.net) a CSS rule using proprietary Mozilla filter that would allow one to specifically target Mozilla.

I'm not a huge fan of CSS hacks like that, I usually restrain them to the bare minimum of IE conditional comments. But in some edge cases, it is sometimes useful, if you really don't have other options.

I'd like to find the equivalent rules (using proprietary rules, no parser bug) for Safari, Chrome and Opera

@-moz-document url-prefix() {
  p { color: red; }
}

Updated CSSTidy files

CSSTidy allows you to optimize your CSS files by aggregating them in one unique file, removing useless spaces and comments as well as running some other optimizations on multiple declarations and shorthand notations.

But if, like me, you're still using the 1.3 version available on the official website, you may have run into issues when dealing with the latest CSS3 goodies.

I've been hacking this library in the last year, adding support for @font- face and for proprietary prefixed properties values, but today I was faced with some other issues that I wasn't able to resolve.

CSSTidy does not use regexp to parse the file, it reads it one char at a time and does its optimization at the same time, and it is sometimes quite hard to follow.

Anyway, I just discovered that the Sourceforge page of the project is still up and running and that a commit was added today, so the project is not dead ! I also posted two bug reports and one (dummy) patch.

Here's the link, you got a download link at the bottom : http://csstidy.svn.sourceforge.net/viewvc/csstidy/trunk/