summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal/web/bug_modal.js
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/BugModal/web/bug_modal.js
parentc2364b357634e07c1b709c5cb120181ae3bc5e65 (diff)
downloadbugzilla-bb7cbda33555735d17c41d2b9bdd54359dad2d94.tar.gz
bugzilla-bb7cbda33555735d17c41d2b9bdd54359dad2d94.tar.xz
Bug 1149899 - Remember expanded/collapsed sections
Diffstat (limited to 'extensions/BugModal/web/bug_modal.js')
-rw-r--r--extensions/BugModal/web/bug_modal.js64
1 files changed, 41 insertions, 23 deletions
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())