jQuery Panelizr
Toggle panels persisted in local memory
Panelizr is a lightweight jQuery plugin for managing toggleable panels and persisting their state in local memory (using either localStorage or sessionStorage).
It's flexible and non-opinionated and has no required styling and only minimal required markup.
View the demo.
Usage
-
Get Plugin:
$ bower install Panelizr --save-dev
or simply download the .zip.
-
Include jQuery:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
-
Include plugin's code:
<script src="dist/jquery.panelizr.min.js"></script>
-
Write HTML:
<div id="mypanel"> <!-- any element with a selector to call --> <h3 class="panel-toggle">A Panel</h3> <!-- any element, will act as trigger for open/close --> <div class="panel-content"> <!-- any block element that wraps content to be shown/hidden --> Lorem ipsum. </div> </div>
-
Call the plugin:
$("#mypanel").Panelizr({ panelName: "someUniqueName" });
Options
panelName: [string] (required) - A unique identifier for your panel
storageType: [string] (optional - default is localStorage) - Type of storage to use, accepts "localStorage" or "sessionStorage"
user: [string] (optional - default is "defaultUser") - If you have a user ID variable available, you can scope the localStorage key to your current user
initialState: [boolean] (optional - default is true) - Defines if on the first instance of the panel being shown if it should be open (true) or closed (false)