Added Class rules
authorveltr
Fri, 16 Aug 2013 19:12:05 +0200
changeset 92 8e017d512ef5
parent 91 5b770cf1a6e3
child 93 dc66d623dddd
Added Class rules
timeline/js/timeline.js
--- a/timeline/js/timeline.js	Tue Aug 13 17:25:20 2013 +0200
+++ b/timeline/js/timeline.js	Fri Aug 16 19:12:05 2013 +0200
@@ -162,6 +162,18 @@
         "valide": "Validée",
         "a_valider": "A valider",
         "a_realiser": "A réaliser"
+    },
+    class_labels: {
+        "Cms\\Previously": "Précédemment",
+        "Cms\\Chapter": "Chapitre",
+        "Cms\\Article": "Article",
+        "Cms\\Poll": "Sondage",
+        "Cms\\CallWitness": "Appel à Témoins",
+        "Cms\\CallCharacter": "Appel à Personnage",
+        "Cms\\Message": "Message",
+        "Cms\\Rule": "Règle",
+        "Cms\\Video": "Vidéo",
+        "Cms\\SweetCadaver": "Cadavre exquis"
     }
 }
 
@@ -184,7 +196,7 @@
     + '{{#image}}<img src="{{image}}" />{{/image}}'
     + '</div>{{/occurrences}}';
 
-Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} &mdash; {{translated_status}} &mdash; {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} &mdash; {{format}}{{/format}}</p>'
+Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} &mdash; {{translated_status}} &mdash; {{format}}</p>'
     + '<p class="Tl-Tooltip-Description">{{description}}</p>'
 //    + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>'
 
@@ -421,11 +433,21 @@
 Tlns.Classes.Timeline.prototype.createOrUpdateOccurrence = function(_data) {
     var _id = _data.id,
         _occurrence = this.getOccurrence(_id);
-    if (typeof _occurrence === "undefined") {
-        _occurrence = new Tlns.Classes.Occurrence(this);
-        this.occurrences.push(_occurrence);
+    switch (_data.__CLASS__) {
+        case "Cms\\Previously":
+        case "Cms\\Chapter":
+        case "Cms\\Article":
+        case "Cms\\Poll":
+        case "Cms\\CallWitness":
+        case "Cms\\CallCharacter":
+        case "Cms\\SweetCadaver":
+            if (typeof _occurrence === "undefined") {
+                _occurrence = new Tlns.Classes.Occurrence(this);
+                this.occurrences.push(_occurrence);
+            }
+            _occurrence.update(_data);
+        break;
     }
-    _occurrence.update(_data);
     return _occurrence;
 }
 
@@ -530,8 +552,7 @@
  */
 
 Tlns.Classes.Univers = function(_data, _timeline, _index) {
-    this.id = "u_" + _index;
-    this.index = _index;
+    this.id = this.index = _index;
     this.title = _data;
 //    this.mainCharacter = _data.personnage;
     this.y = (_timeline.univers_height * _index);
@@ -560,9 +581,25 @@
     this.date = new Date(1000 * (_data.dateFirstPublication || _data.dateCreate) || Date.now);
     this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format);
     this.title = _data.title;
-    this.univers_id = this.timeline.univers[Math.floor(Math.random() * this.timeline.univers.length)].id;
-    this.univers = this.timeline.getUnivers(this.univers_id);
-    this.type = "publication";
+    this.type = _data.__CLASS__;
+    switch(_data.__CLASS__) {
+        case "Cms\\Previously":
+        case "Cms\\Chapter":
+            this.univers_id = 0;
+        break;
+        case "Cms\\Article":
+            this.univers_id = 1;
+        break;
+        case "Cms\\Poll":
+        case "Cms\\CallWitness":
+        case "Cms\\CallCharacter":
+            this.univers_id = 2;
+        break;
+        case "Cms\\SweetCadaver":
+            this.univers_id = 3;
+        break;
+    }
+    this.univers = this.timeline.univers[this.univers_id];
     if (typeof _data.statut !== "undefined" || typeof this.status === "undefined") {
         switch(_data.statut) {
             case "Validée":
@@ -579,10 +616,7 @@
                 this.status = "a_valider";
         }
     }
-    if (typeof _data.typeOccurrencePublication !== "undefined" || typeof this.format === "undefined") {
-        this.format = _data.typeOccurrencePublication || 'Format non défini';
-    }
-    console.log(_data, _data.contentHasMedias);
+    this.format = this.timeline.class_labels[this.type];
     if (_data.contentHasMedias && _data.contentHasMedias.length) {
         this.image = _data.contentHasMedias[0].media.cinema.replace(/cinema\/[\d]+\/[\d]+/,'cinema/85/38');
     }