forked from mattheworiordan/jquery.infinite.tabs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
example.html
232 lines (202 loc) · 6.82 KB
/
example.html
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Infinite Rounded Out Tabs</title>
<link rel="stylesheet" href="css/infinite.tabs.css" />
<script src="vendor/js/jquery.1.6.2.min.js"></script>
<!--[if (gte IE 6)&(lte IE 8)]>
<script type="text/javascript" src="vendor/js/selectivizr-min.js"></script>
<link rel="stylesheet" href="css/infinite.tabs.lteqie8.css" />
<![endif]-->
<script src="jquery.infinite.tabs.js"></script>
<style>
* { margin: 0; padding: 0; }
body { font: 14px Georgia, serif; }
h1 {
width: 660px;
margin: 0 auto;
padding: 20px 0;
color: #222;
}
body {
background: #222;
}
.tab-content {
background: white;
min-height: 50px;
}
.breaker {
min-height: 20px;
}
.buttons {
padding: 20px;
}
</style>
<script>
/* Sample code to handle tab selection */
$(function() {
var clickEvent = function(event) {
event.preventDefault();
event.stopPropagation();
$(this).parents('ul.infinite-tabs').find('li').removeClass("active");
$(this).addClass("active");
},
lastTab = false;
$("ul.infinite-tabs").infiniteTabs()
.find('li').click(clickEvent);
$('#remove-tab').click(function(event) {
var lastTab = $('#js-target li.scroller li:not(.hidden):not(.navigation):last')
if (lastTab.length == 1) {
$('#js-target').infiniteTabs('remove-tab', lastTab);
}
});
$('#append-tab').click(function(event) {
var newTab = $('<li><a href="#">' + Math.floor(Math.random() * 100) + '</a></li>').click(clickEvent).click(selectedEvent);
$('#js-target').infiniteTabs('append-tab', newTab);
});
$('#prepend-tab').click(function(event) {
var newTab = $('<li><a href="#">' + Math.floor(Math.random() * 100) + '</a></li>').click(clickEvent).click(selectedEvent);
$('#js-target').infiniteTabs('prepend-tab', newTab);
});
var selectedEvent = function(event) {
$('#js-target').infiniteTabs('set-tab-content', this, $(this).find('a').html() + ' selected');
if (lastTab) {
$('#js-target').infiniteTabs('set-tab-content', lastTab, $(lastTab).find('a').html().replace(/ selected/,''));
}
lastTab = this;
};
$('#js-target li.scroller li').click(selectedEvent);
});
</script>
</head>
<body>
<ul id="js-target" class="infinite-tabs">
<li class="active locked"><a href="#one">Pinned</a></li>
<li class="locked"><a href="#one">Also pinned</a></li>
<li><a href="#one">1</a></li>
<li><a href="#two">2</a></li>
<li><a href="#three">3</a></li>
<li><a href="#three">4</a></li>
<li><a href="#one">5</a></li>
<li><a href="#two">6</a></li>
<li><a href="#three">7</a></li>
<li><a href="#three">8</a></li>
<li><a href="#one">9</a></li>
<li><a href="#two">10</a></li>
<li><a href="#three">11</a></li>
<li><a href="#three">12</a></li>
<li><a href="#one">13</a></li>
<li><a href="#two">14</a></li>
<li><a href="#three">15</a></li>
<li><a href="#three">16</a></li>
<li><a href="#one">17</a></li>
<li><a href="#two">18</a></li>
<li><a href="#three">19</a></li>
<li><a href="#three">20</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (even number tabs) with Javascript manipulation</h1>
<div class="buttons">
<input type="button" id="remove-tab" value="Remove Tab">
<input type="button" id="append-tab" value="Append Tab">
<input type="button" id="prepend-tab" value="Prepend Tab">
</div>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li class="active locked"><a href="#one">Pinned</a></li>
<li class="locked"><a href="#one">Also pinned</a></li>
<li><a href="#one">1</a></li>
<li><a href="#two">2</a></li>
<li><a href="#three">3</a></li>
<li><a href="#three">4</a></li>
<li><a href="#one">5</a></li>
<li><a href="#two">6</a></li>
<li><a href="#three">7</a></li>
<li><a href="#three">8</a></li>
<li><a href="#one">9</a></li>
<li><a href="#two">10</a></li>
<li><a href="#three">11</a></li>
<li><a href="#three">12</a></li>
<li><a href="#one">13</a></li>
<li><a href="#two">14</a></li>
<li><a href="#three">15</a></li>
<li><a href="#three">16</a></li>
<li><a href="#one">17</a></li>
<li><a href="#two">18</a></li>
<li><a href="#three">19</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (odd number tabs)</h1>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li class="active locked"><a href="#one">Pinned</a></li>
<li><a href="#one">1</a></li>
<li><a href="#two">2</a></li>
<li><a href="#three">3</a></li>
<li><a href="#three">4</a></li>
<li><a href="#one">5</a></li>
<li><a href="#two">6</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (few tabs, one pinned)</h1>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li><a href="#one">1</a></li>
<li><a href="#two">2</a></li>
<li><a href="#three">3</a></li>
<li><a href="#three">4</a></li>
<li><a href="#one">5</a></li>
<li><a href="#two">6</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (few tabs, none pinned)</h1>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li><a href="#one">1</a></li>
<li><a href="#two">2</a></li>
<li><a href="#three">3</a></li>
<li><a href="#three">4</a></li>
<li><a href="#one">5</a></li>
<li><a href="#two">6</a></li>
<li><a href="#three">7</a></li>
<li><a href="#three">8</a></li>
<li><a href="#one">9</a></li>
<li><a href="#two">10</a></li>
<li><a href="#three">11</a></li>
<li><a href="#three">12</a></li>
<li><a href="#one">13</a></li>
<li><a href="#two">14</a></li>
<li><a href="#three">15</a></li>
<li><a href="#three">16</a></li>
<li><a href="#one">17</a></li>
<li><a href="#two">18</a></li>
<li><a href="#three">19</a></li>
<li><a href="#three">20</a></li>
<li><a href="#two">21</a></li>
<li><a href="#three">22</a></li>
<li><a href="#three">23</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (lots of tabs, none pinned)</h1>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li class="active locked"><a href="#one">Pinned</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (one pinned, no other tabs)</h1>
</div>
<div class="breaker"></div>
<ul class="infinite-tabs">
<li class="active locked"><a href="#one">Pinned</a></li>
<li class="locked"><a href="#two">Second pinned</a></li>
</ul>
<div class="tab-content">
<h1>Infinite Round Out Tabs (two pinned, no other tabs)</h1>
</div>
</body>