bloodhound-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rjol...@apache.org
Subject svn commit: r1455006 - in /incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates: bh_wiki_edit.html bh_wiki_edit_form.html
Date Mon, 11 Mar 2013 06:10:57 GMT
Author: rjollos
Date: Mon Mar 11 06:10:57 2013
New Revision: 1455006

URL: http://svn.apache.org/r1455006
Log:
Fixes #456:
 * Copied JS code contained within the `script` elements of the `wiki_edit` template to `bh_wiki_edit`
(​[trac 11109], ​[trac 11110]), providing the functionality to automatically refresh the
page when toggling the ''Edit side-by-side'' checkbox and resize the text area relative to
the preview.
 * Hide the navigation controls when in side-by-side edit mode. Removed some navigation controls
that had also been removed in Trac.
 * Adjusted the size of the ''Adjust edit area height'' select box.

Modified:
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit.html
    incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit_form.html

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit.html?rev=1455006&r1=1455005&r2=1455006&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit.html (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit.html Mon Mar
11 06:10:57 2013
@@ -55,24 +55,50 @@
         $("#editrows").change(function() {
           resizeTextArea("text", this.options[this.selectedIndex].value);
         });
+        $("#sidebyside").change(function() {
+          $("#edit input[type=submit][name=preview]").click();
+        });
         <py:if test="not sidebyside and (action == 'preview' or diff)">
           $("#info").scrollToTop();
         </py:if>
-        <py:if test="sidebyside">
+        <py:if test="sidebyside">/*<![CDATA[*/
+          function editorHeight() {
+            return $("#text").closest("fieldset").innerHeight();
+          }
+          function previewHeight() {
+            return $("#preview").innerHeight();
+          }
+          var preview_pad = previewHeight() - $("#preview").height();
+          var editor_pad = editorHeight() - $("#text").height();
           function autoResizeText() {
-            var preview_height = $("#preview").height();
-            if (preview_height)
-              $("#text").height(preview_height + 15);
+            $("#preview").height(0); // neutralize preview
+            $("#text").height("auto"); // adapt textarea to its content
+            var text_height = $("#text").prop("scrollHeight");
+            var wikipage_height = $("#preview div.wikipage").height();
+            if (wikipage_height > text_height) {
+              // expand #text to its natural height and adapt #preview to it
+              $("#text").height(text_height).css("overflow-y", "hidden");
+              $("#preview").height(Math.max(16, editorHeight() - preview_pad));
+            } else {
+              // expand .wikipage to its natural height and adapt #text to it
+              $("#preview").height("auto");
+              $("#text").height(Math.max(16, previewHeight() - editor_pad))
+                .css("overflow-y", "auto");
+            }
           }
           autoResizeText();
           $(window).resize(autoResizeText);
-        </py:if>
+        /*]]>*/</py:if>
         <py:if test="sidebyside and not diff">
           $("#text").autoPreview("${href.wiki_render()}", {
               realm: "${page.resource.realm}", id: "${page.resource.id}"
             }, function(textarea, text, rendered) {
+              var window_scroll_top = $(window).scrollTop();
+              var editor_scroll_top = $("#text").scrollTop();
               $("#preview div.wikipage").html(rendered);
               autoResizeText();
+              $(window).scrollTop(window_scroll_top);
+              $("#text").scrollTop(editor_scroll_top);
           });
         </py:if>
         $(".foldable").enableFolding(true, true);
@@ -83,18 +109,15 @@
   <body>
     <div id="content" class="wiki row"
          py:with="preview_or_review = action == 'preview' and (not diff or changes[0].diffs)">
-      <div class="trac-topnav span12" py:if="sidebyside or preview_or_review" py:choose="">
-        <a py:when="sidebyside" href="#changeinfo"
-           title="Go to Save, Preview, Review or Cancel buttons">Actions</a>
+      <div class="trac-topnav span12" py:if="not sidebyside and preview_or_review" py:choose="">
         <a py:when="diff" href="#info" title="See the diffs">Review</a>
         <a py:otherwise="" href="#info" title="See the preview">Preview</a>
         &darr;
       </div>
-      <span class="span12"><h1 i18n:msg="name">Editing ${name_of(page.resource)}</h1></span>
+      <h1 class="span12" i18n:msg="name">Editing ${name_of(page.resource)}</h1>
       <div py:if="merge" class="system-message span12">
         <div class="alert">
-          <p>
-          <span class="label label-important">Important</span>
+          <p><span class="label label-important">Important</span>
           Someone else has modified that page since you started your edits.</p><br
/>
           <p i18n:msg=""><strong>If you save right away, you risk to revert those
changes
           (highlighted below as deletions).</strong></p><br />
@@ -130,7 +153,7 @@
       (the  #preview will float at the right of the edit form's textarea)
 
       -->
-      <div class="span12" py:if="not sidebyside">
+      <div py:if="not sidebyside" class="span12">
         <xi:include href="bh_wiki_edit_form.html" />
       </div>
       <py:choose test="action">
@@ -152,15 +175,15 @@
           </div>
           <div class="${sidebyside and 'sidebyside preview-right span6' or 'span12'}"
               py:choose="">
-            <div class="trac-nav" py:if="not sidebyside and preview_or_review">
+            <div py:if="not sidebyside and preview_or_review" class="trac-nav">
               <a href="#content" title="Go to the editor">Edit</a> &uarr;
             </div>
-            <h2 py:choose="">
+            <h2 py:if="not sidebyside" py:choose="">
               <py:when test="preview_or_review and diff">Review Changes</py:when>
-              <py:when test="preview_or_review">Preview</py:when>
+              <py:when test="preview_or_review"></py:when>
               <py:otherwise>No changes</py:otherwise>
             </h2>
-            <div id="preview">
+            <div id="preview" class="trac-content">
               <div py:when="diff" class="diff">
                 <xi:include href="diff_div.html" py:with="no_id=True" />
               </div>

Modified: incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit_form.html
URL: http://svn.apache.org/viewvc/incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit_form.html?rev=1455006&r1=1455005&r2=1455006&view=diff
==============================================================================
--- incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit_form.html (original)
+++ incubator/bloodhound/trunk/bloodhound_theme/bhtheme/templates/bh_wiki_edit_form.html Mon
Mar 11 06:10:57 2013
@@ -24,7 +24,7 @@
       xmlns:py="http://genshi.edgewall.org/"
       xmlns:i18n="http://genshi.edgewall.org/i18n" py:strip="">
   <form id="edit" action="${href.wiki(page.name)}" method="post">
-    <fieldset class="iefix control-group">
+    <fieldset class="${classes('controlgroup', sidebyside=sidebyside)}">
       <input type="hidden" name="from_editor" value="1" />
       <input type="hidden" name="action" value="edit" />
       <input type="hidden" name="version" value="$page.version" />
@@ -32,20 +32,20 @@
              value="$scroll_bar_pos" />
       <div id="rows">
         <py:if test="not sidebyside">
-          <label for="editrows">Adjust edit area height:</label>
-          <select size="1" name="editrows" id="editrows" tabindex="43">
-            <option py:for="rows in range(8, 42, 4)" value="$rows"
-                    selected="${str(rows) == edit_rows or None}">
-              $rows
-            </option>
-          </select>
-        </py:if>
-        <span class="pull-right">
-          <label for="sidebyside" title="Selecting and pressing 'Preview' enters a two-column
[edit|preview] mode">
-            Edit side-by-side
+          <label for="editrows">Adjust edit area height:
+            <select id="editrows" class="span1" name="editrows" tabindex="43">
+              <option py:for="rows in range(8, 42, 4)" value="$rows"
+                      selected="${str(rows) == edit_rows or None}">
+                $rows
+              </option>
+            </select>
           </label>
+        </py:if>
+        <label for="sidebyside" class="pull-right"
+               title="Selecting and pressing 'Preview' enters a two-column [edit|preview]
mode">
+          Edit side-by-side
           <input type="checkbox" name="sidebyside" id="sidebyside" checked="$sidebyside"
/>
-        </span>
+        </label>
         <br/>
       </div>
       <p><textarea id="text" class="wikitext${' trac-resizable' if not sidebyside
else None}"
@@ -58,18 +58,13 @@ $page.text</textarea>
         <a href="${href.wiki('TracWiki')}">TracWiki</a> for help on editing wiki
content.
       </div>
     </fieldset>
-    <div class="trac-nav" py:if="sidebyside" py:choose="">
-      <a py:when="diff" href="#content" title="See the start of the diffs">Review</a>
-      <a py:otherwise="" href="#content" title="See the start of the preview">Preview</a>
-      &uarr;
-    </div>
     <div class="well">
       <fieldset id="changeinfo">
         <legend>Change information</legend>
         <div id="changeinfo1">
           <div py:if="authname == 'anonymous'" class="field">
             <label>Your email or username:<br />
-              <input id="author" type="text" name="author" size="30" value="$author" />
+              <input id="author" type="text" class="input-xlarge" name="author" value="$author"
/>
             </label>
             <p py:if="author == 'anonymous'" class="hint">
               <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>
@@ -77,7 +72,7 @@ $page.text</textarea>
           </div>
           <div class="field">
             <label>Comment about this change (optional):<br />
-              <input id="comment" type="text" name="comment" size="60" value="$comment"
/>
+              <input id="comment" type="text" class="input-xlarge" name="comment" value="$comment"
/>
             </label>
           </div>
         </div>



Mime
View raw message