Skip to content

Commit 68a5cde

Browse files
moving files
1 parent a389edc commit 68a5cde

File tree

19 files changed

+127
-63
lines changed

19 files changed

+127
-63
lines changed

packages/unity-bootstrap-theme/.storybook/local-addon/decorators/withHeader.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useRef} from 'react';
22
import { makeDecorator } from '@storybook/addons';
33

4-
import { Basic as Header } from "../../../stories/organisms/global-header/global-header.templates";
4+
import { Basic as Header } from "../../../stories/organisms/global-header/global-header.templates.jsx";
55

66
import { initGlobalHeader } from "../../../src/js/storybook-global-header";
77

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
const bootstrap = require('bootstrap');
1+
import { EventHandler } from "./bootstrap-helper";
22

3-
function initializeAnchorMenu () {
3+
function initAnchorMenu () {
44
const HEADER_IDS = ['asu-header', 'asuHeader'];
55

66
const globalHeaderId = HEADER_IDS.find((id) => document.getElementById(id));
7+
8+
if (globalHeaderId === undefined) {
9+
// Asu header not found in the DOM.
10+
return;
11+
}
12+
713
const globalHeader = document.getElementById(globalHeaderId);
814
const navbar = document.getElementById('uds-anchor-menu');
915
const navbarOriginalParent = navbar.parentNode;
@@ -115,4 +121,6 @@ function initializeAnchorMenu () {
115121
}
116122
};
117123

118-
export { initializeAnchorMenu };
124+
EventHandler.on(window, 'load.uds.anchor-menu', initAnchorMenu);
125+
126+
export { initAnchorMenu };
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
function initializeBlockquoteAnimation () {
2-
window.addEventListener("load", () => {
1+
import { EventHandler } from "./bootstrap-helper";
2+
3+
function initBlockquoteAnimation () {
34
// Find all marks with a class starting with pen-
45
const markers = document.querySelectorAll('mark[class^="pen-"]');
56

@@ -24,7 +25,8 @@ function initializeBlockquoteAnimation () {
2425
markers.forEach((mark) => {
2526
observer.observe(mark);
2627
});
27-
});
2828
}
2929

30-
export { initializeBlockquoteAnimation };
30+
EventHandler.on(window, 'load.uds.blockquote-animation', initBlockquoteAnimation);
31+
32+
export { initBlockquoteAnimation };
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import BaseComponent from 'bootstrap/js/src/base-component.js'
2+
import EventHandler from "bootstrap/js/src/dom/event-handler.js";
3+
import { enableDismissTrigger } from 'bootstrap/js/src/util/component-functions.js'
4+
import { defineJQueryPlugin } from 'bootstrap/js/src/util/index.js'
5+
6+
export {
7+
BaseComponent,
8+
EventHandler,
9+
enableDismissTrigger,
10+
defineJQueryPlugin,
11+
};
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { EventHandler } from "./bootstrap-helper";
2+
13
function initCalendar() {
24
const months = [
35
'January',
@@ -81,6 +83,11 @@ function initCalendar() {
8183

8284
const render = () => {
8385
const calendarContainer = document.getElementById('calendar');
86+
87+
if (!calendarContainer) {
88+
return;
89+
}
90+
8491
calendarContainer.innerHTML = `
8592
<h2><span class="highlight-black">${months[state.month]} ${
8693
state.year
@@ -154,4 +161,6 @@ function initCalendar() {
154161
showCalendar(0);
155162
};
156163

164+
EventHandler.on(window, 'load.uds.calendar', initCalendar);
165+
157166
export { initCalendar }
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1+
import { EventHandler } from "./bootstrap-helper";
2+
13
// method ot handle the custom behavior of the ranking card
24
function rankingFunc() {
35
const $infoLayer = document.querySelector(".info-layer");
46
const $toggleIcon = document.getElementById("dispatch");
57

6-
$toggleIcon?.addEventListener("click", function () {
8+
EventHandler.on($toggleIcon, "click", function () {
79
$infoLayer?.classList.toggle("active");
810
});
911

1012
};
1113

14+
EventHandler.on(window, 'load.uds.ranking-card', rankingFunc);
15+
1216
export { rankingFunc };
Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
import { Chart, registerables } from 'chart.js';
2+
import { EventHandler } from './bootstrap-helper';
3+
4+
// Chart.js library should be peer dependency
5+
26
Chart.register(...registerables);
37

48
function initChart() {
59
const GRAPH_PERCENTAGE_COMPLETE = 50;
10+
11+
var ctx = document.getElementById('uds-donut');
12+
13+
if (!ctx) {
14+
// id="uds-donut" not found in the DOM.
15+
return;
16+
}
17+
618
document.getElementById('percentage-display').innerHTML =
719
GRAPH_PERCENTAGE_COMPLETE + '%';
8-
var ctx = document.getElementById('uds-donut');
920

1021
const config = {
1122
type: 'doughnut',
@@ -29,4 +40,6 @@ function initChart() {
2940
var myChart = new Chart(ctx, config);
3041
};
3142

43+
EventHandler.on(window, 'load.uds.chart', initChart);
44+
3245
export { initChart };
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
function initVideo() {
1+
import { EventHandler } from "./bootstrap-helper";
2+
3+
function initHeroesVideo() {
24
// common selectors
35
const DOM_ELEMENT_VIDEO = "video";
46
const DOM_ELEMENT_BTN_PLAY = "#playHeroVid";
@@ -50,4 +52,6 @@ function initVideo() {
5052

5153
};
5254

53-
export { initVideo };
55+
EventHandler.on(window, 'load.uds.heroes-video', initHeroesVideo);
56+
57+
export { initHeroesVideo };
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { EventHandler } from "./bootstrap-helper";
2+
13
export const initImageParallax = () => {
24
const MAGIC_PARALLAX_FACTOR = 1.2;
35

@@ -91,7 +93,7 @@ export const initImageParallax = () => {
9193
// dataLayer elements focus event listener
9294
const elements = document.querySelectorAll('[data-ga-image-parallax]');
9395
elements.forEach((element) =>
94-
element.addEventListener('focus', () => {
96+
EventHandler.on(element, 'focus.uds.image-parallax', () => {
9597
const args = {
9698
section: element
9799
.getAttribute('data-ga-image-parallax-section')
@@ -103,13 +105,11 @@ export const initImageParallax = () => {
103105
);
104106

105107
// Window management
106-
window.addEventListener('DOMContentLoaded', function () {
107-
manage_image_sizes();
108-
});
108+
manage_image_sizes();
109109

110-
window.addEventListener('resize', function () {
111-
manage_image_sizes();
112-
});
110+
EventHandler.on(window, 'resize.uds.image-parallax', manage_image_sizes);
113111

114-
window.addEventListener('scroll', scrollHandler);
112+
EventHandler.on(window, 'scroll.uds.image-parallax', scrollHandler);
115113
};
114+
115+
EventHandler.on(window, 'load.uds.image-parallax', initImageParallax);

0 commit comments

Comments
 (0)