This repository has been archived by the owner on Jun 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
356 lines (325 loc) · 12.4 KB
/
index.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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
<!doctype html>
<html class="no-js" lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Tabit - JavaScript tabs plugin</title>
<meta name="description" content="">
<script
src="https://code.jquery.com/jquery-3.1.1.js"
integrity="sha256-16cdPddA6VdVInumRGo6IbivbERE8p7CQR3HzTBuELA="
crossorigin="anonymous"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
</head>
<body>
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Tabit!</h1>
<p class="lead text-muted">Just javascript tabs. Make it where you want.<br>No dependencies. Lightweight. Customizable.</p>
<p>
<a href="https://github.com/andrey-hohlov/tabit" target="_blank" class="btn btn-primary">Documentation and download</a>
</p>
</div>
</section>
<div class="container mb-5">
<h2 class="h1">Examples</h2>
</div>
<!-- Default-->
<div class="container mb-5">
<h3 class="mb-3">Default</h3>
<div id="tabs-default" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-default-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-default-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-default-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-default-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-default-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-default-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
</div>
<!-- Set active-->
<div class="container mb-5">
<h3 class="mb-3">Set active tab</h3>
<div id="tabs-set-active" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-set-active-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-set-active-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-set-active-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-set-active-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-set-active-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-set-active-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
</div>
<!-- Set event-->
<div class="container mb-5">
<h3 class="mb-3">Change on hover</h3>
<div id="tabs-set-event" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-set-event-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-set-event-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-set-event-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-set-event-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-set-event-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-set-event-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
</div>
<!-- Closable-->
<div class="container mb-5">
<h3 class="mb-3">Closable</h3>
<div id="tabs-closable" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-closable-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-closable-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-closable-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-closable-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-closable-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-closable-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
<i class="small">Click on active tab for close it.</i>
</div>
<!-- Animation-->
<div class="container mb-5">
<h3 class="mb-3">Custom animations</h3>
<div id="tabs-animations" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-animations-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-animations-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-animations-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-animations-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-animations-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-animations-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
<i class="small">In example used jQuery for animations.</i>
</div>
<!-- Rotate -->
<div class="container mb-5">
<h3 class="mb-3">Autorotate</h3>
<div id="tabs-rotate" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-rotate-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-rotate-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-rotate-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-rotate-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-rotate-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-rotate-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
</div>
<!-- Manual control -->
<div class="container mb-5">
<h3 class="mb-3">Manual control</h3>
<div id="tabs-manual" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-manual-1" class="btn btn-primary">Tab 1</a>
<a href="#tabs-manual-2" class="btn btn-primary">Tab 2</a>
<a href="#tabs-manual-3" class="btn btn-primary">Tab 3</a>
</nav>
<div id="tabs-manual-1" class="card">
<span class="card-block">Content of first tab</span>
</div>
<div id="tabs-manual-2" class="card">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-manual-3" class="card">
<span class="card-block">Content of third tab</span>
</div>
</div>
<div class="mb-2">
<nav class="btn-group">
<button type="button" id="tab-prev" class="btn btn-secondary">Prev</button>
<button type="button" id="tab-next" class="btn btn-secondary">Next</button>
<button type="button" id="tab-set-2" class="btn btn-secondary">Set 2</button>
<button type="button" id="tab-get-active" class="btn btn-secondary">Get active</button>
<button type="button" id="tab-get-active-index" class="btn btn-secondary">Get active index</button>
<button type="button" id="tab-destroy" class="btn btn-secondary">Destroy</button>
<button type="button" id="tab-reinit" class="btn btn-secondary">Reinit</button>
</nav>
</div>
<i class="small">Look in console for result of `get active`.</i>
</div>
<!-- Tabs in tabs -->
<div class="container mb-5">
<h3 class="mb-3">Tabs in tabs</h3>
<div id="tabs-parent" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-parent-1" class="btn btn-primary js-parent-tab">Tab 1</a>
<a href="#tabs-parent-2" class="btn btn-primary js-parent-tab">Tab 2</a>
<a href="#tabs-parent-3" class="btn btn-primary js-parent-tab">Tab 3</a>
</nav>
<div id="tabs-parent-1" class="card js-parent-content">
<div class="card-block">
<div id="tabs-child" class="mb-2">
<nav class="btn-group mb-2">
<a href="#tabs-child-1" class="btn btn-primary js-child-tab">Tab 1</a>
<a href="#tabs-child-2" class="btn btn-primary js-child-tab">Tab 2</a>
<a href="#tabs-child-3" class="btn btn-primary js-child-tab">Tab 3</a>
</nav>
<div id="tabs-child-1" class="card js-child-content">
<span class="card-block">Content of first child tab</span>
</div>
<div id="tabs-child-2" class="card js-child-content">
<span class="card-block">Content of second child tab</span>
</div>
<div id="tabs-child-3" class="card js-child-content">
<span class="card-block">Content of third child tab</span>
</div>
</div>
</div>
</div>
<div id="tabs-parent-2" class="card js-parent-content">
<span class="card-block">Content of second tab</span>
</div>
<div id="tabs-parent-3" class="card js-parent-content">
<span class="card-block">Content of third tab</span>
</div>
</div>
<i class="small">Use different selectors for parent and child tabs.</i>
</div>
<!-- Footer -->
<footer class="pb-5">
<div class="container">
<div class="small text-right">
Made by <a href="http://hohlov.pro" target="_blank">Andrey Hohlov</a>
</div>
</div>
</footer>
<!-- GitHub -->
<a href="https://github.com/andrey-hohlov/tabit" target="_blank">
<img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/38ef81f8aca64bb9a64448d0d70f1308ef5341ab/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png">
</a>
<script src="dist/Tabit.min.js"></script>
<script>
(function(){
/**
* Default init
*/
var tabsDefault = new Tabit(document.getElementById('tabs-default'), {buttonActiveClass: 'active'});
/**
* Set active tab
*/
var tabsSetActive = new Tabit(document.getElementById('tabs-set-active'), {buttonActiveClass: 'active', active: 1});
/**
* Set event to tab
*/
var tabsSetEvent = new Tabit(document.getElementById('tabs-set-event'), {buttonActiveClass: 'active', event: ['mouseover', 'click']});
/**
* Closable
*/
var tabsClosable = new Tabit(document.getElementById('tabs-closable'), {buttonActiveClass: 'active', activeIndex: -1, closable: true});
/**
* Animations
*/
var tabsAnimation = new Tabit(
document.getElementById('tabs-animations'),
{
buttonActiveClass: 'active',
toggleDisplay: false,
onInit: function () {
this.tabs.forEach(function (item, i) {
if (i !== 0) $(item.content).hide();
});
},
beforeChange: function (activeTab, newTab, instance) {
if (!activeTab) return; // no animate on init
$(activeTab.content)
.stop()
.fadeOut(function () {
$(newTab.content).stop().fadeIn()
});
}
}
);
/**
* Rotate
*/
var tabsRotate = new Tabit(document.getElementById('tabs-rotate'), {buttonActiveClass: 'active'});
var rotate = setInterval(function() {
tabsRotate.next();
}, 2000)
/**
* Manual control
*/
var tabsManual;
function initManualTabs() {
tabsManual = new Tabit(document.getElementById('tabs-manual'), { buttonActiveClass: 'active'});
}
initManualTabs();
document.getElementById('tab-next').addEventListener('click', function () {
tabsManual.next();
});
document.getElementById('tab-prev').addEventListener('click', function () {
tabsManual.prev();
});
document.getElementById('tab-set-2').addEventListener('click', function () {
tabsManual.setActiveTab(1);
});
document.getElementById('tab-get-active').addEventListener('click', function () {
console.log(tabsManual.getActiveTab());
});
document.getElementById('tab-get-active-index').addEventListener('click', function () {
console.log(tabsManual.getActiveTabIndex());
});
document.getElementById('tab-destroy').addEventListener('click', function () {
tabsManual.destroy();
console.log(tabsManual); // undefined
});
document.getElementById('tab-reinit').addEventListener('click', initManualTabs);
/**
* Tabs in tabs
*/
var tabsParent = new Tabit(document.getElementById('tabs-parent'), {
buttonActiveClass: 'active',
buttonSelector: '.js-parent-tab',
contentSelector: '.js-parent-content',
});
var tabsChild = new Tabit(document.getElementById('tabs-child'), {
buttonActiveClass: 'active',
buttonSelector: '.js-child-tab',
contentSelector: '.js-child-content',
});
})();
</script>
</body>
</html>