Please check your spacing on this and the rest of the code. It should follow MediaWiki conventions.

Also, right now the code has several problems. fullscreenElement is never defined, and you have no need to redefine the $.fn's, since just calling enterFullscreen()/exitFullscreen() is enough.

Please test your code first :)