Skip to content

Instantly share code, notes, and snippets.

@elizad
Created July 9, 2018 20:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elizad/d79539c8811a99bff4b78bac2fc0f0c8 to your computer and use it in GitHub Desktop.
Save elizad/d79539c8811a99bff4b78bac2fc0f0c8 to your computer and use it in GitHub Desktop.
js
// Write your JavaScript code.
// js for google capcha
function onSubmit(token) {
alert('thanks ' + document.getElementById('field-submitcv').value);
}
function validate(event) {
event.preventDefault();
if (!document.getElementById('field-submitcv').value) {
alert("You must add text to the required field");
} else {
grecaptcha.execute();
}
}
function onload() {
var element = document.getElementByClassName('btnuploadtopcv');
element.onclick = validate;
}
//end google capcha
$(function () {
var theWindow = $(window),
$bg = $(".img-fluid_jsfit"),
aspectRatio = $bg.width() / $bg.height();
resizeBg = function () {
if ((theWindow.width() / theWindow.height()) < aspectRatio) {
$bg
.removeClass('img-fluid_jsfit bgwidth')
.addClass('bgheight');
console.log('bg height');
} else {
$bg
.removeClass('img-fluid_jsfit bgheight')
.addClass('bgwidth');
console.log('bg with');
}
}
theWindow.resize(function () {
resizeBg();
}).trigger("resize");
equalheight = function (container) {
var currentTallest = 0,
currentRowStart = 0,
rowDivs = new Array(),
$el,
topPosition = 0;
$(container).each(function () {
$el = $(this);
$($el).height('auto')
topPostion = $el.position().top;
if (currentRowStart !== topPostion) {
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPostion;
currentTallest = $el.height();
rowDivs.push($el);
} else {
rowDivs.push($el);
currentTallest = (currentTallest < $el.height()) ? ($el.height()) : (currentTallest);
}
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
});
}
//theWindow.on(load, function (event) {
// equalheight('.jobsearch .jobtitle');
// equalheight('.downloadapp .equal');
//}).trigger('resize');
window.addEventListener("load", function (event) {
equalheight('.testimonials .testimonial-text');
equalheight('.choose-itch-box .choose-itch-card');
equalheight('.teacherscard .teacher-card_text');
console.log('hhhhhload');
});
window.addEventListener("scroll", function (event) {
//equalheight('.testimonials .testimonial-text');
//equalheight('.choose-itch-box .choose-itch-card');
//equalheight('.bg-blue .aa');
console.log('hhhhhhhscroll');
});
window.addEventListener('resize', function (event) {
equalheight('.testimonials .testimonial-text ');
equalheight('.choose-itch-box .choose-itch-card');
equalheight('.teacherscard .teacher-card_text ');
console.log('hhhhhhhresize');
});
//end equalheight
window.addEventListener('scroll', function (event) {
if ($(window).scrollTop() > 200) {
$('#navbarfixedTop').addClass('fixed-top');
}
if ($(window).scrollTop() < 201) {
$('#navbarfixedTop').removeClass('fixed-top');
}
});
$.fn.randomColor = function () {
// return list[Math.floor(Math.random() * list.lenght )];
var colorsList = ["#52b5ab", "#16a7ba", "#c16ba4"];
return color = colorsList[Math.floor(Math.random() * colorsList.length)];
console.log(color);
}
$(".diffently-square_box .diffently-square__text").hover(function () {
$(this)
}, function () {
$(this).css("background-color", color);
}, function () {
$(this).css("background-color", "#c16ba4");
}
);
$.fn.textWidth = function () {
var hnav = parseInt(window.getComputedStyle(document.querySelector("#navbarfixedTop")).height);
console.log(hnav);
var uploadcv = document.querySelector('.uploadcv');
var hUpCv = parseInt(window.getComputedStyle(uploadcv, ':after').height);
console.log('hupcv:' + hUpCv);
var hbanner = parseInt(window.getComputedStyle(document.querySelector(".homebanner-row")).height);
console.log('hbanner:' + hbanner);
var helement = hbanner - hnav;
console.log('H element :' + helement);
return helement;
};
window.addEventListener('load', function (event) {
$('.uploadcv').each(function () {
$(this).append('<style>.uploadcv:after{border-bottom-width:' + $(this).textWidth() + 'px;}</style>');
});
});
window.addEventListener('resize', function (event) {
$('.uploadcv').each(function(){
$(this).append('<style>.uploadcv:after{border-bottom-width:'+$(this).textWidth() +'px;}</style>');
});
});
});
//carousel 4 items function
$('.carousel .carousel-item').each(function(){
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
for (var i=0;i<2;i++) {
next=next.next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment