# HG changeset patch # User veltr # Date 1341247522 -7200 # Node ID a000f6a29dfaa59f29d2c2f8434627a888bf414d # Parent fa03eb8a3fe564bcf71e30d5d1c69acb6f5607c6 Added production-production linking capabilities diff -r fa03eb8a3fe5 -r a000f6a29dfa timeline/js/timeline.js --- a/timeline/js/timeline.js Wed Jun 27 13:15:28 2012 +0200 +++ b/timeline/js/timeline.js Mon Jul 02 18:45:22 2012 +0200 @@ -145,9 +145,9 @@ Tlns.Templates.Occurrence = '{{#clusters}}
{{formatted_date}}
' @@ -468,20 +468,21 @@ } } -Tlns.Classes.Timeline.prototype.deleteOccurrence = function(_type, _id) { +Tlns.Classes.Timeline.prototype.deleteOccurrence = function(_id) { this.occurrences = _(this.occurrences).reject(function(_occ) { - return (_occ.type == _type && _occ.id == _id); + return occ.id == _id; }); } -Tlns.Classes.Timeline.prototype.getOccurrence = function(_type, _id) { +Tlns.Classes.Timeline.prototype.getOccurrence = function(_id) { return _(this.occurrences).find(function(_occ) { - return (_occ.type == _type && _occ.id == _id); + return _occ.id == _id; }); } Tlns.Classes.Timeline.prototype.createOrUpdateOccurrence = function(_type, _data) { - var _occurrence = this.getOccurrence(_type, _data.id); + var _id = _type + "_" + _data.id, + _occurrence = this.getOccurrence(_id); if (typeof _occurrence === "undefined") { _occurrence = new Tlns.Classes.Occurrence(this); this.occurrences.push(_occurrence); @@ -585,7 +586,7 @@ _(_visible).each(function(_occurrence) { _(_occurrence.dependsOn).each(function(_dependance) { var _parent = _(_visible).find(function(_o) { - return _o.type == "narrative" && _o.id == _dependance; + return _o.id == _dependance; }); if (typeof _parent !== "undefined") { _links.push({ @@ -630,10 +631,9 @@ this.$.find('.Tl-Occurrence').mousedown(function() { var _el = $(this), - _type = _el.attr("occurrence-type"), _id = _el.attr("occurrence-id"); - if (typeof _type !== "undefined" && typeof _id !== "undefined") { - _this.editing_occurrence = _this.getOccurrence(_type,_id); + if (typeof _id !== "undefined") { + _this.editing_occurrence = _this.getOccurrence(_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; @@ -641,10 +641,9 @@ } }).mouseover(function(_event) { var _el = $(this), - _type = _el.attr("occurrence-type"), _id = _el.attr("occurrence-id"); - if (typeof _type !== "undefined" && typeof _id !== "undefined") { - var _occurrence = _this.getOccurrence(_type, _id); + if (typeof _id !== "undefined") { + var _occurrence = _this.getOccurrence(_id); if (!_occurrence.locked) { _el.find('.Tl-Link').show(); } @@ -654,10 +653,9 @@ } }).mouseout(function() { var _el = $(this), - _type = _el.attr("occurrence-type"), _id = _el.attr("occurrence-id"); - if (typeof _type !== "undefined" && typeof _id !== "undefined") { - var _occurrence = _this.getOccurrence(_type, _id); + if (typeof _id !== "undefined") { + var _occurrence = _this.getOccurrence(_id); _this.hideTooltip(); if (!_occurrence.editing) { $(this).find('.Tl-Link').hide(); @@ -665,14 +663,15 @@ } }).mouseup(function() { var _el = $(this); - if (_this.dragging_type == "link" && _el.attr("occurrence-type") == "narrative") { + if (_this.dragging_type == "link") { _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")); + var _el = $(this).parent(), + _id = _el.attr("occurrence-id"); + _this.editing_occurrence = _this.getOccurrence(_id); if (typeof _this.editing_occurrence !== "undefined" && !_this.editing_occurrence.locked) { _this.dragging_type = "link"; _this.editing_occurrence.editing = true; @@ -733,7 +732,8 @@ Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { this.type = _type; - this.id = _data.id || Tlns.Utils.guid(); + this.original_id = _data.id || Tlns.Utils.guid(); + this.id = _type + "_" + this.original_id; this.date = _data.date || _data.datePublication; this.title = _data.titre || "