AMD/requirejs support, encapsulate function

In reference to https://github.com/23/resumable.js/issues/122