From 500b697ecbd35a3c9865d730c1aa2f1f1c323697 Mon Sep 17 00:00:00 2001 From: Tom Preston-Werner Date: Wed, 4 Aug 2010 16:59:19 -0600 Subject: [PATCH] Javascript goodies for History page. --- lib/gollum/frontend/public/css/screen.css | 4 +++ .../frontend/public/javascript/gollum.js | 34 +++++++++++++++++++ .../frontend/templates/history.mustache | 6 ++-- 3 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lib/gollum/frontend/public/css/screen.css b/lib/gollum/frontend/public/css/screen.css index 8f152b8d..faa22a4c 100644 --- a/lib/gollum/frontend/public/css/screen.css +++ b/lib/gollum/frontend/public/css/screen.css @@ -505,6 +505,10 @@ table.commits { background-color: #eaf2f5; } + table.commits tr.selected td { + background-color: #FEFFE6; + } + table.commits th { font-weight: normal; border-bottom: 1px solid #ccc; diff --git a/lib/gollum/frontend/public/javascript/gollum.js b/lib/gollum/frontend/public/javascript/gollum.js index 9a3b6386..bcf270f6 100644 --- a/lib/gollum/frontend/public/javascript/gollum.js +++ b/lib/gollum/frontend/public/javascript/gollum.js @@ -204,4 +204,38 @@ $(function(){ }) $('ul.inline-tabs').tabs() + + var selectedRevisions = [] + + $('form#history input[type=checkbox]').change(function() { + var id = $(this).val() + var i = selectedRevisions.indexOf(id) + + if (i > -1) { + selectedRevisions.splice(i, 1) + } else { + selectedRevisions.push(id) + if (selectedRevisions.length > 2) { + var shiftedId = selectedRevisions.shift() + $('input[value=' + shiftedId + ']').attr('checked', false) + } + } + + $('form#history tr.commit').removeClass("selected") + $('form#history input[type=submit]').attr('disabled', true) + + if (selectedRevisions.length == 2) { + $('form#history input[type=submit]').attr('disabled', false) + var on = false + $('form#history tr.commit').each(function() { + if (on) { $(this).addClass("selected") } + + if ($(this).find('input:checked').length > 0) { + on = !on + } + + if (on) { $(this).addClass("selected") } + }) + } + }) }) diff --git a/lib/gollum/frontend/templates/history.mustache b/lib/gollum/frontend/templates/history.mustache index 7a7ee653..8f17c786 100644 --- a/lib/gollum/frontend/templates/history.mustache +++ b/lib/gollum/frontend/templates/history.mustache @@ -4,14 +4,14 @@ « Back

History of {{human_name}}

-
+ {{#versions}} - +
- Select any two versions to + Select any two versions to