205 Tlns.Defaults.Timeline.timescales[_i].level = _i; |
205 Tlns.Defaults.Timeline.timescales[_i].level = _i; |
206 } |
206 } |
207 |
207 |
208 /* Templates */ |
208 /* Templates */ |
209 |
209 |
210 Tlns.Templates.Timeline = '<ul class="Onglets"><li>Frise chronologique</li><li>Liste des occurrences</li></ul><div class="Tl-Main"><div class="Tl-TopBar"><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-AddButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
210 Tlns.Templates.Timeline = '<ul class="Onglets"><li class="Onglet-Tl active">Frise chronologique</li><li class="Onglet-Ls">Liste des occurrences</li></ul><div class="Tl-Main"><div class="Tl-TopBar"><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-AddButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
211 + '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-PreviousButton"></div></div><div class="Tl-TopBar-TimeSpan Tl-TopBar-TextBtn Tl-Border-Right">--/--</div>' |
211 + '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-PreviousButton"></div></div><div class="Tl-TopBar-TimeSpan Tl-TopBar-TextBtn Tl-Border-Right">--/--</div>' |
212 + '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-SyncButton"></div></div><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-NextButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
212 + '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-SyncButton"></div></div><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-NextButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
213 + '<div class="Tl-TopBar-Timescales">{{#timescales}}<div class="Tl-TopBar-Button Tl-TopBar-TextBtn Tl-Border-Right" data-level="{{level}}">{{label}}</div>{{/timescales}}</div></div>' |
213 + '<div class="Tl-TopBar-Timescales">{{#timescales}}<div class="Tl-TopBar-Button Tl-TopBar-TextBtn Tl-Border-Right" data-level="{{level}}">{{label}}</div>{{/timescales}}</div></div>' |
214 + '<div class="Tl-BottomPart"><ul class="Tl-UniversLabels"></ul>' |
214 + '<div class="Tl-BottomPart"><ul class="Tl-UniversLabels"></ul>' |
215 + '<div class="Tl-MainPart"><div class="Tl-Layer Tl-Grid"></div><canvas class="Tl-Layer Tl-Canvas"></canvas><canvas class="Tl-Layer Tl-Linking-Canvas"></canvas><div class="Tl-Layer Tl-Occurrences"></div>' |
215 + '<div class="Tl-MainPart"><div class="Tl-Layer Tl-Grid"></div><canvas class="Tl-Layer Tl-Canvas"></canvas><canvas class="Tl-Layer Tl-Linking-Canvas"></canvas><div class="Tl-Layer Tl-Occurrences"></div>' |
237 + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}'; |
237 + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}'; |
238 |
238 |
239 Tlns.Templates.Occurrence_List = '{{#occurrences}}<li class="Ls-Occurrence"><div class="Ls-OccIcon Tl-Occ{{type}} Tl-Occ{{status}}"></div><div class="Ls-Occurrence-Title">{{title}}</div><div class="Tl-Tooltip-Date">{{formatted_date}}</div><div style="clear:both;"></div></li>{{/occurrences}}'; |
239 Tlns.Templates.Occurrence_List = '{{#occurrences}}<li class="Ls-Occurrence"><div class="Ls-OccIcon Tl-Occ{{type}} Tl-Occ{{status}}"></div><div class="Ls-Occurrence-Title">{{title}}</div><div class="Tl-Tooltip-Date">{{formatted_date}}</div><div style="clear:both;"></div></li>{{/occurrences}}'; |
240 |
240 |
241 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} - {{translated_status}}</p>' |
241 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} - {{translated_status}}</p>' |
242 + '<p class="Tl-Tooltip-Description">{{description}}</p><p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
242 + '<p class="Tl-Tooltip-Description">{{description}}</p>' |
|
243 // + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
243 |
244 |
244 /* Classes */ |
245 /* Classes */ |
245 |
246 |
246 Tlns.Classes.Timeline = function(_options) { |
247 Tlns.Classes.Timeline = function(_options) { |
247 |
248 |
346 _d = _this.timeFromMouse(_event.pageX), |
347 _d = _this.timeFromMouse(_event.pageX), |
347 _u = _this.universFromMouse(_event.pageY), |
348 _u = _this.universFromMouse(_event.pageY), |
348 _occ = _this.createOrUpdateOccurrence( |
349 _occ = _this.createOrUpdateOccurrence( |
349 _type, |
350 _type, |
350 { |
351 { |
351 date: _d, |
352 datePublication: Math.floor(_d / 1000), |
352 titre: '<Nouvelle occurrence>', |
353 titre: '<Nouvelle occurrence>', |
353 univers: _this.univers[_u].id, |
354 idUnivers: _this.univers[_u].id, |
354 publie: true, |
|
355 statut: 'a_realiser' |
355 statut: 'a_realiser' |
356 } |
356 } |
357 ); |
357 ); |
358 _occ.just_created = true; |
358 _occ.just_created = true; |
359 _occ.editing = true; |
359 _occ.editing = true; |
374 _this.onUniversLoaded(_data); |
374 _this.onUniversLoaded(_data); |
375 }); |
375 }); |
376 |
376 |
377 /* LIST */ |
377 /* LIST */ |
378 |
378 |
379 $("li.Ls-Critere").click(function() { |
379 this.$.find("li.Ls-Critere").click(function() { |
380 $(this).toggleClass("Ls-Active"); |
380 $(this).toggleClass("Ls-Active"); |
381 _this.throttledDrawList(); |
381 _this.throttledDrawList(); |
382 }); |
382 }); |
383 $(".Ls-Search").bind("keyup change click", function() { |
383 this.$.find(".Ls-Search").bind("keyup change click", function() { |
384 _this.throttledDrawList(); |
384 _this.throttledDrawList(); |
385 }); |
385 }); |
386 $(".Ls-From-Date, .Ls-To-Date").datepicker( |
386 this.$.find(".Ls-From-Date, .Ls-To-Date").datepicker( |
387 { |
387 { |
388 dateFormat: "dd/mm/yy", |
388 dateFormat: "dd/mm/yy", |
389 dayNames: [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ], |
389 dayNames: [ "Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi" ], |
390 dayNamesShort: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ], |
390 dayNamesShort: [ "Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam" ], |
391 dayNamesMin: [ "D", "L", "Ma", "Me", "J", "V", "S" ], |
391 dayNamesMin: [ "D", "L", "Ma", "Me", "J", "V", "S" ], |
401 } |
401 } |
402 _this.drawList(); |
402 _this.drawList(); |
403 }).bind("keyup", function() { |
403 }).bind("keyup", function() { |
404 _this.throttledDrawList(); |
404 _this.throttledDrawList(); |
405 }); |
405 }); |
406 $(".Ls-From-Time, .Ls-To-Time").change(function() { |
406 this.$.find(".Ls-From-Time, .Ls-To-Time").change(function() { |
407 var _val = $(this).val(); |
407 var _val = $(this).val(); |
408 if (_val) { |
408 if (_val) { |
409 $(this).val(Tlns.Utils.timeFieldProcess( _val ).text); |
409 $(this).val(Tlns.Utils.timeFieldProcess( _val ).text); |
410 } |
410 } |
411 _this.throttledDrawList(); |
411 _this.throttledDrawList(); |
412 }).bind("keyup", function() { |
412 }).bind("keyup", function() { |
413 _this.throttledDrawList(); |
413 _this.throttledDrawList(); |
414 }); |
414 }); |
415 |
415 |
|
416 this.$.find(".Onglet-Tl").click(function() { |
|
417 _this.$.find(".Tl-Main").show(); |
|
418 _this.$.find(".Ls-Main").hide(); |
|
419 _this.$.find(".Onglet-Ls").removeClass("active"); |
|
420 _this.$.find(".Onglet-Tl").addClass("active"); |
|
421 }); |
|
422 |
|
423 this.$.find(".Onglet-Ls").click(function() { |
|
424 _this.$.find(".Ls-Main").show(); |
|
425 _this.$.find(".Tl-Main").hide(); |
|
426 _this.$.find(".Onglet-Tl").removeClass("active"); |
|
427 _this.$.find(".Onglet-Ls").addClass("active"); |
|
428 }); |
416 } |
429 } |
417 |
430 |
418 Tlns.Classes.Timeline.prototype.onMouseDown = function(_event) { |
431 Tlns.Classes.Timeline.prototype.onMouseDown = function(_event) { |
419 this.mouse_down = true; |
432 this.mouse_down = true; |
420 this.is_dragging = false; |
433 this.is_dragging = false; |
510 } |
523 } |
511 for(var _i = 0; _i < _data.length; _i++) { |
524 for(var _i = 0; _i < _data.length; _i++) { |
512 this.univers.push(new Tlns.Classes.Univers(_data[_i], this, _i)); |
525 this.univers.push(new Tlns.Classes.Univers(_data[_i], this, _i)); |
513 } |
526 } |
514 |
527 |
515 $(".Ls-Univers").html(Mustache.to_html(Tlns.Templates.Univers_List, this)); |
528 this.$.find(".Ls-Univers").html(Mustache.to_html(Tlns.Templates.Univers_List, this)); |
516 var _this = this; |
529 var _this = this; |
517 $(".Ls-Univers li.Ls-Critere").click( function() { |
530 this.$.find(".Ls-Univers li.Ls-Critere").click( function() { |
518 $(this).toggleClass("Ls-Active"); |
531 $(this).toggleClass("Ls-Active"); |
519 _this.throttledDrawList(); |
532 _this.throttledDrawList(); |
520 }); |
533 }); |
521 this.loadOccurrences(); |
534 this.loadOccurrences(); |
522 } |
535 } |
548 |
561 |
549 Tlns.Classes.Timeline.prototype.changeSpan = function() { |
562 Tlns.Classes.Timeline.prototype.changeSpan = function() { |
550 var _now = new Date().valueOf(); |
563 var _now = new Date().valueOf(); |
551 if (this.sync_now) { |
564 if (this.sync_now) { |
552 this.central_time = _now; |
565 this.central_time = _now; |
553 this.$.find('.Tl-TopBar-SyncButton').addClass("active"); |
|
554 } else { |
|
555 this.$.find('.Tl-TopBar-SyncButton').removeClass("active"); |
|
556 } |
566 } |
557 var _timescale = this.timescales[this.level]; |
567 var _timescale = this.timescales[this.level]; |
558 this.current_scale = this.main_width / (_timescale.span); |
568 this.current_scale = this.main_width / (_timescale.span); |
559 this.start_time = this.central_time - (_timescale.span / 2); |
569 this.start_time = this.central_time - (_timescale.span / 2); |
560 this.end_time = this.central_time + (_timescale.span / 2); |
570 this.end_time = this.central_time + (_timescale.span / 2); |
561 $(".Ls-From-Time").val(Tlns.Utils.dateFormat(this.start_time, '{{0hours}}:{{0minutes}}')); |
571 this.$.find(".Ls-From-Time").val(Tlns.Utils.dateFormat(this.start_time, '{{0hours}}:{{0minutes}}')); |
562 $(".Ls-From-Date").val(Tlns.Utils.dateFormat(this.start_time, '{{0dayOfMonth}}/{{0monthNumber}}/{{year}}')); |
572 this.$.find(".Ls-From-Date").val(Tlns.Utils.dateFormat(this.start_time, '{{0dayOfMonth}}/{{0monthNumber}}/{{year}}')); |
563 $(".Ls-To-Time").val(Tlns.Utils.dateFormat(this.end_time, '{{0hours}}:{{0minutes}}')); |
573 this.$.find(".Ls-To-Time").val(Tlns.Utils.dateFormat(this.end_time, '{{0hours}}:{{0minutes}}')); |
564 $(".Ls-To-Date").val(Tlns.Utils.dateFormat(this.end_time, '{{0dayOfMonth}}/{{0monthNumber}}/{{year}}')); |
574 this.$.find(".Ls-To-Date").val(Tlns.Utils.dateFormat(this.end_time, '{{0dayOfMonth}}/{{0monthNumber}}/{{year}}')); |
565 this.throttledDrawGrid(); |
575 this.throttledDrawGrid(); |
566 this.throttledDrawList(); |
576 this.throttledDrawList(); |
567 } |
577 } |
568 |
578 |
569 Tlns.Classes.Timeline.prototype.drawGrid = function() { |
579 Tlns.Classes.Timeline.prototype.drawGrid = function() { |
|
580 if (this.sync_now) { |
|
581 this.$.find('.Tl-TopBar-SyncButton').addClass("active"); |
|
582 } else { |
|
583 this.$.find('.Tl-TopBar-SyncButton').removeClass("active"); |
|
584 } |
570 var _now = new Date().valueOf(), |
585 var _now = new Date().valueOf(), |
571 _timescale = this.timescales[this.level], |
586 _timescale = this.timescales[this.level], |
572 _offset = new Date().getTimezoneOffset() * 60000, |
587 _offset = new Date().getTimezoneOffset() * 60000, |
573 _grid_width = Math.floor(_timescale.grid_interval * this.current_scale), |
588 _grid_width = Math.floor(_timescale.grid_interval * this.current_scale), |
574 _roundstart = Math.floor((this.start_time - _offset) / _timescale.grid_interval) * _timescale.grid_interval + _offset, |
589 _roundstart = Math.floor((this.start_time - _offset) / _timescale.grid_interval) * _timescale.grid_interval + _offset, |
587 this.$.find('.Tl-Grid').html(_html); |
602 this.$.find('.Tl-Grid').html(_html); |
588 this.drawOccurrences(); |
603 this.drawOccurrences(); |
589 } |
604 } |
590 |
605 |
591 Tlns.Classes.Timeline.prototype.loadOccurrences = function() { |
606 Tlns.Classes.Timeline.prototype.loadOccurrences = function() { |
592 var _url = Mustache.to_html(this.url_occurrences, { |
607 var _this = this; |
593 from_time: this.start_time, |
608 _(this.urls_occurrences).each(function(_url_occ) { |
594 to_time: this.end_time |
609 $.getJSON(_url_occ.url, function(_data) { |
595 }), |
610 _this.onOccurrencesLoaded(_data, _url_occ.type); |
596 _this = this; |
611 }); |
597 $.getJSON(_url, function(_data) { |
612 }); |
598 _this.onOccurrencesLoaded(_data); |
613 |
599 }); |
614 } |
600 } |
615 |
601 |
616 Tlns.Classes.Timeline.prototype.onOccurrencesLoaded = function(_data, _type) { |
602 Tlns.Classes.Timeline.prototype.onOccurrencesLoaded = function(_data) { |
617 for (var _i = 0; _i < _data.length; _i++) { |
603 if (typeof _data.occurrencesNarratives === "object" && _data.occurrencesNarratives !== null) { |
618 this.createOrUpdateOccurrence(_type, _data[_i]); |
604 for (var _i = 0; _i < _data.occurrencesNarratives.length; _i++) { |
|
605 this.createOrUpdateOccurrence("narrative", _data.occurrencesNarratives[_i]); |
|
606 } |
|
607 for (var _i = 0; _i < _data.occurrencesPublication.length; _i++) { |
|
608 this.createOrUpdateOccurrence("publication", _data.occurrencesPublication[_i]); |
|
609 } |
|
610 } |
619 } |
611 if (!this.mouse_down) { |
620 if (!this.mouse_down) { |
612 this.drawOccurrences(); |
621 this.drawOccurrences(); |
613 } |
622 } |
614 this.throttledDrawList(); |
623 this.throttledDrawList(); |
654 } |
663 } |
655 |
664 |
656 Tlns.Classes.Timeline.prototype.drawOccurrences = function() { |
665 Tlns.Classes.Timeline.prototype.drawOccurrences = function() { |
657 var _this = this, |
666 var _this = this, |
658 _visible = _(this.occurrences).filter(function(_occ) { |
667 _visible = _(this.occurrences).filter(function(_occ) { |
659 return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.published); |
668 return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.status); |
660 }); |
669 }); |
661 _(_visible).each(function(_occ) { |
670 _(_visible).each(function(_occ) { |
662 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
671 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
663 _occ.y = _occ.univers.y; |
672 _occ.y = _occ.univers.y; |
664 _occ.in_cluster = false; |
673 _occ.in_cluster = false; |
826 _this.throttledDrawGrid(); |
835 _this.throttledDrawGrid(); |
827 }) |
836 }) |
828 } |
837 } |
829 |
838 |
830 Tlns.Classes.Timeline.prototype.drawList = function() { |
839 Tlns.Classes.Timeline.prototype.drawList = function() { |
831 var _universfilter = $(".Ls-Univers li.Ls-Active").map(function(){return $(this).attr("data")}), |
840 var _universfilter = this.$.find(".Ls-Univers li.Ls-Active").map(function(){return $(this).attr("data")}), |
832 _occtypefilter = $(".Ls-Occtypes li.Ls-Active").map(function(){return $(this).attr("data")}), |
841 _occtypefilter = this.$.find(".Ls-Occtypes li.Ls-Active").map(function(){return $(this).attr("data")}), |
833 _statusfilter = $(".Ls-Occstatuses li.Ls-Active").map(function(){return $(this).attr("data")}), |
842 _statusfilter = this.$.find(".Ls-Occstatuses li.Ls-Active").map(function(){return $(this).attr("data")}), |
834 _title = $(".Ls-Search").val() || "", |
843 _title = this.$.find(".Ls-Search").val() || "", |
835 _titleregexp = new RegExp( "(" + _title.replace(/(\W)/gm, "\\$1") + ")", "gim" ), |
844 _titleregexp = new RegExp( "(" + _title.replace(/(\W)/gm, "\\$1") + ")", "gim" ), |
836 _startdate = false, |
845 _startdate = false, |
837 _enddate = false, |
846 _enddate = false, |
838 _fromDate = $(".Ls-From-Date").val(), |
847 _fromDate = this.$.find(".Ls-From-Date").val(), |
839 _toDate = $(".Ls-To-Date").val(); |
848 _toDate = this.$.find(".Ls-To-Date").val(); |
840 if (_fromDate) { |
849 if (_fromDate) { |
841 var _date = Tlns.Utils.dateFieldProcess(_fromDate), |
850 var _date = Tlns.Utils.dateFieldProcess(_fromDate), |
842 _time = Tlns.Utils.timeFieldProcess($(".Ls-From-Time").val()); |
851 _time = Tlns.Utils.timeFieldProcess(this.$.find(".Ls-From-Time").val()); |
843 _startdate = new Date(_date.year, _date.month - 1, _date.date, _time.hours, _time.minutes); |
852 _startdate = new Date(_date.year, _date.month - 1, _date.date, _time.hours, _time.minutes); |
844 } |
853 } |
845 if (_toDate) { |
854 if (_toDate) { |
846 var _date = Tlns.Utils.dateFieldProcess(_toDate), |
855 var _date = Tlns.Utils.dateFieldProcess(_toDate), |
847 _time = Tlns.Utils.timeFieldProcess($(".Ls-To-Time").val()); |
856 _time = Tlns.Utils.timeFieldProcess(this.$.find(".Ls-To-Time").val()); |
848 _enddate = new Date(_date.year, _date.month - 1, _date.date, _time.hours, _time.minutes); |
857 _enddate = new Date(_date.year, _date.month - 1, _date.date, _time.hours, _time.minutes); |
849 } |
858 } |
850 $(".Ls-Occurrences").html( |
859 this.$.find(".Ls-Occurrences").html( |
851 Mustache.to_html( |
860 Mustache.to_html( |
852 Tlns.Templates.Occurrence_List, |
861 Tlns.Templates.Occurrence_List, |
853 { |
862 { |
854 occurrences: this.occurrences.filter(function(_occ) { |
863 occurrences: this.occurrences.filter(function(_occ) { |
855 var _titletest = (!!_occ.title.match(_titleregexp)), |
864 var _titletest = (!!_occ.title.match(_titleregexp)), |
882 /* |
891 /* |
883 * Univers |
892 * Univers |
884 */ |
893 */ |
885 |
894 |
886 Tlns.Classes.Univers = function(_data, _timeline, _index) { |
895 Tlns.Classes.Univers = function(_data, _timeline, _index) { |
887 this.id = _data.id; |
896 this.id = _data.idUnivers; |
888 this.index = _index; |
897 this.index = _index; |
889 this.title = _data.nom; |
898 this.title = _data.nomUnivers; |
890 this.mainCharacter = _data.personnage; |
899 // this.mainCharacter = _data.personnage; |
891 this.y = (_timeline.univers_height * _index); |
900 this.y = (_timeline.univers_height * _index); |
892 |
901 |
893 this.$label = $('<li>').css({ |
902 this.$label = $('<li>').css({ |
894 height : _timeline.univers_height + "px" |
903 height : _timeline.univers_height + "px" |
895 }).html(Mustache.to_html(Tlns.Templates.Univers, this)) |
904 }).html(Mustache.to_html(Tlns.Templates.Univers, this)) |
896 .addClass((_index % 2) ? 'Tl-Line-Odd' : 'Tl-Line-Even'); |
905 .addClass((_index % 2) ? 'Tl-Line-Odd' : 'Tl-Line-Even'); |
897 |
906 |
898 _timeline.$.find('.Tl-UniversLabels').append(this.$label); |
907 _timeline.$.find('.Tl-UniversLabels').append(this.$label); |
899 var _txt = _data.nom, |
908 var _txt = this.title, |
900 _span = this.$label.find('span'); |
909 _span = this.$label.find('span'); |
901 |
|
902 while (_span.outerWidth() > (_timeline.width - _timeline.main_width) && _txt) { |
910 while (_span.outerWidth() > (_timeline.width - _timeline.main_width) && _txt) { |
903 _txt = _txt.substr(0, _txt.length - 1); |
911 _txt = _txt.substr(0, _txt.length - 1); |
904 _span.html(_txt + '…'); |
912 _span.html(_txt + '…'); |
905 } |
913 } |
906 } |
914 } |
913 this.timeline = _timeline; |
921 this.timeline = _timeline; |
914 } |
922 } |
915 |
923 |
916 Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { |
924 Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { |
917 this.type = _type; |
925 this.type = _type; |
918 this.original_id = _data.id || Tlns.Utils.guid(); |
926 this.original_id = _data.idOccurrencePublication || _data.id || Tlns.Utils.guid(); |
919 this.id = _type + "_" + this.original_id; |
927 this.id = _type + "_" + this.original_id; |
920 this.date = _data.date || _data.datePublication; |
928 this.date = 1000 * (_data.datePublication || _data.date); |
921 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
929 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
922 this.title = _data.titre || "<untitled>"; |
930 this.title = _data.titre || "<untitled>"; |
923 this.univers_id = _data.univers; |
931 this.univers_id = _data.idUnivers; |
924 this.univers = this.timeline.getUnivers(this.univers_id); |
932 this.univers = this.timeline.getUnivers(this.univers_id); |
925 this.status = _data.statut; |
933 switch(_data.statut) { |
|
934 case "Validée": |
|
935 case "valide": |
|
936 this.status = "valide" |
|
937 break; |
|
938 case "A valider": |
|
939 case "a_valider": |
|
940 this.status = "a_valider"; |
|
941 break; |
|
942 case "A réaliser": |
|
943 case "a_realiser": |
|
944 this.status = "a_realiser"; |
|
945 break; |
|
946 default: |
|
947 this.status = false; |
|
948 } |
926 this.translated_status = Tlns.Defaults.Timeline.statuses[this.status]; |
949 this.translated_status = Tlns.Defaults.Timeline.statuses[this.status]; |
927 this.published = _data.publie || false; |
950 // this.published = (_data.publication && _data.publication == "En ligne"); |
928 // this.locked = _data.verrouille || false; |
951 // this.locked = _data.verrouille || false; |
929 this.characters = _data.personnagesSecondaires || []; |
952 // this.characters = _data.personnagesSecondaires || []; |
930 this.dependsOn = _(_data.dependDe || []).map(function(_id) { |
953 this.dependsOn = []; |
931 return "narrative_" + _id; |
954 if (_data.dependanceNarrative) { |
932 }); |
955 for (var _i = 0; _i < _data.dependanceNarrative.length; _i++) { |
933 this.description = _data.description || ""; |
956 this.dependsOn.push("narrative_" + _data.dependanceNarrative[_i]) |
|
957 } |
|
958 } |
|
959 if (_data.dependancePublication) { |
|
960 for (var _i = 0; _i < _data.dependancePublication.length; _i++) { |
|
961 this.dependsOn.push("publication_" + _data.dependancePublication[_i]) |
|
962 } |
|
963 } |
|
964 var _tmp = $('<p>').html(_data.accroche || ""); |
|
965 this.description = _tmp.text().trim().replace(/(^.{60,80})[\s].+$/m,'$1…'); |
934 } |
966 } |
935 |
967 |
936 Tlns.Classes.Occurrence.prototype.addDependency = function(_id) { |
968 Tlns.Classes.Occurrence.prototype.addDependency = function(_id) { |
937 if (_(this.dependsOn).indexOf(_id) == -1) { |
969 if (_(this.dependsOn).indexOf(_id) == -1) { |
938 this.dependsOn.push(_id); |
970 this.dependsOn.push(_id); |