Modularized gallery.js