Created
March 31, 2017 03:00
-
-
Save jaotors/b220c4d8df1e54c8eb3e45688639785b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
/** | |
* -------------------------------------------------------------------------- | |
* SEARCH LABAS | |
* -------------------------------------------------------------------------- | |
*/ | |
var searchBtn = function(){ | |
$('.search-btn').click(function(e){ | |
e.preventDefault(); | |
$(this).siblings('.form-search').fadeToggle(); | |
$('.menu-shadow').fadeToggle(); | |
}); | |
$('.close-search').click(function(e) { | |
e.preventDefault(); | |
$('.form-search').fadeOut(); | |
$('.menu-shadow').fadeOut(); | |
}); | |
$('.form-search').on('submit', function(e) { | |
e.preventDefault(); | |
var text = $(this).serializeArray()[0].value.split(' '); | |
$('.search-tag-container').fadeIn(); | |
for (var i = 0; i < text.length; i++) { | |
$('.search-tag-container .search-tag-list').append("<li><a href='#'>" + text[i] + "<i class='fa fa-times'></i></a></li>"); | |
} | |
$('.search-tag-list a').click(function(e) { | |
e.preventDefault(); | |
console.log(); | |
if($('.search-tag-list li').length != 1) { | |
$(this).parent('li').remove(); | |
} else { | |
$('#search-keywords').val(''); | |
$(this).parent('li').remove(); | |
$('.search-tag-container').fadeOut(); | |
} | |
}); | |
}); | |
}(); | |
/** | |
* -------------------------------------------------------------------------- | |
* ELASTIC MENU | |
* -------------------------------------------------------------------------- | |
*/ | |
var isAnimate = false; | |
var menuBtn = function(){ | |
var morphEl = document.getElementById( 'morph-shape' ), | |
pathOpen = morphEl.getAttribute( 'data-morph-open' ), | |
s = Snap( morphEl.querySelector( 'svg' ) ), | |
path = s.select( 'path' ), | |
initialPath = path.attr('d'); | |
$('.menu-btn').click(function() { | |
if(isAnimate) { return false; } | |
isAnimate = true; | |
$('body').addClass('show-menu'); | |
path.animate( { 'path' : pathOpen }, 400, mina.easeinout, function() { isAnimate = false; }); | |
$('.menu-shadow').fadeIn().css('z-index', 4); | |
}); | |
$('#close-button').click(function() { | |
$('.menu-shadow').fadeOut().css('z-index', 1); | |
path.attr( 'd', initialPath ); | |
$('body').removeClass('show-menu'); | |
}); | |
$('.menu-shadow').click(function(){ | |
$('.form-search').fadeOut(); | |
$(this).fadeOut().css('z-index', 1); | |
$('body').removeClass('show-menu'); | |
setTimeout( function() { | |
// reset path | |
path.attr( 'd', initialPath ); | |
}, 300 ); | |
$('.search-tag-container').fadeOut(); | |
$('.search-tag-container li').remove(); | |
$('#search-keywords').val(''); | |
}); | |
}(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment