Skip to content

Instantly share code, notes, and snippets.

@elizad
Last active August 31, 2018 15:30
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/b7c912fc9422e5b52786ce30e4e9fa0f to your computer and use it in GitHub Desktop.
Save elizad/b7c912fc9422e5b52786ce30e4e9fa0f to your computer and use it in GitHub Desktop.
jstltp,.js
"use strict";
(function () {
var theWindow = $(window);
var bg = $('.img-fluid_jsfit');
var aspectRatio = bg.width() / bg.height();
var resizeBg = function () {
if ( theWindow.width() / theWindow.height() < aspectRatio) {
bg
.removeClass('img-fluid_jsfit bgwidth')
.addClass('bgheight');
} else {
bg
.removeClass('img-fluid_jsfit bgheight')
.addClass('bgwidth');
}
};
var equalheight = function (container) {
var currentTallest = 0,
currentRowStart = 0,
topPosition = 0,
currentDiv,
rowDivs = new Array(),
$el;
$(container).each(function () {
$el = $(this);
$($el).height('auto');
topPosition = $el.position().top;
if (currentRowStart !== topPosition) {
for (currentDiv = 0; currentDiv < rowDivs.length; currentDiv++) {
rowDivs[currentDiv].height(currentTallest);
}
rowDivs.length = 0; // empty the array
currentRowStart = topPosition;
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);
}
});
};
var navHeadResponsive = function () {
var hnavbarfixedTop = $("#navbarfixedTop").height() || 0;
console.log('hnavbarfixedTop ' + hnavbarfixedTop);
if ($(window).width() >= 767) {
if ($("#topJobSearch")[0]) {
var hTopJobSearch = $("#topJobSearch").height() || 0;
} else {
hTopJobSearch = 0;
}
}
if ($('.jobfilter.jobfilterfixed')[0]) {
var hjobfilter = $(".jobfilter.jobfilterfixed").height() || 0;
} else {
hjobfilter = 0;
}
if ($('nav.jobfilterfixed')[0]) {
var hnavjobfilterfixed = $('nav.jobfilterfixed').height() || 0;
} else {
hnavjobfilterfixed = 0;
}
console.log('var hnavfilter ' + hnavjobfilterfixed);
if ($('.jobfilter_search')[0]) {
var hjobfilter_search = $('.jobfilter_search').innerHeight() || 0;
} else {
hjobfilter_search = 0;
}
if ($('.nav-news')[0]) {
var hnavNews = $('.nav-news').innerHeight() || 0;
} else {
hnavNews = 0;
}
var hTop = hnavbarfixedTop + hTopJobSearch;
var hnavTop = hnavjobfilterfixed + hTopJobSearch;
$('.body-content').css({
'margin-top': hnavbarfixedTop + 'px'
});
$('.top-job-search__formfixed').css({
'top': hnavbarfixedTop + 'px'
});
console.log('topbreadcrumb: hnav ' + hnavbarfixedTop + "topsearch " + hTopJobSearch + "hnavtopseach " + hTopJobSearch);
$('.jobfilterfixed').css({
'top': hTop + 'px'
});
if ($('#topBreadcrumb')[0]) {
var htopBreadcrumb = $('#topBreadcrumb').height() || 0;
} else {
htopBreadcrumb = 0;
}
if ($(window).width() >= 767) {
$('.breadcrumb.jobfilterfixed').css({
'top': hTop + 'px',
'border-top': '12.5px solid #fff'
});
$('.jobpage_jobarea').css({
'margin-top': 0 + 'px'
});
$('#topBreadcrumb').css({
'margin-top': hnavbarfixedTop + hTopJobSearch + 'px'
});
} else {
$('.breadcrumb.jobfilterfixed').css({
'top': hnavbarfixedTop + hjobfilter_search + hnavNews + 'px',
'border-top': '2.5px solid #fff',
'max-width': '100%'
});
$('.jobpage_jobarea').css({
'margin-top': hjobfilter_search + hnavNews + 'px'
});
$('#topBreadcrumb').css({
'margin-top': hnavbarfixedTop + hTopJobSearch - 30 + 'px'
});
}
if ($(window).width() >= 993) {
$('.onepage_selectionsticky nav.breadcrumb.jobfilterfixed').css({
'top': hTop + htopBreadcrumb + 'px',
'border-top': '5px solid #fff',
'background': '#eaeaea'
});
$('.onepage_selectionsticky > nav.breadcrumb.jobfilterfixed.active').css({
'top': hTop + htopBreadcrumb - 0 + 'px'
});
//$('.singlejob-sticky.active').css({
// 'margin-top': $('.onepage_selectionsticky nav.breadcrumb.jobfilterfixed').height() + 'px'
// // 'margin-top' : 0 + 'px'
//});
$('.singlejob-sticky').css({
'margin-top': $('.onepage_selectionsticky nav.breadcrumb.jobfilterfixed').height() + 'px'
//'margin-top' : 0 + 'px'
});
$('.singlejob-about').css({
// 'margin-top': $('.singlejob-sticky').height() + hnavjobfilterfixed + htopBreadcrumb + 25 +'px'
'margin-top': 10 + 'px'
});
} else {
$('.singlejob-sticky').css({
'margin-top': 0 + 'px'
//'margin-top': $('.onepage_selectionsticky nav.breadcrumb.jobfilterfixed').height() + 0 + 'px'
});
$('.singlejob-about').css({
'margin-top': $('.onepage_selectionsticky nav.breadcrumb.jobfilterfixed').height() + $('.singlejob-sticky').height() + 30 + 'px'
});
}
//$('#newsmainpage').css({ 'top': hTop + 'px' });
$('#jobmainarea').css({
'top': hnavTop + 20 + 'px'
});
$('#newsmainarea').css({
'top': hnavTop + 20 + 'px'
});
//$('.alljobs').css({
// 'margin-top' : hnavjobfilterfixed + 'px'
//})
//$('.allnews').css({
// 'margin-top': hnavjobfilterfixed + 'px'
//})
$('.onejobpage').css({
'top': hjobfilter_search + hnavNews + 'px'
});
};
resizeBg();
equalheight('.feature .card__borderapply');
equalheight('.teaching .equal');
equalheight('.jobsearch .jobtitle');
equalheight('.downloadapp .equal');
equalheight('.job_bottomCTA .col-lg-6');
equalheight('.allnews-box .card-title_news');
// // headHeightR();
navHeadResponsive();
var resizeEventResizeElements = function () {
equalheight('.feature .card__borderapply');
equalheight('.teaching .equal');
equalheight('.jobsearch .jobtitle');
equalheight('.downloadapp .equal');
equalheight('.job_bottomCTA .col-lg-6');
equalheight('.allnews-box .card-title_news');
navHeadResponsive();
};
// //window.addEventListener("load", loadEventResizeElements);
window.addEventListener('resize', resizeEventResizeElements);
//carousel 2 items function
if (theWindow.width() > 767) {
console.log('WINDOWS width' + theWindow.width());
$('.carousel .carousel-item').each(function () {
var next = $(this).next();
if (!next.length) {
next = $(this).siblings(':first');
}
next.children(':first-child').clone().appendTo($(this));
});
} else {
$('.carousel .carousel-item')();
}
$('#carouselReviewControls').carousel({
interval: 1000000
});
})();
// cookies
function buildCC() {
var e = document.createElement("link");
e.href = "/css/cookiePopUp.css", e.type = "text/css", e.rel = "stylesheet"; var c = document.createElement("div");
c.className = "cc-pop", c.innerHTML = "<div class='cc-wrap'><div class='cc-close'><a onclick='ccClose()'>Close</a></div><div class='cc-h'>What about Cookies? </div><div class='cc-flex'> <div class='cc-p-cont'> <div class='cc-p'>By continuing to browse, you consent to our policy regarding the use of cookies. </div><div class='cc-p-sm'>To know more, please refer to our <a href='/Home/PrivacyPolicy' target='_blank'>Privacy Policy.</a></div></div><div class='cc-th'><a onclick='ccClose()'>OK</a></div></div></div>", document.head.appendChild(e), document.body.appendChild(c), setTimeout(function (e) { document.querySelector(".cc-pop").classList.add("active"); }, 3e3);
}
function getCookie(e) {
for (var c = e + "=", o = decodeURIComponent(document.cookie).split(";"), t = 0; t < o.length; t++) {
for (var i = o[t];
" " === i.charAt(0);) i = i.substring(1); if (0 === i.indexOf(c)) return i.substring(c.length, i.length);
} return !1;
}
function ccClose() { document.cookie = "SBCC=True; expires=Thu, 31 Dec 2999 12:00:00 UTC; path=/", document.querySelector(".cc-pop").classList.add("removed"), setTimeout(function () { document.querySelector(".cc-pop").remove(); }, 3e3); }
function checkCC() { getCookie("SBCC") || buildCC(); } checkCC();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment