var angular = require('angular');
require('../modules');

var module = angular.module('commons.directives');

module.directive('onTouchstart', function($parse) {
  return {
    restrict: 'A',
    link: function(scope, element, attrs) {
      var onTouchstartHandler = $parse(attrs.onTouchstart);
      function onTouchstart($event) {
        scope.$evalAsync(function() {
          onTouchstartHandler(scope, {$event: $event});
        });
      }
      element.on('touchstart', onTouchstart);
    }
  };
});
