move directive impl into js/directives.js