Edgewall Software

Ticket #8216: 8216-textarea-resize-r8861.patch

File 8216-textarea-resize-r8861.patch, 19.5 KB (added by Remy Blank, 8 years ago)

Updated patch against trunk.

  • trac/admin/templates/admin_basics.html

    diff --git a/trac/admin/templates/admin_basics.html b/trac/admin/templates/admin_basics.html
    a b  
    2727        </div>
    2828        <div class="field">
    2929          <label>Description:<br />
    30             <textarea name="descr" rows="3" cols="50">
     30            <textarea name="descr" class="trac-resizable" rows="3" cols="50">
    3131${project.description}</textarea>
    3232          </label>
    3333        </div>
  • trac/admin/templates/admin_components.html

    diff --git a/trac/admin/templates/admin_components.html b/trac/admin/templates/admin_components.html
    a b  
    4545                here):
    4646              </label>
    4747              <p>
    48                 <textarea id="description" name="description" class="wikitext"
     48                <textarea id="description" name="description" class="wikitext trac-resizable"
    4949                          rows="6" cols="60">
    5050$component.description</textarea>
    5151              </p>
  • trac/admin/templates/admin_milestones.html

    diff --git a/trac/admin/templates/admin_milestones.html b/trac/admin/templates/admin_milestones.html
    a b  
    5858                Description (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):
    5959              </label>
    6060              <p>
    61                 <textarea id="description" name="description" class="wikitext" rows="6" cols="60" readonly="${readonly}">
     61                <textarea id="description" name="description" class="wikitext trac-resizable" rows="6" cols="60" readonly="${readonly}">
    6262${milestone.description}</textarea>
    6363              </p>
    6464            </fieldset>
  • trac/admin/templates/admin_versions.html

    diff --git a/trac/admin/templates/admin_versions.html b/trac/admin/templates/admin_versions.html
    a b  
    3636                Description (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):
    3737              </label>
    3838              <p>
    39                 <textarea id="description" name="description" class="wikitext" rows="6" cols="60">
     39                <textarea id="description" name="description" class="wikitext trac-resizable" rows="6" cols="60">
    4040$version.description</textarea>
    4141              </p>
    4242            </fieldset>
  • trac/admin/web_ui.py

    diff --git a/trac/admin/web_ui.py b/trac/admin/web_ui.py
    a b  
    3434from trac.util.translation import _
    3535from trac.web import HTTPNotFound, IRequestHandler
    3636from trac.web.chrome import add_notice, add_stylesheet, \
    37                             add_warning, INavigationContributor, \
     37                            add_warning, Chrome, INavigationContributor, \
    3838                            ITemplateProvider
    3939
    4040try:
     
    216216            'description': self.env.project_description,
    217217            'url': self.env.project_url
    218218        }
     219        Chrome(self.env).add_textarea_grips(req)
    219220        return 'admin_basics.html', {'project': data}
    220221
    221222
  • trac/htdocs/css/roadmap.css

    diff --git a/trac/htdocs/css/roadmap.css b/trac/htdocs/css/roadmap.css
    a b  
    9090#edit fieldset.iefix { margin-left: 1px; margin-right: 1px }
    9191#edit textarea#description { margin-left: -1px; margin-right: -1px; padding: 0; width: 100% }
    9292#edit .wikitoolbar { margin-left: -1px }
     93#edit div.trac-resizable { width: 100% }
  • trac/htdocs/css/ticket.css

    diff --git a/trac/htdocs/css/ticket.css b/trac/htdocs/css/ticket.css
    a b  
    8080#changelog { border: 1px outset #996; padding: 1em }
    8181.trac-shade { background-color: #eee }
    8282#trac-comment-editor { margin-top: 1em; margin-left: 2em }
     83#trac-comment-editor div.trac-resizable { width: 100% }
    8384#trac-comment-editor textarea { margin-left: -1px; margin-right: -1px; width: 100% }
    8485#trac-comment-editor .wikitoolbar { margin-left: -1px }
    8586#trac-add-comment :link, #trac-add-comment :visited { color: #b00 }
     
    107108label[for=comment] { float: right }
    108109#comment { margin-left: -1px; margin-right: -1px; padding: 0; width: 100% }
    109110form .field .wikitoolbar { margin-left: -1px }
     111form .field div.trac-resizable { width: 100% }
    110112
    111113#properties { white-space: nowrap; line-height: 160%; padding: .5em }
    112114#properties table { border-spacing: 0; width: 100%; }
  • trac/htdocs/css/trac.css

    diff --git a/trac/htdocs/css/trac.css b/trac/htdocs/css/trac.css
    a b  
    403403.wikitoolbar a#br { background-position: 0 -112px }
    404404.wikitoolbar a#img { background-position: 0 -128px }
    405405
     406/* Textarea resizer */
     407div.trac-resizable { display: table; width: 1px }
     408div.trac-resizable > div { display: table-cell }
     409div.trac-resizable textarea { display: block; margin-bottom: 0 }
     410div.trac-grip {
     411 height: 5px;
     412 overflow: hidden;
     413 background: #eee url(../grip.png) no-repeat center 1px;
     414 border: 1px solid #ddd;
     415 border-top-width: 0;
     416 cursor: s-resize;
     417}
     418
    406419/* Styles for the form for adding attachments. */
    407420#attachment .field { margin-top: 1.3em }
    408421#attachment label { padding-left: .2em }
  • trac/htdocs/css/wiki.css

    diff --git a/trac/htdocs/css/wiki.css b/trac/htdocs/css/wiki.css
    a b  
    1212#edit fieldset { margin-left: 1px; margin-right: 1px }
    1313#edit #text { clear: both; margin-left: -1px; margin-right: -1px; padding: 0; width: 100% }
    1414#edit .wikitoolbar { float: left; margin-left: -1px }
     15#edit div.trac-resizable { clear: both; width: 100% }
    1516#changeinfo { padding: .5em }
    1617#changeinfo .field { float: left; margin: 0 1em .5em 0 }
    1718#changeinfo br { clear: left }
  • new file trac/htdocs/grip.png

    diff --git a/trac/htdocs/grip.png b/trac/htdocs/grip.png
    new file mode 100644
    index 0000000000000000000000000000000000000000..ac6ffcdae6790613409c842b9f6ee2b173b9ab63
    GIT binary patch
    literal 118
    zc%17D@N?(olHy`uVBq!ia0vp^(m>42$P6SS=0AG?q!^2X+?^QKos)S9<gf+!gt-3y
    z|9|)H-N(J}{{Tss1o;IsI6S+N2IL5Ox;Tb#Tu=T1RKm<=z_5|QDxQ7!!Gn`ifszcK
    Lu6{1-oD!M<VBRFg
  • new file trac/htdocs/js/resizer.js

    diff --git a/trac/htdocs/js/resizer.js b/trac/htdocs/js/resizer.js
    new file mode 100644
    - +  
     1// Allow resizing <textarea> elements through a drag bar
     2
     3jQuery(document).ready(function($) {
     4  $('textarea.trac-resizable').each(function() {
     5    var textarea = $(this);
     6    var offset = null;
     7   
     8    function beginDrag(e) {
     9      offset = textarea.height() - e.pageY;
     10      textarea.blur();
     11      $(document).mousemove(dragging).mouseup(endDrag);
     12      return false;
     13    }
     14   
     15    function dragging(e) {
     16      textarea.height(Math.max(32, offset + e.pageY) + 'px');
     17      return false;
     18    }
     19   
     20    function endDrag(e) {
     21      textarea.focus();
     22      $(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
     23    }
     24   
     25    $(this).wrap('<div class="trac-resizable"><div></div></div>')
     26           .parent().append($('<div class="trac-grip"></div>').mousedown(beginDrag));
     27    var grip = $('div.trac-grip', $(this).parent())[0];
     28    grip.style.marginLeft = ($(this)[0].offsetLeft - grip.offsetLeft) + 'px';
     29    grip.style.marginRight = (grip.offsetWidth - $(this)[0].offsetWidth) +'px';
     30  });
     31});
  • trac/htdocs/js/trac.js

    diff --git a/trac/htdocs/js/trac.js b/trac/htdocs/js/trac.js
    a b  
    8282  window.resizeTextArea = function (id, rows) {
    8383    var textarea = $("#" + id).get(0);
    8484    if (!textarea || textarea.rows == undefined) return;
     85    $(textarea).height("");
    8586    textarea.rows = rows;
    8687  }
    8788 
  • trac/ticket/admin.py

    diff --git a/trac/ticket/admin.py b/trac/ticket/admin.py
    a b  
    2424                              format_datetime
    2525from trac.util.text import print_table, printout, exception_to_unicode
    2626from trac.util.translation import _
    27 from trac.web.chrome import add_notice, add_script, add_warning
     27from trac.web.chrome import add_notice, add_script, add_warning, Chrome
    2828
    2929
    3030class TicketAdminPanel(Component):
     
    8484                elif req.args.get('cancel'):
    8585                    req.redirect(req.href.admin(cat, page))
    8686
    87             add_script(req, 'common/js/wikitoolbar.js')
     87            Chrome(self.env).add_wiki_toolbars(req)
    8888            data = {'view': 'detail', 'component': comp}
    8989
    9090        else:
     
    269269                elif req.args.get('cancel'):
    270270                    req.redirect(req.href.admin(cat, page))
    271271
    272             add_script(req, 'common/js/wikitoolbar.js')
     272            Chrome(self.env).add_wiki_toolbars(req)
    273273            data = {'view': 'detail', 'milestone': mil}
    274274
    275275        else:
     
    451451                elif req.args.get('cancel'):
    452452                    req.redirect(req.href.admin(cat, page))
    453453
    454             add_script(req, 'common/js/wikitoolbar.js')
     454            Chrome(self.env).add_wiki_toolbars(req)
    455455            data = {'view': 'detail', 'version': ver}
    456456
    457457        else:
  • trac/ticket/report.py

    diff --git a/trac/ticket/report.py b/trac/ticket/report.py
    a b  
    100100        elif action in ('copy', 'edit', 'new'):
    101101            template = 'report_edit.html'
    102102            data = self._render_editor(req, db, id, action=='copy')
     103            Chrome(self.env).add_wiki_toolbars(req)
    103104        elif action == 'delete':
    104105            template = 'report_delete.html'
    105106            data = self._render_confirm_delete(req, db, id)
  • trac/ticket/roadmap.py

    diff --git a/trac/ticket/roadmap.py b/trac/ticket/roadmap.py
    a b  
    4040from trac.timeline.api import ITimelineEventProvider
    4141from trac.web import IRequestHandler, RequestDone
    4242from trac.web.chrome import add_link, add_notice, add_script, add_stylesheet, \
    43                             add_warning, INavigationContributor
     43                            add_warning, Chrome, INavigationContributor
    4444from trac.wiki.api import IWikiSyntaxProvider
    4545from trac.wiki.formatter import format_to
    4646
     
    713713        else:
    714714            req.perm(milestone.resource).require('MILESTONE_CREATE')
    715715
     716        Chrome(self.env).add_wiki_toolbars(req)
    716717        return 'milestone_edit.html', data, None
    717718
    718719    def _render_view(self, req, db, milestone):
  • trac/ticket/templates/milestone_edit.html

    diff --git a/trac/ticket/templates/milestone_edit.html b/trac/ticket/templates/milestone_edit.html
    a b  
    1313    </py:choose>
    1414    <link rel="stylesheet" type="text/css"
    1515          href="${chrome.htdocs_location}css/roadmap.css" />
    16     <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    1716    <script type="text/javascript">/*<![CDATA[*/
    1817      jQuery(document).ready(function($) {
    1918        function updateCompletedDate() {
     
    8483          <fieldset class="iefix">
    8584            <label for="description" i18n:msg="">Description (you may use <a tabindex="42"
    8685                   href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):</label>
    87             <p><textarea id="description" name="description" class="wikitext" rows="10" cols="78">
     86            <p><textarea id="description" name="description" class="wikitext trac-resizable" rows="10" cols="78">
    8887${milestone.description}</textarea></p>
    8988          </fieldset>
    9089        </div>
  • trac/ticket/templates/report_edit.html

    diff --git a/trac/ticket/templates/report_edit.html b/trac/ticket/templates/report_edit.html
    a b  
    2626              Description: (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here)
    2727            </label>
    2828            <br />
    29             <textarea id="description" name="description" class="wikitext" rows="10" cols="78">
     29            <textarea id="description" name="description" class="wikitext trac-resizable" rows="10" cols="78">
    3030$report.description</textarea>
    3131          </div>
    3232          <div class="field">
     
    3434              <strong>Error:</strong> $error
    3535            </div>
    3636            <label for="query" i18n:msg="">Query for Report: (can be either SQL or, if starting with <tt>query:</tt>, a <a tabindex="42" href="${href.wiki('TracQuery') + '#QueryLanguage'}">TracQuery</a> expression)</label><br />
    37             <textarea id="query" name="query" cols="85" rows="20">
     37            <textarea id="query" name="query" class="trac-resizable" cols="85" rows="20">
    3838$report.sql</textarea>
    3939          </div>
    4040          <div class="buttons">
     
    4242            <input type="submit" name="cancel" value="${_('Cancel')}"/>
    4343          </div>
    4444        </div>
    45         <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    4645      </form>
    4746
    4847      <div id="help" i18n:msg="">
  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    a b  
    266266                </div>
    267267                <form py:if="show_editor" id="trac-comment-editor" method="post" action="#comment:${change.cnum}">
    268268                  <div>
    269                     <textarea name="edited_comment" class="wikitext" rows="10" cols="78">
     269                    <textarea name="edited_comment" class="wikitext trac-resizable" rows="10" cols="78">
    270270${(edited_comment, change.comment)[edited_comment is None]}</textarea>
    271271                    <input type="hidden" name="cnum_edit" value="${change.cnum}"/>
     272                  </div>
     273                  <div class="buttons">
    272274                    <input type="submit" name="preview_comment" value="${_('Preview')}" title="Preview changes to comment ${change.cnum}"/>
    273275                    <input type="submit" name="edit_comment" value="${_('Submit changes')}" title="Submit changes to comment ${change.cnum}"/>
    274276                    <input type="submit" name="cancel_comment" value="${_('Cancel')}" title="Cancel comment edit"/>
     
    310312              <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a>
    311313              here.
    312314            </label>
    313             <textarea id="comment" name="comment" class="wikitext" rows="10" cols="78">
     315            <textarea id="comment" name="comment" class="wikitext trac-resizable" rows="10" cols="78">
    314316${comment}</textarea>
    315317          </fieldset>
    316318        </div>
     
    346348                  <tr>
    347349                    <th><label for="field-description">Description:</label></th>
    348350                    <td class="fullrow" colspan="3">
    349                       <textarea id="field-description" name="field_description" class="wikitext" rows="10" cols="68">
     351                      <textarea id="field-description" name="field_description" class="wikitext trac-resizable" rows="10" cols="68">
    350352${ticket.description}</textarea>
    351353                    </td>
    352354                  </tr>
     
    378380                        </select>
    379381                        <textarea py:when="'textarea'" id="field-${field.name}" name="field_${field.name}"
    380382                                  cols="${field.width}" rows="${field.height}"
    381                                   class="${field.format == 'wiki' and 'wikitext' or None}">
     383                                  class="${field.format == 'wiki' and 'wikitext' or None} trac-resizable">
    382384${value}</textarea>
    383385                        <span py:when="'checkbox'">
    384386                          <input type="checkbox" id="field-${field.name}" name="field_${field.name}"
  • trac/ticket/web_ui.py

    diff --git a/trac/ticket/web_ui.py b/trac/ticket/web_ui.py
    a b  
    425425
    426426        add_stylesheet(req, 'common/css/ticket.css')
    427427        add_script(req, 'common/js/folding.js')
    428         add_script(req, 'common/js/wikitoolbar.js')
     428        Chrome(self.env).add_wiki_toolbars(req)
    429429        return 'ticket.html', data, None
    430430
    431431    def _process_ticket_request(self, req):
     
    601601
    602602        add_stylesheet(req, 'common/css/ticket.css')
    603603        add_script(req, 'common/js/folding.js')
    604         add_script(req, 'common/js/wikitoolbar.js')
     604        Chrome(self.env).add_wiki_toolbars(req)
    605605
    606606        # Add registered converters
    607607        for conversion in mime.get_supported_conversions('trac.ticket.Ticket'):
  • trac/web/chrome.py

    diff --git a/trac/web/chrome.py b/trac/web/chrome.py
    a b  
    146146    req.chrome['notices'].append(msg)
    147147
    148148def add_ctxtnav(req, elm_or_label, href=None, title=None):
    149     """Add an entry to the current page's ctxtnav bar.
    150     """
     149    """Add an entry to the current page's ctxtnav bar."""
    151150    if href:
    152151        elm = tag.a(elm_or_label, href=href, title=title)
    153152    else:
     
    305304
    306305    show_email_addresses = BoolOption('trac', 'show_email_addresses', 'false',
    307306        """Show email addresses instead of usernames. If false, we obfuscate
    308         email addresses (''since 0.11'').""")
     307        email addresses (''since 0.11'')""")
    309308
    310309    show_ip_addresses = BoolOption('trac', 'show_ip_addresses', 'false',
    311310        """Show IP addresses for resource edits (e.g. wiki).
    312         (''since 0.11.3'').""")
     311        (''since 0.11.3'')""")
     312
     313    resizable_textareas = BoolOption('trac', 'resizable_textareas', 'true',
     314        """Make `<textarea>` fields resizable. Requires !JavaScript.
     315        (''since 0.12'')""")
    313316
    314317    templates = None
    315318
     
    853856        else:
    854857            return obfuscate_email_address(author)
    855858
     859    # Element modifiers
     860
     861    def add_textarea_grips(self, req):
     862        """Make `<textarea class="trac-resizable">` fields resizable if enabled
     863        by configuration."""
     864        if self.resizable_textareas:
     865            add_script(req, 'common/js/resizer.js')
     866
     867    def add_wiki_toolbars(self, req):
     868        """Add wiki toolbars to `<textarea class="wikitext">` fields."""
     869        add_script(req, 'common/js/wikitoolbar.js')
     870        self.add_textarea_grips(req)
     871
    856872    # Template filters
    857873
    858874    def _add_form_token(self, token):
  • trac/wiki/templates/wiki_edit.html

    diff --git a/trac/wiki/templates/wiki_edit.html b/trac/wiki/templates/wiki_edit.html
    a b  
    99  <xi:include href="macros.html" />
    1010  <head>
    1111    <title>$title</title>
    12     <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    1312    <script type="text/javascript">
    1413      jQuery(document).ready(function($) {
    1514        $("#text").blur(function() {
     
    8079              </option>
    8180            </select>
    8281          </div>
    83           <p><textarea id="text" class="wikitext" name="text" cols="80" rows="$edit_rows">
     82          <p><textarea id="text" class="wikitext trac-resizable" name="text" cols="80" rows="$edit_rows">
    8483$page.text</textarea>
    8584          </p>
    8685        </fieldset>
  • trac/wiki/web_ui.py

    diff --git a/trac/wiki/web_ui.py b/trac/wiki/web_ui.py
    a b  
    3737from trac.versioncontrol.diff import get_diff_options, diff_blocks
    3838from trac.web.chrome import add_ctxtnav, add_link, add_notice, add_script, \
    3939                            add_stylesheet, add_warning, prevnext_nav, \
    40                             INavigationContributor, ITemplateProvider
     40                            Chrome, INavigationContributor, ITemplateProvider
    4141from trac.web import IRequestHandler
    4242from trac.wiki.api import IWikiPageManipulator, WikiSystem
    4343from trac.wiki.formatter import format_to, OneLinerFormatter
     
    448448                         'longcol': 'Version', 'shortcol': 'v'})
    449449       
    450450        self._wiki_ctxtnav(req, page)
     451        Chrome(self.env).add_wiki_toolbars(req)
    451452        return 'wiki_edit.html', data, None
    452453
    453454    def _render_history(self, req, page):