[gitg/wip/techlivezh/diff-view-clean-up: 17/21] Reduce duplicate stage button code
- From: Techlive Zheng <techlivezh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg/wip/techlivezh/diff-view-clean-up: 17/21] Reduce duplicate stage button code
- Date: Sat, 21 Dec 2013 15:52:40 +0000 (UTC)
commit e901cc206e042fbe276e8baad779107e213f0208
Author: Techlive Zheng <techlivezheng gmail com>
Date: Thu Dec 19 09:35:32 2013 +0800
Reduce duplicate stage button code
libgitg/resources/diff-view-html-builder.js | 56 ++++++++++----------------
1 files changed, 22 insertions(+), 34 deletions(-)
---
diff --git a/libgitg/resources/diff-view-html-builder.js b/libgitg/resources/diff-view-html-builder.js
index 04a845b..2405801 100644
--- a/libgitg/resources/diff-view-html-builder.js
+++ b/libgitg/resources/diff-view-html-builder.js
@@ -27,23 +27,7 @@ function diff_file(file, lnstate, data)
var hunk_stats = '<span class="hunk_stats">@@ -' + h.range.old.start + ',' +
h.range.old.lines + ' +' + h.range.new.start + ',' + h.range.new.lines + ' @@</span>';
- if (data.settings.staged || data.settings.unstaged)
- {
- var cls;
-
- if (data.settings.staged)
- {
- cls = 'unstage';
- nm = data.settings.strings.unstage;
- }
- else
- {
- cls = 'stage';
- nm = data.settings.strings.stage;
- }
-
- hunk_stats = '<span class="' + cls + '">' + nm + '</span>' + hunk_stats;
- }
+ hunk_stats = lnstate.stagebutton + hunk_stats;
file_body += '<tr class="hunk_header">\
<td class="gutter old">' + lnstate.gutterdots + '</td> \
@@ -143,23 +127,7 @@ function diff_file(file, lnstate, data)
var file_stats = '<span class="file_stats"><span class="number">' + (added + removed) +
'</span><span class="bar"><span class="added" style="width: ' + addedp + '%;"></span><span class="removed"
style="width: ' + removedp + '%;"></span></span></span>';
- if (data.settings.staged || data.settings.unstaged)
- {
- var cls;
-
- if (data.settings.staged)
- {
- cls = 'unstage';
- nm = data.settings.strings.unstage;
- }
- else
- {
- cls = 'stage';
- nm = data.settings.strings.stage;
- }
-
- file_stats += '<span class="' + cls + '">' + nm + '</span>';
- }
+ file_stats = lnstate.stagebutton + file_stats;
/**
* run template
@@ -207,9 +175,29 @@ function diff_files(files, lines, maxlines, data)
nexttick: 0,
tickfreq: 0.01,
gutterdots: new Array(maxlines.toString().length + 1).join('.'),
+ stagebutton: '',
replacements: replacements,
};
+ if (data.settings.staged || data.settings.unstaged)
+ {
+ var cls;
+ var nm;
+
+ if (data.settings.staged)
+ {
+ cls = 'unstage';
+ nm = data.settings.strings.unstage;
+ }
+ else
+ {
+ cls = 'stage';
+ nm = data.settings.strings.stage;
+ }
+
+ lnstate.stagebutton = '<span class="' + cls + '">' + nm + '</span>';
+ }
+
var f = '';
for (var i = 0; i < files.length; ++i)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]