blob: 2915ce294143208b01e1fb699e81a95cc9a82b1f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
( function( $ ) {
// Small jQuery plugin to handle the toggle function & cookie for state
// For collapsible items in the footer
$.fn.footerCollapsibleList = function( config ) {
if (
! ( 'title' in config ) ||
! ( 'name' in config )
) {
return;
}
return this.each( function () {
// Setup
$( this )
.parent()
.prepend(
$( '<a>' )
.addClass( 'collapsible-list' )
.text( config.title )
.on( 'click', function( e ) {
e.preventDefault();
// Modify state cookie.
var state = ( $.cookie( config.name ) !== 'expanded' ) ?
'expanded' : 'collapsed';
$.cookie( config.name, state );
// Modify DOM.
$( this ).next().toggle();
$( this ).find( 'span' ).toggleClass( 'collapsed' );
} )
.append( $( '<span>' ) )
)
.end()
.prev()
.remove();
// Check cookie and collapse.
if(
$.cookie( config.name ) === null ||
$.cookie( config.name ) === 'collapsed'
) {
$( this )
.slideUp()
.prev()
.find( 'span' ).addClass( 'collapsed' );
}
} );
};
}( jQuery ) );
|