you provide a parameter showCatalog, state is confusing.
<pre>
element.hasClass('collapsed')
</pre>
already refers to the state.