translated gallery.js to gallery.coffee