Edgewall Software

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

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

Patch against 0.11-stable adding resize grips to all <textarea> fields.

  • 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  
    4444                here):
    4545              </label>
    4646              <p>
    47                 <textarea id="description" name="description" class="wikitext"
     47                <textarea id="description" name="description" class="wikitext trac-resizable"
    4848                          rows="6" cols="60">
    4949$component.description</textarea>
    5050              </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  
    5555                Description (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):
    5656              </label>
    5757              <p>
    58                 <textarea id="description" name="description" class="wikitext" rows="6" cols="60">
     58                <textarea id="description" name="description" class="wikitext trac-resizable" rows="6" cols="60">
    5959${milestone.description}</textarea>
    6060              </p>
    6161            </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  
    3535                Description (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):
    3636              </label>
    3737              <p>
    38                 <textarea id="description" name="description" class="wikitext" rows="6" cols="60">
     38                <textarea id="description" name="description" class="wikitext trac-resizable" rows="6" cols="60">
    3939$version.description</textarea>
    4040              </p>
    4141            </fieldset>
  • trac/admin/web_ui.py

    diff --git a/trac/admin/web_ui.py b/trac/admin/web_ui.py
    a b  
    197197            'description': self.env.project_description,
    198198            'url': self.env.project_url
    199199        }
     200        add_script(req, 'common/js/resizer.js')
    200201        return 'admin_basics.html', {'project': data}
    201202
    202203
  • trac/htdocs/css/trac.css

    diff --git a/trac/htdocs/css/trac.css b/trac/htdocs/css/trac.css
    a b  
    376376.wikitoolbar a#br { background-position: 0 -112px }
    377377.wikitoolbar a#img { background-position: 0 -128px }
    378378
     379/* Textarea resizer */
     380div.trac-resizable { display: table; width: 1px }
     381div.trac-resizable > div { display: table-cell }
     382div.trac-resizable textarea { display: block; margin-bottom: 0 }
     383div.trac-grip {
     384 height: 9px;
     385 overflow: hidden;
     386 background: #eee url(../grip.png) no-repeat center 2px;
     387 border: 1px solid #ddd;
     388 border-top-width: 0;
     389 cursor: s-resize;
     390}
     391
    379392/* Styles for the form for adding attachments. */
    380393#attachment .field { margin-top: 1.3em }
    381394#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  
    1111#edit #rows select { font-size: 90% }
    1212#edit #text { clear: both; width: 100% }
    1313#edit .wikitoolbar { float: left; }
     14#edit div.trac-resizable { clear: both; width: 100% }
    1415#changeinfo { padding: .5em }
    1516#changeinfo .field { float: left; margin: 0 1em .5em 0 }
    1617#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..6524d4167d2d6e3939cfcf3111ce520acd66bc21
    GIT binary patch
    literal 162
    zc%17D@N?(olHy`uVBq!ia0vp^(m>40!3-puuch|@DVB6cUq=Rp^(V|(yIunMk|nMY
    zCBgY=CFO}lsSJ)O`AMk?p1FzXsX?iUDV2pMQ*D5X*aCb)TzBu@{r~^}iVZzqfg(&L
    zL4Lvi8J=!8@B;EgJY5_^DsCku9AK6xWM-3k!OUU6z#qV1KKathOF(%BPgg&ebxsLQ
    E0Ke)mAOHXW
  • 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
    - +  
     1jQuery(document).ready(function($) {
     2        $('textarea.trac-resizable').each(function() {
     3            var textarea = $(this);
     4            var offset = null;
     5           
     6            $(this).wrap('<div class="trac-resizable"><div></div></div>')
     7              .parent().append($('<div class="trac-grip"></div>').mousedown(beginDrag));
     8            var grip = $('div.trac-grip', $(this).parent())[0];
     9            grip.style.marginLeft = ($(this)[0].offsetLeft - grip.offsetLeft) + 'px';
     10            grip.style.marginRight = (grip.offsetWidth - $(this)[0].offsetWidth) +'px';
     11           
     12        function beginDrag(e) {
     13                offset = textarea.height() - e.pageY;
     14                textarea.blur();
     15                $(document).mousemove(dragging).mouseup(endDrag);
     16                return false;
     17        }
     18       
     19        function dragging(e) {
     20            textarea.height(Math.max(32, offset + e.pageY) + 'px');
     21                return false;
     22        }
     23       
     24        function endDrag(e) {
     25                textarea.focus();
     26                $(document).unbind('mousemove', dragging).unbind('mouseup', endDrag);
     27        }
     28        });
     29});
  • trac/htdocs/js/trac.js

    diff --git a/trac/htdocs/js/trac.js b/trac/htdocs/js/trac.js
    a b  
    4949 
    5050  // Used for dynamically updating the height of a textarea
    5151  window.resizeTextArea = function (id, rows) {
    52     var textarea = $("#" + id).get(0);
     52    var items = $("#" + id);
     53    var textarea = items.get(0);
    5354    if (!textarea || textarea.rows == undefined) return;
     55    items.height("");
    5456    textarea.rows = rows;
    5557  }
    5658 
  • trac/ticket/admin.py

    diff --git a/trac/ticket/admin.py b/trac/ticket/admin.py
    a b  
    6767                    req.redirect(req.href.admin(cat, page))
    6868
    6969            add_script(req, 'common/js/wikitoolbar.js')
     70            add_script(req, 'common/js/resizer.js')
    7071            data = {'view': 'detail', 'component': comp}
    7172
    7273        else:
     
    163164                    req.redirect(req.href.admin(cat, page))
    164165
    165166            add_script(req, 'common/js/wikitoolbar.js')
     167            add_script(req, 'common/js/resizer.js')
    166168            data = {'view': 'detail', 'milestone': mil}
    167169
    168170        else:
     
    253255                    req.redirect(req.href.admin(cat, page))
    254256
    255257            add_script(req, 'common/js/wikitoolbar.js')
     258            add_script(req, 'common/js/resizer.js')
    256259            data = {'view': 'detail', 'version': ver}
    257260
    258261        else:
  • trac/ticket/report.py

    diff --git a/trac/ticket/report.py b/trac/ticket/report.py
    a b  
    3434from trac.util.text import to_unicode, unicode_urlencode
    3535from trac.util.translation import _
    3636from trac.web.api import IRequestHandler, RequestDone
    37 from trac.web.chrome import add_ctxtnav, add_link, add_stylesheet, \
    38                             INavigationContributor, Chrome
     37from trac.web.chrome import add_ctxtnav, add_link, add_script, \
     38                            add_stylesheet, INavigationContributor, Chrome
    3939from trac.wiki import IWikiSyntaxProvider, WikiParser
    4040
    4141
     
    9898        elif action in ('copy', 'edit', 'new'):
    9999            template = 'report_edit.html'
    100100            data = self._render_editor(req, db, id, action=='copy')
     101            add_script(req, 'common/js/wikitoolbar.js')
     102            add_script(req, 'common/js/resizer.js')
    101103        elif action == 'delete':
    102104            template = 'report_delete.html'
    103105            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  
    3939from trac.ticket.query import Query
    4040from trac.timeline.api import ITimelineEventProvider
    4141from trac.web import IRequestHandler
    42 from trac.web.chrome import add_link, add_stylesheet, add_warning, \
    43                             INavigationContributor
     42from trac.web.chrome import add_link, add_script, add_stylesheet, \
     43                            add_warning, INavigationContributor
    4444from trac.wiki.api import IWikiSyntaxProvider
    4545from trac.wiki.formatter import format_to
    4646
     
    688688        else:
    689689            req.perm(milestone.resource).require('MILESTONE_CREATE')
    690690
     691        add_script(req, 'common/js/wikitoolbar.js')
     692        add_script(req, 'common/js/resizer.js')
    691693        return 'milestone_edit.html', data, None
    692694
    693695    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  
    1212    </py:choose>
    1313    <link rel="stylesheet" type="text/css"
    1414          href="${chrome.htdocs_location}css/roadmap.css" />
    15     <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    1615    <script type="text/javascript">/*<![CDATA[*/
    1716      jQuery(document).ready(function($) {
    1817        function updateCompletedDate() {
     
    8382          <fieldset class="iefix">
    8483            <label for="description">Description (you may use <a tabindex="42"
    8584                   href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here):</label>
    86             <p><textarea id="description" name="description" class="wikitext" rows="10" cols="78">
     85            <p><textarea id="description" name="description" class="wikitext trac-resizable" rows="10" cols="78">
    8786${milestone.description}</textarea></p>
    8887          </fieldset>
    8988        </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  
    2525              Description: (you may use <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a> here)
    2626            </label>
    2727            <br />
    28             <textarea id="description" name="description" class="wikitext" rows="10" cols="78">
     28            <textarea id="description" name="description" class="wikitext trac-resizable" rows="10" cols="78">
    2929$report.description</textarea>
    3030          </div>
    3131          <div class="field">
     
    3333              <strong>Error:</strong> $error
    3434            </div>
    3535            <label for="query">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 />
    36             <textarea id="query" name="query" cols="85" rows="20">
     36            <textarea id="query" name="query" class="trac-resizable" cols="85" rows="20">
    3737$report.sql</textarea>
    3838          </div>
    3939          <div class="buttons">
     
    4141            <input type="submit" name="cancel" value="Cancel"/>
    4242          </div>
    4343        </div>
    44         <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    4544      </form>
    4645
    4746      <div id="help">
  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    a b  
    1818        </py:otherwise>
    1919      </py:choose>
    2020    </title>
    21     <script type="text/javascript" src="${chrome.htdocs_location}js/wikitoolbar.js"></script>
    2221    <script type="text/javascript" py:choose="">
    2322      jQuery(document).ready(function($) {
    2423        $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor("Link to this section");
     
    265264              <a tabindex="42" href="${href.wiki('WikiFormatting')}">WikiFormatting</a>
    266265              here):
    267266            </label><br />
    268             <p><textarea id="comment" name="comment" class="wikitext" rows="10" cols="78">
     267            <p><textarea id="comment" name="comment" class="wikitext trac-resizable" rows="10" cols="78">
    269268${comment}</textarea></p>
    270269          </fieldset>
    271270        </div>
     
    297296                <th><label for="field-description">Description:</label></th>
    298297                <td class="fullrow" colspan="3">
    299298                  <textarea id="field-description" name="field_description"
    300                             class="wikitext" rows="10" cols="68"
     299                            class="wikitext trac-resizable" rows="10" cols="68"
    301300                            py:content="ticket.description"></textarea>
    302301                </td>
    303302              </tr>
     
    328327                    </select>
    329328                    <textarea py:when="'textarea'" id="field-${field.name}" name="field_${field.name}"
    330329                              cols="${field.width}" rows="${field.height}"
    331                               class="${field.format == 'wiki' and 'wikitext' or None}"
     330                              class="${field.format == 'wiki' and 'wikitext' or None} trac-resizable"
    332331                              py:content="value"></textarea>
    333332                    <span py:when="'checkbox'">
    334333                      <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  
    434434        data['fields'] = fields
    435435
    436436        add_stylesheet(req, 'common/css/ticket.css')
     437        add_script(req, 'common/js/wikitoolbar.js')
     438        add_script(req, 'common/js/resizer.js')
    437439        return 'ticket.html', data, None
    438440
    439441    def _process_ticket_request(self, req):
     
    580582                break
    581583
    582584        add_stylesheet(req, 'common/css/ticket.css')
     585        add_script(req, 'common/js/wikitoolbar.js')
     586        add_script(req, 'common/js/resizer.js')
    583587
    584588        # Add registered converters
    585589        for conversion in mime.get_supported_conversions('trac.ticket.Ticket'):
  • trac/wiki/templates/wiki_edit.html

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

    diff --git a/trac/wiki/web_ui.py b/trac/wiki/web_ui.py
    a b  
    438438                         'longcol': 'Version', 'shortcol': 'v'})
    439439       
    440440        self._wiki_ctxtnav(req, page)
     441        add_script(req, 'common/js/wikitoolbar.js')
     442        add_script(req, 'common/js/resizer.js')
    441443        return 'wiki_edit.html', data, None
    442444
    443445    def _render_history(self, req, page):