From b1e3dd22121859da8e8740e463145f5d0553b5de Mon Sep 17 00:00:00 2001 From: Pieter de Bie Date: Tue, 21 Oct 2008 22:46:33 +0200 Subject: [PATCH] WebCommitView: Use a notification to display errors This should give GitX some more consistency. Also, it will give us a basis to build further changes on. --- html/css/GitX.css | 3 +- html/css/notification.css | 23 +++++++++++++++ html/lib/GitX.js | 4 +++ html/views/commit/commit.css | 19 +++++++++++-- html/views/commit/commit.js | 52 ++++++++++++++++++++-------------- html/views/commit/index.html | 2 +- html/views/history/history.css | 24 ---------------- 7 files changed, 77 insertions(+), 50 deletions(-) create mode 100644 html/css/notification.css diff --git a/html/css/GitX.css b/html/css/GitX.css index f94254e..1ef5f58 100644 --- a/html/css/GitX.css +++ b/html/css/GitX.css @@ -1 +1,2 @@ -@import url("diff.css"); \ No newline at end of file +@import url("diff.css"); +@import url("notification.css"); \ No newline at end of file diff --git a/html/css/notification.css b/html/css/notification.css new file mode 100644 index 0000000..3d9c660 --- /dev/null +++ b/html/css/notification.css @@ -0,0 +1,23 @@ +#notification { + margin: 5px; + padding: 3px; + clear: both; + + border: 1px solid black; + background-color: #f3f3f3; + + text-align: center; + font-size: 80%; + + -webkit-border-radius: 2px; +} + +#notification.success { + background-color: #CCFF99; + border: 1px solid #99CC66; +} + +#notification.fail { + background-color: #ff9999; + border: 1px solid #cc6666; +} \ No newline at end of file diff --git a/html/lib/GitX.js b/html/lib/GitX.js index a758288..ff01c79 100644 --- a/html/lib/GitX.js +++ b/html/lib/GitX.js @@ -44,3 +44,7 @@ var notify = function(text, state) { n.setAttribute("class", "fail"); } } + +var hideNotification = function() { + $("notification").style.display = "none"; +} diff --git a/html/views/commit/commit.css b/html/views/commit/commit.css index 3a0b322..b343a70 100644 --- a/html/views/commit/commit.css +++ b/html/views/commit/commit.css @@ -5,7 +5,7 @@ body { } #title { - padding: 0px; + padding: 2px; padding-left: 5px; border-bottom: 1px solid black; margin: 0px; @@ -13,7 +13,22 @@ body { background-color: #ECF3FD; font-size: 100%; position: fixed; - font-family: Helvetica; top: 0px; width: 100%; } + +.floatright { + float: right; +} + +pre { + margin-top: 0; +} + +table.diff { + margin-top: 0; +} + +#notification { + margin-top: 30px; +} \ No newline at end of file diff --git a/html/views/commit/commit.js b/html/views/commit/commit.js index 036bae3..5e4f7b4 100644 --- a/html/views/commit/commit.js +++ b/html/views/commit/commit.js @@ -1,25 +1,33 @@ -var showFileChanges = function(file, cached) { - // New file? - var diff = $("diff"); +var showNewFile = function(file) +{ + $('title').innerHTML = "New file: " + file.path; - if (file.status == 0) - { - var contents = file.unstagedChanges(); - if (contents) - diff.innerHTML = contents.escapeHTML(); - else - diff.innerHTML = "Could not display changes"; - - diff.style.display= ''; - $('title').innerHTML = "New file: " + file.path; - } else { - diff.style.display = 'none'; - if (cached) - diff.innerHTML = file.cachedChangesAmend_(Controller.amend()).escapeHTML(); - else - diff.innerHTML = file.unstagedChanges().escapeHTML(); - highlightDiffs(); - diff.style.display = ''; - $("title").innerHTML = "Changes for " + file.path; + var contents = file.unstagedChanges(); + if (!contents) { + notify("Can not display changes (Binary file?)", -1); + return; } + + diff.innerHTML = contents.escapeHTML(); } + +var showFileChanges = function(file, cached) { + var diff = $("diff"); + diff.style.display = 'none'; + hideNotification(); + + if (file.status == 0) // New file? + return showNewFile(file); + + if (cached) { + $("title").innerHTML = "Staged changes for " + file.path; + diff.innerHTML = file.cachedChangesAmend_(Controller.amend()).escapeHTML(); + } + else { + $("title").innerHTML = "Unstaged changes for " + file.path; + diff.innerHTML = file.unstagedChanges().escapeHTML(); + } + + highlightDiffs(); + diff.style.display = ''; +} \ No newline at end of file diff --git a/html/views/commit/index.html b/html/views/commit/index.html index 208dc99..ac627ab 100644 --- a/html/views/commit/index.html +++ b/html/views/commit/index.html @@ -12,7 +12,7 @@ -

Nothing to commit

+

Nothing to commit