# HG changeset patch
# User veltr
# Date 1376673125 -7200
# Node ID 8e017d512ef56fa370063806065572479c557127
# Parent 5b770cf1a6e3e19445e4362ac4c4fd67871d1ab5
Added Class rules
diff -r 5b770cf1a6e3 -r 8e017d512ef5 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}}{{/image}}'
+ '{{/occurrences}}';
-Tlns.Templates.OccurrenceTooltip = '
{{formatted_date}} — {{translated_status}} — {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} — {{format}}{{/format}}
' +Tlns.Templates.OccurrenceTooltip = '{{formatted_date}} — {{translated_status}} — {{format}}
' + '{{description}}
' // + '{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}
' @@ -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'); }