0% found this document useful (0 votes)
152 views4 pages

Leo Script

The document contains JavaScript code that utilizes jQuery to handle various functionalities such as adjusting image positions on scroll, setting heights for elements, and triggering modal popups. It includes responsive design considerations based on window width and ensures that user inputs are sanitized. Additionally, it provides a smooth scroll-to-top feature and dynamically adjusts textarea heights based on content.

Uploaded by

vpadastro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views4 pages

Leo Script

The document contains JavaScript code that utilizes jQuery to handle various functionalities such as adjusting image positions on scroll, setting heights for elements, and triggering modal popups. It includes responsive design considerations based on window width and ensures that user inputs are sanitized. Additionally, it provides a smooth scroll-to-top feature and dynamically adjusts textarea heights based on content.

Uploaded by

vpadastro
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

/* Add your JavaScript code here.

If you are using the jQuery library, then don't forget to wrap your code inside
jQuery.ready() as follows:
jQuery(document).ready(function( $ ){
// Your code in here
});
--
If you want to link a JavaScript file that resides on another server (similar to
<script src="https://example.com/your-js-file.js"></script>), then please use
the "Add HTML Code" page, as this is a HTML code that links a JavaScript file.
End of comment */

// $(window).on('resize', function() {
// setHeight();
// });

// var socInitialTop = 500; // Initial top position for .soc


// var addonInitialTop = 1080; // Initial top position for .addon
// var socSectionOffset = $('.soc-section').offset().top; // Get the initial
top offset for .soc-section

// $(window).on('scroll', function() {
// var scrollY = $(this).scrollTop();
// var windowHeight = $(window).height();

// // Adjust the trigger to when .soc-section hits the middle of the screen
// var triggerPoint = scrollY + (windowHeight / 1.5);

// // Check if we've scrolled to the .soc-section in the middle of the


screen
// if (triggerPoint >= socSectionOffset) {
// var scrolledPastSocSection = triggerPoint - socSectionOffset;

// // Calculate new positions, ensuring they're within the allowed


range
// var newSocTop = Math.max(-500, Math.min(500, socInitialTop -
scrolledPastSocSection));
// var newAddonTop = Math.max(-100, Math.min(1000, addonInitialTop -
scrolledPastSocSection));

// // Apply the new positions


// $('img.soc').css('top', newSocTop + 'px');
// $('img.addon').css('top', newAddonTop + 'px');
// }
// });

// jQuery(document).ready(function($){
// function setHeight() {
// var packageWrapperHeight = $('.package-wrapper').outerHeight();
// $('.image-container').css('min-height', packageWrapperHeight);
// }
// setHeight();

// if ($('.package-wrapper').length > 0) {
// var windowW = window.innerWidth;

// if(windowW <=1921) {
// var socInitialTop = 420;
// var addonInitialTop = 965;
// var hopInitialTop = 0;
// }
// if(windowW <=1601) {
// var socInitialTop = 520;
// var addonInitialTop = 1075;
// var hopInitialTop = 0;
// }
// if(windowW <=1450) {
// var socInitialTop = 380;
// var addonInitialTop = 940;
// var hopInitialTop = 0;
// }
// if(windowW <=1361) {
// var socInitialTop = 335;
// var addonInitialTop = 890;
// var hopInitialTop = 0;
// }
// if(windowW <=1290) {
// var socInitialTop = 300;
// var addonInitialTop = 860;
// var hopInitialTop = 0;
// }
// if(windowW > 1922){
// var socInitialTop = 485;
// var addonInitialTop = 1058;
// var hopInitialTop = 0;
// }
// console.log(socInitialTop);

// var socSectionOffset = $('.soc-section').offset().top;

// $(window).on('scroll', function() {
// var scrollY = $(this).scrollTop();
// var windowWidth = window.innerWidth;
// // Adjust to trigger when .soc-section is in the middle of the screen
// triggerPoint = socSectionOffset - window.innerHeight / 2.1;

// if (scrollY >= triggerPoint) {


// var scrolledPastSocSection = scrollY - triggerPoint;

// // Calculate new positions, ensuring they're within the allowed


range
// var newSocTop = Math.max(-120, Math.min(600, socInitialTop -
scrolledPastSocSection));
// var newAddonTop = Math.max(-30, Math.min(1000, addonInitialTop -
scrolledPastSocSection));
// var newHopTop = Math.min(0, hopInitialTop - scrolledPastSocSection /
2); // Adjust hop top at half speed for visual effect

// // Apply the new positions


// $('img.soc').css('top', newSocTop + 'px');
// $('img.addon').css('top', newAddonTop + 'px');
// $('img.hop').css('top', newHopTop + 'px');
// }
// });

// }
// if(jQuery(window).width() <= 991) {

// var customButton = jQuery('#ekit-megamenu-mobile-menu').find('a.custom-


button-element');
// var signUpButton = jQuery('#ekit-megamenu-mobile-menu').find('a.mobile-
signup-button');
// var popupButton = jQuery('#pricing-modal').find('a.eae-popup-link');
// triggerModalPopup(customButton, popupButton);
// triggerModalPopup(signUpButton, popupButton);
// }
// function triggerModalPopup(buttonTrigger, popupTrigger) {
// buttonTrigger.on('click', function(e){
// e.preventDefault();
// popupTrigger.trigger('click');
// });
// }
// });

jQuery(document).ready(function($) {

$('textarea').on('input', function () {
this.style.height = 'auto';

this.style.height =
(this.scrollHeight) + 'px';
});

$('input[name="your-phone"]').on('input', function(event) {
var inputValue = $(this).val();
// Remove any non-numeric characters except '+'
$(this).val(inputValue.replace(/[^0-9+]/g, ''));
});

$('.gotop').click(function(){
$('html, body').animate({scrollTop: 0}, 2000);
});

function setHeight() {
var packageWrapperHeight = $('.package-wrapper').outerHeight();
$('.image-container').css('min-height', packageWrapperHeight);
}
setHeight();

// Initial top positions for the images


var initialTopSoc = 365;
var initialTopAddon = 373;

function adjustImagePositions() {
var windowTop = $(window).scrollTop();
var imageWrapperBottom = $('.image-wrapper').offset().top + $('.image-
wrapper').outerHeight();

// Calculate the difference between the image-wrapper bottom and the


section tops
var socDiff = Math.max(0, imageWrapperBottom - $('.soc-
section').offset().top);
var addonDiff = Math.max(0, imageWrapperBottom - $('.addon-
section').offset().top);

// Calculate the new top positions, considering the initial top positions
var newTopSoc = Math.max(initialTopSoc - socDiff, 0);
var newTopAddon = Math.max(initialTopAddon - addonDiff, 0);

// Apply the new top positions


$('img.soc').css('top', newTopSoc + 'px');
$('img.addon').css('top', newTopAddon + 'px');
}

adjustImagePositions();
$(window).on('scroll resize', adjustImagePositions);

if (jQuery(window).width() <= 991) {


var customButton = jQuery('#ekit-megamenu-mobile-menu').find('a.custom-
button-element');
var signUpButton = jQuery('#ekit-megamenu-mobile-menu').find('a.mobile-
signup-button');
var popupButton = jQuery('#pricing-modal').find('a.eae-popup-link');
triggerModalPopup(customButton, popupButton);
triggerModalPopup(signUpButton, popupButton);
}

function triggerModalPopup(buttonTrigger, popupTrigger) {


buttonTrigger.on('click', function(e) {
e.preventDefault();
popupTrigger.trigger('click');
});
}

});

You might also like