CommitView: Allow changing of context size

This adds a slider in the commit view with
which the user can change the context size.

This is useful for example if the hunks are too
big; by changing the context size, a hunk can be
split and then the changes can be committed.
This commit is contained in:
Pieter de Bie
2009-01-19 21:37:37 +00:00
parent 8c34fc9d84
commit 9c4c2a347b
7 changed files with 74 additions and 11 deletions
+12
View File
@@ -48,6 +48,18 @@ table.diff {
margin-top: 30px;
}
#contextSize {
width: 80px;
margin-top: -0.5px;
float: right;
margin-right: 20px;
}
#contextTitle {
margin-right: 3px;
float: right;
}
.diff a.stagebutton {
display: block;
width: 40px;
+22 -5
View File
@@ -1,6 +1,6 @@
var showNewFile = function(file)
{
$('title').innerHTML = "New file: " + file.path;
setTitle("New file: " + file.path);
var contents = IndexController.unstagedChangesForFile_(file);
if (!contents) {
@@ -17,15 +17,26 @@ var hideState = function() {
}
var setState = function(state) {
setTitle(state);
hideNotification();
$("state").style.display = "";
$("diff").style.display = "none";
$("state").innerHTML = state.escapeHTML();
}
var setTitle = function(status) {
$("status").innerHTML = status;
$("contextSize").style.display = "none";
$("contextTitle").style.display = "none";
}
var displayContext = function() {
$("contextSize").style.display = "";
$("contextTitle").style.display = "";
}
var showFileChanges = function(file, cached) {
if (!file) {
$("title").innerHTML = "No file selected";
hideNotification();
setState("No file selected");
return;
}
@@ -33,16 +44,22 @@ var showFileChanges = function(file, cached) {
hideNotification();
hideState();
$("contextSize").oninput = function(element) {
Controller.setContextSize_($("contextSize").value);
}
if (file.status == 0) // New file?
return showNewFile(file);
var changes;
if (cached) {
$("title").innerHTML = "Staged changes for " + file.path;
setTitle("Staged changes for " + file.path);
displayContext();
changes = IndexController.stagedChangesForFile_(file);
}
else {
$("title").innerHTML = "Unstaged changes for " + file.path;
setTitle("Unstaged changes for " + file.path);
displayContext();
changes = IndexController.unstagedChangesForFile_(file);
}
+6 -1
View File
@@ -13,7 +13,12 @@
</head>
<body>
<h1 id='title'><span id="status">Nothing to commit</span></h1>
<h1 id='title'>
<input type="range" min="1" max="8" value="3" id="contextSize">
<span id="contextTitle">Context:</span>
<span id="status">Nothing to commit</span>
</h1>
<div id="notification" style="display:none">
<img src="../../images/spinner.gif" alt="Spinner" id="spinner"></img>