timeline/js/timeline.js
changeset 82 f00eb382bff1
parent 81 bf6adf981cc2
child 83 f8b1d6f5bb33
equal deleted inserted replaced
81:bf6adf981cc2 82:f00eb382bff1
   235 //  + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}'
   235 //  + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}'
   236     + '<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}{{#open_cluster}}<div class="Tl-ClusterOverlay" style="left: {{x}}px; top: {{y}}px;">'
   236     + '<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}{{#open_cluster}}<div class="Tl-ClusterOverlay" style="left: {{x}}px; top: {{y}}px;">'
   237     + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}} Tl-Occ{{status}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}">'
   237     + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}} Tl-Occ{{status}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}">'
   238     + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}';
   238     + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}';
   239 
   239 
   240 Tlns.Templates.Occurrence_List = '{{#occurrences}}<li class="Ls-Occurrence"><div class="Ls-OccIcon Tl-Occ{{type}} Tl-Occ{{status}}"></div><h4 class="Ls-Occurrence-Title">{{title}}</h4>'
   240 Tlns.Templates.Occurrence_List = '{{#occurrences}}<li class="Ls-Occurrence" data-id="{{id}}"><div class="Ls-OccIcon Tl-Occ{{type}} Tl-Occ{{status}}"></div><h4 class="Ls-Occurrence-Title"><a href="#">{{title}}</a></h4>'
   241     + '<p class="Ls-Occ-More">{{formatted_date}} &mdash; {{univers.title}} &mdash; {{translated_status}} &mdash; {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}</p><div style="clear:both;"></div></li>{{/occurrences}}';
   241     + '<p class="Ls-Occ-More">{{formatted_date}} &mdash; {{univers.title}} &mdash; {{translated_status}} &mdash; {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}</p><div style="clear:both;"></div></li>{{/occurrences}}';
   242 
   242 
   243 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} &mdash; {{translated_status}}</p>'
   243 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}} &mdash; {{translated_status}}</p>'
   244     + '<p class="Tl-Tooltip-Description">{{description}}</p>'
   244     + '<p class="Tl-Tooltip-Description">{{description}}</p>'
   245 //    + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>'
   245 //    + '<p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>'
   257     this.$.find('.Tl-Main').css({
   257     this.$.find('.Tl-Main').css({
   258         width : this.width + "px",
   258         width : this.width + "px",
   259         height : this.height + "px"
   259         height : this.height + "px"
   260     });
   260     });
   261     this.main_height = this.height - this.$.find('.Tl-TopBar').outerHeight();
   261     this.main_height = this.height - this.$.find('.Tl-TopBar').outerHeight();
       
   262     //this.main_height = this.height - 27;
   262     this.$.find('.Tl-BottomPart').css("height", this.main_height + "px");
   263     this.$.find('.Tl-BottomPart').css("height", this.main_height + "px");
   263     this.$.find('.Tl-MainPart').css("width", this.main_width + "px");
   264     this.$.find('.Tl-MainPart').css("width", this.main_width + "px");
   264     this.$.find('.Tl-Overlay-Container').css("left", (this.$.find('.Tl-BottomPart').outerWidth() - this.main_width) + "px");
   265     this.$.find('.Tl-Overlay-Container').css("left", (this.$.find('.Tl-BottomPart').outerWidth() - this.main_width) + "px");
   265     this.$.find('canvas.Tl-Layer').attr({
   266     this.$.find('canvas.Tl-Layer').attr({
   266         width: this.main_width,
   267         width: this.main_width,
   434     
   435     
   435     
   436     
   436     /* BINDING MEDIADATA EVENTS */
   437     /* BINDING MEDIADATA EVENTS */
   437    
   438    
   438     $("body").bind("AjoutOccurrenceEditeur MiseAJourOccurrenceEditeur", function(_event, _data) {
   439     $("body").bind("AjoutOccurrenceEditeur MiseAJourOccurrenceEditeur", function(_event, _data) {
   439         var _type = _data.typeOccurrence.replace(/^occurrence/i,'').toLowerCase();
   440         var _type = _data.typeOccurrence.replace(/^Occurrence/i,'').toLowerCase();
   440         _this.createOrUpdateOccurrence(_type, _data);
   441         _this.createOrUpdateOccurrence(_type, _data);
   441         _this.throttledDrawGrid();
   442         _this.throttledDrawGrid();
       
   443         _this.throttledDrawList();
   442     });
   444     });
   443     
   445     
   444     $("body").bind("SuppressionOccurrenceEditeur", function(_event, _data) {
   446     $("body").bind("SuppressionOccurrenceEditeur", function(_event, _data) {
   445         var _id = _data.typeOccurrence.replace(/^occurrence/i,'').toLowerCase() + '_' + _data.id;
   447         var _id = _data.typeOccurrence.replace(/^Occurrence/i,'').toLowerCase() + '_' + _data.id;
   446         _this.deleteOccurrence(_id);
   448         _this.deleteOccurrence(_id);
   447         _this.throttledDrawGrid();
   449         _this.throttledDrawGrid();
       
   450         _this.throttledDrawList();
   448     });
   451     });
   449     
   452     
   450     $("body").bind("AjoutDependanceEditeur", function(_event, _data) {
   453     $("body").bind("AjoutDependanceEditeur", function(_event, _data) {
   451         var _sourceId = _data.typeOccurrence.replace(/^occurrence/i,'').toLowerCase() + '_' + _data.id,
   454         var _sourceId = _data.typeOccurrence.replace(/^Occurrence/i,'').toLowerCase() + '_' + _data.id,
   452             _targetId = _data.typeOccurrenceCible.replace(/^occurrence/i,'').toLowerCase() + '_' + _data.idCible;
   455             _targetId = _data.typeOccurrenceCible.replace(/^Occurrence/i,'').toLowerCase() + '_' + _data.idCible;
   453         _this.getOccurrence(_sourceId).addDependency(_targetId);
   456         _this.getOccurrence(_sourceId).addDependency(_targetId);
   454         _this.throttledDrawGrid();
   457         _this.throttledDrawGrid();
   455     });
   458     });
   456     
   459     
   457     $("body").bind("SuppressionDependanceEditeur", function(_event, _data) {
   460     $("body").bind("SuppressionDependanceEditeur", function(_event, _data) {
   458         var _sourceId = _data.typeOccurrence.replace(/^occurrence/i,'').toLowerCase() + '_' + _data.id,
   461         var _sourceId = _data.typeOccurrence.replace(/^Occurrence/i,'').toLowerCase() + '_' + _data.id,
   459             _targetId = _data.typeOccurrenceCible.replace(/^occurrence/i,'').toLowerCase() + '_' + _data.idCible;
   462             _targetId = _data.typeOccurrenceCible.replace(/^Occurrence/i,'').toLowerCase() + '_' + _data.idCible;
   460         _this.getOccurrence(_sourceId).addDependency(_targetId);
   463         _this.getOccurrence(_sourceId).removeDependency(_targetId);
   461         _this.throttledDrawGrid();
   464         _this.throttledDrawGrid();
   462     });
   465     });
   463     
   466     
   464     
   467     
   465 }
   468 }
   482         switch (this.dragging_type) {
   485         switch (this.dragging_type) {
   483             case "occurrence":
   486             case "occurrence":
   484                 var _event = ( this.editing_occurrence.just_created ? "Ajout" : "MiseAJour" ) + "OccurrenceTimeline",
   487                 var _event = ( this.editing_occurrence.just_created ? "Ajout" : "MiseAJour" ) + "OccurrenceTimeline",
   485                     _data = {
   488                     _data = {
   486                         id: this.editing_occurrence.original_id,
   489                         id: this.editing_occurrence.original_id,
   487                         typeOccurrence: "occurrence" + this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()}),
   490                         typeOccurrence: "Occurrence" + this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()}),
   488                         datePublication : Math.floor(this.editing_occurrence.date / 1000),
   491                         datePublication : Math.floor(this.editing_occurrence.date / 1000),
   489                         titre : this.editing_occurrence.title,
   492                         titre : this.editing_occurrence.title,
   490                         idUnivers: this.editing_occurrence.univers_id,
   493                         idUnivers: this.editing_occurrence.univers_id,
   491                         statut: this.statuses[this.editing_occurrence.status],
   494                         statut: this.statuses[this.editing_occurrence.status],
   492                         JT: +!!this.editing_occurrence.jt
   495                         JT: +!!this.editing_occurrence.jt
   509                 this.deleteOccurrence(this.editing_occurrence.id);
   512                 this.deleteOccurrence(this.editing_occurrence.id);
   510                 this.throttledDrawGrid();
   513                 this.throttledDrawGrid();
   511             } else {
   514             } else {
   512                 var _data = {
   515                 var _data = {
   513                     id: this.editing_occurrence.original_id,
   516                     id: this.editing_occurrence.original_id,
   514                     typeOccurrence: "occurrence" + this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()})
   517                     typeOccurrence: "Occurrence" + this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()})
   515                 }
   518                 }
   516                 $("body").trigger("SelectionOccurrenceTimeline", _data);
   519                 $("body").trigger("SelectionOccurrenceTimeline", _data);
   517             }
   520             }
   518         }
   521         }
   519     }
   522     }
   869             if (_target != _this.editing_occurrence.id) {
   872             if (_target != _this.editing_occurrence.id) {
   870                 _this.editing_occurrence.addDependency(_target);
   873                 _this.editing_occurrence.addDependency(_target);
   871                 $("body").trigger("AjoutDependanceTimeline",
   874                 $("body").trigger("AjoutDependanceTimeline",
   872                     {
   875                     {
   873                         id: _this.editing_occurrence.original_id,
   876                         id: _this.editing_occurrence.original_id,
   874                         typeOccurrence: "occurrence" + _this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()}),
   877                         typeOccurrence: "Occurrence" + _this.editing_occurrence.type.replace(/^./,function(_l) { return _l.toUpperCase()}),
   875                         idCible: _target.replace(/^.*_/,''),
   878                         idCible: _target.replace(/^.*_/,''),
   876                         typeOccurrenceCible: "occurrence" + _target.replace(/_.*$/,'').replace(/^./,function(_l) { return _l.toUpperCase()})
   879                         typeOccurrenceCible: "Occurrence" + _target.replace(/_.*$/,'').replace(/^./,function(_l) { return _l.toUpperCase()})
   877                     }
   880                     }
   878                 );
   881                 );
   879             }
   882             }
   880         }
   883         }
   881     });
   884     });
   946     if (_title) {
   949     if (_title) {
   947         this.$.find(".Ls-Occurrence-Title").each(function() {
   950         this.$.find(".Ls-Occurrence-Title").each(function() {
   948             $(this).html($(this).text().replace(_titleregexp, "<span style='background:yellow'>$1</span>"));
   951             $(this).html($(this).text().replace(_titleregexp, "<span style='background:yellow'>$1</span>"));
   949         });
   952         });
   950     }
   953     }
       
   954     this.$.find(".Ls-Occurrence").click(function() {
       
   955         var _id = $(this).attr("data-id"),
       
   956             _data = {
       
   957                 id: _id.replace(/^.*_/,''),
       
   958                 typeOccurrence: "Occurrence" + _id.replace(/_.*$/,'').replace(/^./,function(_l) { return _l.toUpperCase()})
       
   959             }
       
   960         $("body").trigger("SelectionOccurrenceTimeline", _data);
       
   961         return false;
       
   962     });
   951 }
   963 }
   952 
   964 
   953 Tlns.Classes.Timeline.prototype.getUnivers = function(_id) {
   965 Tlns.Classes.Timeline.prototype.getUnivers = function(_id) {
   954     return _(this.univers).find(function(_univ) {
   966     return _(this.univers).find(function(_univ) {
   955         return (_univ.id == _id);
   967         return (_univ.id == _id);