|
|
@@ -320,14 +320,23 @@ $(document).ready(function() {
|
|
|
cardDiv.data('id', structure.id);
|
|
|
|
|
|
if (structure.practices !== null) {
|
|
|
- structure.practices.forEach(function (practice) {
|
|
|
+ let i = 1;
|
|
|
+ for (const practice of structure.practices) {
|
|
|
let tag = practiceTagModel.clone();
|
|
|
- tag.text(practicesFr[practice]);
|
|
|
+
|
|
|
+ if (i <= 3) {
|
|
|
+ tag.text(practicesFr[practice]);
|
|
|
+ } else {
|
|
|
+ tag.text('+ ' + (practice.length - 3) + ' ...');
|
|
|
+ }
|
|
|
tag.removeClass('structure-practice-model')
|
|
|
tag.addClass('structure-practice')
|
|
|
tag.show();
|
|
|
practiceTagModel.parent().append(tag);
|
|
|
- });
|
|
|
+
|
|
|
+ if (i > 3) { break; }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (structure.logoId) {
|
|
|
@@ -582,13 +591,14 @@ $(document).ready(function() {
|
|
|
resultDiv.empty();
|
|
|
}
|
|
|
inputName.css("cursor", "inherit");
|
|
|
+ inputName.removeClass('loading');
|
|
|
}
|
|
|
|
|
|
document.click(function() {
|
|
|
hideCityResults();
|
|
|
});
|
|
|
|
|
|
- $(document).keyup(function(e) {
|
|
|
+ $(document).keydown(function(e) {
|
|
|
if(e.key === "Escape") {
|
|
|
hideCityResults();
|
|
|
}
|
|
|
@@ -601,6 +611,25 @@ $(document).ready(function() {
|
|
|
e.stopPropagation();
|
|
|
});
|
|
|
|
|
|
+ inputName.keypress(function (e) {
|
|
|
+ if (e.key === "Enter") {
|
|
|
+
|
|
|
+ let results = resultDiv.children('.city-search-item');
|
|
|
+
|
|
|
+ if (inputName.hasClass('loading')) {
|
|
|
+ // A request is currently running, enter will select the first result when the request will complete
|
|
|
+ inputName.addClass('enter-pressed');
|
|
|
+ e.preventDefault();
|
|
|
+ } else if (results.length > 0) {
|
|
|
+ // If results are displayed and no request is currently running, enter select the first result
|
|
|
+ setNewLocation(results[0].text(), results[0].data("x"), results[0].data("y"))
|
|
|
+ e.stopPropagation();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ inputName.addClass('loading');
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
resultDiv.on('click', '.city-search-item', function (e) {
|
|
|
setNewLocation($(this).text(), $(this).data("x"), $(this).data("y"))
|
|
|
e.stopPropagation();
|
|
|
@@ -627,9 +656,10 @@ $(document).ready(function() {
|
|
|
|
|
|
inputLat.val('');
|
|
|
inputLong.val('');
|
|
|
- loadingDiv.show();
|
|
|
- resultDiv.empty();
|
|
|
resultDropdownDiv.show();
|
|
|
+ if (resultDiv.children('.city-search-item').length === 0) {
|
|
|
+ loadingDiv.show()
|
|
|
+ }
|
|
|
noResultDiv.hide();
|
|
|
|
|
|
$.ajax({
|
|
|
@@ -641,19 +671,34 @@ $(document).ready(function() {
|
|
|
.done(function(res) {
|
|
|
console.log(res);
|
|
|
let features = res.features;
|
|
|
+ resultDiv.empty();
|
|
|
+
|
|
|
if (!features.length > 0) {
|
|
|
noResultDiv.show();
|
|
|
- return;
|
|
|
+ resultDiv.hide();
|
|
|
+ } else if (inputName.hasClass('enter-pressed')) {
|
|
|
+ // the enter key has been pressed before the request terminate
|
|
|
+ let f = features[0];
|
|
|
+ setNewLocation(
|
|
|
+ f.properties.name + ' (' + f.properties.postcode + ')',
|
|
|
+ f.geometry.coordinates[0],
|
|
|
+ f.geometry.coordinates[1]
|
|
|
+ )
|
|
|
+ resultDiv.hide();
|
|
|
+ } else {
|
|
|
+ for (const f of features) {
|
|
|
+ let x = f.geometry.coordinates[0];
|
|
|
+ let y = f.geometry.coordinates[1];
|
|
|
+ let name = f.properties.name;
|
|
|
+ let postcode = f.properties.postcode;
|
|
|
+ let span = '<div class="city-search-item" data-x="' + x + '" data-y="' + y + '">' + name + ' (' + postcode + ')</div>';
|
|
|
+ resultDiv.append(span);
|
|
|
+ }
|
|
|
+ resultDiv.show();
|
|
|
}
|
|
|
- features.forEach(function (f) {
|
|
|
- let x = f.geometry.coordinates[0];
|
|
|
- let y = f.geometry.coordinates[1];
|
|
|
- let name = f.properties.name;
|
|
|
- let postcode = f.properties.postcode;
|
|
|
- let span = '<div class="city-search-item" data-x="' + x + '" data-y="' + y + '">' + name + ' (' + postcode + ')</div>';
|
|
|
- resultDiv.append(span);
|
|
|
- });
|
|
|
- loadingDiv.hide();
|
|
|
+ inputName.removeClass('loading');
|
|
|
+ inputName.removeClass('enter-pressed');
|
|
|
+ loadingDiv.hide()
|
|
|
})
|
|
|
.fail(function(e) {
|
|
|
console.error(e);
|
|
|
@@ -743,6 +788,30 @@ $(document).ready(function() {
|
|
|
instagramLink.hide();
|
|
|
}
|
|
|
|
|
|
+ let practiceTagModel = structureFrameDetails.find('.structure-practice-model').first();
|
|
|
+ let practiceContainer = practiceTagModel.parent();
|
|
|
+ practiceContainer.children('.structure-practice').remove();
|
|
|
+
|
|
|
+ if (structure.practices !== null) {
|
|
|
+ let i = 1;
|
|
|
+ for (const practice of structure.practices) {
|
|
|
+ let tag = practiceTagModel.clone();
|
|
|
+
|
|
|
+ if (i <= 3) {
|
|
|
+ tag.text(practicesFr[practice]);
|
|
|
+ } else {
|
|
|
+ tag.text('+ ' + (practice.length - 3) + ' ...');
|
|
|
+ }
|
|
|
+ tag.removeClass('structure-practice-model')
|
|
|
+ tag.addClass('structure-practice')
|
|
|
+ tag.show();
|
|
|
+ practiceContainer.append(tag);
|
|
|
+
|
|
|
+ if (i > 3) { break; }
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
let contact = structureFrameDetails.find('.contact').first();
|
|
|
contact.find('.address').first().text(
|
|
|
[structure.streetAddress, structure.postalCode, structure.addressCity].join(" ")
|
|
|
@@ -823,6 +892,7 @@ $(document).ready(function() {
|
|
|
timeout : 5000
|
|
|
})
|
|
|
.done(function(structure) {
|
|
|
+ structure.practices = structure.practices !== null ? structure.practices.split(",") : [];
|
|
|
populateDetailsView(structure)
|
|
|
|
|
|
structureFrameDetails.find('.please-wait').first().hide();
|