Cross-browser jQuery plugin to react on visibility change