Gkey improved. New pages. Home improved based in startbootstrap

This commit is contained in:
vjrj 2017-12-10 03:32:12 +01:00
parent 6497278755
commit b6b8f893e3
19 changed files with 782 additions and 269 deletions

View file

@ -1,47 +1,52 @@
import React from 'react';
import { Meteor } from 'meteor/meteor';
import { ReactiveVar } from 'meteor/reactive-var';
import i18n from 'i18next';
const gmapkey = new ReactiveVar();
Meteor.startup(function() {
Meteor.call('getMapKey', function (error, key) {
if (typeof key !== 'undefined') {
// console.log(key);
gmapkey.set(key);
} else {
callback(error, null)
}
})
});
import { Tracker } from 'meteor/tracker';
class GkeysC {
constructor() {
this.state = { init: false };
this.gmapkey = new ReactiveVar(null);
const self = this;
this.callbacks = [];
Meteor.startup(() => {
Meteor.call('getMapKey', (error, key) => {
const script = document.createElement('script');
script.type = 'text/javascript';
script.onload = () => {
self.gmapkey.set(key);
console.log('GMaps script just loaded');
self.doCallbacks(key);
};
// https://stackoverflow.com/questions/28130114/google-maps-places-autocomplete-language-output
script.src = `https://maps.googleapis.com/maps/api/js?key=${key}&libraries=places&language=${i18n.language}`;
document.body.appendChild(script);
});
});
}
doCallbacks(key) {
for (let i = 0; i < this.callbacks.length; i += 1) {
this.callbacks[i](null, key);
}
this.callbacks = [];
}
load(callback) {
if (this.state.init) {
// already loaded
callback(null, gmapkey.get());
} else {
this.state.init = true;
Meteor.autorun(function() {
var key = gmapkey.get();
if (typeof key !== 'undefined') {
var script = document.createElement('script');
script.type = 'text/javascript';
script.onload = function () {
// console.log(key);
callback(null, key);
}.bind(this);
// https://stackoverflow.com/questions/28130114/google-maps-places-autocomplete-language-output
script.src = `https://maps.googleapis.com/maps/api/js?key=${key}&libraries=places&language=${i18n.language}`
document.body.appendChild(script);
}
}.bind(this));
}
this.callbacks.push(callback);
Tracker.autorun((computation) => {
const key = this.gmapkey.get();
if (key) {
// already loaded
console.log(`GMaps already loaded: ${key}`);
this.doCallbacks(key);
computation.stop();
} else {
console.log('Waiting for the gkey');
}
});
}
}
export let Gkeys = new GkeysC();
const Gkeys = new GkeysC();
export default Gkeys;

View file

@ -37,7 +37,8 @@ const cacheOptions = {
i18nOpts.cache = cacheOptions;
i18nOpts.detection = detectorOptions;
i18nOpts.react = {
wait: true
wait: true,
defaultTransParent: 'span'
// https://react.i18next.com/components/i18next-instance.ht
/* bindI18n: 'languageChanged loaded',
bindStore: 'added removed',