--- 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}}<div class="Tl-Cluster Tl-Occ{{type}}" style="left: {{x}}px; top: {{y}}px;" cluster-contents="{{contents}}">'
+ '<div class="Tl-ClusterCount">{{occurrences.length}}</div></div>{{/clusters}}'
- + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-type="{{type}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;">'
+ + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;">'
+ '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<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;">'
- + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-type="{{type}}" occurrence-id="{{id}}">'
+ + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}">'
+ '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}';
Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}}</p>'
@@ -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 || "<untitled>";
this.univers_id = _data.univers;
@@ -742,7 +742,9 @@
this.published = _data.publie || false;
this.locked = _data.verrouille || false;
this.characters = _data.personnagesSecondaires || [];
- this.dependsOn = _data.dependDe || [];
+ this.dependsOn = _(_data.dependDe || []).map(function(_id) {
+ return "narrative_" + _id;
+ });
this.description = _data.description || "";
}