demarches-normaliennes/app/assets/javascripts/old_design/search.js

60 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-03-30 17:00:35 +02:00
$(document).on('turbolinks:load', init_search_anim);
2016-11-29 09:56:11 +01:00
function init_search_anim(){
$("#search-area").on('click', search_fadeIn);
2016-11-29 09:56:11 +01:00
}
function search_fadeIn(){
var search_area = $("#search-area");
2017-04-04 16:15:33 +02:00
var body_dom = $('body');
var positions = search_area.position();
var width = search_area.width();
search_area.css('position', 'fixed');
search_area.css('top', positions.top + $('.navbar').height());
search_area.css('left', positions.left);
search_area.css('z-index', 300);
search_area.css('width', width);
search_area.find('#q').animate({ height: '50px' });
search_area.find('#search-button').animate({ height: '50px' });
2017-04-04 16:15:33 +02:00
body_dom.append(search_area);
$('#mask-search').fadeIn(200);
2017-04-04 16:15:33 +02:00
var body_width = body_dom.width();
var search_area_width = body_width/2.5;
search_area.animate({
width: search_area_width,
left: (body_width/2 - search_area_width/2 + 40)
}, 400, function() {
search_area.off();
$("#search-area input").focus();
2017-04-04 16:15:33 +02:00
$('#mask-search').on('click', search_fadeOut)
2017-04-04 16:15:33 +02:00
});
2016-11-29 09:56:11 +01:00
}
function search_fadeOut(){
var search_area = $("#search-area");
2016-11-29 09:56:11 +01:00
$('#mask-search').fadeOut(200);
2016-11-29 09:56:11 +01:00
2017-04-04 16:15:33 +02:00
search_area.fadeOut(200, function(){
search_area.css('position', 'static');
search_area.css('top', '');
search_area.css('left', '');
search_area.css('z-index', '');
search_area.css('width', 'auto');
search_area.find('#q').css('height', 34);
search_area.find('#search-button').css('height', 34);
2016-11-29 09:56:11 +01:00
2017-04-04 16:15:33 +02:00
$('#search-block').append(search_area);
search_area.fadeIn(200);
2016-11-29 09:56:11 +01:00
2017-04-04 16:15:33 +02:00
init_search_anim();
});
2016-11-29 09:56:11 +01:00
2016-12-02 19:05:24 +01:00
}