# HG changeset patch # User veltr # Date 1376392586 -7200 # Node ID 8bab0eb0d79159eea9f2c9ce3828386f050c8cdc # Parent 4dc63e325f4831fb962ac39b491340f7c59d823f adapted ajax request to solicis api diff -r 4dc63e325f48 -r 8bab0eb0d791 timeline/css/timeline.css --- a/timeline/css/timeline.css Tue Aug 13 11:14:25 2013 +0200 +++ b/timeline/css/timeline.css Tue Aug 13 13:16:26 2013 +0200 @@ -137,7 +137,8 @@ } .Tl-MainPart { - position: absolute; right: 0; top: 0; bottom: 0; border-left: 1px solid #ccc; + position: absolute; right: 0; top: 0; bottom: 0; border-left: 1px solid #ccc; overflow: hidden; + box-shadow: 0 0 20px #999999 inset } .Tl-UniversLabels { @@ -148,10 +149,6 @@ font-size: 13px; margin: 2px 0; } -.Tl-Line-Even { - background: #e0e0e0; -} - .Tl-Layer { position: absolute; top: 0; left: 0; height: 100%; } diff -r 4dc63e325f48 -r 8bab0eb0d791 timeline/js/timeline.js --- a/timeline/js/timeline.js Tue Aug 13 11:14:25 2013 +0200 +++ b/timeline/js/timeline.js Tue Aug 13 13:16:26 2013 +0200 @@ -126,13 +126,15 @@ /* Defaults */ Tlns.Defaults.Timeline = { + email: "", + token: "", container : "timeline", - width : 950, - height : 200, - url_univers : '', + width : 780, + height : 225, min_width : 400, min_height : 100, - main_width : 800, + main_width : 700, + linelabels : [], timescales : [{ label : "Mois", span : 32 * 86400 * 1000, @@ -179,7 +181,8 @@ level: 0, central_time: 0, sync_now: true, - urls_occurrences: [], + api_endpoint: "", + api_method: "fetchAll", occurrences: [], cluster_spacing: 12, tooltip_date_format: '{{dayOfMonth}} {{shortMonthName}} {{year}} {{0hours}}:{{0minutes}}', @@ -201,7 +204,7 @@ + '
{{formatted_date}} — {{univers.title}} — {{translated_status}} — {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} — {{format}}{{/format}}
{{formatted_date}} — {{univers.title}} — {{translated_status}}{{#format}} — {{format}}{{/format}}
{{/occurrences}}'; Tlns.Templates.OccurrenceTooltip = '{{formatted_date}} — {{translated_status}} — {{#jt}}Au JT{{/jt}}{{^jt}}Hors JT{{/jt}}{{#format}} — {{format}}{{/format}}
' + '{{description}}
' @@ -253,10 +256,7 @@ this.$.find('.Tl-BottomPart').css("height", this.main_height + "px"); this.$.find('.Tl-MainPart').css("width", this.main_width + "px"); this.$.find('.Tl-Overlay-Container').css("left", (this.$.find('.Tl-BottomPart').outerWidth() - this.main_width) + "px"); - this.$.find('canvas.Tl-Layer').attr({ - width: this.main_width, - height: this.main_height - }); + var _o = this.$.find('.Tl-MainPart').offset(); this.dragging_bounds = { left: _o.left, @@ -264,6 +264,9 @@ right: _o.left + this.$.find('.Tl-MainPart').outerWidth(), bottom: _o.top + this.$.find('.Tl-MainPart').outerHeight(), }; + this.$.find('.Tl-UniversLabels').css({ + width: this.width - this.main_width + }); var _this = this; @@ -329,10 +332,6 @@ $(this).hide(); }); - /* Loading Univers */ - $.getJSON(this.url_univers, function(_data) { - _this.onUniversLoaded(_data); - }); /* LIST */ @@ -397,6 +396,7 @@ _this.throttledDrawList(); }); + this.onUniversLoaded(this.linelabels); } @@ -555,17 +555,20 @@ Tlns.Classes.Timeline.prototype.loadOccurrences = function() { var _this = this; - _(this.urls_occurrences).each(function(_url_occ) { - $.getJSON(_url_occ.url, function(_data) { - _this.onOccurrencesLoaded(_data, _url_occ.type); - }); + $.getJSON(this.api_endpoint, { + method: this.api_method, + api_key: this.token, + mail: this.email + }, function(_data) { + console.log(_data); + _this.onOccurrencesLoaded(_data); }); } -Tlns.Classes.Timeline.prototype.onOccurrencesLoaded = function(_data, _type) { - for (var _i = 0; _i < _data.length; _i++) { - this.createOrUpdateOccurrence(_type, _data[_i]); +Tlns.Classes.Timeline.prototype.onOccurrencesLoaded = function(_data) { + for (var _i = 0; _i < _data.data.length; _i++) { + this.createOrUpdateOccurrence(_data.data[_i]); } if (!this.mouse_down) { this.drawOccurrences(); @@ -598,14 +601,14 @@ }); } -Tlns.Classes.Timeline.prototype.createOrUpdateOccurrence = function(_type, _data) { - var _id = _type + "_" + _data.id, +Tlns.Classes.Timeline.prototype.createOrUpdateOccurrence = function(_data) { + var _id = _data.id, _occurrence = this.getOccurrence(_id); if (typeof _occurrence === "undefined") { _occurrence = new Tlns.Classes.Occurrence(this); this.occurrences.push(_occurrence); } - _occurrence.update(_type, _data); + _occurrence.update(_data); return _occurrence; } @@ -831,24 +834,17 @@ */ Tlns.Classes.Univers = function(_data, _timeline, _index) { - this.id = _data.idUnivers; + this.id = "u_" + _index; this.index = _index; - this.title = _data.nomUnivers; + this.title = _data; // this.mainCharacter = _data.personnage; this.y = (_timeline.univers_height * _index); this.$label = $('').html(_data.accroche || ""); + var _tmp = $('
').html(_data.resume || ""); this.description = _tmp.text().trim().replace(/(\n|\r|\r\n)/mg,' ').replace(/(^.{60,80})[\s].+$/m,'$1…'); } diff -r 4dc63e325f48 -r 8bab0eb0d791 timeline/timeline.html --- a/timeline/timeline.html Tue Aug 13 11:14:25 2013 +0200 +++ b/timeline/timeline.html Tue Aug 13 13:16:26 2013 +0200 @@ -6,14 +6,14 @@