c3nav.js load locations before initiating anything else
This commit is contained in:
parent
d4f6906a62
commit
cb452643df
1 changed files with 17 additions and 14 deletions
|
@ -30,6 +30,19 @@
|
||||||
|
|
||||||
c3nav = {
|
c3nav = {
|
||||||
init: function () {
|
init: function () {
|
||||||
|
$.getJSON('/api/locations/?searchable', function (data) {
|
||||||
|
for (var i = 0; i < data.length; i++) {
|
||||||
|
var location = data[i];
|
||||||
|
location.elem = c3nav._build_location_html(location);
|
||||||
|
location.title_words = location.title.toLowerCase().split(/\s+/);
|
||||||
|
location.match = ' ' + location.title_words.join(' ') + ' ';
|
||||||
|
c3nav.locations.push(location);
|
||||||
|
c3nav.locations_by_id[location.id] = location;
|
||||||
|
}
|
||||||
|
c3nav.continue_init();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
continue_init: function() {
|
||||||
c3nav.init_map();
|
c3nav.init_map();
|
||||||
|
|
||||||
$('.locationinput').data('location', null);
|
$('.locationinput').data('location', null);
|
||||||
|
@ -270,21 +283,11 @@ c3nav = {
|
||||||
},
|
},
|
||||||
|
|
||||||
// location inputs
|
// location inputs
|
||||||
|
locations: [],
|
||||||
|
locations_by_id: {},
|
||||||
|
current_locationinput: null,
|
||||||
|
last_match_words_key: null,
|
||||||
init_locationinputs: function () {
|
init_locationinputs: function () {
|
||||||
c3nav.locations = [];
|
|
||||||
c3nav.locations_by_id = {};
|
|
||||||
c3nav.current_locationinput = null;
|
|
||||||
c3nav._last_match_words_key = null;
|
|
||||||
$.getJSON('/api/locations/?searchable', function (data) {
|
|
||||||
for (var i = 0; i < data.length; i++) {
|
|
||||||
var location = data[i];
|
|
||||||
location.elem = c3nav._build_location_html(location);
|
|
||||||
location.title_words = location.title.toLowerCase().split(/\s+/);
|
|
||||||
location.match = ' ' + location.title_words.join(' ') + ' ';
|
|
||||||
c3nav.locations.push(location);
|
|
||||||
c3nav.locations_by_id[location.id] = location;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.locationinput input').on('input', c3nav._locationinput_input)
|
$('.locationinput input').on('input', c3nav._locationinput_input)
|
||||||
.on('blur', c3nav._locationinput_blur)
|
.on('blur', c3nav._locationinput_blur)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue