[bugzilla-gnome-org-extensions] Improve file and hunk headers



commit 0818ad0a141f511dbc00cb19f057eacce3370955
Author: Owen W. Taylor <otaylor fishsoup net>
Date:   Sat Oct 3 17:38:36 2009 -0400

    Improve file and hunk headers
    
    * Remove border and cyan background from filename labels
    * Add (new file) or (removed) when appropriate
    * Make hunk headers less conspicuous: remove border, switch to a darker
      color, use the same font as the changed lines, and make the line
      numbers not red.
    * Don't show a hunk header if the first hunk starts at the beginning
      of the file.

 js/splinter.js   |   41 ++++++++++++++++++++++++++++++-----------
 web/splinter.css |   16 +++++++---------
 2 files changed, 37 insertions(+), 20 deletions(-)
---
diff --git a/js/splinter.js b/js/splinter.js
index c441e03..b99f1a8 100644
--- a/js/splinter.js
+++ b/js/splinter.js
@@ -501,8 +501,25 @@ function addPatchFile(file) {
     var fileDiv = $("<div class='file'></div>").appendTo("#files").get(0);
     file.div = fileDiv;
 
-    $("<div class='file-label'><span></span></div/>")
-        .find("span").text(file.filename).end()
+    var statusString;
+    switch (file.status) {
+    case Patch.ADDED:
+        statusString = " (new file)";
+       break;
+    case Patch.REMOVED:
+        statusString = " (removed)";
+       break;
+    case Patch.CHANGED:
+        statusString = "";
+       break;
+    }
+
+    $("<div class='file-label'>"
+      + "<span class='file-label-name'></span>"
+      + "<span class='file-label-status'></span>"
+      + "</div/>")
+        .find(".file-label-name").text(file.filename).end()
+        .find(".file-label-status").text(statusString).end()
         .appendTo(fileDiv);
 
     var q = $("<table class='file-table'>"
@@ -521,15 +538,17 @@ function addPatchFile(file) {
     var tbody = q.find("tbody").get(0);
     for (var i = 0; i  < file.hunks.length; i++) {
         var hunk = file.hunks[i];
-        var hunkHeader = EL("tr", "hunk-header");
-        tbody.appendChild(hunkHeader);
-        var hunkCell = EL("td", "hunk-cell");
-        hunkCell.appendChild(EL("div", "hunk-lines",
-                                "Lines " + hunk.oldStart + "-" + (hunk.oldStart + hunk.oldCount - 1)));
-        if (hunk.functionLine)
-            hunkCell.appendChild(EL("div", "hunk-function-line", hunk.functionLine));
-        hunkCell.colSpan = file.status == Patch.CHANGED ? 3 : 1;
-        hunkHeader.appendChild(hunkCell);
+        if (hunk.oldStart > 1) {
+            var hunkHeader = EL("tr", "hunk-header");
+            tbody.appendChild(hunkHeader);
+            var hunkCell = EL("td", "hunk-cell");
+            hunkCell.appendChild(EL("div", "hunk-lines",
+                                    "Lines " + hunk.oldStart + "-" + (hunk.oldStart + hunk.oldCount - 1)));
+            if (hunk.functionLine)
+                hunkCell.appendChild(EL("div", "hunk-function-line", hunk.functionLine));
+            hunkCell.colSpan = file.status == Patch.CHANGED ? 3 : 1;
+            hunkHeader.appendChild(hunkCell);
+        }
 
         hunk.iterate(function(loc, oldLine, oldText, newLine, newText, flags, line) {
                          var tr = document.createElement("tr");
diff --git a/web/splinter.css b/web/splinter.css
index d463ab4..480c9eb 100644
--- a/web/splinter.css
+++ b/web/splinter.css
@@ -178,18 +178,17 @@ body {
 
 .file-label {
     margin-top: 1em;
-    padding: 0.5em;
+    margin-bottom: 0.5em;
 }
 
-.file-label span {
-    border: 1px solid black;
-    padding: 0.5em;
-    background: #ccffff;
+.file-label-name {
+    font-weight: bold;
 }
 
-.hunk-header {
-    border: 1px solid black;
-    background: #dddddd;
+.hunk-header td {
+    background: #ddccbb;
+    font-family: "DejaVu Sans Mono", monospace;
+    font-size: 80%;
 }
 
 .hunk-cell {
@@ -197,7 +196,6 @@ body {
 }
 
 .hunk-lines {
-    color: red;
     float: left;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]