Created
January 7, 2016 22:53
-
-
Save theskillwithin/3b58fb54fa959a42fd24 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Core scripts | |
$(document).ready(function() { | |
//search | |
var searchInput = $('#search input'); | |
searchInput.addClass('hide'); | |
$('#search').click(function(event) { | |
searchInput.removeClass('hide'); | |
event.stopPropagation(); | |
$('body').click(function() { | |
searchInput.addClass('hide'); | |
}); | |
}); | |
//item page size select | |
$('div.size div').click(function(){ | |
$('div.size div').removeClass('selected'); | |
$(this).addClass('selected'); | |
value = $(this).attr("data-value"); | |
$('#hidden-select select').val(value); | |
}); | |
//item page OWL | |
var owl = $("#carousel"); | |
owl.owlCarousel({ | |
items : 3 | |
}); | |
$(".right-arrow").click(function(){ owl.trigger('owl.next'); }); | |
$(".left-arrow").click(function(){ owl.trigger('owl.prev'); }); | |
// nav | |
var themenu = $('.left'), | |
hamburger = $('.mobile-nav-toggle'), | |
theWindow = $(window); | |
function menuAction(status = 'close') { | |
mheight = themenu.height() + 5; | |
if (status === 'close') { | |
themenu.removeClass('open'); | |
themenu.addClass('closed'); | |
themenu.css('top',-mheight); | |
console.log('close'); | |
} else if (status === 'open') { | |
themenu.removeClass('closed'); | |
themenu.addClass('open'); | |
themenu.css('top','35px'); | |
$('html').on('click', function() { menuAction('close') }); | |
} else if (status === 'desktop') { | |
themenu.removeClass('open'); | |
themenu.removeClass('closed'); | |
themenu.css('top','0px'); | |
} | |
} | |
function stopProp(e) { e.stopPropagation(); } // for click anywhere to close functionality | |
themenu.on('click',stopProp); | |
hamburger.on('click',stopProp); | |
themenu.on('touchstart',stopProp); | |
hamburger.on('touchstart',stopProp); | |
var nav = function nav() { | |
if (theWindow.width() < 788) { | |
menuAction('close'); | |
hamburger.on('click', function() { | |
if (themenu.hasClass('open')) { | |
menuAction('close'); | |
} else { | |
menuAction('open'); | |
} | |
}); | |
} else { | |
menuAction('desktop'); | |
} | |
} | |
nav(); | |
theWindow.resize(nav); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment