jQuery(document).ready(function($){ if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) { $(".main-navigation li:has(ul) > a").bind('touchstart',function(e){ e.stopPropagation(); e.preventDefault(); if($(this).hasClass("oneTouch")){ $(this).removeClass("oneTouch"); window.location = $(this).attr("href"); } else{ $(this).addClass("oneTouch"); } }); } });
Category: jQuery
Bootstrap 3 Carousel randomize item (Snippet)
$('#myCarousel.carousel[data-type="multi"] .item').each(function(){ $('#myCarousel.carousel[data-type="multi"] .item').removeClass('active').eq(Math.floor((Math.random() * $('#myCarousel.carousel[data-type="multi"] .item').length))).addClass("active"); var next = $(this).next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); for (var i=0;i<4;i++) { next=next.next(); if (!next.length) { next = $(this).siblings(':first'); } next.children(':first-child').clone().appendTo($(this)); } });
Superslides for Mobile
To make the superslide script work also for mobile in addition to the left & right arrow key add this snippet:
$("#slideshow").on("touchstart", function(event){ var xClick = event.originalEvent.touches[0].pageX; $(this).one("touchmove", function(event){ var xMove = event.originalEvent.touches[0].pageX; if( Math.floor(xClick - xMove) > 5 ){ $(this).superslides('animate', 'next'); } else if( Math.floor(xClick - xMove) < -5 ){ $(this).superslides('animate', 'prev'); } }); $("#slideshow").on("touchend", function(){ $(this).off("touchmove"); }); });