Fix dired_preview command and refactor.

If user toggle preview mode off, dired_preview command close preview
only except for edditing files.