--- a/timeline/js/timeline.js Mon Jul 02 18:45:22 2012 +0200
+++ b/timeline/js/timeline.js Wed Jul 04 16:13:49 2012 +0200
@@ -63,6 +63,32 @@
});
}
+Tlns.Utils.drawArrow = function(_ctx, _color, _x1, _y1, _x2, _y2) {
+ _ctx.strokeStyle = _color;
+ _ctx.fillStyle = _color;
+ _ctx.beginPath();
+ _ctx.moveTo(_x1,_y1);
+ _ctx.lineTo(_x2,_y2);
+ _ctx.stroke();
+ var _mod = Math.sqrt(Math.pow(_x2 - _x1, 2) + Math.pow(_y2 - _y1, 2)),
+ _xu = (_x2 - _x1) / _mod,
+ _yu = (_y2 - _y1) / _mod,
+ _xm = (_x1 + _x2) / 2,
+ _ym = (_y1 + _y2) / 2,
+ _arrowWidth = 4,
+ _arrowLength = 8,
+ _x3 = _xm - _arrowLength * _xu + _arrowWidth * _yu,
+ _y3 = _ym - _arrowLength * _yu - _arrowWidth * _xu,
+ _x4 = _xm - _arrowLength * _xu - _arrowWidth * _yu,
+ _y4 = _ym - _arrowLength * _yu + _arrowWidth * _xu;
+ _ctx.beginPath();
+ _ctx.moveTo(_x3, _y3);
+ _ctx.lineTo(_xm, _ym);
+ _ctx.lineTo(_x4, _y4);
+ _ctx.fill();
+ _ctx.stroke();
+}
+
/* Defaults */
Tlns.Defaults.Timeline = {
@@ -138,7 +164,7 @@
+ '<div class="Tl-BottomPart"><ul class="Tl-UniversLabels"></ul>'
+ '<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>'
+ '<ul class="Tl-Adding"><li class="Tl-AddingTitle">Ajout d\'une occurrence</li><li><span>Narrative</span><div class="Tl-AddOccurrence Tl-Occnarrative" occurrence-type="narrative" title="Glisser sur la frise chronologique pour ajouter"></div></li>'
- + '<li><span>De Production</span><div class="Tl-AddOccurrence Tl-Occproduction" occurrence-type="production" title="Glisser sur la frise chronologique pour ajouter"></div></li></ul></div>'
+ + '<li><span>De Publication</span><div class="Tl-AddOccurrence Tl-Occpublication" occurrence-type="publication" title="Glisser sur la frise chronologique pour ajouter"></div></li></ul></div>'
+ '<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>';
Tlns.Templates.Univers = '<span class="Tl-UniversText">{{title}}</span>';
@@ -358,11 +384,14 @@
case "link":
var _ctx = this.$.find('.Tl-Linking-Canvas')[0].getContext('2d');
_ctx.clearRect(0,0,this.main_width, this.main_height);
- _ctx.beginPath();
- _ctx.strokeStyle = '#800080';
- _ctx.moveTo(this.editing_occurrence.x,this.editing_occurrence.y + Math.floor(this.univers_height / 2));
- _ctx.lineTo(_event.pageX - this.dragging_bounds.left, _event.pageY - this.dragging_bounds.top);
- _ctx.stroke();
+ Tlns.Utils.drawArrow(
+ _ctx,
+ '#800080',
+ this.editing_occurrence.x,
+ this.editing_occurrence.y + Math.floor(this.univers_height / 2),
+ _event.pageX - this.dragging_bounds.left,
+ _event.pageY - this.dragging_bounds.top
+ );
break;
}
}
@@ -459,8 +488,8 @@
for (var _i = 0; _i < _data.occurrencesNarratives.length; _i++) {
this.createOrUpdateOccurrence("narrative", _data.occurrencesNarratives[_i]);
}
- for (var _i = 0; _i < _data.occurrencesProduction.length; _i++) {
- this.createOrUpdateOccurrence("production", _data.occurrencesProduction[_i]);
+ for (var _i = 0; _i < _data.occurrencesPublication.length; _i++) {
+ this.createOrUpdateOccurrence("publication", _data.occurrencesPublication[_i]);
}
}
if (!this.mouse_down) {
@@ -602,10 +631,7 @@
var _ctx = this.$.find('.Tl-Canvas')[0].getContext('2d');
_ctx.clearRect(0,0,this.main_width, this.main_height);
_(_links).each(function(_link) {
- _ctx.beginPath();
- _ctx.moveTo(_link.from_x,_link.from_y);
- _ctx.lineTo(_link.to_x,_link.to_y);
- _ctx.stroke();
+ Tlns.Utils.drawArrow(_ctx, "#505050", _link.from_x,_link.from_y, _link.to_x,_link.to_y);
});
var _html = Mustache.to_html(Tlns.Templates.Occurrence, {
@@ -647,9 +673,11 @@
if (!_occurrence.locked) {
_el.find('.Tl-Link').show();
}
- _occurrence.formatted_date = Tlns.Utils.dateFormat(_occurrence.date,_this.tooltip_date_format);
- var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence);
- _this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) );
+ if (!_this.is_dragging) {
+ _occurrence.formatted_date = Tlns.Utils.dateFormat(_occurrence.date,_this.tooltip_date_format);
+ var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence);
+ _this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) );
+ }
}
}).mouseout(function() {
var _el = $(this),