fixed translation switch bugs

This commit is contained in:
2018-06-20 12:30:44 +02:00
parent dcdd8e0011
commit 30443960ab
11 changed files with 7576 additions and 12171 deletions
+3
View File
@@ -0,0 +1,3 @@
{
"plugins": ["transform-object-rest-spread"]
}
+5 -2
View File
@@ -889,13 +889,15 @@ main#content.mode-text .enonce.nested, main#content.mode-text .item.nested {
main#content.mode-text .opened-link .close-link-btn {
width: 20px;
height: 20px;
margin: 1em 0 -2.1em 61px;
position: relative;
background-color: white;
z-index: 10;
cursor: pointer;
text-align: center; }
main#content.mode-text .opened-link .close-link-btn span {
main#content.mode-text .opened-link .close-link-btn:before {
content: "\1F7AC";
font-style: normal;
font-size: 0.7em;
font-weight: 300; }
@@ -991,7 +993,8 @@ main#content.mode-text .opened-link .close-link-btn {
font-weight: 300; }
.dot .close-link-btn {
cursor: pointer; }
.dot .close-link-btn span {
.dot .close-link-btn:before {
content: "\1F7AC";
font-style: normal;
font-size: 0.7em;
font-weight: 300; }
+1 -12077
View File
File diff suppressed because one or more lines are too long
+1 -1
View File
File diff suppressed because one or more lines are too long
+15 -3
View File
@@ -390,7 +390,7 @@ main#content.mode-text{
// position:relative;
// outline: 1px solid red;
.close-link-btn{
width:20px;
width:20px; height: 20px;
margin:1em 0 -2.1em $margin_left - 9px;
// outline: 1px solid green;
// display:inline-block;
@@ -400,11 +400,17 @@ main#content.mode-text{
// top:0; left:-1em;
cursor: pointer;
text-align: center;
span{
&:before{
content:"\1f7ac";
font-style: normal;
font-size: 0.7em;
font-weight: 300;
}
// span{
// font-style: normal;
// font-size: 0.7em;
// font-weight: 300;
// }
}
}
}
@@ -589,11 +595,17 @@ main#content.mode-connections{
.close-link-btn{
cursor: pointer;
span{
&:before{
content:"\1f7ac";
font-style: normal;
font-size: 0.7em;
font-weight: 300;
}
// span{
// font-style: normal;
// font-size: 0.7em;
// font-weight: 300;
// }
}
&.nested{
+1 -1
View File
@@ -173,7 +173,7 @@ var _Dot = {
vn.dom.querySelector(`nav.links>div[uid="${id}"]`).classList.add('highlight');
}else{
// remove all hilight class
for (link of vn.dom.querySelectorAll('nav.links>div.dot')) {
for (let link of vn.dom.querySelectorAll('nav.links>div.dot')) {
link.classList.remove('highlight');
}
}
+65 -35
View File
@@ -28,14 +28,24 @@ var _Link = {
this.tid = vn.attrs.href;
},
view(vn){
this.tid_known = typeof _dbs.data_byid[_dbs.lang][this.tid] === 'undefined' ? false : true;
// console.log(vn.attrs);
this.tid_known =
typeof vn.attrs.lang === 'undefined'
? false
: typeof _dbs.data_byid[vn.attrs.lang][this.tid] === 'undefined'
? false
: true;
if (!this.tid_known) {
// console.log(`!! in ${this.id}, target id ${this.tid} is unkonwn !!`);
}
if(this.opened && this.tid_known){
// console.log('this.tid', vn.state);
console.log('link vn.state', vn.state);
// traget object
this.tob = Object.assign({"nested":true},_dbs.data_byid[_dbs.lang][this.tid]);
this.tob = Object.assign({"nested":true},_dbs.data_byid[vn.attrs.lang][this.tid]);
// this.tob = Object.assign({'lang':vn.attrs.lang}, this.tob);
console.log('this.tob',this.tob);
return m('div', {'class':'opened-link'},
[
@@ -48,8 +58,8 @@ var _Link = {
vn.state.opened = false;
// return false;
}
}, m('span', m.trust("🗙"))),
typeof _dbs.data_byid[_dbs.lang][this.tid].childs != "undefined"
}),//, m('span', m.trust("🗙"))),
typeof this.tob.childs !== "undefined"
? m(_Enonce, this.tob)
: m(_Item, this.tob)
]
@@ -66,7 +76,7 @@ var _Link = {
vn.state.opened = true;
return false;
}
}, vn.children); // c'est quoi ce vn.children ?
}, vn.children);
}
}
@@ -120,15 +130,15 @@ function parseTextDom(nodes){
}
// recusive fucntion to generate mithril object from information recorded with parseTextDom()
function populateTextDom(n,i){
function populateTextDom(n){
// console.log('populateTextDom : '+i,n);
return n.tag == "#text"
? m.trust(n.text)
: m(
n.tag != 'a' ? n.tag : _Link,
typeof n.attrs != "undefined" ? n.attrs : {},
typeof n.attrs != "undefined" ? Object.assign({"lang":this.attrs.lang},n.attrs) : {},
typeof n.childs != "undefined"
? n.childs.map(populateTextDom)
? n.childs.map(populateTextDom, this)
: typeof n.text != "undefined"
? m.trust(n.text)
: null
@@ -141,31 +151,39 @@ var _Text = {
texthtml:"",
textdom:null,
textchilds:[],
parsetext(){
parsetext(vn){
// if(vn.attrs.nested){debugger;}
// console.log('parsetext', this);
// !! we need to convert markdown to html here because parseTextDom() is recursive through nodes tree
// convert markdown to html
this.texthtml = markdown.render(this.text)
// if(typeof this.text === "undefined"){
// debugger;
// }
this.texthtml = markdown.render(this.text);
// convert html string to virtual dom
this.textdom = new DOMParser().parseFromString(this.texthtml, "text/html");
// get the text nodes (avoid html document extra) and apply some transformations
this.textchilds = parseTextDom(this.textdom.getElementsByTagName('body')[0].childNodes);
},
oninit(vn){
// if(vn.attrs.nested){debugger;}
this.id = vn.attrs.id;
this.text = vn.attrs.text || "";
this.parsetext();
// if(vn.attrs.nested){debugger;}
this.parsetext(vn);
},
onbeforeupdate(vn,old){
// if(vn.attrs.nested){debugger;}
this.text = vn.attrs.text;
this.parsetext();
this.parsetext(vn);
},
view(vn){
// console.log('_Text :: view : '+vn.attrs.slug, vn);
return m('div',
{'class':'text'},
// loop through childNodes list generated by parseTextDom() in init
this.textchilds.map(populateTextDom)
// TODO : pass lang to populateTextDom
this.textchilds.map(populateTextDom, vn)
); // /m.div.text
} // view:
}
@@ -181,6 +199,9 @@ var _Item = {
type:null,
nested:false,
oninit(vn){
// if(vn.attrs.nested){debugger;}
// TODO: what to do with items without text ? as type title for example
// if(typeof vn.attrs.text === 'undefined'){debugger;}
// console.log('vn.attrs', vn.attrs);
this.id = vn.attrs.id;
this.type = vn.attrs.type;
@@ -214,7 +235,9 @@ var _Item = {
}, m.trust(markdown.renderInline(this.type)))
: null,
// create text node
m(_Text, {'text':this.text, 'id':this.id}),
typeof vn.attrs.text !== "undefined"
? m(_Text, {'text':this.text, 'id':this.id, 'lang':vn.attrs.lang})
: null,
// add children (only if not nested)
// typeof vn.attrs.childs !== 'undefined' && !this.nested
// ? vn.attrs.childs.map(c => { return m(_Item, c); })
@@ -231,43 +254,49 @@ var _Item = {
// /_____/_/ /_/\____/_/ /_/\___/\___/
var _Enonce = {
partid:null,
id:null,
// id:null,
title:null,
text:null,
nested:false,
childs:[],
// text:null,
// nested:false,
// childs:[],
oninit(vn){
// if(vn.attrs.nested){debugger;}
// // console.log('Enonce on init', vn);
this.partid = vn.attrs.partid;
this.id = vn.attrs.id;
// this.id = vn.attrs.id;
this.title = vn.attrs.title || "";
this.text = vn.attrs.text;
this.childs = vn.attrs.childs || [];
this.nested = vn.attrs.nested || false;
// this.text = vn.attrs.text;
// this.childs = vn.attrs.childs || [];
// this.nested = vn.attrs.nested || false;
this.dottype = vn.attrs.dottype || "no-dottype";
},
onbeforeupdate(vn, old) {
// console.log(vn.attrs.childs);
this.title = vn.attrs.title || "";
this.text = vn.attrs.text;
this.childs = vn.attrs.childs || [];
this.nested = vn.attrs.nested || false;
// this.text = vn.attrs.text;
// this.childs = vn.attrs.childs || [];
// this.nested = vn.attrs.nested || false;
// if(vn.attrs.id == '1d1') console.log('_Enonce UPDATE, text :', vn.attrs.text);
},
view(vn){
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
// if(vn.attrs.nested){
// console.log('ennonce vn.attrs', vn.attrs);
// }
return m("section", {
'id' :this.id,
'class' :`enonce${this.nested ? ' nested':''} ${this.dottype}`
'id' :vn.attrs.id,
'class' :`enonce${vn.attrs.nested ? ' nested':''} ${this.dottype}`
},
[
// create title node (only if not nested)
!this.nested ? m("h2", {}, m.trust(markdown.renderInline(this.title))) : null,
!vn.attrs.nested ? m("h2", {}, m.trust(markdown.renderInline(this.title))) : null,
// create text node
m(_Text, {'text':this.text, 'id':this.id}),
m(_Text, {'text':vn.attrs.text, 'id':vn.attrs.id, 'nested':vn.attrs.nested}),
// add children (only if not nested)
typeof this.childs !== 'undefined' && !this.nested
? this.childs.map(c => { return m(_Item, c); })
typeof vn.attrs.childs !== 'undefined' && !vn.attrs.nested
? vn.attrs.childs.map(c => {
c.lang = vn.attrs.lang;
return m(_Item, c);
})
: null
])
}
@@ -315,6 +344,7 @@ var _Part = {
break;
default:
// or build structure
e.lang = vn.attrs.lang;
return m(_Enonce, Object.assign({"partid":vn.attrs.id},e));
}
})
@@ -343,7 +373,6 @@ var _Intro = {
}
}
// ______ __
// /_ __/__ _ __/ /_
// / / / _ \| |/_/ __/
@@ -364,9 +393,10 @@ module.exports = {
// // i18next.changeLanguage(vn.attrs.lang);
// },
view(vn){
// console.log('_ModeText view : _dbs.data', _dbs.data);
// console.log('_ModeText view', vn.attrs.lang);
return m('main', {id:"content", 'class':'mode-text'}, _dbs.data[vn.attrs.lang].map((p) => {
// console.log("MAP _dbs", p);
p.lang = vn.attrs.lang;
if(p.id == 'intro'){
return m(_Intro,p);
}else{
+3 -3
View File
@@ -96,7 +96,7 @@ module.exports = {
xobj.addEventListener("progress", function(oEvent){
if (oEvent.lengthComputable) {
var percentComplete = oEvent.loaded / oEvent.total * 100;
console.log(lc+' loaded :',percentComplete);
// console.log(lc+' loaded :',percentComplete);
this.loaded_by_file[lc] = percentComplete;
var totalloaded = 0;
for (var i = 0; i < this.langs.length; i++) {
@@ -181,7 +181,7 @@ module.exports = {
// console.log(_db[p][e][c]);
if(this.data[l][p].enonces[e].childs[c].childs[cc].id){
cc_id = this.data[l][p].enonces[e].childs[c].childs[cc].id;
console.log('cc_id', cc_id);
// console.log('cc_id', cc_id);
// guess the type from the id
this.data[l][p].enonces[e].childs[c].childs[cc].dottype = this.setupType(cc_id);
// breadcrumb (full tree title)
@@ -207,7 +207,7 @@ module.exports = {
if(m){
m.shift();
// removing undefined
m_clean = [];
let m_clean = [];
for (let i = 0; i < m.length; i++) {
if(typeof m[i] !== 'undefined'){
m_clean.push(m[i]);
+7417
View File
File diff suppressed because it is too large Load Diff
+13 -8
View File
@@ -6,19 +6,24 @@
"author": "Bachir Soussi Chiadmi <bachir@g-u-i.me>",
"license": "GPL-3.0",
"devDependencies": {
"babel-core": "^6.26.3",
"babel-loader": "^7.1.4",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-es2015": "^6.24.1",
"css-loader": "^0.28.11",
"extract-text-webpack-plugin": "^3.0.2",
"uglifyjs-webpack-plugin": "^1.1.6",
"webpack": "^3.10.0"
"file-loader": "^1.1.11",
"node-sass": "^4.9.0",
"sass-loader": "^6.0.7",
"uglifyjs-webpack-plugin": "^1.2.5",
"webpack": "^3.12.0"
},
"dependencies": {
"css-loader": "^0.28.0",
"file-loader": "^1.1.6",
"jquery": "^3.2.1",
"markdown-it": "^8.3.1",
"markdown-it": "^8.4.1",
"markdown-it-footnote": "^3.0.1",
"mithril": "^1.1.1",
"node-sass": "^4.5.3",
"normalize.css": "^8.0.0",
"sass-loader": "^6.0.3"
"normalize.css": "^8.0.0"
}
}
+52 -41
View File
@@ -21,6 +21,17 @@ module.exports = {
module: {
rules: [
/* your other rules for JavaScript transpiling go in here */
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: ['es2015'],
// plugins: [require('@babel/plugin-proposal-object-rest-spread')]
}
}
},
{
// regular css files
test: /\.css$/,
@@ -35,7 +46,7 @@ module.exports = {
// fonts
test: /\.(eot|svg|ttf|woff|woff2)$/,
use: "file-loader?name=fonts/[name].[ext]"
},
}
]
},
plugins: [
@@ -43,46 +54,46 @@ module.exports = {
// define where to save the file
filename: '[name].css', allChunks: true,
}),
// new UglifyJsPlugin({
// sourceMap: true,
// parallel:4,
// uglifyOptions: {
// ecma: 8,
// // disable most of compress to gain in compilation speed
// // https://slack.engineering/keep-webpack-fast-a-field-guide-for-better-build-performance-f56a5995e8f1
// compress: {
// arrows: false,
// booleans: false,
// // cascade: false,
// collapse_vars: false,
// comparisons: false,
// computed_props: false,
// hoist_funs: false,
// hoist_props: false,
// hoist_vars: false,
// if_return: false,
// inline: false,
// join_vars: false,
// keep_infinity: true,
// loops: false,
// negate_iife: false,
// properties: false,
// reduce_funcs: false,
// reduce_vars: false,
// sequences: false,
// side_effects: false,
// switches: false,
// top_retain: false,
// toplevel: false,
// typeofs: false,
// unused: false,
// conditionals: false,
// dead_code: true,
// evaluate: false,
// warnings: false
// },
// }
// })
new UglifyJsPlugin({
sourceMap: true,
parallel:4,
uglifyOptions: {
ecma: 8,
// disable most of compress to gain in compilation speed
// https://slack.engineering/keep-webpack-fast-a-field-guide-for-better-build-performance-f56a5995e8f1
compress: {
arrows: false,
booleans: false,
// cascade: false,
collapse_vars: false,
comparisons: false,
computed_props: false,
hoist_funs: false,
hoist_props: false,
hoist_vars: false,
if_return: false,
inline: false,
join_vars: false,
keep_infinity: true,
loops: false,
negate_iife: false,
properties: false,
reduce_funcs: false,
reduce_vars: false,
sequences: false,
side_effects: false,
switches: false,
top_retain: false,
toplevel: false,
typeofs: false,
unused: false,
conditionals: false,
dead_code: true,
evaluate: false,
warnings: false
},
}
})
],
watch: true
};