Refactor interface integration code

Reduce document.ready code by moving functions outside and grouping
tooltip related code to a function.

Also remove window and document from wrapper anon function since
browser: true is defined in .jshintrc

Bug: 48156
Change-Id: I7228285cdcb33b915e96e7e2c59e4dbc90f5fc96