summaryrefslogtreecommitdiffstats
path: root/extensions
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-10-12 06:56:46 +0200
committerByron Jones <glob@mozilla.com>2015-10-12 06:56:46 +0200
commitbb7cbda33555735d17c41d2b9bdd54359dad2d94 (patch)
treea26287c6e48f3b5c00fac515dd2f832bbd23d085 /extensions
parentc2364b357634e07c1b709c5cb120181ae3bc5e65 (diff)
downloadbugzilla-bb7cbda33555735d17c41d2b9bdd54359dad2d94.tar.gz
bugzilla-bb7cbda33555735d17c41d2b9bdd54359dad2d94.tar.xz
Bug 1149899 - Remember expanded/collapsed sections
Diffstat (limited to 'extensions')
-rw-r--r--extensions/BugModal/Extension.pm1
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl6
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/header.html.tmpl3
-rw-r--r--extensions/BugModal/template/en/default/hook/global/setting-descs-settings.none.tmpl1
-rw-r--r--extensions/BugModal/web/bug_modal.js64
5 files changed, 51 insertions, 24 deletions
diff --git a/extensions/BugModal/Extension.pm b/extensions/BugModal/Extension.pm
index 54ef8f4ca..2c60ef35a 100644
--- a/extensions/BugModal/Extension.pm
+++ b/extensions/BugModal/Extension.pm
@@ -293,6 +293,7 @@ sub webservice {
sub install_before_final_checks {
my ($self, $args) = @_;
add_setting('ui_experiments', ['on', 'off'], 'off');
+ add_setting('ui_remember_collapsed', ['on', 'off'], 'off');
# ensure the correct skin is being used
my $dbh = Bugzilla->dbh;
diff --git a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
index ddf37a26c..2663d5562 100644
--- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
@@ -1015,6 +1015,12 @@
[% END %]
[% END %]
+[%# === initialise module visibility === %]
+
+<script>
+ init_module_visibility();
+</script>
+
[%# === top (between modules and comments) actions === %]
[% IF user.id %]
diff --git a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
index 7fdb2ed49..361b9ec9d 100644
--- a/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/header.html.tmpl
@@ -99,7 +99,8 @@
can_tag: [% user.can_tag_comments ? "true" : "false" %],
settings: {
quote_replies: '[% user.settings.quote_replies.value FILTER js %]',
- zoom_textareas: [% user.settings.zoom_textareas.value == "on" ? "true" : "false" %]
+ zoom_textareas: [% user.settings.zoom_textareas.value == "on" ? "true" : "false" %],
+ remember_collapsed: [% user.settings.ui_remember_collapsed.value == "on" ? "true" : "false" %]
}
};
[% IF user.id %]
diff --git a/extensions/BugModal/template/en/default/hook/global/setting-descs-settings.none.tmpl b/extensions/BugModal/template/en/default/hook/global/setting-descs-settings.none.tmpl
index 7214977bb..4ca9c3003 100644
--- a/extensions/BugModal/template/en/default/hook/global/setting-descs-settings.none.tmpl
+++ b/extensions/BugModal/template/en/default/hook/global/setting-descs-settings.none.tmpl
@@ -8,4 +8,5 @@
[%
setting_descs.ui_experiments = "Use experimental user interface"
+ setting_descs.ui_remember_collapsed = "Remember visibility of header sections when viewing a bug"
%]
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js
index 74ee83312..ac467aa0f 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -5,6 +5,47 @@
* This Source Code Form is "Incompatible With Secondary Licenses", as
* defined by the Mozilla Public License, v. 2.0. */
+// expand/collapse module
+function slide_module(module, action, fast) {
+ if (!module.attr('id'))
+ return;
+ var latch = module.find('.module-latch');
+ var spinner = $(latch.children('.module-spinner')[0]);
+ var content = $(module.children('.module-content')[0]);
+ var duration = fast ? 0 : 200;
+
+ function slide_done() {
+ var is_visible = content.is(':visible');
+ spinner.html(is_visible ? '&#9662;' : '&#9656;');
+ if (BUGZILLA.user.settings.remember_collapsed)
+ localStorage.setItem(module.attr('id') + '.visibility', is_visible ? 'show' : 'hide');
+ }
+
+ if (action == 'show') {
+ content.slideDown(duration, 'swing', slide_done);
+ }
+ else if (action == 'hide') {
+ content.slideUp(duration, 'swing', slide_done);
+ }
+ else {
+ content.slideToggle(duration, 'swing', slide_done);
+ }
+}
+
+function init_module_visibility() {
+ if (!BUGZILLA.user.settings.remember_collapsed)
+ return;
+ $('.module').each(function() {
+ var that = $(this);
+ var id = that.attr('id');
+ if (!id) return;
+ var stored = localStorage.getItem(id + '.visibility');
+ if (stored) {
+ slide_module(that, stored, true);
+ }
+ });
+}
+
$(function() {
'use strict';
@@ -25,29 +66,6 @@ $(function() {
// products with descriptions (also lazy-loaded)
var products = [];
- // expand/collapse module
- function slide_module(module, action, fast) {
- if (!module.attr('id'))
- return;
- var latch = module.find('.module-latch');
- var spinner = $(latch.children('.module-spinner')[0]);
- var content = $(module.children('.module-content')[0]);
- var duration = fast ? 0 : 200;
-
- function slide_done() {
- spinner.html(content.is(':visible') ? '&#9662;' : '&#9656;');
- }
- if (action == 'show') {
- content.slideDown(duration, 'swing', slide_done);
- }
- else if (action == 'hide') {
- content.slideUp(duration, 'swing', slide_done);
- }
- else {
- content.slideToggle(duration, 'swing', slide_done);
- }
- }
-
// restore edit mode after navigating back
function restoreEditMode() {
if (!$('#editing').val())