fix bug with button down/up event
add require.js
rewriten using require.js