# HG changeset patch # User veltr # Date 1338300986 -7200 # Node ID 43012525c832d1c5436e2e3cea63867deeb9424b # Parent 7bb5f89ad24261a7a611477c654594c4a2905547 Added linking and better Tooltip diff -r 7bb5f89ad242 -r 43012525c832 timeline/assets/sprites.psd Binary file timeline/assets/sprites.psd has changed diff -r 7bb5f89ad242 -r 43012525c832 timeline/css/timeline.css --- a/timeline/css/timeline.css Fri May 25 16:45:40 2012 +0200 +++ b/timeline/css/timeline.css Tue May 29 16:16:26 2012 +0200 @@ -112,7 +112,11 @@ } .Tl-OccInCluster { - float: left; + float: left; position: relative; +} + +.Tl-Locked { + position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: url(../img/sprites.png); background-position: -57px -50px; } .Tl-Occnarrative { @@ -135,6 +139,10 @@ background-position: -38px -50px; } +.Tl-Link { + position: absolute; left: 0; bottom: 0; width: 11px; height: 11px; background: url(../img/sprites.png) -38px -83px; display: none; +} + .Tl-ClusterCount { position: absolute; right: 0; top: 0; border: 1px solid #999999; background: #333333; padding: 1px 2px; font-size: 9px; color: #ffffff; border-radius: 5px; @@ -187,3 +195,15 @@ .Tl-Overlay-Up .Tl-Overlay-Tip-Top, .Tl-Overlay-Down .Tl-Overlay-Tip-Bottom { display: none; } + +h3.Tl-Tooltip-Title { + font-size: 14px; font-weight: bold; color: #000080; margin: 0; +} + +p.Tl-Tooltip-Date { + font-size: 11px; margin: 2px 0; color: #000080; border-bottom: 1px dotted; float: left; +} + +p.Tl-Tooltip-Description, p.Tl-Tooltip-Characters { + font-size: 12px; margin: 5px 0 0; clear: both; +} diff -r 7bb5f89ad242 -r 43012525c832 timeline/data/occurrences.json --- a/timeline/data/occurrences.json Fri May 25 16:45:40 2012 +0200 +++ b/timeline/data/occurrences.json Tue May 29 16:16:26 2012 +0200 @@ -74,7 +74,7 @@ "univers" : "U06", "statut" : "valide", "publie" : true, - "verrouille" : false, + "verrouille" : true, "dependDe" : [ "N01" ] @@ -100,7 +100,6 @@ "publie" : true, "verrouille" : false, "dependDe" : [ - "N01", "N03" ] } diff -r 7bb5f89ad242 -r 43012525c832 timeline/img/sprites.png Binary file timeline/img/sprites.png has changed diff -r 7bb5f89ad242 -r 43012525c832 timeline/js/timeline.js --- a/timeline/js/timeline.js Fri May 25 16:45:40 2012 +0200 +++ b/timeline/js/timeline.js Tue May 29 16:16:26 2012 +0200 @@ -115,7 +115,8 @@ sync_now: true, url_occurrences: '', occurrences: [], - cluster_spacing: 10 + cluster_spacing: 10, + tooltip_date_format: '{{dayOfMonth}} {{shortMonthName}} {{year}} {{0hours}}:{{0minutes}}' } for (var _i = 0; _i < Tlns.Defaults.Timeline.timescales.length; _i++) { @@ -128,12 +129,20 @@ + '
--/--
' + '
' + '
{{#timescales}}
{{label}}
{{/timescales}}
' - + '
' + + '
' + '
'; Tlns.Templates.Univers = '{{title}}'; -Tlns.Templates.Occurrence = '{{#clusters}}
{{occurrences.length}}
{{/clusters}}{{#occurrences}}
{{/occurrences}}{{#open_cluster}}
{{#occurrences}}
{{/occurrences}}
{{/open_cluster}}'; +Tlns.Templates.Occurrence = '{{#clusters}}
' + + '
{{occurrences.length}}
{{/clusters}}' + + '{{#occurrences}}
' + + '{{#locked}}
{{/locked}}
{{/occurrences}}{{#open_cluster}}
' + + '{{#occurrences}}
' + + '{{#locked}}
{{/locked}}
{{/occurrences}}
{{/open_cluster}}'; + +Tlns.Templates.OccurrenceTooltip = '

{{title}}

{{formatted_date}}

' + + '

{{description}}

{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}

' /* Classes */ @@ -155,7 +164,7 @@ this.$.find('.Tl-BottomPart').css("height", this.main_height + "px"); this.$.find('.Tl-MainPart').css("width", this.main_width + "px"); this.$.find('.Tl-Overlay-Container').css("left", (this.$.find('.Tl-BottomPart').outerWidth() - this.main_width) + "px"); - this.$.find('.Tl-Canvas').attr({ + this.$.find('canvas.Tl-Layer').attr({ width: this.main_width, height: this.main_height }); @@ -253,6 +262,12 @@ this.editing_occurrence.editing = false; this.throttledDrawGrid(); break; + case "link": + this.editing_occurrence.editing = false; + this.throttledDrawGrid(); + var _ctx = this.$.find('.Tl-Linking-Canvas')[0].getContext('2d'); + _ctx.clearRect(0,0,this.main_width, this.main_height); + break; } } this.mouse_down = false; @@ -284,6 +299,15 @@ case "timeline": this.setTime(this.time_at_start + Math.floor(( this.start_pos.x - _event.pageX ) / this.current_scale)); break; + 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(); + break; } } } @@ -474,6 +498,9 @@ } } _(_clusters).each(function(_cluster) { + _cluster.occurrences = _(_cluster.occurrences).sortBy(function(_o) { + return _o.date; + }); _cluster.type = _cluster.occurrences[0].type; _cluster.contents = _cluster.occurrences.map(function(_o) { return _o.type + ":" + _o.id; @@ -515,9 +542,7 @@ _ctx.moveTo(_link.from_x,_link.from_y); _ctx.lineTo(_link.to_x,_link.to_y); _ctx.stroke(); - }) - - console.log(_openCluster); + }); var _html = Mustache.to_html(Tlns.Templates.Occurrence, { occurrences:_(_visible).reject(function(_o) {return _o.in_cluster}), @@ -542,18 +567,43 @@ this.$.find('.Tl-Occurrence').mousedown(function() { var _el = $(this); - _this.editing_occurrence = _occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); - if (typeof _this.editing_occurrence !== "undefined") { + _this.editing_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); + if (typeof _this.dragging_type === "undefined" && typeof _this.editing_occurrence !== "undefined" && !_this.editing_occurrence.locked) { _this.dragging_type = "occurrence"; _this.editing_occurrence.editing = true; } }).mouseover(function(_event) { var _el = $(this), _occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); - _this.showTooltip(_occurrence.x, _occurrence.y, _occurrence.title, (_event.pageY - _this.dragging_bounds.top) > (_this.main_height / 2) ); + 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) ); }).mouseout(function() { + var _el = $(this), + _occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); _this.hideTooltip(); + if (!_occurrence.editing) { + $(this).find('.Tl-Link').hide(); + } + }).mouseup(function() { + var _el = $(this); + if (_this.dragging_type == "link" && _el.attr("occurrence-type") == "narrative") { + _this.editing_occurrence.addDependency(_el.attr("occurrence-id")); + } }); + + this.$.find('.Tl-Link').mousedown(function() { + var _el = $(this).parent(); + _this.editing_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); + if (typeof _this.editing_occurrence !== "undefined" && !_this.editing_occurrence.locked) { + _this.dragging_type = "link"; + _this.editing_occurrence.editing = true; + } + }) + this.$.find('.Tl-Cluster').click(function() { var _el = $(this), _contents = _el.attr("cluster-contents"); @@ -562,7 +612,6 @@ } else { _this.open_cluster = _contents; } - console.log(_this.open_cluster); _this.throttledDrawGrid(); }) } @@ -619,6 +668,13 @@ this.locked = _data.verrouille || false; this.characters = _data.personnagesSecondaires || []; this.dependsOn = _data.dependDe || []; + this.description = _data.description || ""; +} + +Tlns.Classes.Occurrence.prototype.addDependency = function(_id) { + if (_(this.dependsOn).indexOf(_id) == -1) { + this.dependsOn.push(_id); + } } Tlns.Classes.Occurrence.prototype.toString = function() {