author | veltr |
Tue, 29 May 2012 16:16:26 +0200 | |
changeset 70 | 43012525c832 |
parent 69 | 7bb5f89ad242 |
child 71 | fa03eb8a3fe5 |
permissions | -rw-r--r-- |
65 | 1 |
/* |
2 |
* Main Timeline code |
|
3 |
*/ |
|
4 |
||
5 |
window.Tlns = { |
|
6 |
Utils : {}, |
|
7 |
Defaults : {}, |
|
8 |
Templates : {}, |
|
9 |
Classes : {} |
|
10 |
}; |
|
11 |
||
12 |
/* Utility Functions */ |
|
13 |
||
14 |
Tlns.Utils.SetDefaults = function(_object, _defaults, _options) { |
|
15 |
var _options = _options || {}; |
|
16 |
_(_defaults).each(function(_v, _k) { |
|
17 |
if(/^m(in|ax)_/.test(_k)) { |
|
18 |
var _tab = _k.split('_') |
|
19 |
if( typeof _object[_tab[1]] !== "undefined") { |
|
20 |
var _fn = (_tab[0] === "min" ? Math.max : Math.min); |
|
21 |
_object[_tab[1]] = _fn(_object[_tab[1]], _v); |
|
22 |
} |
|
23 |
} else { |
|
24 |
if( typeof _options[_k] !== "undefined") { |
|
25 |
_object[_k] = _options[_k]; |
|
26 |
} else { |
|
27 |
_object[_k] = _v; |
|
28 |
} |
|
29 |
} |
|
30 |
}); |
|
31 |
} |
|
32 |
||
33 |
Tlns.Utils.dateFormat = function(_date, _template) { |
|
34 |
if (typeof _data !== "object") { |
|
35 |
_date = new Date(_date); |
|
36 |
} |
|
37 |
function zeroPad(_n) { |
|
38 |
return (_n < 10 ? "0" : "") + _n |
|
39 |
} |
|
40 |
var _params = { |
|
41 |
hours: _date.getHours(), |
|
42 |
"0hours": zeroPad(_date.getHours()), |
|
43 |
minutes: _date.getMinutes(), |
|
44 |
"0minutes": zeroPad(_date.getMinutes()), |
|
45 |
seconds: _date.getSeconds(), |
|
46 |
"0seconds": zeroPad(_date.getSeconds()), |
|
47 |
dayOfWeek: ["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"][_date.getDay()], |
|
48 |
shortDayOfWeek: ["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"][_date.getDay()], |
|
49 |
dayOfMonth: _date.getDate(), |
|
50 |
"0dayOfMonth": zeroPad(_date.getDate()), |
|
51 |
monthNumber: 1+_date.getMonth(), |
|
52 |
"0monthNumber": zeroPad(1+_date.getMonth()), |
|
53 |
monthName: ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"][_date.getMonth()], |
|
54 |
shortMonthName: ["jan","fev","mar","avr","mai","jun","jul","aou","sep","oct","nov","dec"][_date.getMonth()], |
|
55 |
year: _date.getFullYear() |
|
56 |
} |
|
57 |
return Mustache.to_html(_template, _params); |
|
58 |
} |
|
59 |
||
60 |
/* Defaults */ |
|
61 |
||
62 |
Tlns.Defaults.Timeline = { |
|
63 |
container : "timeline", |
|
64 |
width : 950, |
|
65 |
height : 200, |
|
66 |
url_univers : '', |
|
67 |
min_width : 400, |
|
68 |
min_height : 100, |
|
69 |
main_width : 800, |
|
70 |
timescales : [{ |
|
71 |
label : "Mois", |
|
72 |
span : 32 * 86400 * 1000, |
|
73 |
grid_interval : 5 * 86400 * 1000, |
|
74 |
grid_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
|
75 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
|
76 |
end_date_format : '{{dayOfMonth}} {{shortMonthName}} {{year}}' |
|
77 |
}, { |
|
78 |
label : "Semaine", |
|
79 |
span : 8 * 86400 * 1000, |
|
80 |
grid_interval : 86400 * 1000, |
|
81 |
grid_date_format : '{{shortDayOfWeek}} {{0dayOfMonth}}/{{0monthNumber}}', |
|
82 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
|
83 |
end_date_format : '{{dayOfMonth}} {{shortMonthName}}' |
|
84 |
}, { |
|
85 |
label : "2 jours", |
|
86 |
span : 2 * 86400 * 1000, |
|
87 |
grid_interval : 8 * 3600 * 1000, |
|
88 |
grid_date_format : '{{shortDayOfWeek}} {{0dayOfMonth}}/{{0monthNumber}} {{hours}}h', |
|
89 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
|
90 |
end_date_format : '{{dayOfMonth}} {{shortMonthName}}' |
|
91 |
}, { |
|
92 |
label : "Demi-Journée", |
|
93 |
span : 12 * 3600 * 1000, |
|
94 |
grid_interval : 2 * 3600 * 1000, |
|
95 |
grid_date_format : '{{hours}}h', |
|
96 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h', |
|
97 |
end_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h' |
|
98 |
}, { |
|
99 |
label : "3 Heures", |
|
100 |
span : 3 * 3600 * 1000, |
|
101 |
grid_interval : 30 * 60 * 1000, |
|
102 |
grid_date_format : '{{0hours}}:{{0minutes}}', |
|
103 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}} {{0hours}}:{{0minutes}}', |
|
104 |
end_date_format : '{{0hours}}:{{0minutes}}' |
|
105 |
}, { |
|
106 |
label : "1 Heure", |
|
66 | 107 |
span : 60 * 60 * 1000, |
65 | 108 |
grid_interval : 15 * 60 * 1000, |
109 |
grid_date_format : '{{0hours}}:{{0minutes}}', |
|
110 |
start_date_format : '{{dayOfMonth}} {{shortMonthName}} {{0hours}}:{{0minutes}}', |
|
111 |
end_date_format : '{{0hours}}:{{0minutes}}' |
|
112 |
}], |
|
113 |
level: 0, |
|
114 |
central_time: 0, |
|
115 |
sync_now: true, |
|
116 |
url_occurrences: '', |
|
66 | 117 |
occurrences: [], |
70 | 118 |
cluster_spacing: 10, |
119 |
tooltip_date_format: '{{dayOfMonth}} {{shortMonthName}} {{year}} {{0hours}}:{{0minutes}}' |
|
65 | 120 |
} |
121 |
||
122 |
for (var _i = 0; _i < Tlns.Defaults.Timeline.timescales.length; _i++) { |
|
123 |
Tlns.Defaults.Timeline.timescales[_i].level = _i; |
|
124 |
} |
|
125 |
||
126 |
/* Templates */ |
|
127 |
||
128 |
Tlns.Templates.Timeline = '<div class="Tl-TopBar"><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-AddButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
|
129 |
+ '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-PreviousButton"></div></div><div class="Tl-TopBar-TimeSpan Tl-TopBar-TextBtn Tl-Border-Right">--/--</div>' |
|
130 |
+ '<div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-SyncButton"></div></div><div class="Tl-TopBar-Button Tl-Border-Right"><div class="Tl-TopBar-NextButton"></div></div><div class="Tl-TopBar-Spacer Tl-Border-Right"></div>' |
|
131 |
+ '<div class="Tl-TopBar-Timescales">{{#timescales}}<div class="Tl-TopBar-Button Tl-TopBar-TextBtn Tl-Border-Right" data-level="{{level}}">{{label}}</div>{{/timescales}}</div></div>' |
|
70 | 132 |
+ '<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></div>' |
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
133 |
+ '<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>'; |
65 | 134 |
|
66 | 135 |
Tlns.Templates.Univers = '<span class="Tl-UniversText">{{title}}</span>'; |
136 |
||
70 | 137 |
Tlns.Templates.Occurrence = '{{#clusters}}<div class="Tl-Cluster Tl-Occ{{type}}" style="left: {{x}}px; top: {{y}}px;" cluster-contents="{{contents}}">' |
138 |
+ '<div class="Tl-ClusterCount">{{occurrences.length}}</div></div>{{/clusters}}' |
|
139 |
+ '{{#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;">' |
|
140 |
+ '{{#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;">' |
|
141 |
+ '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-type="{{type}}" occurrence-id="{{id}}">' |
|
142 |
+ '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}'; |
|
143 |
|
|
144 |
Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}}</p>' |
|
145 |
+ '<p class="Tl-Tooltip-Description">{{description}}</p><p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
|
65 | 146 |
|
147 |
/* Classes */ |
|
148 |
||
149 |
Tlns.Classes.Timeline = function(_options) { |
|
150 |
||
151 |
/* Setting Defaults */ |
|
152 |
Tlns.Utils.SetDefaults(this, Tlns.Defaults.Timeline, _options); |
|
153 |
||
154 |
/* Setting container CSS */ |
|
155 |
this.$ = $('#' + this.container); |
|
156 |
this.$.addClass('Tl-Main'); |
|
157 |
this.$.css({ |
|
158 |
width : this.width + "px", |
|
159 |
height : this.height + "px" |
|
160 |
}); |
|
161 |
this.$.html(Mustache.to_html(Tlns.Templates.Timeline, this)); |
|
162 |
|
|
163 |
this.main_height = this.height - this.$.find('.Tl-TopBar').outerHeight(); |
|
164 |
this.$.find('.Tl-BottomPart').css("height", this.main_height + "px"); |
|
165 |
this.$.find('.Tl-MainPart').css("width", this.main_width + "px"); |
|
67 | 166 |
this.$.find('.Tl-Overlay-Container').css("left", (this.$.find('.Tl-BottomPart').outerWidth() - this.main_width) + "px"); |
70 | 167 |
this.$.find('canvas.Tl-Layer').attr({ |
67 | 168 |
width: this.main_width, |
169 |
height: this.main_height |
|
170 |
}); |
|
65 | 171 |
var _o = this.$.find('.Tl-MainPart').offset(); |
172 |
this.dragging_bounds = { |
|
173 |
left: _o.left, |
|
174 |
top: _o.top, |
|
175 |
right: _o.left + this.$.find('.Tl-MainPart').outerWidth(), |
|
176 |
bottom: _o.top + this.$.find('.Tl-MainPart').outerHeight(), |
|
177 |
}; |
|
178 |
|
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
179 |
var _this = this; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
180 |
|
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
181 |
this.throttledDrawGrid = _.throttle(function() { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
182 |
_this.drawGrid(); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
183 |
}, 150); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
184 |
|
65 | 185 |
this.setLevel(this.level); |
186 |
|
|
187 |
this.$.find('.Tl-TopBar-Timescales>div').click(function() { |
|
188 |
_this.setLevel($(this).attr("data-level")); |
|
189 |
}); |
|
190 |
|
|
191 |
this.$.find('.Tl-TopBar-SyncButton').click(function() { |
|
192 |
_this.sync_now = !_this.sync_now; |
|
193 |
_this.drawGrid(); |
|
194 |
}) |
|
195 |
|
|
196 |
this.$.find('.Tl-TopBar-PreviousButton').click(function() { |
|
197 |
_this.offsetTime(-_this.timescales[_this.level].span / 4); |
|
198 |
}); |
|
199 |
|
|
200 |
this.$.find('.Tl-TopBar-NextButton').click(function() { |
|
201 |
_this.offsetTime(_this.timescales[_this.level].span / 4); |
|
202 |
}); |
|
203 |
|
|
204 |
this.$.find('.Tl-MainPart').mousedown(function(_event) { |
|
205 |
_this.onMouseDown(_event); |
|
206 |
return false; |
|
207 |
}); |
|
208 |
|
|
209 |
this.$.find('.Tl-MainPart').mousemove(function(_event) { |
|
210 |
_this.onMouseMove(_event); |
|
211 |
return false; |
|
212 |
}); |
|
213 |
|
|
214 |
this.$.find('.Tl-MainPart').mouseup(function(_event) { |
|
215 |
_this.onMouseUp(_event); |
|
216 |
return false; |
|
217 |
}); |
|
218 |
|
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
219 |
this.$.find('.Tl-MainPart').mousewheel(function(_event, _delta) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
220 |
var _newLevel = Math.max(0,Math.min(_this.timescales.length-1, (_delta < 0 ? -1 : 1) + parseInt(_this.level))); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
221 |
if (_newLevel != _this.level) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
222 |
_this.hideTooltip(); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
223 |
var _deltaX = _event.pageX - _this.dragging_bounds.left, |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
224 |
_tAtMouse = _this.timeFromMouse(_event.pageX), |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
225 |
_newScale = _this.main_width / (_this.timescales[_newLevel].span), |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
226 |
_newStart = _tAtMouse - _deltaX / _newScale; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
227 |
_this.central_time = _newStart + _this.timescales[_newLevel].span / 2; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
228 |
_this.setLevel(_newLevel); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
229 |
} |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
230 |
return false; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
231 |
}); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
232 |
|
66 | 233 |
this.$.find('.Tl-Overlay-Box').mouseover(function(_event) { |
234 |
$(this).show(); |
|
235 |
}).mouseout(function(_event) { |
|
236 |
$(this).hide(); |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
237 |
}); |
65 | 238 |
|
239 |
/* Loading Univers */ |
|
240 |
$.getJSON(this.url_univers, function(_data) { |
|
241 |
_this.onUniversLoaded(_data); |
|
242 |
}); |
|
243 |
} |
|
244 |
||
245 |
Tlns.Classes.Timeline.prototype.onMouseDown = function(_event) { |
|
246 |
this.mouse_down = true; |
|
247 |
this.is_dragging = false; |
|
248 |
this.start_pos = { |
|
249 |
x: _event.pageX, |
|
250 |
y: _event.pageY |
|
251 |
}; |
|
66 | 252 |
if (typeof this.dragging_type === "undefined") { |
67 | 253 |
this.time_at_start = this.central_time; |
66 | 254 |
this.dragging_type = "timeline"; |
65 | 255 |
} |
256 |
} |
|
257 |
||
258 |
Tlns.Classes.Timeline.prototype.onMouseUp = function(_event) { |
|
67 | 259 |
if (this.is_dragging) { |
260 |
switch (this.dragging_type) { |
|
261 |
case "occurrence": |
|
262 |
this.editing_occurrence.editing = false; |
|
263 |
this.throttledDrawGrid(); |
|
264 |
break; |
|
70 | 265 |
case "link": |
266 |
this.editing_occurrence.editing = false; |
|
267 |
this.throttledDrawGrid(); |
|
268 |
var _ctx = this.$.find('.Tl-Linking-Canvas')[0].getContext('2d'); |
|
269 |
_ctx.clearRect(0,0,this.main_width, this.main_height); |
|
270 |
break; |
|
67 | 271 |
} |
272 |
} |
|
65 | 273 |
this.mouse_down = false; |
274 |
this.is_dragging = false; |
|
66 | 275 |
this.dragging_type = undefined; |
65 | 276 |
} |
277 |
||
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
278 |
Tlns.Classes.Timeline.prototype.timeFromX = function(_x) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
279 |
return Math.max(this.start_time,Math.min(this.end_time, this.start_time + _x / this.current_scale)); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
280 |
} |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
281 |
|
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
282 |
Tlns.Classes.Timeline.prototype.timeFromMouse = function(_pageX) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
283 |
return this.timeFromX(_pageX - this.dragging_bounds.left); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
284 |
} |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
285 |
|
65 | 286 |
Tlns.Classes.Timeline.prototype.onMouseMove = function(_event) { |
287 |
if (this.mouse_down) { |
|
288 |
this.is_dragging = true; |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
289 |
this.hideTooltip(); |
69 | 290 |
switch (this.dragging_type) { |
291 |
case "occurrence": |
|
292 |
var _d = this.timeFromMouse(_event.pageX); |
|
293 |
this.editing_occurrence.date = _d; |
|
294 |
var _u = Math.max(0,Math.min(this.univers.length, Math.floor((_event.pageY - this.dragging_bounds.top) / this.univers_height))); |
|
295 |
this.editing_occurrence.univers = this.univers[_u]; |
|
296 |
this.editing_occurrence.univers_id = this.univers[_u].id; |
|
297 |
this.throttledDrawGrid(); |
|
298 |
break; |
|
299 |
case "timeline": |
|
300 |
this.setTime(this.time_at_start + Math.floor(( this.start_pos.x - _event.pageX ) / this.current_scale)); |
|
301 |
break; |
|
70 | 302 |
case "link": |
303 |
var _ctx = this.$.find('.Tl-Linking-Canvas')[0].getContext('2d'); |
|
304 |
_ctx.clearRect(0,0,this.main_width, this.main_height); |
|
305 |
_ctx.beginPath(); |
|
306 |
_ctx.strokeStyle = '#800080'; |
|
307 |
_ctx.moveTo(this.editing_occurrence.x,this.editing_occurrence.y + Math.floor(this.univers_height / 2)); |
|
308 |
_ctx.lineTo(_event.pageX - this.dragging_bounds.left, _event.pageY - this.dragging_bounds.top); |
|
309 |
_ctx.stroke(); |
|
310 |
break; |
|
65 | 311 |
} |
312 |
} |
|
313 |
} |
|
314 |
||
315 |
Tlns.Classes.Timeline.prototype.onUniversLoaded = function(_data) { |
|
316 |
this.univers = []; |
|
317 |
if(_data.length) { |
|
318 |
this.univers_height = Math.floor(this.main_height / _data.length); |
|
319 |
} |
|
320 |
for(var _i = 0; _i < _data.length; _i++) { |
|
321 |
this.univers.push(new Tlns.Classes.Univers(_data[_i], this, _i)); |
|
322 |
} |
|
66 | 323 |
this.loadOccurrences(); |
65 | 324 |
} |
325 |
||
326 |
Tlns.Classes.Timeline.prototype.offsetTime = function(_timeOffset) { |
|
327 |
this.setTime(this.central_time + _timeOffset); |
|
328 |
} |
|
329 |
||
330 |
Tlns.Classes.Timeline.prototype.setTime = function(_centralTime) { |
|
331 |
this.sync_now = false; |
|
332 |
this.central_time = _centralTime; |
|
67 | 333 |
this.throttledDrawGrid(); |
65 | 334 |
} |
335 |
||
336 |
Tlns.Classes.Timeline.prototype.setLevel = function(_level) { |
|
337 |
if (_level >= 0 && _level < this.timescales.length) { |
|
338 |
this.$.find('.Tl-TopBar-Timescales>div').each(function() { |
|
339 |
var _el = $(this); |
|
340 |
if (_el.attr("data-level") == _level) { |
|
341 |
_el.addClass("active"); |
|
342 |
} else { |
|
343 |
_el.removeClass("active"); |
|
344 |
} |
|
345 |
}); |
|
346 |
this.level = _level; |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
347 |
this.throttledDrawGrid(); |
65 | 348 |
} |
349 |
} |
|
350 |
||
351 |
Tlns.Classes.Timeline.prototype.drawGrid = function() { |
|
352 |
var _now = new Date().valueOf(); |
|
353 |
if (this.sync_now) { |
|
354 |
this.central_time = _now; |
|
355 |
this.$.find('.Tl-TopBar-SyncButton').addClass("active"); |
|
356 |
} else { |
|
357 |
this.$.find('.Tl-TopBar-SyncButton').removeClass("active"); |
|
358 |
} |
|
359 |
var _timescale = this.timescales[this.level], |
|
360 |
_offset = new Date().getTimezoneOffset() * 60000; |
|
66 | 361 |
this.current_scale = this.main_width / (_timescale.span) |
362 |
this.start_time = this.central_time - (_timescale.span / 2); |
|
363 |
this.end_time = this.central_time + (_timescale.span / 2); |
|
364 |
var _grid_width = Math.floor(_timescale.grid_interval * this.current_scale), |
|
365 |
_roundstart = Math.floor((this.start_time - _offset) / _timescale.grid_interval) * _timescale.grid_interval + _offset, |
|
65 | 366 |
_html = ''; |
66 | 367 |
this.$.find('.Tl-TopBar-TimeSpan').html(Tlns.Utils.dateFormat(this.start_time, _timescale.start_date_format) + ' - ' + Tlns.Utils.dateFormat(this.end_time, _timescale.end_date_format)); |
368 |
for (var _t = _roundstart; _t < this.end_time; _t += _timescale.grid_interval) { |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
369 |
var _x = this.current_scale * (_t - this.start_time); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
370 |
if (_x > 0) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
371 |
_html += '<div class="Tl-Grid-Column" style="width:' + _grid_width + 'px; left: ' + _x + 'px">' |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
372 |
+ '<div class="Tl-Grid-Label">' + Tlns.Utils.dateFormat(_t, _timescale.grid_date_format) + '</div></div>'; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
373 |
} |
65 | 374 |
} |
375 |
/* |
|
376 |
|
|
377 |
for (var _t = _roundstart; _t < _tmax; _t += _timescale.grid_interval) { |
|
378 |
var _isMajor = !(Math.floor((_t - _offset) / _timescale.grid_interval) % _timescale.major_interval); |
|
67 | 379 |
_html += '<div class="Tl-Grid-Column' + ( _isMajor ? ' Tl-Grid-Major' : '' ) + '" style="width:' + _grid_width + 'px; left: ' + _scale * (_t - this.start_time) + 'px">' |
65 | 380 |
+ ( _isMajor ? '<div class="Tl-Grid-Label">' + Tlns.Utils.dateFormat(_t, _timescale.date_format) + '</div>' : '' ) + '</div>'; |
381 |
} |
|
382 |
*/ |
|
66 | 383 |
if (this.start_time <= _now && this.end_time >= _now) { |
67 | 384 |
_html += '<div class="Tl-Grid-Now" style="left: ' + this.current_scale * (_now - this.start_time) + 'px"></div>' |
65 | 385 |
} |
386 |
this.$.find('.Tl-Grid').html(_html); |
|
66 | 387 |
this.drawOccurrences(); |
388 |
} |
|
389 |
||
390 |
Tlns.Classes.Timeline.prototype.loadOccurrences = function() { |
|
391 |
var _url = Mustache.to_html(this.url_occurrences, { |
|
392 |
from_time: this.start_time, |
|
393 |
to_time: this.end_time |
|
394 |
}), |
|
395 |
_this = this; |
|
396 |
$.getJSON(_url, function(_data) { |
|
397 |
_this.onOccurrencesLoaded(_data); |
|
398 |
}); |
|
399 |
} |
|
400 |
||
401 |
Tlns.Classes.Timeline.prototype.onOccurrencesLoaded = function(_data) { |
|
402 |
if (typeof _data.occurrencesNarratives === "object" && _data.occurrencesNarratives !== null) { |
|
403 |
for (var _i = 0; _i < _data.occurrencesNarratives.length; _i++) { |
|
404 |
this.createOrUpdateOccurrence("narrative", _data.occurrencesNarratives[_i]); |
|
405 |
} |
|
406 |
for (var _i = 0; _i < _data.occurrencesProduction.length; _i++) { |
|
407 |
this.createOrUpdateOccurrence("production", _data.occurrencesProduction[_i]); |
|
408 |
} |
|
409 |
} |
|
410 |
if (!this.mouse_down) { |
|
411 |
this.drawOccurrences(); |
|
412 |
} |
|
413 |
} |
|
414 |
||
415 |
Tlns.Classes.Timeline.prototype.getOccurrence = function(_type, _id) { |
|
416 |
return _(this.occurrences).find(function(_occ) { |
|
417 |
return (_occ.type == _type && _occ.id == _id); |
|
418 |
}); |
|
419 |
} |
|
420 |
||
421 |
Tlns.Classes.Timeline.prototype.createOrUpdateOccurrence = function(_type, _data) { |
|
422 |
var _occurrence = this.getOccurrence(_type, _data.id); |
|
423 |
if (typeof _occurrence === "undefined") { |
|
424 |
_occurrence = new Tlns.Classes.Occurrence(this); |
|
425 |
this.occurrences.push(_occurrence); |
|
426 |
} |
|
427 |
_occurrence.update(_type, _data); |
|
428 |
} |
|
429 |
||
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
430 |
Tlns.Classes.Timeline.prototype.showTooltip = function(_x, _y, _html, _isUp) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
431 |
this.$.find('.Tl-Overlay-Box') |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
432 |
.removeClass(_isUp ? 'Tl-Overlay-Down' : 'Tl-Overlay-Up') |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
433 |
.addClass(_isUp ? 'Tl-Overlay-Up' : 'Tl-Overlay-Down') |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
434 |
.show() |
66 | 435 |
.css({ |
436 |
left: _x + "px", |
|
437 |
top: _y + "px" |
|
438 |
}); |
|
439 |
this.$.find('.Tl-Overlay-Main').html(_html); |
|
440 |
} |
|
441 |
||
442 |
Tlns.Classes.Timeline.prototype.hideTooltip = function() { |
|
443 |
this.$.find('.Tl-Overlay-Box').hide(); |
|
65 | 444 |
} |
445 |
||
446 |
Tlns.Classes.Timeline.prototype.drawOccurrences = function() { |
|
66 | 447 |
var _this = this, |
448 |
_visible = _(this.occurrences).filter(function(_occ) { |
|
449 |
return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.published); |
|
450 |
}); |
|
451 |
_(_visible).each(function(_occ) { |
|
67 | 452 |
_occ.x = _this.current_scale * (_occ.date - _this.start_time); |
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
453 |
_occ.y = _occ.univers.y; |
66 | 454 |
_occ.in_cluster = false; |
455 |
}); |
|
65 | 456 |
|
66 | 457 |
var _moved = true; |
458 |
while (_moved) { |
|
459 |
_moved = false; |
|
460 |
for (var _i = 0; _i < _visible.length; _i++) { |
|
461 |
for (var _j = 0; _j < _i; _j++) { |
|
462 |
if (_visible[_j].univers_id == _visible[_i].univers_id |
|
463 |
&& _visible[_j].x != _visible[_i].x |
|
464 |
&& Math.abs(_visible[_j].x-_visible[_i].x) < this.cluster_spacing |
|
465 |
) { |
|
466 |
_moved = true; |
|
467 |
_visible[_i].x = this.cluster_spacing * Math.round(_visible[_i].x / this.cluster_spacing); |
|
468 |
_visible[_j].x = this.cluster_spacing * Math.round(_visible[_j].x / this.cluster_spacing); |
|
469 |
} |
|
470 |
} |
|
471 |
} |
|
472 |
} |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
473 |
var _clusters = [], |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
474 |
_openCluster = false; |
66 | 475 |
for (var _i = 0; _i < _visible.length; _i++) { |
476 |
for (var _j = 0; _j < _i; _j++) { |
|
477 |
if (_visible[_j].univers_id == _visible[_i].univers_id && _visible[_j].x == _visible[_i].x) { |
|
478 |
_visible[_j].in_cluster = true; |
|
479 |
_visible[_i].in_cluster = true; |
|
480 |
var _x = _visible[_j].x, |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
481 |
_y = _visible[_j].y; |
66 | 482 |
_cluster = _(_clusters).find(function(_c) { return _c.x == _x && _c.y == _y }); |
483 |
if (typeof _cluster === "undefined") { |
|
484 |
_cluster = { x: _x, y: _y, occurrences: [] }; |
|
485 |
_clusters.push(_cluster); |
|
486 |
} |
|
487 |
if ("undefined" === typeof _(_cluster.occurrences).find(function(_o) { |
|
488 |
return _o.type == _visible[_j].type && _o.id == _visible[_j].id; |
|
489 |
})) { |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
490 |
_cluster.occurrences.push(_visible[_j]); |
66 | 491 |
} |
492 |
if ("undefined" === typeof _(_cluster.occurrences).find(function(_o) { |
|
493 |
return _o.type == _visible[_i].type && _o.id == _visible[_i].id; |
|
494 |
})) { |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
495 |
_cluster.occurrences.push(_visible[_i]); |
66 | 496 |
} |
497 |
} |
|
498 |
} |
|
499 |
} |
|
500 |
_(_clusters).each(function(_cluster) { |
|
70 | 501 |
_cluster.occurrences = _(_cluster.occurrences).sortBy(function(_o) { |
502 |
return _o.date; |
|
503 |
}); |
|
66 | 504 |
_cluster.type = _cluster.occurrences[0].type; |
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
505 |
_cluster.contents = _cluster.occurrences.map(function(_o) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
506 |
return _o.type + ":" + _o.id; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
507 |
}).join("|"); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
508 |
if (_cluster.contents == _this.open_cluster) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
509 |
_openCluster = _cluster; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
510 |
} |
66 | 511 |
for (var _i = 1; _i < _cluster.occurrences.length; _i++) { |
512 |
if (_cluster.occurrences[_i].type !== _cluster.type) { |
|
513 |
_cluster.type = "both"; |
|
514 |
break; |
|
515 |
} |
|
516 |
} |
|
517 |
}); |
|
518 |
|
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
519 |
|
67 | 520 |
var _links = []; |
521 |
|
|
522 |
_(_visible).each(function(_occurrence) { |
|
523 |
_(_occurrence.dependsOn).each(function(_dependance) { |
|
524 |
var _parent = _(_visible).find(function(_o) { |
|
525 |
return _o.type == "narrative" && _o.id == _dependance; |
|
526 |
}); |
|
527 |
if (typeof _parent !== "undefined") { |
|
528 |
_links.push({ |
|
529 |
from_x: _occurrence.x, |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
530 |
from_y: _occurrence.y + Math.floor(_this.univers_height / 2), |
67 | 531 |
to_x: _parent.x, |
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
532 |
to_y: _parent.y + Math.floor(_this.univers_height / 2) |
67 | 533 |
}); |
534 |
} |
|
535 |
}); |
|
536 |
}); |
|
537 |
|
|
538 |
var _ctx = this.$.find('.Tl-Canvas')[0].getContext('2d'); |
|
539 |
_ctx.clearRect(0,0,this.main_width, this.main_height); |
|
540 |
_(_links).each(function(_link) { |
|
541 |
_ctx.beginPath(); |
|
542 |
_ctx.moveTo(_link.from_x,_link.from_y); |
|
543 |
_ctx.lineTo(_link.to_x,_link.to_y); |
|
544 |
_ctx.stroke(); |
|
70 | 545 |
}); |
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
546 |
|
66 | 547 |
var _html = Mustache.to_html(Tlns.Templates.Occurrence, { |
548 |
occurrences:_(_visible).reject(function(_o) {return _o.in_cluster}), |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
549 |
clusters: _clusters, |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
550 |
open_cluster: _openCluster |
66 | 551 |
}); |
552 |
this.$.find('.Tl-Occurrences').html(_html); |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
553 |
|
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
554 |
|
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
555 |
if (_openCluster) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
556 |
var _w = this.$.find('.Tl-Occurrence').width(), |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
557 |
_ww = _w * _openCluster.occurrences.length; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
558 |
this.$.find('.Tl-ClusterOverlay').css({ |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
559 |
"margin-left": - Math.floor(_ww/2) + "px", |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
560 |
width: _ww |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
561 |
}); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
562 |
_(_openCluster.occurrences).each(function(_o, _i) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
563 |
_o.y = _o.y - 20; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
564 |
_o.x = _o.x - (_ww / 2) + ((_i + .5) * _w); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
565 |
}); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
566 |
} |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
567 |
|
66 | 568 |
this.$.find('.Tl-Occurrence').mousedown(function() { |
67 | 569 |
var _el = $(this); |
70 | 570 |
_this.editing_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); |
571 |
if (typeof _this.dragging_type === "undefined" && typeof _this.editing_occurrence !== "undefined" && !_this.editing_occurrence.locked) { |
|
67 | 572 |
_this.dragging_type = "occurrence"; |
573 |
_this.editing_occurrence.editing = true; |
|
574 |
} |
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
575 |
}).mouseover(function(_event) { |
66 | 576 |
var _el = $(this), |
577 |
_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); |
|
70 | 578 |
if (!_occurrence.locked) { |
579 |
_el.find('.Tl-Link').show(); |
|
580 |
} |
|
581 |
_occurrence.formatted_date = Tlns.Utils.dateFormat(_occurrence.date,_this.tooltip_date_format); |
|
582 |
var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence); |
|
583 |
_this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) ); |
|
66 | 584 |
}).mouseout(function() { |
70 | 585 |
var _el = $(this), |
586 |
_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); |
|
66 | 587 |
_this.hideTooltip(); |
70 | 588 |
if (!_occurrence.editing) { |
589 |
$(this).find('.Tl-Link').hide(); |
|
590 |
} |
|
591 |
}).mouseup(function() { |
|
592 |
var _el = $(this); |
|
593 |
if (_this.dragging_type == "link" && _el.attr("occurrence-type") == "narrative") { |
|
594 |
_this.editing_occurrence.addDependency(_el.attr("occurrence-id")); |
|
595 |
} |
|
66 | 596 |
}); |
70 | 597 |
|
598 |
this.$.find('.Tl-Link').mousedown(function() { |
|
599 |
var _el = $(this).parent(); |
|
600 |
_this.editing_occurrence = _this.getOccurrence(_el.attr("occurrence-type"),_el.attr("occurrence-id")); |
|
601 |
if (typeof _this.editing_occurrence !== "undefined" && !_this.editing_occurrence.locked) { |
|
602 |
_this.dragging_type = "link"; |
|
603 |
_this.editing_occurrence.editing = true; |
|
604 |
} |
|
605 |
}) |
|
606 |
|
|
68
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
607 |
this.$.find('.Tl-Cluster').click(function() { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
608 |
var _el = $(this), |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
609 |
_contents = _el.attr("cluster-contents"); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
610 |
if (_this.open_cluster == _contents) { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
611 |
_this.open_cluster = false; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
612 |
} else { |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
613 |
_this.open_cluster = _contents; |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
614 |
} |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
615 |
_this.throttledDrawGrid(); |
4def147b1604
Added a visualization of the contents of clusters + mousewheel support
veltr
parents:
67
diff
changeset
|
616 |
}) |
65 | 617 |
} |
618 |
||
66 | 619 |
Tlns.Classes.Timeline.prototype.getUnivers = function(_id) { |
620 |
return _(this.univers).find(function(_univ) { |
|
621 |
return (_univ.id == _id); |
|
622 |
}); |
|
623 |
} |
|
624 |
||
625 |
/* |
|
626 |
* Univers |
|
627 |
*/ |
|
628 |
||
65 | 629 |
Tlns.Classes.Univers = function(_data, _timeline, _index) { |
630 |
this.id = _data.id; |
|
631 |
this.index = _index; |
|
632 |
this.title = _data.nom; |
|
633 |
this.mainCharacter = _data.personnage; |
|
66 | 634 |
this.y = (_timeline.univers_height * _index); |
65 | 635 |
|
636 |
this.$label = $('<li>').css({ |
|
637 |
height : _timeline.univers_height + "px" |
|
638 |
}).html(Mustache.to_html(Tlns.Templates.Univers, this)) |
|
66 | 639 |
.addClass((_index % 2) ? 'Tl-Line-Odd' : 'Tl-Line-Even'); |
65 | 640 |
|
641 |
_timeline.$.find('.Tl-UniversLabels').append(this.$label); |
|
642 |
var _txt = _data.nom, |
|
643 |
_span = this.$label.find('span'); |
|
644 |
||
645 |
while (_span.outerWidth() > (_timeline.width - _timeline.main_width) && _txt) { |
|
646 |
_txt = _txt.substr(0, _txt.length - 1); |
|
647 |
_span.html(_txt + '…'); |
|
648 |
} |
|
649 |
} |
|
66 | 650 |
|
651 |
/* |
|
652 |
* Occurrence |
|
653 |
*/ |
|
654 |
||
655 |
Tlns.Classes.Occurrence = function(_timeline) { |
|
656 |
this.timeline = _timeline; |
|
657 |
} |
|
658 |
||
659 |
Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { |
|
660 |
this.type = _type; |
|
661 |
this.id = _data.id || _.uniqueId(); |
|
662 |
this.date = _data.date || _data.datePublication; |
|
663 |
this.title = _data.titre || "<untitled>"; |
|
664 |
this.univers_id = _data.univers; |
|
665 |
this.univers = this.timeline.getUnivers(this.univers_id); |
|
666 |
this.status = _data.statut; |
|
667 |
this.published = _data.publie || false; |
|
668 |
this.locked = _data.verrouille || false; |
|
669 |
this.characters = _data.personnagesSecondaires || []; |
|
670 |
this.dependsOn = _data.dependDe || []; |
|
70 | 671 |
this.description = _data.description || ""; |
672 |
} |
|
673 |
||
674 |
Tlns.Classes.Occurrence.prototype.addDependency = function(_id) { |
|
675 |
if (_(this.dependsOn).indexOf(_id) == -1) { |
|
676 |
this.dependsOn.push(_id); |
|
677 |
} |
|
66 | 678 |
} |
679 |
||
680 |
Tlns.Classes.Occurrence.prototype.toString = function() { |
|
681 |
return "Occurrence " + this.type + ': "' + this.title + '"'; |
|
682 |
} |