elixir-toolkit-theme 5.0.0 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +3 -2
- data/_includes/affiliation-logo.html +10 -0
- data/_includes/affiliation-tiles-page.html +27 -27
- data/_includes/citation-page.html +19 -17
- data/_includes/contributor-avatar.html +16 -0
- data/_includes/contributor-card.html +33 -0
- data/_includes/contributor-carousel-selection.html +17 -68
- data/_includes/contributor-minitiles-page.html +18 -107
- data/_includes/contributor-tiles-all.html +8 -61
- data/_includes/github-buttons.html +14 -14
- data/_includes/head.html +3 -3
- data/_includes/more-information-tiles.html +5 -5
- data/_includes/page-metadata-tabs.html +92 -0
- data/_includes/resource-table-all.html +28 -16
- data/_includes/scroll-top.html +1 -1
- data/_includes/section-navigation-tiles.html +10 -5
- data/_includes/sidebar.html +58 -42
- data/_includes/toc.html +1 -1
- data/_includes/topnav.html +2 -1
- data/_layouts/default.html +3 -3
- data/_layouts/page.html +4 -4
- data/_sass/_bootstrap_variables.scss +2 -1
- data/_sass/_variables.scss +11 -17
- data/assets/css/main.scss +235 -107
- data/assets/img/apple-touch-icon.png +0 -0
- data/assets/img/favicon.svg +24 -0
- data/assets/img/site.webmanifest +19 -17
- data/assets/img/web-app-manifest-192x192.png +0 -0
- data/assets/img/web-app-manifest-512x512.png +0 -0
- data/assets/js/main.js +133 -22
- data/assets/js/toc.js +5 -3
- metadata +11 -8
- data/assets/img/android-chrome-192x192.png +0 -0
- data/assets/img/android-chrome-512x512.png +0 -0
- data/assets/img/safari-pinned-tab.svg +0 -29
- data/assets/js/jquery.navgoco.js +0 -314
data/assets/img/site.webmanifest
CHANGED
|
@@ -3,21 +3,23 @@ layout: none
|
|
|
3
3
|
permalink: assets/img/site.webmanifest
|
|
4
4
|
---
|
|
5
5
|
{
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
"name": "{{ site.title | default: '0d6efd' }}",
|
|
7
|
+
"short_name": "",
|
|
8
|
+
"icons": [
|
|
9
|
+
{
|
|
10
|
+
"src": "{{ 'assets/img/web-app-manifest-192x192.png' | relative_url }}",
|
|
11
|
+
"sizes": "192x192",
|
|
12
|
+
"type": "image/png",
|
|
13
|
+
"purpose": "maskable"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"src": "{{ 'assets/img/web-app-manifest-512x512.png' | relative_url }}",
|
|
17
|
+
"sizes": "512x512",
|
|
18
|
+
"type": "image/png",
|
|
19
|
+
"purpose": "maskable"
|
|
20
|
+
}
|
|
21
|
+
],
|
|
22
|
+
"theme_color": "#{{ site.theme_variables.theme_color | default: '0d6efd' }}",
|
|
23
|
+
"background_color": "#ffffff",
|
|
24
|
+
"display": "standalone"
|
|
23
25
|
}
|
|
Binary file
|
|
Binary file
|
data/assets/js/main.js
CHANGED
|
@@ -27,27 +27,45 @@ $(document).ready(function () {
|
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Sidebar height
|
|
31
31
|
*/
|
|
32
32
|
$(document).ready(function () {
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
33
|
+
const breakpointLg = 992; // Bootstrap's lg breakpoint in pixels
|
|
34
|
+
const main = document.getElementById('main');
|
|
35
|
+
const sideNav = document.getElementById('side-nav');
|
|
36
|
+
|
|
37
|
+
// If either element is missing, don't do anything
|
|
38
|
+
if (!main || !sideNav) return;
|
|
39
|
+
|
|
40
|
+
function getVisibleHeight(el) {
|
|
41
|
+
const rect = el.getBoundingClientRect();
|
|
42
|
+
const windowHeight = window.innerHeight || document.documentElement.clientHeight;
|
|
43
|
+
|
|
44
|
+
const visibleTop = Math.max(rect.top, 0);
|
|
45
|
+
const visibleBottom = Math.min(rect.bottom, windowHeight);
|
|
46
|
+
const visibleHeight = Math.max(0, visibleBottom - visibleTop);
|
|
47
|
+
|
|
48
|
+
return visibleHeight;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function adjustSidebarHeight() {
|
|
52
|
+
window.requestAnimationFrame(() => {
|
|
53
|
+
if (window.innerWidth < breakpointLg) {
|
|
54
|
+
sideNav.style.height = 'auto';
|
|
55
|
+
} else {
|
|
56
|
+
const visibleHeight = getVisibleHeight(main);
|
|
57
|
+
sideNav.style.height = visibleHeight + 'px';
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
adjustSidebarHeight();
|
|
63
|
+
|
|
64
|
+
window.addEventListener('scroll', adjustSidebarHeight);
|
|
65
|
+
window.addEventListener('resize', adjustSidebarHeight);
|
|
49
66
|
});
|
|
50
67
|
|
|
68
|
+
|
|
51
69
|
/**
|
|
52
70
|
* Back to top button
|
|
53
71
|
*/
|
|
@@ -170,8 +188,101 @@ $(function () {
|
|
|
170
188
|
*/
|
|
171
189
|
|
|
172
190
|
$(function () {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
191
|
+
const bs = window.bootstrap;
|
|
192
|
+
// Initialize all popovers (click to open; HTML allowed; render in body)
|
|
193
|
+
$('[data-bs-toggle="popover"]').each(function () {
|
|
194
|
+
new bs.Popover(this, {
|
|
195
|
+
html: true,
|
|
196
|
+
sanitize: false, // allow dropdown markup inside
|
|
197
|
+
container: 'body',
|
|
198
|
+
trigger: 'click'
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
// When a popover is shown, initialize any dropdowns inside it
|
|
203
|
+
$(document).on('shown.bs.popover', '[data-bs-toggle="popover"]', function () {
|
|
204
|
+
const tipId = $(this).attr('aria-describedby');
|
|
205
|
+
if (!tipId) return;
|
|
206
|
+
const $tip = $('#' + tipId);
|
|
207
|
+
if (!$tip.length) return;
|
|
208
|
+
|
|
209
|
+
$tip.find('[data-bs-toggle="dropdown"]').each(function () {
|
|
210
|
+
new bs.Dropdown(this);
|
|
211
|
+
});
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
// Prevent clicks *inside* the popover from bubbling up (so it doesn't immediately close)
|
|
215
|
+
$('body').on('click', function (e) {
|
|
216
|
+
if ($(e.target).closest('.popover').length) {
|
|
217
|
+
e.stopPropagation();
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Close popovers when clicking outside any popover/trigger
|
|
222
|
+
$(document).on('click', function (e) {
|
|
223
|
+
const $t = $(e.target);
|
|
224
|
+
const clickedTrigger = $t.closest('[data-bs-toggle="popover"]').length > 0;
|
|
225
|
+
const clickedInsidePopover = $t.closest('.popover').length > 0;
|
|
226
|
+
if (clickedTrigger || clickedInsidePopover) return;
|
|
227
|
+
|
|
228
|
+
$('[data-bs-toggle="popover"]').each(function () {
|
|
229
|
+
const inst = bs.Popover.getInstance(this);
|
|
230
|
+
if (inst) inst.hide();
|
|
231
|
+
});
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
// Close on ESC
|
|
235
|
+
$(document).on('keydown', function (e) {
|
|
236
|
+
if (e.key !== 'Escape') return;
|
|
237
|
+
$('[data-bs-toggle="popover"]').each(function () {
|
|
238
|
+
const inst = bs.Popover.getInstance(this);
|
|
239
|
+
if (inst) inst.hide();
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Equalize contributor card heights in carousels and position arrows
|
|
247
|
+
*/
|
|
248
|
+
function equalizeContributorCardHeights() {
|
|
249
|
+
$('.carousel[id^="contributors-carousel-"]').each(function() {
|
|
250
|
+
var carousel = $(this);
|
|
251
|
+
var maxHeight = 0;
|
|
252
|
+
|
|
253
|
+
carousel.find('.contributor-cards .card').css('min-height', '');
|
|
254
|
+
|
|
255
|
+
// Measure all slides by temporarily making them active
|
|
256
|
+
carousel.find('.carousel-item').each(function() {
|
|
257
|
+
var $item = $(this);
|
|
258
|
+
var wasActive = $item.hasClass('active');
|
|
259
|
+
|
|
260
|
+
$item.addClass('active').css({'visibility': 'hidden', 'position': 'absolute'});
|
|
261
|
+
$item.find('.contributor-cards .card').each(function() {
|
|
262
|
+
maxHeight = Math.max(maxHeight, $(this).outerHeight());
|
|
263
|
+
});
|
|
264
|
+
$item.css({'visibility': '', 'position': ''});
|
|
265
|
+
if (!wasActive) $item.removeClass('active');
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
// Apply max height and position arrows
|
|
269
|
+
if (maxHeight > 0) {
|
|
270
|
+
carousel.find('.contributor-cards .card').css('min-height', maxHeight + 'px');
|
|
271
|
+
carousel.find('.carousel-control-prev, .carousel-control-next').css('top', (maxHeight / 2 - 24) + 'px');
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
$(document).ready(function() {
|
|
277
|
+
// Equalize heights on page load
|
|
278
|
+
equalizeContributorCardHeights();
|
|
279
|
+
|
|
280
|
+
// Re-equalize on window resize
|
|
281
|
+
var resizeTimer;
|
|
282
|
+
$(window).on('resize', function() {
|
|
283
|
+
clearTimeout(resizeTimer);
|
|
284
|
+
resizeTimer = setTimeout(function() {
|
|
285
|
+
equalizeContributorCardHeights();
|
|
286
|
+
}, 250);
|
|
287
|
+
});
|
|
288
|
+
});
|
data/assets/js/toc.js
CHANGED
|
@@ -48,11 +48,12 @@
|
|
|
48
48
|
});
|
|
49
49
|
|
|
50
50
|
var output = $(this); // the TOC container (e.g., #toc-contents)
|
|
51
|
-
var
|
|
51
|
+
var main = $('#main');
|
|
52
|
+
var button = $('#btn-toc-hide')
|
|
52
53
|
|
|
53
54
|
// Prevents calling get_level(headers[0]) on undefined and collapses layout/space.
|
|
54
55
|
if (!headers.length || headers.length < settings.minimumHeaders || !output.length) {
|
|
55
|
-
|
|
56
|
+
main.removeClass('add-grid'); // collapse layout (your existing side-effect + our flag)
|
|
56
57
|
output.empty().hide(); // hide/clear inner TOC container
|
|
57
58
|
return;
|
|
58
59
|
}
|
|
@@ -113,6 +114,7 @@
|
|
|
113
114
|
(render[settings.showEffect] || render.none)();
|
|
114
115
|
|
|
115
116
|
// Add grid + flag on #main (if your layout uses it), and flag #toc so CSS applies margin.
|
|
116
|
-
|
|
117
|
+
main.addClass('add-grid');
|
|
118
|
+
button.show()
|
|
117
119
|
};
|
|
118
120
|
})(jQuery);
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: elixir-toolkit-theme
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 6.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- bedroesb
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-01-27 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: jekyll
|
|
@@ -30,14 +30,14 @@ dependencies:
|
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
|
-
version:
|
|
33
|
+
version: 1.1.0
|
|
34
34
|
type: :runtime
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
38
|
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
|
-
version:
|
|
40
|
+
version: 1.1.0
|
|
41
41
|
- !ruby/object:Gem::Dependency
|
|
42
42
|
name: bundler
|
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -76,12 +76,15 @@ files:
|
|
|
76
76
|
- LICENSE
|
|
77
77
|
- README.md
|
|
78
78
|
- _data/countries.yml
|
|
79
|
+
- _includes/affiliation-logo.html
|
|
79
80
|
- _includes/affiliation-tiles-page.html
|
|
80
81
|
- _includes/affiliation-tiles-selection.html
|
|
81
82
|
- _includes/banner.html
|
|
82
83
|
- _includes/breadcrumb.html
|
|
83
84
|
- _includes/callout.html
|
|
84
85
|
- _includes/citation-page.html
|
|
86
|
+
- _includes/contributor-avatar.html
|
|
87
|
+
- _includes/contributor-card.html
|
|
85
88
|
- _includes/contributor-carousel-selection.html
|
|
86
89
|
- _includes/contributor-minitiles-page.html
|
|
87
90
|
- _includes/contributor-tiles-all.html
|
|
@@ -94,6 +97,7 @@ files:
|
|
|
94
97
|
- _includes/image.html
|
|
95
98
|
- _includes/more-information-tiles.html
|
|
96
99
|
- _includes/news.html
|
|
100
|
+
- _includes/page-metadata-tabs.html
|
|
97
101
|
- _includes/pageids-overview.html
|
|
98
102
|
- _includes/related-pages.html
|
|
99
103
|
- _includes/resource-table-all.html
|
|
@@ -479,8 +483,6 @@ files:
|
|
|
479
483
|
- assets/flags/zm.svg
|
|
480
484
|
- assets/flags/zw.svg
|
|
481
485
|
- assets/img/Flag_of_Europe.svg
|
|
482
|
-
- assets/img/android-chrome-192x192.png
|
|
483
|
-
- assets/img/android-chrome-512x512.png
|
|
484
486
|
- assets/img/apple-touch-icon.png
|
|
485
487
|
- assets/img/carpentries_logo.svg
|
|
486
488
|
- assets/img/dsw_logo.svg
|
|
@@ -492,11 +494,13 @@ files:
|
|
|
492
494
|
- assets/img/favicon-16x16.png
|
|
493
495
|
- assets/img/favicon-32x32.png
|
|
494
496
|
- assets/img/favicon.ico
|
|
497
|
+
- assets/img/favicon.svg
|
|
495
498
|
- assets/img/main_logo.svg
|
|
496
499
|
- assets/img/rdmkit_logo.svg
|
|
497
|
-
- assets/img/safari-pinned-tab.svg
|
|
498
500
|
- assets/img/site.webmanifest
|
|
499
501
|
- assets/img/tess_logo.svg
|
|
502
|
+
- assets/img/web-app-manifest-192x192.png
|
|
503
|
+
- assets/img/web-app-manifest-512x512.png
|
|
500
504
|
- assets/img/youtube_logo.svg
|
|
501
505
|
- assets/img/zenodo_logo.svg
|
|
502
506
|
- assets/js/anchor.min.js
|
|
@@ -510,7 +514,6 @@ files:
|
|
|
510
514
|
- assets/js/jquery.dataTables.min.js
|
|
511
515
|
- assets/js/jquery.min.js
|
|
512
516
|
- assets/js/jquery.min.map
|
|
513
|
-
- assets/js/jquery.navgoco.js
|
|
514
517
|
- assets/js/lunr.min.js
|
|
515
518
|
- assets/js/main.js
|
|
516
519
|
- assets/js/search-data.json
|
|
Binary file
|
|
Binary file
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" standalone="no"?>
|
|
2
|
-
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20010904//EN"
|
|
3
|
-
"http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
|
4
|
-
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
|
|
5
|
-
width="700.000000pt" height="700.000000pt" viewBox="0 0 700.000000 700.000000"
|
|
6
|
-
preserveAspectRatio="xMidYMid meet">
|
|
7
|
-
<metadata>
|
|
8
|
-
Created by potrace 1.14, written by Peter Selinger 2001-2017
|
|
9
|
-
</metadata>
|
|
10
|
-
<g transform="translate(0.000000,700.000000) scale(0.100000,-0.100000)"
|
|
11
|
-
fill="#000000" stroke="none">
|
|
12
|
-
<path d="M3270 6994 c-432 -38 -776 -119 -1123 -265 -1015 -427 -1773 -1308
|
|
13
|
-
-2041 -2374 -73 -289 -101 -529 -101 -855 0 -333 28 -566 106 -874 269 -1067
|
|
14
|
-
1059 -1965 2089 -2376 922 -368 1976 -323 2861 120 956 480 1649 1386 1859
|
|
15
|
-
2430 54 267 64 378 64 700 0 223 -4 327 -17 425 -24 175 -68 394 -111 543 -20
|
|
16
|
-
68 -36 125 -36 128 0 2 -123 4 -274 4 -261 0 -274 -1 -300 -21 l-26 -20 -2
|
|
17
|
-
-1310 -3 -1311 -24 -19 c-21 -18 -42 -19 -271 -19 l-249 0 -20 26 -21 27 0
|
|
18
|
-
1299 0 1299 -25 24 -24 25 -701 0 -701 0 -24 -25 -25 -24 0 -1299 0 -1299 -21
|
|
19
|
-
-27 -20 -26 -248 0 c-198 0 -251 3 -267 14 -19 14 -19 42 -24 1326 l-5 1312
|
|
20
|
-
-28 24 -28 24 -839 0 c-617 0 -846 -3 -865 -12 -42 -19 -46 -57 -43 -409 3
|
|
21
|
-
-305 4 -328 22 -348 19 -21 25 -21 426 -21 419 0 460 -3 480 -40 6 -11 10
|
|
22
|
-
-114 10 -238 0 -201 -2 -222 -19 -243 l-19 -24 -431 -5 c-396 -5 -432 -6 -448
|
|
23
|
-
-23 -17 -16 -18 -46 -18 -387 l0 -369 23 -23 23 -23 484 -3 484 -3 21 -26 c19
|
|
24
|
-
-24 20 -39 20 -240 0 -214 0 -214 -25 -238 l-24 -25 -775 0 -775 0 -20 26 -21
|
|
25
|
-
27 0 1566 c1 1215 3 1570 13 1582 7 9 22 21 34 27 16 9 682 12 2697 12 1472 0
|
|
26
|
-
2676 2 2676 5 0 13 -99 178 -176 295 -427 646 -1089 1149 -1827 1389 -346 112
|
|
27
|
-
-638 160 -1022 165 -132 2 -260 2 -285 0z"/>
|
|
28
|
-
</g>
|
|
29
|
-
</svg>
|
data/assets/js/jquery.navgoco.js
DELETED
|
@@ -1,314 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* jQuery Navgoco Menus Plugin v0.2.1 (2014-04-11)
|
|
3
|
-
* https://github.com/tefra/navgoco
|
|
4
|
-
*
|
|
5
|
-
* Copyright (c) 2014 Chris T (@tefra)
|
|
6
|
-
* BSD - https://github.com/tefra/navgoco/blob/master/LICENSE-BSD
|
|
7
|
-
*/
|
|
8
|
-
(function($) {
|
|
9
|
-
|
|
10
|
-
"use strict";
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Plugin Constructor. Every menu must have a unique id which will either
|
|
14
|
-
* be the actual id attribute or its index in the page.
|
|
15
|
-
*
|
|
16
|
-
* @param {Element} el
|
|
17
|
-
* @param {Object} options
|
|
18
|
-
* @param {Integer} idx
|
|
19
|
-
* @returns {Object} Plugin Instance
|
|
20
|
-
*/
|
|
21
|
-
var Plugin = function(el, options, idx) {
|
|
22
|
-
this.el = el;
|
|
23
|
-
this.$el = $(el);
|
|
24
|
-
this.options = options;
|
|
25
|
-
this.uuid = this.$el.attr('id') ? this.$el.attr('id') : idx;
|
|
26
|
-
this.state = {};
|
|
27
|
-
this.init();
|
|
28
|
-
return this;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Plugin methods
|
|
33
|
-
*/
|
|
34
|
-
Plugin.prototype = {
|
|
35
|
-
/**
|
|
36
|
-
* Load cookie, assign a unique data-index attribute to
|
|
37
|
-
* all sub-menus and show|hide them according to cookie
|
|
38
|
-
* or based on the parent open class. Find all parent li > a
|
|
39
|
-
* links add the carent if it's on and attach the event click
|
|
40
|
-
* to them.
|
|
41
|
-
*/
|
|
42
|
-
init: function() {
|
|
43
|
-
var self = this;
|
|
44
|
-
self._load();
|
|
45
|
-
self.$el.find('ul').each(function(idx) {
|
|
46
|
-
var sub = $(this);
|
|
47
|
-
sub.attr('data-index', idx);
|
|
48
|
-
if (self.options.save && self.state.hasOwnProperty(idx)) {
|
|
49
|
-
sub.parent().addClass(self.options.openClass);
|
|
50
|
-
sub.show();
|
|
51
|
-
} else if (sub.parent().hasClass(self.options.openClass)) {
|
|
52
|
-
sub.show();
|
|
53
|
-
self.state[idx] = 1;
|
|
54
|
-
} else {
|
|
55
|
-
sub.hide();
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
var caret = $('<span></span>').prepend(self.options.caretHtml);
|
|
60
|
-
var links = self.$el.find("li > a");
|
|
61
|
-
self._trigger(caret, false);
|
|
62
|
-
self._trigger(links, true);
|
|
63
|
-
self.$el.find("li:has(ul) > a").prepend(caret);
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* Add the main event trigger to toggle menu items to the given sources
|
|
67
|
-
* @param {Element} sources
|
|
68
|
-
* @param {Boolean} isLink
|
|
69
|
-
*/
|
|
70
|
-
_trigger: function(sources, isLink) {
|
|
71
|
-
var self = this;
|
|
72
|
-
sources.on('click', function(event) {
|
|
73
|
-
event.stopPropagation();
|
|
74
|
-
var sub = isLink ? $(this).next() : $(this).parent().next();
|
|
75
|
-
var isAnchor = false;
|
|
76
|
-
if (isLink) {
|
|
77
|
-
var href = $(this).attr('href');
|
|
78
|
-
isAnchor = href === undefined || href === '' || href === '#';
|
|
79
|
-
}
|
|
80
|
-
sub = sub.length > 0 ? sub : false;
|
|
81
|
-
self.options.onClickBefore.call(this, event, sub);
|
|
82
|
-
|
|
83
|
-
if (!isLink || sub && isAnchor) {
|
|
84
|
-
event.preventDefault();
|
|
85
|
-
self._toggle(sub, sub.is(":hidden"));
|
|
86
|
-
self._save();
|
|
87
|
-
} else if (self.options.accordion) {
|
|
88
|
-
var allowed = self.state = self._parents($(this));
|
|
89
|
-
self.$el.find('ul').filter(':visible').each(function() {
|
|
90
|
-
var sub = $(this),
|
|
91
|
-
idx = sub.attr('data-index');
|
|
92
|
-
|
|
93
|
-
if (!allowed.hasOwnProperty(idx)) {
|
|
94
|
-
self._toggle(sub, false);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
self._save();
|
|
98
|
-
}
|
|
99
|
-
self.options.onClickAfter.call(this, event, sub);
|
|
100
|
-
});
|
|
101
|
-
},
|
|
102
|
-
/**
|
|
103
|
-
* Accepts a JQuery Element and a boolean flag. If flag is false it removes the `open` css
|
|
104
|
-
* class from the parent li and slides up the sub-menu. If flag is open it adds the `open`
|
|
105
|
-
* css class to the parent li and slides down the menu. If accordion mode is on all
|
|
106
|
-
* sub-menus except the direct parent tree will close. Internally an object with the menus
|
|
107
|
-
* states is maintained for later save duty.
|
|
108
|
-
*
|
|
109
|
-
* @param {Element} sub
|
|
110
|
-
* @param {Boolean} open
|
|
111
|
-
*/
|
|
112
|
-
_toggle: function(sub, open) {
|
|
113
|
-
var self = this,
|
|
114
|
-
idx = sub.attr('data-index'),
|
|
115
|
-
parent = sub.parent();
|
|
116
|
-
|
|
117
|
-
self.options.onToggleBefore.call(this, sub, open);
|
|
118
|
-
if (open) {
|
|
119
|
-
parent.addClass(self.options.openClass);
|
|
120
|
-
sub.slideDown(self.options.slide);
|
|
121
|
-
self.state[idx] = 1;
|
|
122
|
-
|
|
123
|
-
if (self.options.accordion) {
|
|
124
|
-
var allowed = self.state = self._parents(sub);
|
|
125
|
-
allowed[idx] = self.state[idx] = 1;
|
|
126
|
-
|
|
127
|
-
self.$el.find('ul').filter(':visible').each(function() {
|
|
128
|
-
var sub = $(this),
|
|
129
|
-
idx = sub.attr('data-index');
|
|
130
|
-
|
|
131
|
-
if (!allowed.hasOwnProperty(idx)) {
|
|
132
|
-
self._toggle(sub, false);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
} else {
|
|
137
|
-
parent.removeClass(self.options.openClass);
|
|
138
|
-
sub.slideUp(self.options.slide);
|
|
139
|
-
self.state[idx] = 0;
|
|
140
|
-
}
|
|
141
|
-
self.options.onToggleAfter.call(this, sub, open);
|
|
142
|
-
},
|
|
143
|
-
/**
|
|
144
|
-
* Returns all parents of a sub-menu. When obj is true It returns an object with indexes for
|
|
145
|
-
* keys and the elements as values, if obj is false the object is filled with the value `1`.
|
|
146
|
-
*
|
|
147
|
-
* @since v0.1.2
|
|
148
|
-
* @param {Element} sub
|
|
149
|
-
* @param {Boolean} obj
|
|
150
|
-
* @returns {Object}
|
|
151
|
-
*/
|
|
152
|
-
_parents: function(sub, obj) {
|
|
153
|
-
var result = {},
|
|
154
|
-
parent = sub.parent(),
|
|
155
|
-
parents = parent.parents('ul');
|
|
156
|
-
|
|
157
|
-
parents.each(function() {
|
|
158
|
-
var par = $(this),
|
|
159
|
-
idx = par.attr('data-index');
|
|
160
|
-
|
|
161
|
-
if (!idx) {
|
|
162
|
-
return false;
|
|
163
|
-
}
|
|
164
|
-
result[idx] = obj ? par : 1;
|
|
165
|
-
});
|
|
166
|
-
return result;
|
|
167
|
-
},
|
|
168
|
-
/**
|
|
169
|
-
* If `save` option is on the internal object that keeps track of the sub-menus states is
|
|
170
|
-
* saved with a cookie. For size reasons only the open sub-menus indexes are stored. *
|
|
171
|
-
*/
|
|
172
|
-
_save: function() {
|
|
173
|
-
if (this.options.save) {
|
|
174
|
-
var save = {};
|
|
175
|
-
for (var key in this.state) {
|
|
176
|
-
if (this.state[key] === 1) {
|
|
177
|
-
save[key] = 1;
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
cookie[this.uuid] = this.state = save;
|
|
181
|
-
$.cookie(this.options.cookie.name, JSON.stringify(cookie), this.options.cookie);
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
/**
|
|
185
|
-
* If `save` option is on it reads the cookie data. The cookie contains data for all
|
|
186
|
-
* navgoco menus so the read happens only once and stored in the global `cookie` var.
|
|
187
|
-
*/
|
|
188
|
-
_load: function() {
|
|
189
|
-
if (this.options.save) {
|
|
190
|
-
if (cookie === null) {
|
|
191
|
-
var data = $.cookie(this.options.cookie.name);
|
|
192
|
-
cookie = (data) ? JSON.parse(data) : {};
|
|
193
|
-
}
|
|
194
|
-
this.state = cookie.hasOwnProperty(this.uuid) ? cookie[this.uuid] : {};
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
/**
|
|
198
|
-
* Public method toggle to manually show|hide sub-menus. If no indexes are provided all
|
|
199
|
-
* items will be toggled. You can pass sub-menus indexes as regular params. eg:
|
|
200
|
-
* navgoco('toggle', true, 1, 2, 3, 4, 5);
|
|
201
|
-
*
|
|
202
|
-
* Since v0.1.2 it will also open parents when providing sub-menu indexes.
|
|
203
|
-
*
|
|
204
|
-
* @param {Boolean} open
|
|
205
|
-
*/
|
|
206
|
-
toggle: function(open) {
|
|
207
|
-
var self = this,
|
|
208
|
-
length = arguments.length;
|
|
209
|
-
|
|
210
|
-
if (length <= 1) {
|
|
211
|
-
self.$el.find('ul').each(function() {
|
|
212
|
-
var sub = $(this);
|
|
213
|
-
self._toggle(sub, open);
|
|
214
|
-
});
|
|
215
|
-
} else {
|
|
216
|
-
var idx,
|
|
217
|
-
list = {},
|
|
218
|
-
args = Array.prototype.slice.call(arguments, 1);
|
|
219
|
-
length--;
|
|
220
|
-
|
|
221
|
-
for (var i = 0; i < length; i++) {
|
|
222
|
-
idx = args[i];
|
|
223
|
-
var sub = self.$el.find('ul[data-index="' + idx + '"]').first();
|
|
224
|
-
if (sub) {
|
|
225
|
-
list[idx] = sub;
|
|
226
|
-
if (open) {
|
|
227
|
-
var parents = self._parents(sub, true);
|
|
228
|
-
for (var pIdx in parents) {
|
|
229
|
-
if (!list.hasOwnProperty(pIdx)) {
|
|
230
|
-
list[pIdx] = parents[pIdx];
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
for (idx in list) {
|
|
238
|
-
self._toggle(list[idx], open);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
self._save();
|
|
242
|
-
},
|
|
243
|
-
/**
|
|
244
|
-
* Removes instance from JQuery data cache and unbinds events.
|
|
245
|
-
*/
|
|
246
|
-
destroy: function() {
|
|
247
|
-
$.removeData(this.$el);
|
|
248
|
-
this.$el.find("li:has(ul) > a").unbind('click');
|
|
249
|
-
this.$el.find("li:has(ul) > a > span").unbind('click');
|
|
250
|
-
}
|
|
251
|
-
};
|
|
252
|
-
|
|
253
|
-
/**
|
|
254
|
-
* A JQuery plugin wrapper for navgoco. It prevents from multiple instances and also handles
|
|
255
|
-
* public methods calls. If we attempt to call a public method on an element that doesn't have
|
|
256
|
-
* a navgoco instance, one will be created for it with the default options.
|
|
257
|
-
*
|
|
258
|
-
* @param {Object|String} options
|
|
259
|
-
*/
|
|
260
|
-
$.fn.navgoco = function(options) {
|
|
261
|
-
if (typeof options === 'string' && options.charAt(0) !== '_' && options !== 'init') {
|
|
262
|
-
var callback = true,
|
|
263
|
-
args = Array.prototype.slice.call(arguments, 1);
|
|
264
|
-
} else {
|
|
265
|
-
options = $.extend({}, $.fn.navgoco.defaults, options || {});
|
|
266
|
-
if (!$.cookie) {
|
|
267
|
-
options.save = false;
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
return this.each(function(idx) {
|
|
271
|
-
var $this = $(this),
|
|
272
|
-
obj = $this.data('navgoco');
|
|
273
|
-
|
|
274
|
-
if (!obj) {
|
|
275
|
-
obj = new Plugin(this, callback ? $.fn.navgoco.defaults : options, idx);
|
|
276
|
-
$this.data('navgoco', obj);
|
|
277
|
-
}
|
|
278
|
-
if (callback) {
|
|
279
|
-
obj[options].apply(obj, args);
|
|
280
|
-
}
|
|
281
|
-
});
|
|
282
|
-
};
|
|
283
|
-
/**
|
|
284
|
-
* Global var holding all navgoco menus open states
|
|
285
|
-
*
|
|
286
|
-
* @type {Object}
|
|
287
|
-
*/
|
|
288
|
-
var cookie = null;
|
|
289
|
-
|
|
290
|
-
/**
|
|
291
|
-
* Default navgoco options
|
|
292
|
-
*
|
|
293
|
-
* @type {Object}
|
|
294
|
-
*/
|
|
295
|
-
$.fn.navgoco.defaults = {
|
|
296
|
-
caretHtml: '',
|
|
297
|
-
accordion: false,
|
|
298
|
-
openClass: 'open',
|
|
299
|
-
save: true,
|
|
300
|
-
cookie: {
|
|
301
|
-
name: 'navgoco',
|
|
302
|
-
expires: false,
|
|
303
|
-
path: '/'
|
|
304
|
-
},
|
|
305
|
-
slide: {
|
|
306
|
-
duration: 400,
|
|
307
|
-
easing: 'swing'
|
|
308
|
-
},
|
|
309
|
-
onClickBefore: $.noop,
|
|
310
|
-
onClickAfter: $.noop,
|
|
311
|
-
onToggleBefore: $.noop,
|
|
312
|
-
onToggleAfter: $.noop
|
|
313
|
-
};
|
|
314
|
-
})(jQuery);
|