Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
163 lines (118 loc) · 5.08 KB
/
Copy pathscript.js
File metadata and controls
163 lines (118 loc) · 5.08 KB
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
//-------------------------site logo for returing home---------------------------
// this is the shortcut for returning to the header section/ home page when the is somewhen within the page
const siteLogo = document.getElementById('Site_logo');
const headerSection = document.getElementById('header');
siteLogo.addEventListener('click', (event) => {
event.preventDefault();
// Scroll smoothly to the header section
headerSection.scrollIntoView({ behavior: 'smooth' });
});
const contactUs = document.querySelector('.contact-button');
const contactSection = document.getElementById('Contact');
contactUs.addEventListener('click', (event) => {
event.preventDefault();
// Scroll smoothly to the header section
contactSection.scrollIntoView({ behavior: 'smooth' });
});
const featuredProjects = document.querySelector('.featured-button');
const featuredSection = document.getElementById('featured_projects');
featuredProjects.addEventListener('click', (event) => {
event.preventDefault();
// Scroll smoothly to the featured section
featuredSection.scrollIntoView({ behavior: 'smooth' });
});
//grid icon links to page section
document.addEventListener('DOMContentLoaded', function() {
const gridIcons = document.querySelectorAll('.grid a');
gridIcons.forEach((gridIcon) => {
gridIcon.addEventListener('click', (event) => {
event.preventDefault();
const selectedId = gridIcon.getAttribute('href');
const targetSecId = document.querySelector(selectedId);
if (targetSecId) {
targetSecId.scrollIntoView({ behavior: 'smooth' });
}
});
});
});
// -------------------sidebar--------------------------
// This focuses on the opening of the sidear when the hamburger menu is clicked
// Also closes the sidebar if user click outside the sidebar
const navBar = document.querySelector("nav");
const menuBtns = document.querySelectorAll(".menu-icon");
const overlay = document.querySelector(".overlay");
menuBtns.forEach((menuBtn) => {
menuBtn.addEventListener("click", () => {
navBar.classList.toggle("open");
});
});
overlay.addEventListener("click", () => {
navBar.classList.remove("open");
});
// -------------------sidebar Menu links--------------------------
// When clicking on the sidebar menu this will navigate to the coressponding section in the page and close the sidebar simultaneously.
document.addEventListener('DOMContentLoaded', function() {
const menuItems = document.querySelectorAll('#sidebarMenu a');
const sidebar = document.querySelector('.sidebar');
menuItems.forEach(function(menuItem) {
menuItem.addEventListener('click', function(event) {
event.preventDefault();
const targetId = menuItem.getAttribute('href');
const targetSection = document.querySelector(targetId);
if (targetSection) {
targetSection.scrollIntoView({ behavior: 'smooth' });
sidebar.addEventListener("click", () => {
navBar.classList.remove("open");
});
}
});
});
});
//-------------------------------------------------
//smooth transistion to external link with the page
//-------------------------------------------------
function redirectToHome() {
document.body.style.opacity = '0'; // Set the body opacity to 0 for the fade-out effect
// Wait for the transition to complete
setTimeout(function() {
try {
window.location.href = 'Video Editing.html'; // Redirect to homesamp.html
} catch (error) {
console.error('Error redirecting to Video Editing.html:', error);
}
}, 100); // Adjust the duration (in milliseconds) based on your desired transition time
// Set body opacity back to 1 after the transition completes
setTimeout(function() {
document.body.style.opacity = '1';
}, 500); // Adjust the duration (in milliseconds) based on your desired fade-in time
}
document.addEventListener('DOMContentLoaded', function() {
let clickMeButton = document.getElementById('call_button');
if (clickMeButton) {
clickMeButton.addEventListener('click', function(event) {
event.preventDefault();
redirectToHome();
});
}
});
//--------------------------------------
// MESSENGER API POP UP
//----------------------------------------
// Your Chat Plugin code -->
var chatbox = document.getElementById('fb-customer-chat');
chatbox.setAttribute("page_id", "106592624696896");
chatbox.setAttribute("attribution", "biz_inbox");
// Your SDK code -->
window.fbAsyncInit = function() {
FB.init({
xfbml : true,
version : 'v17.0'
});
};
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = 'https://connect.facebook.net/en_US/sdk/xfbml.customerchat.js';
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));