Subversion Repositories eFlore/Applications.cel

Compare Revisions

Ignore whitespace Rev 3848 → Rev 3849

/trunk/widget/modules/saisie/squelettes/js/tb-geoloc/js/Geoloc.js
155,9 → 155,7
this.initMap();
this.handleCoordinates();
this.onCoordinates();
if('point' === this.geometryFilter) {
this.initSearchLocality();
}
this.initSearchLocality();
};
 
Geoloc.prototype.initMap = function() {
284,7 → 282,7
const lthis = this;
// move marker on click
$(this.map).off('click').on('click', function(evt) {
lthis.handleNewLocation(evt.latlng);
lthis.handleNewLocation(evt.originalEvent.latlng);
});
// move marker on drag
$(this.map.marker).off('dragend').on('dragend', function() {
322,12 → 320,20
coordinates = this.formatCoordinates(coordinates);
 
if(!!coordinates && !!coordinates.lat && coordinates.lng) {
this.zoom = 20;
this.setMapCoordinates(coordinates);
 
if('point' === this.geometryFilter) {
this.createDraggableMarker();
this.handleMarkerEvents();
}
this.getLocationInfo(coordinates, polyline);
 
if (
('rue' === this.geometryFilter && 0 < polyline.length) ||
('point' === this.geometryFilter && 0 === polyline.length)
) {
this.getLocationInfo(coordinates, polyline);
}
}
};
 
353,7 → 359,7
Geoloc.prototype.setMapCoordinates = function (coordinates) {
this.coordinates = coordinates;
// updates map
this.map.setView(coordinates);
this.map.setView(coordinates,this.zoom);
};
 
Geoloc.prototype.createDraggableMarker = function() {
504,7 → 510,10
'lng' : localityData.lon
};
 
this.map.removeControl(this.drawControl);
if ('point' === this.geometryFilter) {
this.map.removeControl(this.drawControl);
}
this.zoom = 18;
this.handleNewLocation(coordinates);
}
};
/trunk/widget/modules/saisie/squelettes/js/tb-geoloc/js/modules/Locality.js
40,24 → 40,33
 
this.toggleCloseButton(false);
this.places.off('input').on('input', debounce(this.launchSearch.bind(this), 500));
this.places.off('keydown').on('keydown', evt => {
const suggestionEl = $('.tb-places-suggestion');
this.places.off('keydown').on('keydown', debounce(this.handlePlacesKeydown.bind(this), 500));
}
};
 
if (27 === evt.keyCode || ESC_KEY_STRING.test(evt.key)) {
evt.preventDefault();
TbPlaces.prototype.handlePlacesKeydown = function(evt) {
const suggestionEl = $('.tb-places-suggestion'),
isEscape = 27 === evt.keyCode || ESC_KEY_STRING.test(evt.key),
isArrowDown = 40 === evt.keyCode || 'ArrowDown' === evt.key,
isEnter = 13 === evt.keyCode || 'Enter' === evt.key;
 
this.placesCloseButton.trigger('click');
this.places.focus();
} else if((40 === evt.keyCode || 'ArrowDown' === evt.key) && 0 < suggestionEl.length) {
evt.preventDefault();
if (isEscape || isArrowDown || isEnter) {
evt.preventDefault();
 
if (isEscape) {
this.placesCloseButton.trigger('click');
this.places.focus();
} else if(isArrowDown || isEnter) {
if ( 0 < suggestionEl.length) {
suggestionEl.first().focus();
} else {
this.launchSearch();
}
});
}
}
};
 
TbPlaces.prototype.launchSearch = function (evt) {
TbPlaces.prototype.launchSearch = function () {
if (!!this.places.val()) {
const url = NOMINATIM_OSM_URL+'search',
params = {'q': this.places.val()};
70,6 → 79,7
success: this.nominatimOsmResponseCallback.bind(this),
error: () => {
this.placeLabel.removeClass('loading');
this.handleSearchError();
}
});
}
83,6 → 93,8
this.toggleCloseButton();
this.resetOnClick();
this.onSuggestionSelected();
} else {
this.handleSearchError();
}
};
 
165,8 → 177,21
$('.tb-places-search-icon').toggleClass('hidden', isShow);
};
 
TbPlaces.prototype.handleSearchError = function() {
this.resetPlacesSearch();
if (0 === $('#tb-places-error').length) {
this.places.closest('#tb-places-zone').after(
`<span id="tb-places-error" class="error mb-3 mt-3">
Votre recherche n’a rien donné.<br>veuillez modifier votre recherche ou rechercher votre station directement sur la carte.
</span>`
);
setTimeout(function() {
$('#tb-places-error').remove();
}, 5000);
}
};
 
TbPlaces.prototype.resetPlacesSearch = function() {
this.places.val('');
this.toggleCloseButton(false);
this.placesResultsContainer.addClass('hidden');
this.placesResults.empty();