178 + '<div class="Tl-Overlay-Container"><div class="Tl-Overlay-Box"><div class="Tl-Overlay"><div class="Tl-Overlay-Tip-Top"></div><div class="Tl-Overlay-Main"></div><div class="Tl-Overlay-Tip-Bottom"></div></div></div></div></div></div>' |
178 + '<div class="Tl-Overlay-Container"><div class="Tl-Overlay-Box"><div class="Tl-Overlay"><div class="Tl-Overlay-Tip-Top"></div><div class="Tl-Overlay-Main"></div><div class="Tl-Overlay-Tip-Bottom"></div></div></div></div></div></div>' |
179 |
179 |
180 Tlns.Templates.Univers = '<div class="Tl-UniversText">{{title}}</div>'; |
180 Tlns.Templates.Univers = '<div class="Tl-UniversText">{{title}}</div>'; |
181 |
181 |
182 Tlns.Templates.Occurrence = |
182 Tlns.Templates.Occurrence = |
183 '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}} Tl-Occ{{status}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;"></div>{{/occurrences}}'; |
183 '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}} Tl-Occ{{status}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;">' |
|
184 + '{{#image}}<img src="{{image}}" />{{/image}}' |
|
185 + '</div>{{/occurrences}}'; |
184 |
186 |
185 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} — {{translated_status}} — {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} — {{format}}{{/format}}</p>' |
187 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} — {{translated_status}} — {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} — {{format}}{{/format}}</p>' |
186 + '<p class="Tl-Tooltip-Description">{{description}}</p>' |
188 + '<p class="Tl-Tooltip-Description">{{description}}</p>' |
187 // + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
189 // + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
188 |
190 |
449 _(this.occurrences).each(function(_occ) { |
451 _(this.occurrences).each(function(_occ) { |
450 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
452 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
451 _occ.y = _occ.univers.y; |
453 _occ.y = _occ.univers.y; |
452 }); |
454 }); |
453 var _visible = _(this.occurrences).filter(function(_occ) { |
455 var _visible = _(this.occurrences).filter(function(_occ) { |
454 return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.status); |
456 return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.status); |
455 }); |
457 }); |
456 |
458 |
457 var _moved = true, l = 0; |
459 var _moved = true, l = 0; |
458 while (_moved && l < 200) { |
460 while (_moved && l < 10) { |
459 l++; |
461 l++; |
460 _moved = false; |
462 _moved = false; |
461 for (var _i = 0; _i < _visible.length; _i++) { |
463 for (var _i = 0; _i < _visible.length; _i++) { |
462 for (var _j = 0; _j < _i; _j++) { |
464 for (var _j = 0; _j < _i; _j++) { |
463 var delta = Math.abs(_visible[_j].x-_visible[_i].x); |
465 var delta = Math.abs(_visible[_j].x-_visible[_i].x); |
464 if (_visible[_j].univers_id == _visible[_i].univers_id |
466 if (_visible[_j].univers_id == _visible[_i].univers_id |
465 && delta < this.grid_spacing |
467 && delta < this.grid_spacing |
466 ) { |
468 ) { |
467 var sign = _visible[_i].x < _visible[_j].x ? 1 : -1, |
469 var sign = _visible[_i].x < _visible[_j].x ? 1 : -1, |
468 add = sign * (this.cluster_spacing - delta) / 2; |
470 add = sign * (this.grid_spacing - delta) / 2; |
469 _moved = true; |
471 _moved = true; |
470 _visible[_i].x -= add; |
472 _visible[_i].x -= add; |
471 _visible[_j].x += add; |
473 _visible[_j].x += add; |
472 } |
474 } |
473 } |
475 } |
499 var _el = $(this), |
501 var _el = $(this), |
500 _id = _el.attr("occurrence-id"); |
502 _id = _el.attr("occurrence-id"); |
501 if (typeof _id !== "undefined") { |
503 if (typeof _id !== "undefined") { |
502 var _occurrence = _this.getOccurrence(_id); |
504 var _occurrence = _this.getOccurrence(_id); |
503 if (!_this.is_dragging) { |
505 if (!_this.is_dragging) { |
504 var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence); |
506 var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence), |
505 _this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) ); |
507 isup = (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height); |
|
508 _this.showTooltip(_occurrence.x + 42, _occurrence.y + (isup ? 10 : 20), _html, isup); |
506 } |
509 } |
507 } |
510 } |
508 }).mouseout(function() { |
511 }).mouseout(function() { |
509 var _el = $(this), |
512 var _el = $(this), |
510 _id = _el.attr("occurrence-id"); |
513 _id = _el.attr("occurrence-id"); |
555 this.original_data = _data; |
558 this.original_data = _data; |
556 this.id = _data.id; |
559 this.id = _data.id; |
557 this.date = new Date(1000 * (_data.dateFirstPublication || _data.dateCreate) || Date.now); |
560 this.date = new Date(1000 * (_data.dateFirstPublication || _data.dateCreate) || Date.now); |
558 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
561 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
559 this.title = _data.title; |
562 this.title = _data.title; |
560 this.univers_id = this.timeline.univers[0].id; |
563 this.univers_id = this.timeline.univers[Math.floor(Math.random() * this.timeline.univers.length)].id; |
561 this.univers = this.timeline.getUnivers(this.univers_id); |
564 this.univers = this.timeline.getUnivers(this.univers_id); |
562 this.type = "publication"; |
565 this.type = "publication"; |
563 if (typeof _data.statut !== "undefined" || typeof this.status === "undefined") { |
566 if (typeof _data.statut !== "undefined" || typeof this.status === "undefined") { |
564 switch(_data.statut) { |
567 switch(_data.statut) { |
565 case "Validée": |
568 case "Validée": |
577 } |
580 } |
578 } |
581 } |
579 if (typeof _data.typeOccurrencePublication !== "undefined" || typeof this.format === "undefined") { |
582 if (typeof _data.typeOccurrencePublication !== "undefined" || typeof this.format === "undefined") { |
580 this.format = _data.typeOccurrencePublication || 'Format non défini'; |
583 this.format = _data.typeOccurrencePublication || 'Format non défini'; |
581 } |
584 } |
|
585 console.log(_data, _data.contentHasMedias); |
|
586 if (_data.contentHasMedias && _data.contentHasMedias.length) { |
|
587 this.image = _data.contentHasMedias[0].media.cinema.replace(/cinema\/[\d]+\/[\d]+/,'cinema/85/38'); |
|
588 } |
582 this.translated_status = Tlns.Defaults.Timeline.statuses[this.status]; |
589 this.translated_status = Tlns.Defaults.Timeline.statuses[this.status]; |
583 // this.published = (_data.publication && _data.publication == "En ligne"); |
590 // this.published = (_data.publication && _data.publication == "En ligne"); |
584 // this.locked = _data.verrouille || false; |
591 // this.locked = _data.verrouille || false; |
585 // this.characters = _data.personnagesSecondaires || []; |
592 // this.characters = _data.personnagesSecondaires || []; |
586 var _tmp = $('<p>').html(_data.resume || ""); |
593 var _tmp = $('<p>').html(_data.resume || ""); |