in my way to display full titles on connection mode
This commit is contained in:
@@ -27,75 +27,12 @@ var _Dot = {
|
||||
links:null,
|
||||
parents:[],
|
||||
lang:_dbs.lang,
|
||||
setupDotType(vn){
|
||||
// var rx_id = /^(\d)(app|agd|\d\d|pr|ad|ap|c|p|d|a)(cd|sc|\d\d|d|c|a|l|p|\d)?(e|\d|sc)?(d|c|a|sc)?$/;
|
||||
// var m = this.id.match(rx_id);
|
||||
// if(m){
|
||||
// switch(true){
|
||||
// case /^\d{2}$/.test(m[2]):
|
||||
// switch(true){
|
||||
// case /^cd$/.test(m[3]) : this.dottype = 'corollaire-demo'; break;
|
||||
// case /^sc$/.test(m[3]) : this.dottype = 'scolie'; break;
|
||||
// case /^d$/.test(m[3]) : this.dottype = 'demonstration'; break;
|
||||
// case /^c$/.test(m[3]) :
|
||||
// switch(true){
|
||||
// case /^sc$/.test(m[4]): this.dottype = 'scolie'; break;
|
||||
// case /^d$/.test(m[4]) : this.dottype = 'demonstration'; break;
|
||||
// case /^d$/.test(m[5]) : this.dottype = 'demonstration'; break;
|
||||
// case /^sc$/.test(m[5]): this.dottype = 'scolie'; break;
|
||||
// case /^\d$/.test(m[4]): this.dottype = 'corollaire'; break;
|
||||
// case !m[4] : this.dottype = 'corollaire'; break;
|
||||
// }
|
||||
// break;
|
||||
// case /^a$/.test(m[3]) : this.dottype = 'axiom'; break;
|
||||
// case /^l$/.test(m[3]) :
|
||||
// switch(true){
|
||||
// case /^d$/.test(m[5]) : this.dottype = 'demonstration'; break;
|
||||
// case /^sc$/.test(m[5]): this.dottype = 'scolie'; break;
|
||||
// case !m[5] : this.dottype = 'lemme'; break;
|
||||
// }
|
||||
// break;
|
||||
// case /^p$/.test(m[3]) : this.dottype = 'postulat'; break;
|
||||
// case /^\d$/.test(m[3]) : this.dottype = '??'; break;
|
||||
// case /^\d{2}$/.test(m[3]) : this.dottype = '??'; break;
|
||||
// case !m[3] : this.dottype = 'proposition'; break;
|
||||
// }
|
||||
// break;
|
||||
// case /^app|ap$/.test(m[2]) : this.dottype = 'appendice'; break;
|
||||
// case /^agd$/.test(m[2]) : this.dottype = 'def-gen-affect'; break;
|
||||
// case /^pr$/.test(m[2]) : this.dottype = 'preface'; break;
|
||||
// case /^ad$/.test(m[2]) :
|
||||
// switch(true){
|
||||
// case /^e$/.test(m[4]) :this.dottype = 'explication'; break;
|
||||
// case !m[4] :this.dottype = 'def-affect'; break;
|
||||
// }
|
||||
// break;
|
||||
// case /^c$/.test(m[2]) : this.dottype = 'chapitre'; break;
|
||||
// case /^p$/.test(m[2]) : this.dottype = 'postulat'; break;
|
||||
// case /^d$/.test(m[2]) :
|
||||
// switch(true){
|
||||
// case /^e$/.test(m[4]) : this.dottype = 'explication'; break;
|
||||
// case !m[4] : this.dottype = 'definition'; break;
|
||||
// }
|
||||
// break;
|
||||
// case /^a$/.test(m[2]) : this.dottype = 'axiom'; break;
|
||||
// }
|
||||
// // }
|
||||
// }
|
||||
// console.log(`${this.id} -> ${this.dottype}`,m);
|
||||
//
|
||||
// // TODO: fix false ids
|
||||
// // we have app and ap for appendice (1app | 4ap)
|
||||
// // 213def ??
|
||||
// // 209cd demo ou corollaire-demo ??
|
||||
// // 210csc scolie ou corollaire-scolie ??
|
||||
// // 213l1d demo ??
|
||||
},
|
||||
setupTitle(vn){
|
||||
this.title = vn.attrs.title;
|
||||
if(!this.title){
|
||||
this.title = this.type;
|
||||
}
|
||||
this.title = markdown.renderInline(this.title);
|
||||
},
|
||||
setuptext(vn){
|
||||
// console.log('setuptext', vn);
|
||||
@@ -113,16 +50,15 @@ var _Dot = {
|
||||
|
||||
},
|
||||
oninit(vn){
|
||||
// console.log('Dot init : vn',vn);
|
||||
this.id = vn.attrs.id;
|
||||
this.type = vn.attrs.type;
|
||||
// this.title = vn.attrs.title || "title";
|
||||
// this.setupDotType(vn);
|
||||
this.dottype = vn.attrs.dottype;
|
||||
|
||||
this.setupTitle(vn);
|
||||
this.setuptext(vn);
|
||||
|
||||
console.log(`${this.id} -> ${this.dottype}`);
|
||||
// console.log(`${this.id} -> ${this.dottype}`);
|
||||
|
||||
if(typeof vn.attrs.active !== 'undefined')
|
||||
this.active = vn.attrs.active;
|
||||
@@ -150,6 +86,7 @@ var _Dot = {
|
||||
if(this.lang != _dbs.lang){
|
||||
this.lang = _dbs.lang;
|
||||
this.setuptext(vn);
|
||||
this.setupTitle(vn);
|
||||
}
|
||||
},
|
||||
view(vn){
|
||||
@@ -158,15 +95,17 @@ var _Dot = {
|
||||
// console.log('_Dot view '+this.id+' parents :',this.parents);
|
||||
var dot_content = [
|
||||
// links to
|
||||
// TODO: add dottype class to nested dots
|
||||
this.links.to.length
|
||||
? m('nav', {'class':'links to'}, this.links.to.map(id => {
|
||||
// console.log(id);
|
||||
if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
|
||||
var obj = _dbs.data_byid[_dbs.lang][id];
|
||||
// console.log('link to : obj', obj);
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
'text':obj.text,
|
||||
'dottype':obj.dottype,
|
||||
'type':obj.type,
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
@@ -175,7 +114,7 @@ var _Dot = {
|
||||
}
|
||||
})
|
||||
)
|
||||
: null,
|
||||
: null, // if no links to, add nothing
|
||||
// id
|
||||
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
// bullet
|
||||
@@ -214,12 +153,14 @@ var _Dot = {
|
||||
// links from
|
||||
this.links.from.length
|
||||
? m('nav', {'class':'links from'}, this.links.from.map(id => {
|
||||
// retrun a dot
|
||||
// TODO: add dottype class to nested dots
|
||||
var obj = _dbs.data_byid[_dbs.lang][id];
|
||||
// console.log('link from : obj', obj);
|
||||
// return a dot
|
||||
return m(_Dot, {
|
||||
"id":id,
|
||||
'text':_dbs.data_byid[_dbs.lang][id].text,
|
||||
'type':'',
|
||||
'text':obj.text,
|
||||
'dottype':obj.dottype,
|
||||
'type':obj.type,
|
||||
// passe the memory of crossed dots plus the current one
|
||||
'parents':vn.state.parents.concat([vn.state.id]),
|
||||
// activate link only if not in parents (already went through it)
|
||||
@@ -227,14 +168,20 @@ var _Dot = {
|
||||
});
|
||||
})
|
||||
)
|
||||
: null
|
||||
: null, // if no links from, add nothing
|
||||
];
|
||||
}else{
|
||||
// preview dot
|
||||
var dot_content = [
|
||||
// m('span', {'class':'id'}, this.id), // this.type+' '+
|
||||
// m('span', {'class':'bullet'}, m.trust('•')),
|
||||
m('span', {'class':'title'}, m.trust(this.title)),
|
||||
m('span', {
|
||||
'class':'title',
|
||||
onclick(e){
|
||||
// TODO: animate openening (text and links separatly)
|
||||
vn.state.opened = true;
|
||||
}
|
||||
}, m.trust(this.title)), // TODO: on nested dot add full description : Part 1, Prop 8, scolie
|
||||
m('p', {
|
||||
'class':'summary',
|
||||
onclick(e){
|
||||
@@ -247,7 +194,11 @@ var _Dot = {
|
||||
|
||||
return m('div',{
|
||||
'uid':this.id,
|
||||
'class':`dot ${this.dottype}`
|
||||
'class':`dot ${this.dottype}`,
|
||||
// onclick(e){
|
||||
// // TODO: animate openening (text and links separatly)
|
||||
// vn.state.opened = true;
|
||||
// }
|
||||
},
|
||||
dot_content
|
||||
);
|
||||
@@ -352,7 +303,7 @@ var _Enonce = {
|
||||
// if(vn.attrs.id == '1d1') console.log('_Enonce VIEW, text :', vn.attrs.text);
|
||||
return [
|
||||
// create dot
|
||||
m(_Dot, {"id":this.id, 'text':this.text,'type':this.title, 'dottype':this.dottype}),
|
||||
m(_Dot, {"id":this.id, 'text':this.text, 'type':this.title, 'dottype':this.dottype}),
|
||||
// addd children
|
||||
this.childs.map(c => { return m(_Child, c); })
|
||||
]
|
||||
|
||||
@@ -78,6 +78,7 @@ module.exports = {
|
||||
|
||||
},
|
||||
parseByID(callback){
|
||||
// create a id keyed array of contents
|
||||
// loop through laguages
|
||||
for(l in this.data){
|
||||
// console.log('l', l);
|
||||
@@ -93,18 +94,18 @@ module.exports = {
|
||||
// guess the type from the id
|
||||
// console.log(this.data[l][p].enonces[e].id);
|
||||
this.data[l][p].enonces[e].dottype = this.setupType(this.data[l][p].enonces[e].id);
|
||||
// records childs in array keyed by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].id] = this.data[l][p].enonces[e];
|
||||
}
|
||||
// records childs in flat array by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].id] = this.data[l][p].enonces[e];
|
||||
// loop through childs
|
||||
for (c in this.data[l][p].enonces[e].childs){
|
||||
// console.log(_db[p][e][c]);
|
||||
if(this.data[l][p].enonces[e].childs[c].id){
|
||||
// guess the type from the id
|
||||
this.data[l][p].enonces[e].childs[c].dottype = this.setupType(this.data[l][p].enonces[e].childs[c].id);
|
||||
// records childs in array keyed by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].childs[c].id] = this.data[l][p].enonces[e].childs[c];
|
||||
}
|
||||
// records childs in flat array by ids
|
||||
this.data_byid[l][this.data[l][p].enonces[e].childs[c].id] = this.data[l][p].enonces[e].childs[c];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user