124 timescales : [{ |
124 timescales : [{ |
125 label : "Semaine", |
125 label : "Semaine", |
126 span : 7 * 86400 * 1000, |
126 span : 7 * 86400 * 1000, |
127 grid_interval : 86400 * 1000, |
127 grid_interval : 86400 * 1000, |
128 grid_date_format : '{{dayOfMonth}} {{monthName}}', |
128 grid_date_format : '{{dayOfMonth}} {{monthName}}', |
129 start_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
129 min_importance : 1 |
130 end_date_format : '{{dayOfMonth}} {{shortMonthName}}' |
|
131 }, { |
130 }, { |
132 label : "3 jours", |
131 label : "3 jours", |
133 span : 3 * 86400 * 1000, |
132 span : 3 * 86400 * 1000, |
134 grid_interval : 6 * 3600 * 1000, |
133 grid_interval : 6 * 3600 * 1000, |
135 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
134 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
136 start_date_format : '{{dayOfMonth}} {{shortMonthName}}', |
135 min_importance : 0 |
137 end_date_format : '{{dayOfMonth}} {{shortMonthName}}' |
|
138 }, { |
136 }, { |
139 label : "Journée", |
137 label : "Journée", |
140 span : 86400 * 1000, |
138 span : 86400 * 1000, |
141 grid_interval : 2 * 3600 * 1000, |
139 grid_interval : 2 * 3600 * 1000, |
142 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
140 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
143 start_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h', |
141 min_importance : 0 |
144 end_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h' |
|
145 }, { |
142 }, { |
146 label : "Demi-Journée", |
143 label : "Demi-Journée", |
147 span : 6 * 3600 * 1000, |
144 span : 6 * 3600 * 1000, |
148 grid_interval : 3600 * 1000, |
145 grid_interval : 3600 * 1000, |
149 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
146 grid_date_format : '{{^isDayStart}}{{0hours}}h{{0minutes}}{{/isDayStart}}{{#isDayStart}}{{dayOfMonth}} {{shortMonthName}}{{/isDayStart}}', |
150 start_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h', |
147 min_importance : 0 |
151 end_date_format : '{{dayOfMonth}} {{shortMonthName}} {{hours}}h' |
|
152 }], |
148 }], |
153 level: 0, |
149 level: 0, |
154 central_time: 0, |
150 central_time: 0, |
155 sync_now: true, |
151 sync_now: true, |
156 api_endpoint: "", |
152 api_endpoint: "", |
172 "Cms\\CallCharacter": "Appel à Personnage", |
168 "Cms\\CallCharacter": "Appel à Personnage", |
173 "Cms\\Message": "Message", |
169 "Cms\\Message": "Message", |
174 "Cms\\Rule": "Règle", |
170 "Cms\\Rule": "Règle", |
175 "Cms\\Video": "Vidéo", |
171 "Cms\\Video": "Vidéo", |
176 "Cms\\SweetCadaver": "Cadavre exquis" |
172 "Cms\\SweetCadaver": "Cadavre exquis" |
177 } |
173 }, |
|
174 maxtime: false |
178 } |
175 } |
179 |
176 |
180 for (var _i = 0; _i < Tlns.Defaults.Timeline.timescales.length; _i++) { |
177 for (var _i = 0; _i < Tlns.Defaults.Timeline.timescales.length; _i++) { |
181 Tlns.Defaults.Timeline.timescales[_i].level = _i; |
178 Tlns.Defaults.Timeline.timescales[_i].level = _i; |
182 } |
179 } |
260 if (_newLevel != _this.level) { |
257 if (_newLevel != _this.level) { |
261 _this.hideTooltip(); |
258 _this.hideTooltip(); |
262 var _deltaX = _event.pageX - _this.dragging_bounds.left, |
259 var _deltaX = _event.pageX - _this.dragging_bounds.left, |
263 _tAtMouse = _this.timeFromMouse(_event.pageX), |
260 _tAtMouse = _this.timeFromMouse(_event.pageX), |
264 _newScale = _this.main_width / (_this.timescales[_newLevel].span), |
261 _newScale = _this.main_width / (_this.timescales[_newLevel].span), |
265 _newStart = _tAtMouse - _deltaX / _newScale; |
262 _newStart = _tAtMouse - _deltaX / _newScale, |
266 _this.central_time = _newStart + _this.timescales[_newLevel].span / 2; |
263 _newTime = _newStart + _this.timescales[_newLevel].span / 2; |
|
264 _this.central_time = _this.maxtime ? Math.min(_newTime, _this.maxtime) : _newTime; |
267 _this.setLevel(_newLevel); |
265 _this.setLevel(_newLevel); |
268 } |
266 } |
269 return false; |
267 return false; |
270 }); |
268 }); |
271 |
269 |
298 this.is_dragging = false; |
296 this.is_dragging = false; |
299 this.dragging_type = undefined; |
297 this.dragging_type = undefined; |
300 } |
298 } |
301 |
299 |
302 Tlns.Classes.Timeline.prototype.timeFromX = function(_x) { |
300 Tlns.Classes.Timeline.prototype.timeFromX = function(_x) { |
303 return Math.max(this.start_time,Math.min(this.end_time, this.start_time + _x / this.current_scale)); |
301 return this.start_time + _x / this.current_scale; |
304 } |
302 } |
305 |
303 |
306 Tlns.Classes.Timeline.prototype.timeFromMouse = function(_pageX) { |
304 Tlns.Classes.Timeline.prototype.timeFromMouse = function(_pageX) { |
307 return this.timeFromX(_pageX - this.dragging_bounds.left); |
305 return this.timeFromX(_pageX - this.dragging_bounds.left); |
308 } |
306 } |
350 this.setTime(this.central_time + _timeOffset); |
348 this.setTime(this.central_time + _timeOffset); |
351 } |
349 } |
352 |
350 |
353 Tlns.Classes.Timeline.prototype.setTime = function(_centralTime) { |
351 Tlns.Classes.Timeline.prototype.setTime = function(_centralTime) { |
354 this.sync_now = false; |
352 this.sync_now = false; |
355 this.central_time = _centralTime; |
353 this.central_time = this.maxtime ? Math.min(_centralTime, this.maxtime) : _centralTime; |
356 this.changeSpan(); |
354 this.changeSpan(); |
357 } |
355 } |
358 |
356 |
359 Tlns.Classes.Timeline.prototype.setLevel = function(_level) { |
357 Tlns.Classes.Timeline.prototype.setLevel = function(_level) { |
360 if (_level >= 0 && _level < this.timescales.length) { |
358 if (_level >= 0 && _level < this.timescales.length) { |
472 var _this = this; |
470 var _this = this; |
473 _(this.occurrences).each(function(_occ) { |
471 _(this.occurrences).each(function(_occ) { |
474 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
472 _occ.x = _this.current_scale * (_occ.date - _this.start_time); |
475 _occ.y = _occ.univers.y; |
473 _occ.y = _occ.univers.y; |
476 }); |
474 }); |
|
475 var minT = this.timeFromX(-85), |
|
476 minI = this.timescales[this.level].min_importance; |
477 var _visible = _(this.occurrences).filter(function(_occ) { |
477 var _visible = _(this.occurrences).filter(function(_occ) { |
478 return (_occ.date >= _this.start_time && _occ.date <= _this.end_time && _occ.status); |
478 return (_occ.date >= minT && _occ.date <= _this.end_time && _occ.status && (_occ.importance >= minI)); |
479 }); |
479 }); |
480 |
480 |
481 var _moved = true, l = 0; |
481 var _moved = true, l = 0; |
482 while (_moved && l < 10) { |
482 while (_moved && l < 10) { |
483 l++; |
483 l++; |
580 this.id = _data.id; |
580 this.id = _data.id; |
581 this.date = new Date(1000 * (_data.dateFirstPublication || _data.dateCreate) || Date.now); |
581 this.date = new Date(1000 * (_data.dateFirstPublication || _data.dateCreate) || Date.now); |
582 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
582 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
583 this.title = _data.title; |
583 this.title = _data.title; |
584 this.type = _data.__CLASS__; |
584 this.type = _data.__CLASS__; |
|
585 this.importance = _data.importance; |
585 switch(_data.__CLASS__) { |
586 switch(_data.__CLASS__) { |
586 case "Cms\\Previously": |
587 case "Cms\\Previously": |
587 case "Cms\\Chapter": |
588 case "Cms\\Chapter": |
588 this.univers_id = 0; |
589 this.univers_id = 0; |
589 break; |
590 break; |