Refactored toggleDirectory.

refs #6134