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

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

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