Browse Source

fixe language bug in dots

Bachir Soussi Chiadmi 6 years ago
parent
commit
0d98b60d26
4 changed files with 65 additions and 27 deletions
  1. 27 12
      assets/dist/main.js
  2. 0 0
      assets/dist/main.js.map
  3. 27 12
      assets/modules/dots.js
  4. 11 3
      upload.sh

+ 27 - 12
assets/dist/main.js

@@ -3232,9 +3232,9 @@ var _Dot = {
   opened:false,
   links:null,
   parents:[],
-  oninit: function(vn){
-    this.id = vn.attrs.id;
-    this.type = vn.attrs.type;
+  lang:_dbs.lang,
+  setuptext:function(vn){
+    // console.log('setuptext', vn);
 
     // construct text
     this.text = markdown.render(vn.attrs.text);
@@ -3246,6 +3246,13 @@ var _Dot = {
     this.summary = this.summary.replace(/\[([^\]]+)$/g, "$1");
     this.summary = markdown.renderInline(this.summary) + " …";
 
+  },
+  oninit: function(vn){
+    this.id = vn.attrs.id;
+    this.type = vn.attrs.type;
+
+    this.setuptext(vn);
+
     if(typeof vn.attrs.active !== 'undefined')
       this.active = vn.attrs.active;
 
@@ -3268,6 +3275,11 @@ var _Dot = {
     }
   },
   onbeforeupdate: function(vn){
+    // console.log('onbeforeupdate');
+    if(this.lang != _dbs.lang){
+      this.lang = _dbs.lang;
+      this.setuptext(vn);
+    }
   },
   view: function(vn){
     if (this.active && this.opened) {
@@ -3278,15 +3290,17 @@ var _Dot = {
         this.links.to.length
           ? m('nav', {'class':'links to'}, this.links.to.map(function(id){
               // console.log(id);
-              return m(_Dot, {
-                "id":id,
-                'text':_dbs.data_byid[_dbs.lang][id].text,
-                '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)
-                'active':vn.state.parents.indexOf(id) == -1 ? true:false
-              });
+              if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
+                return m(_Dot, {
+                  "id":id,
+                  'text':_dbs.data_byid[_dbs.lang][id].text,
+                  '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)
+                  'active':vn.state.parents.indexOf(id) == -1 ? true:false
+                });
+              }
             })
           )
           : null,
@@ -3348,6 +3362,7 @@ var _Dot = {
           m('p', {
             'class':'summary',
             onclick:function(e){
+              // TODO: animate openening (text and links separatly)
               vn.state.opened = true;
             }
           }, m.trust(this.summary))

File diff suppressed because it is too large
+ 0 - 0
assets/dist/main.js.map


+ 27 - 12
assets/modules/dots.js

@@ -25,9 +25,9 @@ var _Dot = {
   opened:false,
   links:null,
   parents:[],
-  oninit: function(vn){
-    this.id = vn.attrs.id;
-    this.type = vn.attrs.type;
+  lang:_dbs.lang,
+  setuptext:function(vn){
+    // console.log('setuptext', vn);
 
     // construct text
     this.text = markdown.render(vn.attrs.text);
@@ -39,6 +39,13 @@ var _Dot = {
     this.summary = this.summary.replace(/\[([^\]]+)$/g, "$1");
     this.summary = markdown.renderInline(this.summary) + " …";
 
+  },
+  oninit: function(vn){
+    this.id = vn.attrs.id;
+    this.type = vn.attrs.type;
+
+    this.setuptext(vn);
+
     if(typeof vn.attrs.active !== 'undefined')
       this.active = vn.attrs.active;
 
@@ -61,6 +68,11 @@ var _Dot = {
     }
   },
   onbeforeupdate: function(vn){
+    // console.log('onbeforeupdate');
+    if(this.lang != _dbs.lang){
+      this.lang = _dbs.lang;
+      this.setuptext(vn);
+    }
   },
   view: function(vn){
     if (this.active && this.opened) {
@@ -71,15 +83,17 @@ var _Dot = {
         this.links.to.length
           ? m('nav', {'class':'links to'}, this.links.to.map(function(id){
               // console.log(id);
-              return m(_Dot, {
-                "id":id,
-                'text':_dbs.data_byid[_dbs.lang][id].text,
-                '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)
-                'active':vn.state.parents.indexOf(id) == -1 ? true:false
-              });
+              if(typeof _dbs.data_byid[_dbs.lang][id] !== 'undefined'){
+                return m(_Dot, {
+                  "id":id,
+                  'text':_dbs.data_byid[_dbs.lang][id].text,
+                  '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)
+                  'active':vn.state.parents.indexOf(id) == -1 ? true:false
+                });
+              }
             })
           )
           : null,
@@ -141,6 +155,7 @@ var _Dot = {
           m('p', {
             'class':'summary',
             onclick:function(e){
+              // TODO: animate openening (text and links separatly)
               vn.state.opened = true;
             }
           }, m.trust(this.summary))

+ 11 - 3
upload.sh

@@ -1,5 +1,13 @@
 #!/bin/sh
 
-rsync -rvc index.html CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/
-rsync -rvc assets/dist CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/assets/
-rsync -rvc assets/jsondb CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/assets/
+rsync -rvc --delete-before \
+  index.html \
+  CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/
+
+rsync -rvc --delete-before \
+  assets/dist \
+  CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/assets/
+
+rsync -rvc --delete-before \
+  assets/jsondb \
+  CT-figli-deb9-lamp:www/ethica-spinoza.net/public_html/assets/

Some files were not shown because too many files changed in this diff