164 + '<div class="Tl-BottomPart"><ul class="Tl-UniversLabels"></ul>' |
164 + '<div class="Tl-BottomPart"><ul class="Tl-UniversLabels"></ul>' |
165 + '<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>' |
165 + '<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>' |
166 + '<ul class="Tl-Adding"><li class="Tl-AddingTitle">Ajout d\'une occurrence</li><li><span>Narrative</span><div class="Tl-AddOccurrence Tl-Occnarrative" occurrence-type="narrative" title="Glisser sur la frise chronologique pour ajouter"></div></li>' |
166 + '<ul class="Tl-Adding"><li class="Tl-AddingTitle">Ajout d\'une occurrence</li><li><span>Narrative</span><div class="Tl-AddOccurrence Tl-Occnarrative" occurrence-type="narrative" title="Glisser sur la frise chronologique pour ajouter"></div></li>' |
167 + '<li><span>De Publication</span><div class="Tl-AddOccurrence Tl-Occpublication" occurrence-type="publication" title="Glisser sur la frise chronologique pour ajouter"></div></li></ul></div>' |
167 + '<li><span>De Publication</span><div class="Tl-AddOccurrence Tl-Occpublication" occurrence-type="publication" title="Glisser sur la frise chronologique pour ajouter"></div></li></ul></div>' |
168 + '<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>'; |
168 + '<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>'; |
|
169 |
|
170 Tlns.Templates.List = '<div class="Ls-Main"><h2>Filtres :</h2><h3>Titre</h3><p><input class="Ls-Search" type="search" placeholder="Rechercher" /></p><h3>Univers :</h3><ul class="Ls-Univers"></ul>' |
|
171 + '<h3>Type d\'occurrence</h3><ul class="Ls-Occtypes"><li><input type="checkbox" value="narrative" checked>Narratives</li><li><input type="checkbox" value="publication" checked>de Publication</li></ul></p>' |
|
172 + '<h2>Occurrences :</h2><ul class="Ls-Occurrences"></ul></div>'; |
169 |
173 |
170 Tlns.Templates.Univers = '<span class="Tl-UniversText">{{title}}</span>'; |
174 Tlns.Templates.Univers = '<span class="Tl-UniversText">{{title}}</span>'; |
|
175 |
|
176 Tlns.Templates.Univers_List = '{{#univers}}<li><input type="checkbox" value="{{id}}" checked>{{title}}</li>{{/univers}}'; |
171 |
177 |
172 Tlns.Templates.Occurrence = '{{#clusters}}<div class="Tl-Cluster Tl-Occ{{type}}" style="left: {{x}}px; top: {{y}}px;" cluster-contents="{{contents}}">' |
178 Tlns.Templates.Occurrence = '{{#clusters}}<div class="Tl-Cluster Tl-Occ{{type}}" style="left: {{x}}px; top: {{y}}px;" cluster-contents="{{contents}}">' |
173 + '<div class="Tl-ClusterCount">{{occurrences.length}}</div></div>{{/clusters}}' |
179 + '<div class="Tl-ClusterCount">{{occurrences.length}}</div></div>{{/clusters}}' |
174 + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;">' |
180 + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccOnGrid Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}" style="left: {{x}}px; top: {{y}}px;">' |
175 + '{{#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;">' |
181 + '{{#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;">' |
176 + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}">' |
182 + '{{#occurrences}}<div class="Tl-Occurrence Tl-OccInCluster Tl-Occ{{type}}{{#editing}} Tl-Editing{{/editing}}" occurrence-id="{{id}}">' |
177 + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}'; |
183 + '{{#locked}}<div class="Tl-Locked"></div>{{/locked}}<div class="Tl-Link"{{#editing}} style="display: block"{{/editing}}></div></div>{{/occurrences}}</div>{{/open_cluster}}'; |
178 |
184 |
|
185 Tlns.Templates.Occurrence_List = '{{#occurrences}}<li><h3>{{title}}</h3><p><b>Type d\'occurrence :</b> {{type}}</p><p>' |
|
186 + '<b>Univers :</b> {{univers.title}}</p><p><b>Date :</b> {{formatted_date}}</p><p>{{description}}</p></li>{{/occurrences}}'; |
|
187 |
179 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}}</p>' |
188 Tlns.Templates.OccurrenceTooltip = '<h3 class="Tl-Tooltip-Title">{{title}}</h3><p class="Tl-Tooltip-Date">{{formatted_date}}</p>' |
180 + '<p class="Tl-Tooltip-Description">{{description}}</p><p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
189 + '<p class="Tl-Tooltip-Description">{{description}}</p><p class="Tl-Tooltip-Characters">{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}</p>' |
181 |
190 |
182 /* Classes */ |
191 /* Classes */ |
183 |
192 |
306 |
315 |
307 /* Loading Univers */ |
316 /* Loading Univers */ |
308 $.getJSON(this.url_univers, function(_data) { |
317 $.getJSON(this.url_univers, function(_data) { |
309 _this.onUniversLoaded(_data); |
318 _this.onUniversLoaded(_data); |
310 }); |
319 }); |
|
320 |
|
321 |
|
322 |
|
323 /* LIST */ |
|
324 |
|
325 $("body").append(Mustache.to_html(Tlns.Templates.List, this)); |
|
326 |
|
327 $(".Ls-Main input").bind("click change keyup", function() { |
|
328 _this.drawList(); |
|
329 }); |
|
330 |
311 } |
331 } |
312 |
332 |
313 Tlns.Classes.Timeline.prototype.onMouseDown = function(_event) { |
333 Tlns.Classes.Timeline.prototype.onMouseDown = function(_event) { |
314 this.mouse_down = true; |
334 this.mouse_down = true; |
315 this.is_dragging = false; |
335 this.is_dragging = false; |
371 this.hideTooltip(); |
391 this.hideTooltip(); |
372 switch (this.dragging_type) { |
392 switch (this.dragging_type) { |
373 case "occurrence": |
393 case "occurrence": |
374 var _d = this.timeFromMouse(_event.pageX); |
394 var _d = this.timeFromMouse(_event.pageX); |
375 this.editing_occurrence.date = _d; |
395 this.editing_occurrence.date = _d; |
|
396 this.editing_occurrence.formatted_date = Tlns.Utils.dateFormat(this.editing_occurrence.date,this.tooltip_date_format); |
376 var _u = this.universFromMouse(_event.pageY); |
397 var _u = this.universFromMouse(_event.pageY); |
377 this.editing_occurrence.univers = this.univers[_u]; |
398 this.editing_occurrence.univers = this.univers[_u]; |
378 this.editing_occurrence.univers_id = this.univers[_u].id; |
399 this.editing_occurrence.univers_id = this.univers[_u].id; |
379 this.throttledDrawGrid(); |
400 this.throttledDrawGrid(); |
380 break; |
401 break; |
403 this.univers_height = Math.floor(this.main_height / _data.length); |
424 this.univers_height = Math.floor(this.main_height / _data.length); |
404 } |
425 } |
405 for(var _i = 0; _i < _data.length; _i++) { |
426 for(var _i = 0; _i < _data.length; _i++) { |
406 this.univers.push(new Tlns.Classes.Univers(_data[_i], this, _i)); |
427 this.univers.push(new Tlns.Classes.Univers(_data[_i], this, _i)); |
407 } |
428 } |
|
429 |
|
430 $(".Ls-Univers").html(Mustache.to_html(Tlns.Templates.Univers_List, this)); |
|
431 var _this = this; |
|
432 $(".Ls-Univers input").bind("click change keyup", function() { |
|
433 _this.drawList(); |
|
434 }); |
408 this.loadOccurrences(); |
435 this.loadOccurrences(); |
409 } |
436 } |
410 |
437 |
411 Tlns.Classes.Timeline.prototype.offsetTime = function(_timeOffset) { |
438 Tlns.Classes.Timeline.prototype.offsetTime = function(_timeOffset) { |
412 this.setTime(this.central_time + _timeOffset); |
439 this.setTime(this.central_time + _timeOffset); |
455 if (_x > 0) { |
482 if (_x > 0) { |
456 _html += '<div class="Tl-Grid-Column" style="width:' + _grid_width + 'px; left: ' + _x + 'px">' |
483 _html += '<div class="Tl-Grid-Column" style="width:' + _grid_width + 'px; left: ' + _x + 'px">' |
457 + '<div class="Tl-Grid-Label">' + Tlns.Utils.dateFormat(_t, _timescale.grid_date_format) + '</div></div>'; |
484 + '<div class="Tl-Grid-Label">' + Tlns.Utils.dateFormat(_t, _timescale.grid_date_format) + '</div></div>'; |
458 } |
485 } |
459 } |
486 } |
460 /* |
|
461 |
|
462 for (var _t = _roundstart; _t < _tmax; _t += _timescale.grid_interval) { |
|
463 var _isMajor = !(Math.floor((_t - _offset) / _timescale.grid_interval) % _timescale.major_interval); |
|
464 _html += '<div class="Tl-Grid-Column' + ( _isMajor ? ' Tl-Grid-Major' : '' ) + '" style="width:' + _grid_width + 'px; left: ' + _scale * (_t - this.start_time) + 'px">' |
|
465 + ( _isMajor ? '<div class="Tl-Grid-Label">' + Tlns.Utils.dateFormat(_t, _timescale.date_format) + '</div>' : '' ) + '</div>'; |
|
466 } |
|
467 */ |
|
468 if (this.start_time <= _now && this.end_time >= _now) { |
487 if (this.start_time <= _now && this.end_time >= _now) { |
469 _html += '<div class="Tl-Grid-Now" style="left: ' + this.current_scale * (_now - this.start_time) + 'px"></div>' |
488 _html += '<div class="Tl-Grid-Now" style="left: ' + this.current_scale * (_now - this.start_time) + 'px"></div>' |
470 } |
489 } |
471 this.$.find('.Tl-Grid').html(_html); |
490 this.$.find('.Tl-Grid').html(_html); |
472 this.drawOccurrences(); |
491 this.drawOccurrences(); |
672 var _occurrence = _this.getOccurrence(_id); |
692 var _occurrence = _this.getOccurrence(_id); |
673 if (!_occurrence.locked) { |
693 if (!_occurrence.locked) { |
674 _el.find('.Tl-Link').show(); |
694 _el.find('.Tl-Link').show(); |
675 } |
695 } |
676 if (!_this.is_dragging) { |
696 if (!_this.is_dragging) { |
677 _occurrence.formatted_date = Tlns.Utils.dateFormat(_occurrence.date,_this.tooltip_date_format); |
|
678 var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence); |
697 var _html = Mustache.to_html(Tlns.Templates.OccurrenceTooltip, _occurrence); |
679 _this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) ); |
698 _this.showTooltip(_occurrence.x, _occurrence.y, _html, (_event.pageY - _this.dragging_bounds.top) >= (.4 * _this.main_height) ); |
680 } |
699 } |
681 } |
700 } |
682 }).mouseout(function() { |
701 }).mouseout(function() { |
716 } |
735 } |
717 _this.throttledDrawGrid(); |
736 _this.throttledDrawGrid(); |
718 }) |
737 }) |
719 } |
738 } |
720 |
739 |
|
740 Tlns.Classes.Timeline.prototype.drawList = function() { |
|
741 var _universfilter = $(".Ls-Univers input:checked").map(function(){return this.value}), |
|
742 _occtypefilter = $(".Ls-Occtypes input:checked").map(function(){return this.value}), |
|
743 _title = $(".Ls-Search").val(), |
|
744 _titleregexp = new RegExp( "(" + _title.replace(/(\W)/gm, "\\$1") + ")", "gim" ); |
|
745 $(".Ls-Occurrences").html( |
|
746 Mustache.to_html( |
|
747 Tlns.Templates.Occurrence_List, |
|
748 { |
|
749 occurrences: this.occurrences.filter(function(_occ) { |
|
750 var _titletest = (!!_occ.title.match(_titleregexp)), |
|
751 _keep = ( |
|
752 ( !_title || _titletest ) |
|
753 && (_(_occtypefilter).indexOf(_occ.type) !== -1) |
|
754 && (_(_universfilter).indexOf(_occ.univers_id) !== -1) |
|
755 ); |
|
756 return _keep; |
|
757 }) |
|
758 } |
|
759 ) |
|
760 ); |
|
761 if (_title) { |
|
762 $(".Ls-Occurrences h3").each(function() { |
|
763 $(this).html($(this).text().replace(_titleregexp, "<span style='background:yellow'>$1</span>")); |
|
764 }); |
|
765 } |
|
766 } |
|
767 |
721 Tlns.Classes.Timeline.prototype.getUnivers = function(_id) { |
768 Tlns.Classes.Timeline.prototype.getUnivers = function(_id) { |
722 return _(this.univers).find(function(_univ) { |
769 return _(this.univers).find(function(_univ) { |
723 return (_univ.id == _id); |
770 return (_univ.id == _id); |
724 }); |
771 }); |
725 } |
772 } |
761 Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { |
808 Tlns.Classes.Occurrence.prototype.update = function(_type, _data) { |
762 this.type = _type; |
809 this.type = _type; |
763 this.original_id = _data.id || Tlns.Utils.guid(); |
810 this.original_id = _data.id || Tlns.Utils.guid(); |
764 this.id = _type + "_" + this.original_id; |
811 this.id = _type + "_" + this.original_id; |
765 this.date = _data.date || _data.datePublication; |
812 this.date = _data.date || _data.datePublication; |
|
813 this.formatted_date = Tlns.Utils.dateFormat(this.date,Tlns.Defaults.Timeline.tooltip_date_format); |
766 this.title = _data.titre || "<untitled>"; |
814 this.title = _data.titre || "<untitled>"; |
767 this.univers_id = _data.univers; |
815 this.univers_id = _data.univers; |
768 this.univers = this.timeline.getUnivers(this.univers_id); |
816 this.univers = this.timeline.getUnivers(this.univers_id); |
769 this.status = _data.statut; |
817 this.status = _data.statut; |
770 this.published = _data.publie || false; |
818 this.published = _data.publie || false; |