fix #2711 using a custom event, also use css selectors over filterAttr

fixes #2711 and #3295 which are actually the same

tested with the selenium test suite and on chromium, opera next and ie8

also uses css selectors like `data-file="'+file+'"` instead of using `filterAttr('data-file',file)` from js.js, see [The 30 CSS Selectors you Must Memorize](http://net.tutsplus.com/tutorials/html-css-techniques/the-30-css-selectors-you-must-memorize/) or should at least bookmark.

@jancborchardt @merlin2004 @MTGap @raghunayyar @fernandoruiz @schiesbn @beyondthewall @redknight101 @karlitschek please review