[gitg] Add setting to collapse all files in diff by default
- From: Jesse van den Kieboom <jessevdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gitg] Add setting to collapse all files in diff by default
- Date: Fri, 7 Aug 2015 07:11:59 +0000 (UTC)
commit 62eb3fc7e6140a7accca07f439db157f5b09ac90
Author: Jesse van den Kieboom <jessevdk gnome org>
Date: Fri Aug 7 09:11:30 2015 +0200
Add setting to collapse all files in diff by default
libgitg/gitg-diff-view.vala | 2 +
libgitg/resources/ui/diff-view/diff-view.js | 31 ++++++++++++++++++++-------
2 files changed, 25 insertions(+), 8 deletions(-)
---
diff --git a/libgitg/gitg-diff-view.vala b/libgitg/gitg-diff-view.vala
index 3372f61..6b5c437 100644
--- a/libgitg/gitg-diff-view.vala
+++ b/libgitg/gitg-diff-view.vala
@@ -135,6 +135,7 @@ namespace Gitg
public bool staged { get; set; default = false; }
public bool unstaged { get; set; default = false; }
public bool show_parents { get; set; default = false; }
+ public bool default_collapse_all { get; set; default = true; }
private bool d_use_gravatar;
@@ -257,6 +258,7 @@ namespace Gitg
o.set_boolean_member("debug", Environment.get_variable("GITG_GTK_DIFF_VIEW_DEBUG") !=
null);
o.set_boolean_member("changes_inline", changes_inline);
o.set_boolean_member("show_parents", show_parents);
+ o.set_boolean_member("default_collapse_all", default_collapse_all);
o.set_string_member("parent", d_parent);
o.set_boolean_member("use_gravatar", use_gravatar);
diff --git a/libgitg/resources/ui/diff-view/diff-view.js b/libgitg/resources/ui/diff-view/diff-view.js
index 89c3096..8ee721e 100644
--- a/libgitg/resources/ui/diff-view/diff-view.js
+++ b/libgitg/resources/ui/diff-view/diff-view.js
@@ -23,6 +23,7 @@ var default_settings = {
unstaged: false,
show_parents: false,
use_gravatar: true,
+ default_collapse_all: true,
strings: {
stage: 'stage',
unstage: 'unstage',
@@ -332,7 +333,11 @@ function expand_collapse()
}
expander.closest('tbody').toggleClass("collapsed");
+ collapsed_changed();
+}
+function collapsed_changed()
+{
var all = $("#diff_content div.file tbody");
var prevCollapsed = false;
var allUncollapsed = true;
@@ -611,6 +616,20 @@ function expand_collapse_all()
$(this).text(collapse ? "\u25B6" : "\u25BC")
}
+function default_collapse_all()
+{
+ var expanders = document.querySelectorAll("#diff_content div.file:not(.background) .expander");
+
+ // Collapse by default if more than one file
+ if (expanders && expanders.length > 1)
+ {
+ for (var i = 0; i < expanders.length; i++)
+ {
+ expand_collapse.call(expanders[i]);
+ }
+ }
+}
+
function update_diff(id, lsettings)
{
if (html_builder_worker)
@@ -688,17 +707,13 @@ function update_diff(id, lsettings)
content.html(event.data.diff_html);
update_has_selection();
- var expanders = document.querySelectorAll("#diff_content div.file:not(.background)
.expander");
-
- // Collapse by default if more than one file
- if (expanders && expanders.length > 1)
+ if (settings.default_collapse_all)
{
- for (var i = 0; i < expanders.length; i++)
- {
- expand_collapse.call(expanders[i]);
- }
+ default_collapse_all();
}
+ collapsed_changed();
+
$("#diff_content div.file tr.file_header td").click(function() {
expand_collapse.call($(this).find(".expander"));
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]