move all source into template_element.js

R=arv
BUG=

Review URL: https://codereview.appspot.com/9219045