js: refactoring dialog widget