-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
334 lines (279 loc) · 11.9 KB
/
script.js
File metadata and controls
334 lines (279 loc) · 11.9 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
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
$(document).ready(function () {
// Set the default language from localStorage or default to 'ar'
let currentLang = localStorage.getItem('language') || 'ar';
// Initialize the page with the correct language and direction
changeLanguage(currentLang);
// Toggle button click event
$('#toggleLang, #toggleLangOne').on('click', function () {
if (currentLang === 'ar') {
changeLanguage('en');
$(this).text('عربي'); // Switch to Arabic
} else {
changeLanguage('ar');
$(this).text('English'); // Switch to English
}
});
function changeLanguage(lang) {
currentLang = lang;
localStorage.setItem('language', lang); // Store language in localStorage
// Change direction based on language
if (lang === 'ar') {
$('body').attr('dir', 'rtl');
$('#toggleLang, #toggleLangOne').text('English');
$('#toggleLang, #toggleLangOne').addClass('font-english')
} else {
$('body').attr('dir', 'ltr');
$('#toggleLang, #toggleLangOne').text('عربي');
$('#toggleLang, #toggleLangOne').removeClass('font-english');
}
// Update language-specific text and fonts
$('[data-lang-ar]').each(function () {
const text = $(this).data(`lang-${lang}`);
if ($(this).is('input')) {
// Update placeholder for input elements
$(this).attr('placeholder', text);
} else if ($(this).is('button')) {
// Replace the entire content for button elements
$(this).html(text);
} else {
// For other elements, replace the text while preserving nested HTML
$(this).contents().filter(function () {
return this.nodeType === 3; // Only text nodes
}).first().replaceWith(text);
}
// Switch font class based on language
if (lang === 'ar') {
$(this).removeClass('font-english').addClass('font-arabic');
} else {
$(this).removeClass('font-arabic').addClass('font-english');
}
});
const coverImage = lang === 'ar'
? 'img/ST web image Arabic.png'
: 'img/ST web image.png';
$('.cover-image').attr('src', coverImage);
const footerImage = lang === 'ar'
? 'img/ST web footer image copy.png'
: 'img/ST web footer image copy 4.png';
$('.foo-image').attr('src', footerImage);
// Apply specific font-family for carousel
const arabicFont = 'kigelia-arabic-bold';
const englishFont = '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji';
const carouselFont = lang === 'ar' ? arabicFont : englishFont;
$('.title, .topic, .des, .specifications, .mbtn-txt, .seeMore span').css('font-family', carouselFont);
const btnarabicFont = 'kigelia-arabic-bold';
const btnenglishFont = '"Belleza", sans-serif';
const footerTxtFont = lang === 'ar' ? btnarabicFont : btnenglishFont;
$('.foo-button, .as-button, .comment-tab h4').css('font-family', footerTxtFont);
const legalArLetterS = '0';
const legalEnLetterS = '0.2rem';
const legalLetterSpacing = lang === 'ar' ? legalArLetterS : legalEnLetterS;
$('.inner p, .inner h2, .main-nav li a, article h2, .field label, .actions li input, .mbtn-txt, .seeMore span').css('letter-spacing', legalLetterSpacing);
// about screen and people-comment-screen text direction
const asarabicDir = 'rtl';
const asenglishDir = 'ltr';
const aboutScreenDir = lang === 'ar' ? asarabicDir : asenglishDir;
$('.lDir, .comment-tab p').css('direction', aboutScreenDir);
$('input[data-lang-en][data-lang-ar]').each(function () {
// Update the value attribute based on the selected language
const newValue = lang === 'ar' ? $(this).data('lang-ar') : $(this).data('lang-en');
$(this).val(newValue);
});
}
setTimeout(function() {
$('#splashScreen').fadeOut('slow')
}, 1000);
function aboutImgBackground() {
if (window.matchMedia("(max-width: 736px)").matches) {
$('.useFilter').addClass('filtered');
} else {
$('.useFilter').removeClass('filtered');
}
}
aboutImgBackground();
$(window).on('resize', aboutImgBackground);
//common reveal options to create reveal animations
const sr = ScrollReveal({
reset: true,
distance: '60px',
duration: 2500,
delay: 400,
});
//target elements, and specify options to create reveal animations
sr.reveal('.responsive-heading', { delay: 1200, origin: 'top', distance: '0px' });
sr.reveal('.imgSR, .first-imgSR', { delay: 400, origin: 'bottom' });
sr.reveal('.textSR', { delay: 200, origin: 'left' });
function applyScrollReveal() {
if ($(window).width() <= 992) {
// Disable ScrollReveal for mobile devices
ScrollReveal().clean('header, .legalHeader'); // Remove existing ScrollReveal animations
} else {
// Enable ScrollReveal for larger screens
ScrollReveal().reveal('header, .legalHeader', {
delay: 1400,
origin: 'top',
reset: false,
mobile: false
});
}
}
applyScrollReveal();
// Reapply ScrollReveal on window resize
$(window).on('resize', function () {
applyScrollReveal();
});
ScrollReveal().reveal('.main-content .right-section', {
beforeReveal: (el) => {
el.style.opacity = '0'; // Start invisible
el.style.transform = 'translate(50px, 87px)'; // Offset for 60 degrees
},
afterReveal: (el) => {
el.style.transition = 'transform 1s ease-out, opacity 1s ease-out';
el.style.transform = 'translate(0, 0)'; // Animate to original position
el.style.opacity = '1'; // Fade in
},
reset: true, // Reset animation when scrolling back
delay: 100
});
$('.magnetic-btn').each(function() {
$(this).on('mousemove', function(e) {
let x = e.offsetX;
let y = e.offsetY;
let btnWidth = $(this).width();
let btnHeight = $(this).height();
let transX = (x - btnWidth / 2) /100;
let transY = (y - btnHeight / 2) /100;
$(this).css('transform', `translate(${transX}px, ${transY}px)`);
let mx = e.pageX - $(this).offset().left;
let my = e.pageY - $(this).offset().top;
$(this).css('--x', mx + 'px');
$(this).css('--y', my + 'px');
});
$(this).on('mouseout', function() {
$(this).css('transform', '');
});
});
$('#home, #homeOne').on('click', function(e) {
if($(window).scrollTop() === 0) {
location.reload(); // Reloads the page
} else {
e.preventDefault(); // Prevents default behavior if not at the top
$('html, body').animate({ scrollTop: 0 }, 'slow'); // Smooth scroll to top
}
})
$(window).on('beforeunload', function () {
$(window).scrollTop(0);
})
});
$(document).ready(function () {
let $carousel = $('.carousel');
let $listHTML = $('.carousel .list');
let unAcceptClick;
// Next button click event
$('#next').on('click', function () {
showSlider('next');
});
// Previous button click event
$('#prev').on('click', function () {
showSlider('prev');
});
// Function to handle slider navigation
const showSlider = (type) => {
$('#next, #prev').css('pointer-events', 'none'); // Disable pointer events
$carousel.removeClass('next prev'); // Remove existing classes
let $items = $('.carousel .list .item'); // Get all items
if (type === 'next') {
$listHTML.append($items.first()); // Move the first item to the end
$carousel.addClass('next');
} else {
$listHTML.prepend($items.last()); // Move the last item to the beginning
$carousel.addClass('prev');
}
// Re-enable pointer events after a delay
clearTimeout(unAcceptClick);
unAcceptClick = setTimeout(() => {
$('#next, #prev').css('pointer-events', 'auto');
}, 2000);
};
// See more button click events
$('.seeMore').on('click', function () {
$carousel.removeClass('next prev').addClass('showDetail');
});
// Back button click event
$('#back').on('click', function () {
$carousel.removeClass('showDetail');
});
});
$(document).ready(function () {
const $toggleBtn = $('.toggle_btn');
const $dropDownMenu = $('.dropdown_menu');
$toggleBtn.on('click', function() {
$dropDownMenu.toggleClass('open');
const isOpen = $dropDownMenu.hasClass('open');
$toggleBtn.toggleClass('open');
});
$dropDownMenu.find('a').on('click', function() {
$dropDownMenu.removeClass('open');
$toggleBtn.removeClass('open');
});
$(window).on('scroll', function () {
const scrollTop = $(window).scrollTop(); // Current scroll position
const windowHeight = $(window).height(); // Visible part of the window
const documentHeight = $(document).height(); // Total height of the page
if (scrollTop + windowHeight >= documentHeight - 50) {
// Add a class to make the footer visible
$('.footer-tab').addClass('visible');
} else {
// Remove the class to hide the footer
$('.footer-tab').removeClass('visible');
}
});
// Function to check if element is in viewport
function checkInView() {
// Loop through each .mobile-image and .comment-tab to check if it's in view
$('.mobile-image, .comment-tab').each(function() {
var windowHeight = $(window).height();
var elementTop = $(this).offset().top;
var elementBottom = elementTop + $(this).outerHeight();
var viewportTop = $(window).scrollTop();
var viewportBottom = viewportTop + windowHeight;
// If element is in the viewport, add the 'show' class
if (elementBottom > viewportTop && elementTop < viewportBottom) {
$(this).addClass('show');
} else {
// If element is out of viewport, remove the 'show' class to reset animation
$(this).removeClass('show');
}
});
}
// Trigger the check on scroll and load
$(window).on('scroll load', function() {
checkInView();
});
// Initial check on page load
checkInView();
// Dynamically add the required HTML and scripts
(function () {
const div = document.createElement("div");
div.id = "systems_tag_live_chat";
div.setAttribute(
"channel_key",
"656695f324ad5896151eec0cf4202c1066f68119"
);
div.setAttribute("base_url", "http://chat.unitedgroupone.com/");
document.body.appendChild(div);
const link = document.createElement("link");
link.rel = "stylesheet";
link.href = "http://chat.unitedgroupone.com/css/app.css";
document.head.appendChild(link);
const vendorsScript = document.createElement("script");
vendorsScript.src =
"http://chat.unitedgroupone.com/js/chunk-vendors.js";
vendorsScript.defer = true;
document.body.appendChild(vendorsScript);
const appScript = document.createElement("script");
appScript.src = "http://chat.unitedgroupone.com/js/app.js";
appScript.defer = true;
document.body.appendChild(appScript);
})();
});