bludit/bl-themes/lingonberry/js/global.js

58 lines
1.3 KiB
JavaScript

jQuery(document).ready(function($) {
// toggle blog-menu
$(".nav-toggle").on("click", function(){
$(this).toggleClass("active");
$(".navigation").slideToggle(function (){
$(".navigation").css('overflow', 'visible');
});
return false;
});
// Load Flexslider
$(".flexslider").flexslider({
animation: "slide",
controlNav: false,
prevText: "Prev",
nextText: "Next",
smoothHeight: true
});
// Smooth scroll to the top
$('.tothetop').click(function(){
$("html, body").animate({ scrollTop: 0 }, 500);
return false;
});
// resize videos after container
var vidSelector = "iframe, object, video";
var resizeVideo = function(sSel) {
$( sSel ).each(function() {
var $video = $(this),
$container = $video.parent(),
iTargetWidth = $container.width();
if ( !$video.attr("data-origwidth") ) {
$video.attr("data-origwidth", $video.attr("width"));
$video.attr("data-origheight", $video.attr("height"));
}
var ratio = iTargetWidth / $video.attr("data-origwidth");
$video.css("width", iTargetWidth + "px");
$video.css("height", ( $video.attr("data-origheight") * ratio ) + "px");
});
};
resizeVideo(vidSelector);
$(window).resize(function() {
resizeVideo(vidSelector);
});
});