Switch to use $document
Use rootScope instead of the dom
Remove unused