use $window module rather than global
fix up a few more global references
use $log for logging rather than console
Merge pull request #15 from jarcoal/patch-1

use $window module rather than global