added pre-sleep timing feature and ng-blur directive