javascript library and modal refactoring, automatic even binding if flag provided