# HG changeset patch # User veltr # Date 1341411229 -7200 # Node ID 642ef9139fad91aa4edafc8c85ecf9e4117a8aa4 # Parent a000f6a29dfaa59f29d2c2f8434627a888bf414d Replaced "Production" by "Publication". Added beautiful arrows diff -r a000f6a29dfa -r 642ef9139fad timeline/css/timeline.css --- a/timeline/css/timeline.css Mon Jul 02 18:45:22 2012 +0200 +++ b/timeline/css/timeline.css Wed Jul 04 16:13:49 2012 +0200 @@ -123,7 +123,7 @@ background-position: 0 -50px; } -.Tl-Occproduction { +.Tl-Occpublication { background-position: -19px -50px; } @@ -131,7 +131,7 @@ background-position: 0 -72px; } -.Tl-Occproduction.Tl-Editing { +.Tl-Occpublication.Tl-Editing { background-position: -19px -72px; } diff -r a000f6a29dfa -r 642ef9139fad timeline/data/occurrences.json --- a/timeline/data/occurrences.json Mon Jul 02 18:45:22 2012 +0200 +++ b/timeline/data/occurrences.json Wed Jul 04 16:13:49 2012 +0200 @@ -65,12 +65,12 @@ ] } ], - "occurrencesProduction" : [ + "occurrencesPublication" : [ { "id" : "P01", "datePublication" : 1336608060000, - "titre" : "Production 1", - "description" : "Ma première occurrence de production", + "titre" : "Publication 1", + "description" : "Ma première occurrence de publication", "univers" : "U06", "statut" : "valide", "publie" : true, @@ -82,8 +82,8 @@ { "id" : "P02", "datePublication" : 1336608240000, - "titre" : "Production 2", - "description" : "Ma deuxième occurrence de production", + "titre" : "Publication 2", + "description" : "Ma deuxième occurrence de publication", "univers" : "U04", "statut" : "valide", "publie" : true, @@ -93,8 +93,8 @@ { "id" : "P03", "datePublication" : 1336608300000, - "titre" : "Production 3", - "description" : "Ma troisième occurrence de production", + "titre" : "Publication 3", + "description" : "Ma troisième occurrence de publication", "univers" : "U04", "statut" : "valide", "publie" : true, diff -r a000f6a29dfa -r 642ef9139fad timeline/js/timeline.js --- 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 @@ + '
' + '
' + '
' + + '
  • De Publication
  • ' + '
    '; Tlns.Templates.Univers = '{{title}}'; @@ -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),