JS structure change to jQuery plugins