Skip to content

Instantly share code, notes, and snippets.

@gseilheimer
Last active September 19, 2015 12:51
Show Gist options
  • Save gseilheimer/b2f1a09c280b8b4c617b to your computer and use it in GitHub Desktop.
Save gseilheimer/b2f1a09c280b8b4c617b to your computer and use it in GitHub Desktop.
// NAVI
function bs_navigation() {
/* affix the navbar after scroll below header */
$('nav').affix({
offset: {
top: $('header').height()-$('nav').height()
}
});
/* on click hide collapse navbar */
$('.navbar-collapse a').on('click', function(){
$(".navbar-collapse").collapse('hide');
});
$(document).on('scroll', function(){
if ( $(window).scrollTop() > $(window).height() ) {
$('.scroll-to-top').show('slow');
} else {
$('.scroll-to-top').hide('slow');
}
});
/* highlight the top nav as scrolling occurs */
$('body').scrollspy({
target: 'nav', offset: 50
})
/* smooth scrolling for nav sections */
$('a[href^=#]').on('click', function() {
var anchor = $(this).attr('href');
var top = $(anchor).offset().top-50;
console.log("scroll to top: " + top);
if () {
top = $('header').height()-$('nav').height()
}
$('html, body').stop().animate({
scrollTop: $(anchor).offset().top-50
},'slow');
});
/* smooth scrolling for scroll to top */
$('.scroll-to-top').on('click', function(){
$('body,html').animate({scrollTop:0},'slow');
})
/* resize header from window-height to min-height */
$(window).on("resize",function() {
if ( $(window).height() > 470 && $(window).height() < 670 ) {
$('header').height($(window).height() - 120);
}
});
$(window).trigger('resize');
}//end function
// Normalize Carousel Heights - pass in Bootstrap Carousel items.
$.fn.carouselHeights = function() {
var items = $(this), //grab all slides
heights = [], //create empty array to store height values
tallest; //create variable to make note of the tallest slide
var normalizeHeights = function() {
items.each(function() { //add heights to array
heights.push($(this).height());
});
tallest = Math.max.apply(null, heights); //cache largest value
items.each(function() {
//$(this).css('min-height',tallest + 'px');
tallest = $('header').height();
$(this).css('min-height',tallest + 'px');
$(this).css('max-height',tallest + 'px');
});
};
normalizeHeights();
$(window).on('resize orientationchange', function () {
//reset vars
tallest = 0;
heights.length = 0;
items.each(function() {
$(this).css('min-height','0'); //reset min-height
});
normalizeHeights(); //run it again
});
}//end function
// CAROUSEL
function bs_carousel(obj) {
if(!obj.length) return;
obj.carousel({
});
}//end function
// sliderHeight
function bs_sliderHeight() {
var wh = $(window).height();
$('header').css({height: wh});
$('#header_section').css({height: wh});
$(window).on('resize orientationchange', function () {
bs_sliderHeight(); //run it again
});
}//end function
// LAZYLOAD
function bs_lazyload(obj) {
if(!obj.length) return;
obj.lazyload({
threshold: 200,
skip_invisible: true,
effect: "fadeIn"
});
}//end function
// VEGAS
// Define backgrounds array
var bgimages_lalanterna = [
{ src: '/files/la_laterna_-_restaurant_011_-_sm.jpg' },
{ src: '/files/la_lanterna_-_restaurant_022.jpg' },
{ src: '/files/la_lanterna_-_restaurant_042.jpg' }
]
// Define backgrounds array
var bgimages_daisa = [
{ src: '/files/la_laterna_-_restaurant_011_-_sm.jpg' },
{ src: '/files/la_lanterna_-_restaurant_022.jpg' },
{ src: '/files/la_lanterna_-_restaurant_042.jpg' }
]
function bs_vegas(obj, files) {
if(!obj.length) return;
obj.vegas({
delay: 7000,
timer: false,
shuffle: true,
transition: 'blur2',
animation: 'random',
transitionDuration: 2000,
cover: true,
slides: files
});
}//end function
// GOOGLEMAPS
function bs_googlemaps() {
var var_location = new google.maps.LatLng(45.7813218,9.6225415);
var var_mapoptions = {
center: var_location,
zoom: 14
};
var var_marker = new google.maps.Marker({
position: var_location,
map: var_map,
title:"Venice"});
var var_map = new google.maps.Map(document.getElementById("map-container"),
var_mapoptions);
var_marker.setMap(var_map);
}//end function
// READY - START
$(document).ready(function() {
// Call BS_SLIDERHEIGHT
bs_sliderHeight();
// Call BS_NAVIGATION
bs_navigation();
// Call BS_CAROUSEL
//bs_carousel($("#myCarousel"));
// Call BS_LAZYLOAD
bs_lazyload($(".lazyload"));
// Call BS_VEGAS
bs_vegas($("#header_section,[class^=La_Lanterna]"), bgimages_lalanterna);
bs_vegas($("#header_section,[class^=Da_Isa]"), bgimages_daisa);
// Call Google Maps
//google.maps.event.addDomListener(window, 'load', bs_googlemaps);
// Call carouselHeights
//$('#header_section').carouselHeights();
});
// Ende ready function()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment