guardian/frontend — pull request #7101 by uplne (2014-11-13 12:48:00+00:00)
Title: Show more session state

This is taking care of the session based persistent state of the 'More' button + clicked state of the button is changed from 'Less' to 'Fewer'.

![screen shot 2014-11-13 at 12 12 02](https://cloud.githubusercontent.com/assets/2579465/5028420/c94d6fc8-6b32-11e4-8094-9500fdf3bc21.png)
![screen shot 2014-11-13 at 12 11 40](https://cloud.githubusercontent.com/assets/2579465/5028424/d062826c-6b32-11e4-8c61-05e1863da231.png)

This is opening multiple possibilities to refactor and simplify the code. As we want this out and I don't want to create one massive PR changing too many things that will affect other modules I've decided to do it in more iterations. It's nicely tested so the confidence for this refactor will be high.

1. Setting and reading of the session storage is almost the same as the code in 'container-toggle.js' so it will possibly need to be abstracted.
2. The 'storage' and 'userPref' objects will need to rethink a little bit as it is now storing one state. I am passing optional parameter to it's functions so I can make sure that I am working with 'sessionStorage' just for my code. But it's ugly. I am thinking maybe about adding some simple factory before so I can choose which storage I want to use without creating x instances across the whole app.
3. I had to add data-id to 'container__body' element. It's less ugly than trying to find the parent with JS. But as 'container-toggle.js' is doing the same there is possibility to refactor this and pass to both modules the same container object and remove the `data-id` and `data-title` duplicity.