toggle location view

This commit is contained in:
Laura Klünder 2017-10-28 18:45:20 +02:00
parent c317938bff
commit 7d483fc5cc

View file

@ -39,15 +39,22 @@ c3nav = {
_locationinput_set: function (elem, location) { _locationinput_set: function (elem, location) {
// set a location input // set a location input
c3nav._locationinput_reset_autocomplete(); c3nav._locationinput_reset_autocomplete();
var $search = $('#search');
if (location === null || location === undefined) { if (location === null || location === undefined) {
elem.removeClass('selected').addClass('empty').data('location', null).data('lastlocation', null); elem.removeClass('selected').addClass('empty').data('location', null).data('lastlocation', null);
elem.find('input').val('').data('origval', null); elem.find('input').val('').data('origval', null);
elem.find('small').text(''); elem.find('small').text('');
if (elem.attr('id') === 'destination-input') {
$search.removeClass('location-view');
}
return; return;
} }
elem.addClass('selected').removeClass('empty').data('location', location).data('lastlocation', location); elem.addClass('selected').removeClass('empty').data('location', location).data('lastlocation', location);
elem.find('input').val(location.title).data('origval', null); elem.find('input').val(location.title).data('origval', null);
elem.find('small').text(location.subtitle); elem.find('small').text(location.subtitle);
if (elem.attr('id') === 'destination-input' && !$search.is('.location-view, .route-view')) {
$search.addClass('location-view');
}
}, },
_locationinput_reset: function (elem) { _locationinput_reset: function (elem) {
// reset this locationinput to its last location // reset this locationinput to its last location
@ -159,6 +166,9 @@ c3nav = {
val_words_key = val_words.join(' '), val_words_key = val_words.join(' '),
$autocomplete = $('#autocomplete'); $autocomplete = $('#autocomplete');
$(this).parent().removeClass('selected').toggleClass('empty', val === '').data('location', null); $(this).parent().removeClass('selected').toggleClass('empty', val === '').data('location', null);
if ($(this).parent().attr('id') === 'destination-input') {
$('#search').removeClass('location-view');
}
$autocomplete.find('.focus').removeClass('focus'); $autocomplete.find('.focus').removeClass('focus');
c3nav.current_locationinput = $(this).parent().attr('id'); c3nav.current_locationinput = $(this).parent().attr('id');