gent_styleguide 2.10.0 → 2.12.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.
- package/CHANGELOG.md +9 -1
- package/README.md +2 -2
- package/build/styleguide/js/base-min.js +68 -1
- package/build/styleguide/js/breadcrumbs.binding-min.js +13 -1
- package/build/styleguide/js/breadcrumbs.functions-min.js +131 -1
- package/build/styleguide/js/button-drop-min.js +38 -1
- package/build/styleguide/js/button-drop.binding-min.js +13 -1
- package/build/styleguide/js/button-drop.functions-min.js +48 -1
- package/build/styleguide/js/gallery.binding-min.js +12 -1
- package/build/styleguide/js/gallery.functions-min.js +29 -1
- package/build/styleguide/js/hamburger-menu.binding-min.js +17 -1
- package/build/styleguide/js/hamburger-menu.functions-min.js +166 -1
- package/build/styleguide/js/header.binding-min.js +18 -1
- package/build/styleguide/js/header.functions-min.js +73 -1
- package/build/styleguide/js/input-date.binding-min.js +8 -1
- package/build/styleguide/js/input-date.functions-min.js +27 -1
- package/build/styleguide/js/input-multiselect-chosen.binding-min.js +31 -1
- package/build/styleguide/js/input-multiselect-chosen.functions-min.js +24 -1
- package/build/styleguide/js/teaser-collection.binding-min.js +14 -1
- package/build/styleguide/sass/01-mixins/grid/_default_classes.scss +8 -6
- package/build/styleguide/sass/01-mixins/grid/_mixins.scss +22 -20
- package/build/styleguide/sass/11-base/forms/_forms.scss +3 -0
- package/build/styleguide/sass/11-base/grid/_grid.scss +2 -2
- package/build/styleguide/sass/21-atoms/fieldset/_fieldset.scss +1 -1
- package/build/styleguide/sass/21-atoms/inputs/input-multiselect-chosen/_input-multiselect-chosen.scss +1 -1
- package/build/styleguide/sass/21-atoms/tag/_tag.scss +0 -5
- package/build/styleguide/sass/31-molecules/building-blocks/breadcrumbs/_breadcrumbs.scss +33 -37
- package/build/styleguide/sass/31-molecules/building-blocks/hamburger-menu/_hamburger-menu.scss +1 -1
- package/build/styleguide/sass/41-organisms/header/_header.scss +2 -2
- package/build/styleguide/sass/main_cli.scss +102 -0
- package/nbproject/private/private.properties +1 -0
- package/nbproject/private/private.xml +8 -0
- package/nbproject/project.properties +5 -0
- package/nbproject/project.xml +9 -0
- package/package.json +7 -6
- package/yarn.lock +0 -7827
package/CHANGELOG.md
CHANGED
|
@@ -8,11 +8,19 @@ Refer to upcoming changes in our README.md under "Roadmap"
|
|
|
8
8
|
|
|
9
9
|
All notable changes to this style guide are documented here.
|
|
10
10
|
|
|
11
|
-
### 2.
|
|
11
|
+
### 2.11.0
|
|
12
12
|
|
|
13
13
|
* DTGB-140: Removed some files from the NPM package.
|
|
14
14
|
* DTGB-140: Fixed a bug where `npm install` breaks
|
|
15
15
|
the install of the style guide.
|
|
16
|
+
* DTGB-276: Fixed a bug where the breadcrumb alignment was not correct.
|
|
17
|
+
|
|
18
|
+
> **Some markup changes have been introduced so you might need some
|
|
19
|
+
refactoring.**
|
|
20
|
+
* DTGB-397: Changed the markup of radio buttons and checkboxes. They are
|
|
21
|
+
now inside their own fieldset.
|
|
22
|
+
* DTGB-401: Updated links to new public gent_base repository.
|
|
23
|
+
* DTGB-402: Added a required form fields indicator at the top of forms.
|
|
16
24
|
|
|
17
25
|
### 2.9.0
|
|
18
26
|
|
package/README.md
CHANGED
|
@@ -18,11 +18,11 @@ This repository is a read only version of the style guide part of our own
|
|
|
18
18
|
Drupal 8 base theme.
|
|
19
19
|
|
|
20
20
|
If you want to develop for this style guide you need to do it in
|
|
21
|
-
[this repository](https://github.com/
|
|
21
|
+
[this repository](https://github.com/StadGent/drupal_theme_gent-base)
|
|
22
22
|
|
|
23
23
|
> Please do not create any pull requests directly here.
|
|
24
24
|
> Instead use
|
|
25
|
-
> [this repo](https://github.com/
|
|
25
|
+
> [this repo](https://github.com/StadGent/drupal_theme_gent-base) to
|
|
26
26
|
> create your pull requests.
|
|
27
27
|
|
|
28
28
|
To contribute to the style guide please refer to the
|
|
@@ -1 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var gent_styleguide = (function () { // eslint-disable-line no-unused-vars
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Generates a tabTrap object
|
|
7
|
+
*
|
|
8
|
+
* @param {object} container DOM-element
|
|
9
|
+
* @constructor
|
|
10
|
+
*/
|
|
11
|
+
function TabTrap(container) {
|
|
12
|
+
var focusPosition = -1;
|
|
13
|
+
var focusables = getFocusables(container);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Returns all focusable elements within a given container.
|
|
17
|
+
*
|
|
18
|
+
* @param {object} container hamburger DOM-element
|
|
19
|
+
* @return {array} focusable elements
|
|
20
|
+
*/
|
|
21
|
+
function getFocusables(container) {
|
|
22
|
+
var focusables = container
|
|
23
|
+
.querySelectorAll('a[href], ' +
|
|
24
|
+
'area[href], ' +
|
|
25
|
+
'input:not([disabled]):not([hidden]), ' +
|
|
26
|
+
'select:not([disabled]), ' +
|
|
27
|
+
'textarea:not([disabled]), ' +
|
|
28
|
+
'button:not([disabled]), ' +
|
|
29
|
+
'[tabindex="0"]');
|
|
30
|
+
return Array.prototype.slice.call(focusables);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.next = function () {
|
|
34
|
+
if (++focusPosition > focusables.length - 1) {
|
|
35
|
+
focusPosition = 0;
|
|
36
|
+
}
|
|
37
|
+
focusables[focusPosition].focus();
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this.back = function () {
|
|
41
|
+
if (--focusPosition < 0) {
|
|
42
|
+
focusPosition = focusables.length - 1;
|
|
43
|
+
}
|
|
44
|
+
focusables[focusPosition].focus();
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
this.home = function () {
|
|
48
|
+
focusPosition = 0;
|
|
49
|
+
focusables[focusPosition].focus();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
this.end = function () {
|
|
53
|
+
focusPosition = focusables.length - 1;
|
|
54
|
+
focusables[focusPosition].focus();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
this.reset = function () {
|
|
58
|
+
focusPosition = -1;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
this.hasFocusables = focusables && focusables.length > 0;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
TabTrap: TabTrap
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
})();
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Javascript binding of breadcrumb.functions.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
(function ($) {
|
|
9
|
+
$(window).on('load', function (e) {
|
|
10
|
+
this.gentStyleGuideBreadcrumb.updateMobileBreadcrumb();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
})(jQuery);
|
|
@@ -1 +1,131 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Breadcrumb handling and rendering.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Breadcrumb namespace definition.
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
var gentStyleGuideBreadcrumb = {};
|
|
11
|
+
|
|
12
|
+
(function ($) {
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Replace the mobile breadcrumb of Gent base by our own.
|
|
16
|
+
*
|
|
17
|
+
* Adds this function to a global gentStyleBreadcrumb namespace.
|
|
18
|
+
*/
|
|
19
|
+
gentStyleGuideBreadcrumb.updateMobileBreadcrumb = function () {
|
|
20
|
+
var breadcrumb = $('ol.breadcrumb, ul.nav--breadcrumb, ul.breadcrumb');
|
|
21
|
+
if (breadcrumb.length && !breadcrumb.hasClass('gentbe-processed')) {
|
|
22
|
+
// Prevent duplicate processing by us or Gent base.
|
|
23
|
+
breadcrumb.addClass('gentbe-processed');
|
|
24
|
+
breadcrumb.addClass('mobile-breadcrumb-processed');
|
|
25
|
+
|
|
26
|
+
// Remove the mobile breadcrumb of Gent base.
|
|
27
|
+
$('select.nav--mobile-breadcrumb').remove();
|
|
28
|
+
|
|
29
|
+
// Duplicate the original breadcrumb as mobile version.
|
|
30
|
+
var mobile = breadcrumb.clone();
|
|
31
|
+
mobile.removeAttr('id').addClass('nav--mobile-breadcrumb');
|
|
32
|
+
breadcrumb.after(mobile);
|
|
33
|
+
|
|
34
|
+
// Truncate the labels.
|
|
35
|
+
truncateBreadcrumbLabels_(breadcrumb, 150);
|
|
36
|
+
truncateBreadcrumbLabels_(mobile, 100);
|
|
37
|
+
|
|
38
|
+
// Collapse the trail.
|
|
39
|
+
collapseBreadcrumbTrail_(breadcrumb, 6);
|
|
40
|
+
collapseBreadcrumbTrail_(mobile, 5, 1, 2);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Truncate the breadcrumb labels to a maximum length.
|
|
46
|
+
*
|
|
47
|
+
* @param {Object} breadcrumb
|
|
48
|
+
* The breadcrumb element as jQuery object.
|
|
49
|
+
* @param {int} length
|
|
50
|
+
* Maximum length of a label.
|
|
51
|
+
* @param {boolean} [ellipsis]
|
|
52
|
+
* Wether an elipsis should be added, defaults to true.
|
|
53
|
+
*/
|
|
54
|
+
function truncateBreadcrumbLabels_(breadcrumb, length, ellipsis) {
|
|
55
|
+
$('a, span', breadcrumb).each(function () {
|
|
56
|
+
var element = $(this);
|
|
57
|
+
var text = element.text().trim();
|
|
58
|
+
|
|
59
|
+
if (text.length > length) {
|
|
60
|
+
if (ellipsis !== false) {
|
|
61
|
+
text = text.substr(0, (length - 3)).trim() + '...';
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
text = text.substr(0, length).trim();
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
element.text(text);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Collapse the breadcrumb trail by hiding some elements.
|
|
74
|
+
*
|
|
75
|
+
* @param {Object} breadcrumb
|
|
76
|
+
* The breadcrumb element as jQuery object.
|
|
77
|
+
* @param {int} min_length
|
|
78
|
+
* Only collapse if the trail has at least this many items.
|
|
79
|
+
* @param {int} [head]
|
|
80
|
+
* Number of items to show at the start of the trail, defaults to 2.
|
|
81
|
+
* @param {int} [tail]
|
|
82
|
+
* Number of items to show at the end of the trail, defaults to the same value as head.
|
|
83
|
+
* @param {string} [text]
|
|
84
|
+
* Text to use as link to show the collapsed items, defaults to "...".
|
|
85
|
+
*/
|
|
86
|
+
function collapseBreadcrumbTrail_(breadcrumb, min_length, head, tail, text) {
|
|
87
|
+
// Set the default head and tail.
|
|
88
|
+
if (head == null) {
|
|
89
|
+
head = 2;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (tail == null) {
|
|
93
|
+
tail = head;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Make sure we have a sensible minimum length.
|
|
97
|
+
min_length = Math.max(min_length, (head + tail + 1));
|
|
98
|
+
|
|
99
|
+
// Get the number of items.
|
|
100
|
+
var length = $('li', breadcrumb).length;
|
|
101
|
+
|
|
102
|
+
// Check if the trail has the minimum length.
|
|
103
|
+
if (length >= min_length) {
|
|
104
|
+
// Hide the items.
|
|
105
|
+
for (var i = (head + 1); i <= (length - tail); i++) {
|
|
106
|
+
$('li:nth-of-type(' + i + ')', breadcrumb).hide();
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
// Create the uncollapse link.
|
|
110
|
+
var link = $('<li>').append(
|
|
111
|
+
$('<a>')
|
|
112
|
+
.text(text ? text : '...')
|
|
113
|
+
.attr('href', '#')
|
|
114
|
+
.click(function (e) {
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
|
|
117
|
+
$(this).parent().remove();
|
|
118
|
+
$('li', breadcrumb).show();
|
|
119
|
+
})
|
|
120
|
+
);
|
|
121
|
+
|
|
122
|
+
// Add it.
|
|
123
|
+
if (head) {
|
|
124
|
+
$('li:nth-of-type(' + head + ')', breadcrumb).after(link);
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
breadcrumb.prepend(link);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
})(jQuery);
|
|
@@ -1 +1,38 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
(function ($) {
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Invoked after after loading the initial page and after each AJAX request.
|
|
7
|
+
*
|
|
8
|
+
* @param context
|
|
9
|
+
* The DOM context.
|
|
10
|
+
* @param settings
|
|
11
|
+
* Object of additional settings.
|
|
12
|
+
*/
|
|
13
|
+
$(window).on('load', dropButtonLoad);
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Replace the mobile breadcrumb of Gent base by our own.
|
|
17
|
+
*/
|
|
18
|
+
function dropButtonLoad() {
|
|
19
|
+
var dropButton = $('.dropbutton-wrapper');
|
|
20
|
+
var dropButtonToggle = dropButton.find('.dropbutton-toggle button');
|
|
21
|
+
|
|
22
|
+
dropButtonToggle.on('click', function (e) {
|
|
23
|
+
e.stopPropagation();
|
|
24
|
+
if (dropButton.hasClass('open')) {
|
|
25
|
+
dropButton.removeClass('open');
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
dropButton.addClass('open');
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
$(document).on('click', function (e) {
|
|
33
|
+
dropButton.removeClass('open');
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
})(jQuery);
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* binding of button-drop.functions.js
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
(function ($) {
|
|
9
|
+
$(window).on('load', function (e) {
|
|
10
|
+
$('.dropbutton-wrapper').dropButtonLoad();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
})(jQuery);
|
|
@@ -1 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Implements a dropdown button.
|
|
4
|
+
*
|
|
5
|
+
* @author
|
|
6
|
+
* Wim Vantomme
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
(function ($) {
|
|
12
|
+
$.fn.extend({
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Implements a jQuery extension function.
|
|
16
|
+
*
|
|
17
|
+
* @fires event:click
|
|
18
|
+
*/
|
|
19
|
+
dropButtonLoad: function () {
|
|
20
|
+
var dropButton = $(this);
|
|
21
|
+
var dropButtonToggle = dropButton.find('.dropbutton-toggle button');
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Opens or closes the drop-down botton on click.
|
|
25
|
+
*
|
|
26
|
+
* @event click
|
|
27
|
+
*/
|
|
28
|
+
dropButtonToggle.on('click', function (e) {
|
|
29
|
+
e.stopPropagation();
|
|
30
|
+
if (dropButton.hasClass('open')) {
|
|
31
|
+
dropButton.removeClass('open');
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
dropButton.addClass('open');
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Closes the drop-down button
|
|
40
|
+
*
|
|
41
|
+
* @event click
|
|
42
|
+
*/
|
|
43
|
+
$(document).on('click', function (e) {
|
|
44
|
+
dropButton.removeClass('open');
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
})(jQuery);
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
(function ($) {
|
|
4
|
+
$(document).ready(function () {
|
|
5
|
+
var $gallery = $('.gallery');
|
|
6
|
+
|
|
7
|
+
if ($gallery.length > 0) {
|
|
8
|
+
$gallery.loadLightGallery();
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
})(jQuery);
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Implements the jQuery light gallery plugin.
|
|
4
|
+
*
|
|
5
|
+
* @author
|
|
6
|
+
* Gert-Jan Meire
|
|
7
|
+
*
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
(function ($) {
|
|
13
|
+
$.fn.extend({
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Creates a jQuery extension function.
|
|
17
|
+
*
|
|
18
|
+
*/
|
|
19
|
+
loadLightGallery: function () {
|
|
20
|
+
$(this).lightGallery({
|
|
21
|
+
download: false,
|
|
22
|
+
getCaptionFromTitleOrAlt: false,
|
|
23
|
+
counter: false
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
})(jQuery);
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Javascript binding of hamburger-menu.functions.js.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
(function ($) {
|
|
9
|
+
$(window).on('load', function (e) {
|
|
10
|
+
var $hamburgerMenu = $('.hamburger-menu');
|
|
11
|
+
|
|
12
|
+
if ($hamburgerMenu.length > 0) {
|
|
13
|
+
$hamburgerMenu.loadHamburgerMenu();
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
})(jQuery);
|
|
@@ -1 +1,166 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Implements a hamburger-menu button combined with
|
|
4
|
+
* a slide-in panel for easy mobile navigation.
|
|
5
|
+
*
|
|
6
|
+
* @authors
|
|
7
|
+
* Wim Vantomme
|
|
8
|
+
* Bart Delrue
|
|
9
|
+
*
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
(function ($) {
|
|
15
|
+
|
|
16
|
+
$.fn.extend({
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Creates a jQuery extension function.
|
|
20
|
+
*
|
|
21
|
+
* @fires event:click
|
|
22
|
+
*/
|
|
23
|
+
loadHamburgerMenu: function () {
|
|
24
|
+
var $drawer = $(this[0]).find('.hamburger-menu__drawer');
|
|
25
|
+
var $closeBtn = $drawer.find('.close');
|
|
26
|
+
var $overlay = $('.hamburger-menu__overlay');
|
|
27
|
+
var trigger;
|
|
28
|
+
|
|
29
|
+
if (typeof gent_styleguide === 'undefined') {
|
|
30
|
+
console.error('You need to include base.js.'); // eslint-disable-line no-console
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// TabTrap doens't use jquery opbjects.
|
|
35
|
+
var tabTrap = new gent_styleguide.TabTrap($drawer[0]); // eslint-disable-line no-undef
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Closes the hamburger menu
|
|
39
|
+
*
|
|
40
|
+
* @param {event} e onclick or keydown:escape
|
|
41
|
+
*/
|
|
42
|
+
var close = function (e) {
|
|
43
|
+
if (e) {
|
|
44
|
+
e.preventDefault();
|
|
45
|
+
}
|
|
46
|
+
$drawer.removeClass('js-opened');
|
|
47
|
+
$overlay.removeClass('js-opened');
|
|
48
|
+
document.removeEventListener('keydown', handleKeyboardInput);
|
|
49
|
+
tabTrap.reset();
|
|
50
|
+
|
|
51
|
+
// return focus to the trigger
|
|
52
|
+
if (trigger) {
|
|
53
|
+
trigger.focus();
|
|
54
|
+
trigger.setAttribute('aria-expanded', false);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
// remove the menu from the tabindex
|
|
58
|
+
// jquery .css() doesn't now 'important'
|
|
59
|
+
setTimeout(function () {
|
|
60
|
+
$drawer.attr('style', 'display: none');
|
|
61
|
+
}, 500);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Opens the hamburger menu
|
|
66
|
+
*
|
|
67
|
+
* @param {event} e onclick
|
|
68
|
+
*/
|
|
69
|
+
var open = function (e) {
|
|
70
|
+
if (e) {
|
|
71
|
+
e.preventDefault();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// add the menu to the tabindex
|
|
75
|
+
// jquery .css() doesn't now 'important'
|
|
76
|
+
$drawer.attr('style', 'display: block');
|
|
77
|
+
|
|
78
|
+
setTimeout(function () {
|
|
79
|
+
$drawer.addClass('js-opened');
|
|
80
|
+
$overlay.addClass('js-opened');
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
// remember the trigger
|
|
85
|
+
trigger = e.target;
|
|
86
|
+
trigger.setAttribute('aria-expanded', true);
|
|
87
|
+
|
|
88
|
+
// set focus to the menu
|
|
89
|
+
$drawer.focus();
|
|
90
|
+
|
|
91
|
+
// handle keyboard input
|
|
92
|
+
document.addEventListener('keydown', handleKeyboardInput);
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Handle keyboard input
|
|
97
|
+
*
|
|
98
|
+
* @param {object} e event
|
|
99
|
+
*/
|
|
100
|
+
var handleKeyboardInput = function (e) {
|
|
101
|
+
|
|
102
|
+
if (!tabTrap || !tabTrap.hasFocusables || !e) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var keyCode = e.keyCode || e.which;
|
|
107
|
+
|
|
108
|
+
switch (keyCode) {
|
|
109
|
+
case 9: // tab
|
|
110
|
+
e.preventDefault();
|
|
111
|
+
if (e.shiftKey) {
|
|
112
|
+
tabTrap.back();
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
tabTrap.next();
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case 40: // arrow down
|
|
119
|
+
case 39: // arrow right
|
|
120
|
+
e.preventDefault();
|
|
121
|
+
tabTrap.next();
|
|
122
|
+
break;
|
|
123
|
+
case 38: // arrow up
|
|
124
|
+
case 37: // arrow left
|
|
125
|
+
e.preventDefault();
|
|
126
|
+
tabTrap.back();
|
|
127
|
+
break;
|
|
128
|
+
case 36: // home
|
|
129
|
+
e.preventDefault();
|
|
130
|
+
tabTrap.home();
|
|
131
|
+
break;
|
|
132
|
+
case 35: // end
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
tabTrap.end();
|
|
135
|
+
break;
|
|
136
|
+
case 27: // esc
|
|
137
|
+
close(e);
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Indicates that a user has clicked on the hamburger toggle.
|
|
144
|
+
*
|
|
145
|
+
* Opens the overlay and hamburgerMenu.
|
|
146
|
+
*
|
|
147
|
+
* @event click
|
|
148
|
+
*/
|
|
149
|
+
$('.hamburger-menu__toggle').on('click', open);
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Indicates that a user has clicked on the closeBtn hamburger menu
|
|
154
|
+
* toggle.
|
|
155
|
+
*
|
|
156
|
+
* Closes the overlay and hamburgerMenu.
|
|
157
|
+
*
|
|
158
|
+
* @event click
|
|
159
|
+
*/
|
|
160
|
+
$closeBtn.add($overlay).on('click', close);
|
|
161
|
+
|
|
162
|
+
// init the menu as closed on startup
|
|
163
|
+
close();
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
})(jQuery);
|
|
@@ -1 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Javascript binding of header.functions.js.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
'use strict';
|
|
7
|
+
|
|
8
|
+
(function ($) {
|
|
9
|
+
$(window).on('load', function (e) {
|
|
10
|
+
$('.header-search-mobile').loadMobileHeader();
|
|
11
|
+
$('header.header .content-container').displaySiteName();
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
$(window).on('resize', function (e) {
|
|
15
|
+
$('header.header .content-container').displaySiteName();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
})(jQuery);
|
|
@@ -1 +1,73 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
* Implements a responsive search element in
|
|
4
|
+
* the header of a website.
|
|
5
|
+
*
|
|
6
|
+
* @author
|
|
7
|
+
* Wim Vantomme
|
|
8
|
+
*
|
|
9
|
+
*/
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
(function ($) {
|
|
13
|
+
$.fn.extend({
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Implements a jQuery extension function.
|
|
17
|
+
*
|
|
18
|
+
* @fires event:click
|
|
19
|
+
*/
|
|
20
|
+
loadMobileHeader: function () {
|
|
21
|
+
var mobileHeader = $(this);
|
|
22
|
+
var searchForm = mobileHeader.find('.form-search');
|
|
23
|
+
var searchInput = mobileHeader.find('input[type="search"]');
|
|
24
|
+
var searchButton = searchForm.find('input[type="submit"]');
|
|
25
|
+
var closeButton = mobileHeader.find('.close');
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Opens, submits or closes the mobile form.
|
|
29
|
+
*
|
|
30
|
+
* @event click
|
|
31
|
+
*/
|
|
32
|
+
searchButton.on('click', function (e) {
|
|
33
|
+
// Prevent button submission when form is closed.
|
|
34
|
+
if (!searchButton.hasClass('js-form-search-opened')) {
|
|
35
|
+
e.preventDefault();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
mobileHeader.addClass('js-form-search-opened');
|
|
39
|
+
searchInput.addClass('js-form-search-opened');
|
|
40
|
+
closeButton.addClass('js-form-search-opened');
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Close the mobile form.
|
|
44
|
+
closeButton.on('click', function (e) {
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
mobileHeader.removeClass('js-form-search-opened');
|
|
47
|
+
searchInput.removeClass('js-form-search-opened');
|
|
48
|
+
closeButton.removeClass('js-form-search-opened');
|
|
49
|
+
});
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Implements a jQuery extension function.
|
|
54
|
+
*/
|
|
55
|
+
displaySiteName: function () {
|
|
56
|
+
var componentsWidth = 70;
|
|
57
|
+
var logo = null;
|
|
58
|
+
|
|
59
|
+
// Calculate component width except for logo.
|
|
60
|
+
this.children('.header-component:visible').each(function () {
|
|
61
|
+
if ($(this).has('.site-logo').length === 0) {
|
|
62
|
+
componentsWidth += $(this).width();
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
logo = this;
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
// Set available width on the logo component to show the site title.
|
|
70
|
+
$(logo).width(this.width() - componentsWidth);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
})(jQuery);
|