-
Notifications
You must be signed in to change notification settings - Fork 63
/
Copy pathREADME
182 lines (153 loc) · 6.8 KB
/
README
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
----------------No longer being Maintained--------------------
Collapsible, jQuery Plugin
Overview:
================================================================================
This plugin enables site owners to control multiple collapsible panels by auto
opening any defaults specified, and keeping those opened/closed by users as they
left them while browsing your site.
If you find any errors or have suggested changes, please post a comment on the
github project: http://github.com/juven14/Collapsible
Very Basic demos can be found here:
http://www.snyderplace.com/demos/collapsible.html
To enable cookie support you'll need the Cookie plugin here:
https://github.com/carhartl/jquery-cookie
________________________________________________________________________________
================================================================================
Adding a collapsible panel to your html:
================================================================================
You have to create your own html for the collapsible. You need a header element
(div or etc) that gets the "collapsible" class assigned and a
body element. However, the slide effect will be choppy if you have margins and
padding for the container, so here we just use a div. Here I've used
"collapsible" but you can choose any other selector. Here is an example:
---HTML code--------------------------------------------------------------------
<div class="collapsible" id="nav-section1">Navigation Section<span></span></div>
<div>
<ul>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
</ul>
</div>
<div class="collapsible" id="nav-section2">Navigation Section<span></span></div>
<div>
<ul>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
</ul>
</div>
<div class="collapsible" id="nav-section3">Navigation Section<span></span></div>
<div>
<ul>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
<li><a href="#">Navigation Item</a></li>
</ul>
</div>
---end HTML code----------------------------------------------------------------
________________________________________________________________________________
================================================================================
Adding the Javascript to your file:
================================================================================
JavaScript which belongs in the head of the html document, using the
cookie plugin is optional. Please note that our default open / config is only
an example as related to the above HTML.
---JavaScript code--------------------------------------------------------------
<script type="text/javascript" src="javascript/jquery.cookie.js"></script>
<script type="text/javascript" src="javascript/jquery.collapsible.js"></script>
<script type="text/javascript">
$(document).ready(function() {
//collapsible management
$('.collapsible').collapsible({
defaultOpen: 'nav-section1,nav-section3'
});
});
</script>
---end JavaScript code----------------------------------------------------------
The plugin default options are as follows:
---JavaScript code--------------------------------------------------------------
{
cssClose: 'collapse-close',
cssOpen: 'collapse-open',
cookieName: 'collapsible',
cookieOptions: {
path: '/',
expires: 7,
domain: '',
secure: ''
},
defaultOpen: '',
speed: 300,
bind: 'click',
animateOpen: function (elem, opts) {
elem.next().slideUp(opts.speed);
},
animateClose: function (elem, opts) {
elem.next().slideDown(opts.speed);
},
loadOpen: function (elem, opts) {
elem.next().show();
},
loadClose: function (elem, opts) {
elem.next().hide();
}
}
---end JavaScript code----------------------------------------------------------
Option details:
* cssClose - This is the class you want assigned when it is closed.
* cssOpen - This is the class you want assigned when it is opened.
* cookieName - This is the name of the cookie that will store which
collapsibles should be open.
* cookieOptions - See the jquery.cookie plugin for more information.
* defaultOpen - This is comma separated list of collapsible header ids.
* speed - This is the animation speed for the slide up/down.
* bind - This is the event that you want the collapsibles to function on. only
4 are supported: click, dblclick, mouseenter, and mouseover.
* animateOpen - This is a custom callback to alter the way that an element
is opened.
* animateClose - This is a custom callback to alter the way that an element
is closed.
* loadOpen = This is a custom callback to override the default open state
* loadClose = This is a custom callback to override the default close state
Methods:
You can call following methods on collapsible elements:
* collapsed - returns 'true' if element is collapsed
* toggle - toggle collapsible state
* open - open a collapsible
* close - close a collapsible
* openAll - open all closed collapsibles
* closeAll - close all open collapsibles
Call them using jquery-ui style:
$(selector).collapsible('method', [arg]);
Examples:
if ( $('#nav-block').collapsible('collapsed') ) { ... }
or
appendToLog('Error: service is down!');
$('#nav-logs').collapsible('open');
________________________________________________________________________________
================================================================================
Styling
================================================================================
In the above example HTML you will see a span, this is useful if you wish to
assign an open/close image.
This plugin will append a user defined (or default, see options above) class to
header of the collapsible. You can use this to swap out the images or style
the different states of your collapsible.
---CSS code---------------------------------------------------------------------
.collapsible div.collapse-open {}
.collapsible div.collapse-close {}
.collapsible div.collapse-open span {}
.collapsible div.collapse-close span {}
---end CSS code-----------------------------------------------------------------
________________________________________________________________________________
================================================================================