guardian/frontend — pull request #147 by ahume (2012-10-18 15:55:34+00:00)
Title: Refactor userPrefs and enable fonts by default. [DO NOT MERGE]

I created a monster with this userPrefs thing. The fact it's not AMD we have a potential fix for, which should come at some point down the line. Meanwhile, the API sucks because it doesn't know if it's for setting switches or for storing specific values. Here's my refactor which I've implemented to enable switching fonts to on by default.

Firstly, set switches:

prefs.switchOn('font-family');
prefs.switchOff('font-family');
prefs.isOn('font-family');
prefs.isOff('font-family');
prefs.switchRemove('font-family')

?gu.prefs.switchOn=font-family
?gu.prefs.switchOff=font-family

These get stored in localStorage as gu.prefs.switch.font-family=true, or gu.prefs.switch.font-family=false

Secondly, store values:

prefs.set('name', 'value');
prefs.get('name');
prefs.remove('name');]

?gu.prefs.name=value

These get stored in localStorage as gu.prefs.name=value

I think it only effects the font prefs, as other uses were only using get/set which hasn't changed.

Please review.