summaryrefslogtreecommitdiffstats
path: root/extensions/BugModal
diff options
context:
space:
mode:
authorByron Jones <glob@mozilla.com>2015-05-27 06:18:43 +0200
committerByron Jones <glob@mozilla.com>2015-05-27 06:18:43 +0200
commitad9f924253079bdd95721dcede870eae4c07dc61 (patch)
tree4df6df4fa3d95de3c1c6eaf4e2ddad5edf67e821 /extensions/BugModal
parent7810a125c419a6b091fd77aa67de03587eda26c7 (diff)
downloadbugzilla-ad9f924253079bdd95721dcede870eae4c07dc61.tar.gz
bugzilla-ad9f924253079bdd95721dcede870eae4c07dc61.tar.xz
Bug 1162854: hitting back after making an edit should keep edit mode open
Diffstat (limited to 'extensions/BugModal')
-rw-r--r--extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl1
-rw-r--r--extensions/BugModal/web/bug_modal.js48
2 files changed, 38 insertions, 11 deletions
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 67c94f499..ba3973bcf 100644
--- a/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
+++ b/extensions/BugModal/template/en/default/bug_modal/edit.html.tmpl
@@ -130,6 +130,7 @@
<input type="hidden" name="longdesclength" value="[% bug.comments.size FILTER html %]">
<input type="hidden" name="id" id="bug_id" value="[% bug.bug_id FILTER html %]">
<input type="hidden" name="format" value="modal">
+ <input type="hidden" name="editing" id="editing" value="">
<input type="hidden" name="token" value="[% issue_hash_token([bug.id, bug.delta_ts]) FILTER html %]">
[% END %]
diff --git a/extensions/BugModal/web/bug_modal.js b/extensions/BugModal/web/bug_modal.js
index 32949828f..4c4d83ad8 100644
--- a/extensions/BugModal/web/bug_modal.js
+++ b/extensions/BugModal/web/bug_modal.js
@@ -39,22 +39,25 @@ $(function() {
}
// expand/collapse module
- function slide_module(module, action) {
+ 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(200, 'swing', slide_done);
+ content.slideDown(duration, 'swing', slide_done);
}
else if (action == 'hide') {
- content.slideUp(200, 'swing', slide_done);
+ content.slideUp(duration, 'swing', slide_done);
}
else {
- content.slideToggle(200, 'swing', slide_done);
+ content.slideToggle(duration, 'swing', slide_done);
}
}
@@ -289,12 +292,9 @@ $(function() {
$('.edit-hide').hide();
$('.edit-show').show();
- // expand specific modules
- $('#module-details .module-header').each(function() {
- if ($(this.parentNode).find('.module-content:visible').length === 0) {
- $(this).click();
- }
- });
+ // expand specific modules during the initial edit
+ if (!$('#editing').val())
+ slide_module($('#module-details'), 'show');
// if there's no current user-story, it's a better experience if it's editable by default
if ($('#cf_user_story').val() === '') {
@@ -384,6 +384,15 @@ $(function() {
return;
$('.save-btn').attr('disabled', true);
this.form.submit();
+
+ // remember expanded modules
+ $('#editing').val(
+ $('.module .module-content:visible')
+ .parent()
+ .map(function(el) { return $(this).attr('id'); })
+ .toArray()
+ .join(' ')
+ );
})
.attr('disabled', false);
@@ -639,8 +648,11 @@ $(function() {
event.preventDefault();
$('#user-story').hide();
$('#user-story-edit-btn').hide();
- $('#cf_user_story').show().focus().select();
$('#top-save-btn').show();
+ $('#cf_user_story').show();
+ // don't focus the user-story field when restoring edit mode after navigation
+ if ($('#editing').val() === '')
+ $('#cf_user_story').focus().select();
});
$('#user-story-reply-btn')
.click(function(event) {
@@ -1006,6 +1018,20 @@ $(function() {
dirty.val(that.val() === that.data('preselected')[0] ? '' : '1');
}
});
+
+ // finally switch to edit mode if we navigate back to a page that was editing
+ if ($('#editing').val()) {
+ $('.module')
+ .each(function() {
+ slide_module($(this), 'hide', true);
+ });
+ $($('#editing').val().split(' '))
+ .each(function() {
+ slide_module($('#' + this), 'show', true);
+ });
+ $('#mode-btn').click();
+ $('#editing').val('');
+ }
});
function confirmUnsafeURL(url) {