A customisable state machine for Backbone.js views