(function (angular) {

  angular	
    .module('project.directives')
    .directive('input', input);
		
 	// Monkey patch para problema de máscara nos telefone samsung da série 6
  function input($timeout) {
    return {
      restrict: 'E',
      link: function ($scope, $element, $attrs) {
        if ($attrs.$attr.uiBrCepMask || $attrs.$attr.uiBrPhoneNumber) { 
          $element.on('input keydown keyup click focus', function ($event) {
            if ($event.keyCode != 8) {
              $timeout(function () {
                $event.target.selectionStart = $event.target.value.length;
                $event.target.selectionEnd = $event.target.value.length;
              }, 10);
            }
          });
        }
      }
    };
  }

})(window.angular);