Commits

Olemis Lang  committed 51d2c9b

BH Theme #346 : Fields and comments preview just work (though not 100% ok).

Side effect: Reply description button transformed into anchor

  • Participants
  • Parent commits 3459851
  • Branches t346_inplace_preview

Comments (0)

Files changed (2)

+t346/t346_r1430317_ticket_inplace_autosubmit.diff

File t346/t346_r1430317_ticket_inplace_autosubmit.diff

+# HG changeset patch
+# Parent c13bcf01260ad2413ab1c42aed067617af0a5544
+BH Theme #346 : Keep ticket in-place edit form on comment preview
+
+diff -r c13bcf01260a bloodhound_theme/bhtheme/htdocs/bloodhound.css
+--- a/bloodhound_theme/bhtheme/htdocs/bloodhound.css	Tue Jan 08 15:10:18 2013 +0000
++++ b/bloodhound_theme/bhtheme/htdocs/bloodhound.css	Tue Jan 08 17:20:16 2013 -0500
+@@ -231,6 +231,13 @@
+   width: auto;
+ }
+ 
++.trac-loading {
++  background: url(../common/loading.gif) 0 50% no-repeat;
++  margin: 0 1em;
++  padding-left: 16px;
++  display: none;
++}
++
+ /* @end */
+ 
+ /* @group Quick Ticket fieldset */
+diff -r c13bcf01260a bloodhound_theme/bhtheme/templates/bh_ticket.html
+--- a/bloodhound_theme/bhtheme/templates/bh_ticket.html	Tue Jan 08 15:10:18 2013 +0000
++++ b/bloodhound_theme/bhtheme/templates/bh_ticket.html	Tue Jan 08 17:20:16 2013 -0500
+@@ -116,12 +116,16 @@
+                   })
+               }
+             });
++
++          // Enable automatic preview
++          $('#inplace-propertyform').autoSubmit({preview : 1}, 
++              full_preview, '#overview .trac-loading')
+         }
+ 
+         function revert_ticket() {
+           $('[data-edit="inplace"]').each(function() {
+               var fc = $(this).removeClass('edit-active');
+-              fc.html(fc.attr('data-edit-orig'));
++              fc.html(fc.attr('data-edit-orig')).attr('data-edit-orig', '');
+             });
+         }
+ 
+@@ -154,10 +158,8 @@
+         var comment_focused = false;
+         $("#comment").focus(function() { comment_focused = true; })
+                      .blur(function() { comment_focused = false; });
+-        $("#propertyform").autoSubmit({preview: '1'}, function(data, reply) {
++        function full_preview(data, reply) {
+           var items = $(reply);
+-          // Update ticket box
+-          $("#ticket").replaceWith(items.filter('#ticket'));
+           // Unthread, unrevert and update changelog
+           if (!$('#trac-comments-oldest').checked())
+             $('#trac-comments-oldest').click().change();
+@@ -176,7 +178,9 @@
+           // Collapse property form if comment editor has focus
+           if (show_preview && comment_focused)
+             $("#modify").parent().addClass("collapsed");
+-        }, "#ticketchange .trac-loading");
++        }
++        $("#propertyform").autoSubmit({preview: '1'}, full_preview,
++            "#ticketchange .trac-loading");
+         $("#trac-comment-editor").autoSubmit({preview_comment: '1'}, function(data, reply) {
+           var comment = $("#trac-comment-editor").next("div.comment").html(reply);
+           comment.toggle(comment.children().length != 0);
+@@ -678,6 +682,9 @@
+           Cancel
+         </button>
+       </div>
++      <div class="btn-group">
++        <span class="trac-loading">&nbsp;</span>
++      </div>
+       </div>
+     </script>
+   </body>
+diff -r c13bcf01260a bloodhound_theme/bhtheme/templates/bh_ticket_box.html
+--- a/bloodhound_theme/bhtheme/templates/bh_ticket_box.html	Tue Jan 08 15:10:18 2013 +0000
++++ b/bloodhound_theme/bhtheme/templates/bh_ticket_box.html	Tue Jan 08 17:20:16 2013 -0500
+@@ -100,10 +100,8 @@
+         <div class="pull-right">
+           <form py:if="ticket.exists and ticket.description and can_append"
+               id="addreply" method="get" action="#comment">
+-            <input type="hidden" name="replyto" value="description" />
+-            <input type="submit" name="reply" value="${_('Reply')}"
+-                class="btn btn-mini"
+-                title="Reply, quoting this description" />
++            <a href="?replyto=description#trac-add-comment" class="btn btn-mini"
++                title="Reply, quoting this description" type="submit">Reply</a>
+           </form>
+         </div>
+         <div py:if="ticket.description" class="searchable" xml:space="preserve"