JS calculate the dialog size