# HG changeset patch # User veltr # Date 1341855842 -7200 # Node ID ef3377d7a4f7e137a5e7e0da2333f3c3b23917a1 # Parent e107c77600e8c2f432325da5e9276325721c8fbf Improved timeline diff -r e107c77600e8 -r ef3377d7a4f7 timeline/assets/sprites.psd Binary file timeline/assets/sprites.psd has changed diff -r e107c77600e8 -r ef3377d7a4f7 timeline/css/timeline.css --- a/timeline/css/timeline.css Fri Jul 06 18:57:20 2012 +0200 +++ b/timeline/css/timeline.css Mon Jul 09 19:44:02 2012 +0200 @@ -1,5 +1,58 @@ -p, h2, h3 { - margin: 2px 0; padding: 0; +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} + +ul, li { + list-style: none; +} + +input::-moz-focus-inner /*Remove button padding in FF*/ +{ + border: 0; + padding: 0; +} + +table { + border-collapse: separate; border-spacing: 0; +} + +th, td { + vertical-align: top; +} + +img a { + border: none; +} + +body { + font-size: 10px; font-family: Arial, Helvetica, sans-serif; +} + +/*************************************************/ + +.Onglets { + display: inline-block; border-style: solid solid none none; border-color: #ccc; border-width: 1px; +} + +.Onglets li { + display: inline-block; background: url(../img/barbgd.png); font-size: 14px; height: 15px; padding: 5px; border-style: none none none solid; border-color: #ccc; border-width: 1px; } /************************************************/ @@ -113,7 +166,7 @@ position: absolute; top: 0; height: 100%; margin-left: -1px; width: 2px; background: #f000ff; } -.Tl-Occurrence, .Tl-Cluster, .Tl-AddOccurrence { +.Tl-Occurrence, .Tl-Cluster, .Tl-AddOccurrence, .Ls-OccIcon { width: 19px; height: 22px; background: url(../img/sprites.png); cursor: pointer; } @@ -145,12 +198,44 @@ background-position: -19px -72px; } -.Tl-Occboth { +.Tl-Occnarrative.Tl-Occa_valider { background-position: -38px -50px; } +.Tl-Occpublication.Tl-Occa_valider { + background-position: -57px -50px; +} + +.Tl-Occnarrative.Tl-Editing.Tl-Occa_valider { + background-position: -38px -72px; +} + +.Tl-Occpublication.Tl-Editing.Tl-Occa_valider { + background-position: -57px -72px; +} + +.Tl-Occnarrative.Tl-Occvalide { + background-position: -76px -50px; +} + +.Tl-Occpublication.Tl-Occvalide { + background-position: -95px -50px; +} + +.Tl-Occnarrative.Tl-Editing.Tl-Occvalide { + background-position: -76px -72px; +} + +.Tl-Occpublication.Tl-Editing.Tl-Occvalide { + background-position: -95px -72px; +} + +.Tl-Cluster { + background-position: -114px -50px; +} + .Tl-Link { - position: absolute; left: 0; bottom: 0; width: 11px; height: 11px; background: url(../img/sprites.png) -38px -83px; display: none; + position: absolute; left: 0; bottom: 0; width: 11px; height: 11px; background: url(../img/sprites.png) -114px -83px; display: none; } .Tl-ClusterCount { @@ -237,3 +322,78 @@ /**********************************/ +.Ls-Main { + width: 950px; height: 200px; background: #fafafa; border: 1px solid #cccccc; +} + +.Ls-Filtres { + width: 540px; + float: left; +} + +.Ls-Column { + width: 180px; height: 160px; + float: left; +} + +.Ls-Main h2 { + text-align: center; margin: 0; font-size: 14px; font-weight: bold; clear: both; +} + +.Ls-Resultats { + height: 200px; overflow: auto; border-left: 1px solid #cccccc; +} + +.Ls-Input { + width: 100px; margin-right: 5px; +} + +.Ls-Label { + display: inline-block; width: 30px; font-size: 12px; +} + +.Ls-Main h3 { + font-size: 12px; font-weight: bold; margin: 5px 0 0; + clear: both; +} + +.Ls-Critere { + font-size: 11px; background: #ffffff; color: #333333; cursor: pointer; + border-radius: 4px; margin: 2px; padding: 4px; display: inline-block; clear: both; +} + +.Ls-Critere.Ls-Active { + background: #ffb0ff; +} + +.Ls-Critere:hover { + background: #ffe0ff; +} + +.Ls-Resultats ul { + border-top: 1px solid #cccccc; +} + +li.Ls-Occurrence { + border-bottom: 1px solid #cccccc; clear: both; +} + +.Ls-Occurrence-Title { + width: 260px; float: left; font-size: 14px; +} + +.Ls-Occurrence-Date { + padding-top: 2px; font-size: 12px; +} + +.Ls-CrWithIcon { + padding: 5px 2px; +} + +.Ls-OccIcon { + float: right; +} + +.Ls-CrWithIcon .Ls-OccIcon { + margin: -4px 0; +} diff -r e107c77600e8 -r ef3377d7a4f7 timeline/data/occurrences.json --- a/timeline/data/occurrences.json Fri Jul 06 18:57:20 2012 +0200 +++ b/timeline/data/occurrences.json Mon Jul 09 19:44:02 2012 +0200 @@ -6,9 +6,8 @@ "titre" : "Une histoire qui se passe à Carcassonne", "description" : "Ma première occurrence narrative", "univers" : "U06", - "statut" : "valide", + "statut" : "a_valider", "publie" : true, - "verrouille" : false, "personnagesSecondaires": [ "Personnage A", "Personnage B" @@ -23,7 +22,6 @@ "univers" : "U01", "statut" : "valide", "publie" : true, - "verrouille" : false, "personnagesSecondaires": [ "Personnage A", "Personnage B" @@ -38,9 +36,8 @@ "titre" : "Quelques minutes après au même endroit", "description" : "Ma troisième occurrence narrative", "univers" : "U01", - "statut" : "valide", + "statut" : "a_realiser", "publie" : true, - "verrouille" : false, "personnagesSecondaires": [ "Personnage A", "Personnage B" @@ -53,9 +50,8 @@ "titre" : "Alors que, dans la Cité, Azda...", "description" : "Ma quatrième occurrence narrative", "univers" : "U07", - "statut" : "valide", + "statut" : "a_valider", "publie" : true, - "verrouille" : false, "personnagesSecondaires": [ "Personnage A", "Personnage B" @@ -72,9 +68,8 @@ "titre" : "Nous publions des infos sur Bob la Carcasse", "description" : "Ma première occurrence de publication", "univers" : "U06", - "statut" : "valide", + "statut" : "a_realiser", "publie" : true, - "verrouille" : true, "dependDe" : [ "N01" ] @@ -87,7 +82,6 @@ "univers" : "U04", "statut" : "valide", "publie" : true, - "verrouille" : false, "dependDe" : [] }, { @@ -96,9 +90,8 @@ "titre" : "Encore des nouvelles d'Arthur, qui tweete", "description" : "Ma troisième occurrence de publication", "univers" : "U04", - "statut" : "valide", + "statut" : "a_valider", "publie" : true, - "verrouille" : false, "dependDe" : [ "N03" ] diff -r e107c77600e8 -r ef3377d7a4f7 timeline/img/sprites.png Binary file timeline/img/sprites.png has changed diff -r e107c77600e8 -r ef3377d7a4f7 timeline/js/timeline.js --- a/timeline/js/timeline.js Fri Jul 06 18:57:20 2012 +0200 +++ b/timeline/js/timeline.js Mon Jul 09 19:44:02 2012 +0200 @@ -11,6 +11,10 @@ /* Utility Functions */ +Tlns.Utils.zeroPad = function(_n) { + return (_n < 10 ? "0" : "") + _n; +} + Tlns.Utils.SetDefaults = function(_object, _defaults, _options) { var _options = _options || {}; _(_defaults).each(function(_v, _k) { @@ -34,22 +38,19 @@ if (typeof _data !== "object") { _date = new Date(_date); } - function zeroPad(_n) { - return (_n < 10 ? "0" : "") + _n - } var _params = { hours: _date.getHours(), - "0hours": zeroPad(_date.getHours()), + "0hours": Tlns.Utils.zeroPad(_date.getHours()), minutes: _date.getMinutes(), - "0minutes": zeroPad(_date.getMinutes()), + "0minutes": Tlns.Utils.zeroPad(_date.getMinutes()), seconds: _date.getSeconds(), - "0seconds": zeroPad(_date.getSeconds()), + "0seconds": Tlns.Utils.zeroPad(_date.getSeconds()), dayOfWeek: ["dimanche","lundi","mardi","mercredi","jeudi","vendredi","samedi"][_date.getDay()], shortDayOfWeek: ["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"][_date.getDay()], dayOfMonth: _date.getDate(), - "0dayOfMonth": zeroPad(_date.getDate()), + "0dayOfMonth": Tlns.Utils.zeroPad(_date.getDate()), monthNumber: 1+_date.getMonth(), - "0monthNumber": zeroPad(1+_date.getMonth()), + "0monthNumber": Tlns.Utils.zeroPad(1+_date.getMonth()), monthName: ["janvier","février","mars","avril","mai","juin","juillet","août","septembre","octobre","novembre","décembre"][_date.getMonth()], shortMonthName: ["jan","fev","mar","avr","mai","jun","jul","aou","sep","oct","nov","dec"][_date.getMonth()], year: _date.getFullYear() @@ -89,6 +90,50 @@ _ctx.stroke(); } +Tlns.Utils.timeFieldProcess = function(_val) { + var _h = 0, + _m = 0, + _matches = _val.match(/(\d+)/g); + if (_matches && _matches.length) { + _h = Math.min(23, +(_matches[0])); + if (_matches.length > 1) { + _m = Math.min(59, +(_matches[1])); + } + } + return { + hours: _h, + minutes: _m, + text: Tlns.Utils.zeroPad(_h) + ':' + Tlns.Utils.zeroPad(_m) + } +} + +Tlns.Utils.dateFieldProcess = function(_val) { + var _now = new Date(), + _y = _now.getFullYear(), + _m = 1 + _now.getMonth(), + _d = _now.getDate(), + _matches = _val.match(/(\d+)/g); + if (_matches && _matches.length) { + _d = Math.min(31, +(_matches[0])); + if (_matches.length > 1) { + _m = Math.min(12, +(_matches[1])); + } + if (_matches.length > 2) { + _y = parseInt(_matches[2]); + if (_y < 2000) { + _y += 2000; + } + _y = Math.min(2020, Math.max(2000, _y)); + } + } + return { + year: _y, + month: _m, + date: _d, + text: Tlns.Utils.zeroPad(_d) + '/' + Tlns.Utils.zeroPad(_m) + '/' + _y + } +} + /* Defaults */ Tlns.Defaults.Timeline = { @@ -147,8 +192,13 @@ sync_now: true, url_occurrences: '', occurrences: [], - cluster_spacing: 10, - tooltip_date_format: '{{dayOfMonth}} {{shortMonthName}} {{year}} {{0hours}}:{{0minutes}}' + cluster_spacing: 12, + tooltip_date_format: '{{dayOfMonth}} {{shortMonthName}} {{year}} {{0hours}}:{{0minutes}}', + statuses: { + "valide": "Validée", + "a_valider": "À valider", + "a_realiser": "À réaliser" + } } for (var _i = 0; _i < Tlns.Defaults.Timeline.timescales.length; _i++) { @@ -157,7 +207,7 @@ /* Templates */ -Tlns.Templates.Timeline = '
Type d\'occurrence : {{type}}
' - + 'Univers : {{univers.title}}
Date : {{formatted_date}}
{{description}}
{{formatted_date}}
' +Tlns.Templates.OccurrenceTooltip = '{{formatted_date}} - {{translated_status}}
' + '{{description}}
{{univers.mainCharacter}}{{#characters}}, {{.}}{{/characters}}
' /* Classes */ @@ -196,14 +249,12 @@ Tlns.Utils.SetDefaults(this, Tlns.Defaults.Timeline, _options); /* Setting container CSS */ - this.$ = $('#' + this.container); - this.$.addClass('Tl-Main'); - this.$.css({ + this.$ = $('#' + this.container).html(Mustache.to_html(Tlns.Templates.Timeline, this)); + + this.$.find('.Tl-Main').css({ width : this.width + "px", height : this.height + "px" }); - this.$.html(Mustache.to_html(Tlns.Templates.Timeline, this)); - this.main_height = this.height - this.$.find('.Tl-TopBar').outerHeight(); this.$.find('.Tl-BottomPart').css("height", this.main_height + "px"); this.$.find('.Tl-MainPart').css("width", this.main_width + "px"); @@ -226,6 +277,10 @@ _this.drawGrid(); }, 150); + this.throttledDrawList = _.throttle(function() { + _this.drawList(); + }, 150); + this.setLevel(this.level); this.$.find('.Tl-TopBar-Timescales>div').click(function() { @@ -296,7 +351,8 @@ date: _d, titre: '