Edgewall Software

Opened 11 years ago

Last modified 11 years ago

#11127 closed enhancement

Open preferences in new window — at Version 9

Reported by: orymate@… Owned by: Ryan J Ollos
Priority: low Milestone: 1.0.2
Component: ticket system Version:
Severity: minor Keywords:
Cc: Branch:
Release Notes:

The Preferences link on the ticket and wiki edit pages will open in a new window or tab when JavaScript is enabled.

API Changes:
Internal Changes:

Description

In the reporter fieldset of the ticket submission form there is a notice: E-mail address and user name can be saved in the Preferences.

New users of a trac system find this notice after filling in the form. If they click on the suggested preferences link, they will lose their ticket (at least in Firefox).

A workaround is opening this page in a new window/tab.

Change History (9)

comment:1 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos added

Should we just add the target=_blank attribute to the link?

comment:2 by Remy Blank, 11 years ago

There's no target attribute on links in XHTML. So you would have to do this with JavaScript.

comment:3 by Ryan J Ollos, 11 years ago

Milestone: next-stable-1.0.x

Thanks, I will investigate a JavaScript implementation after 1.0.2.

comment:4 by Ryan J Ollos, 11 years ago

How about this?:

  • trac/ticket/templates/ticket.html

    diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html
    index 6a39059..c2b83a3 100644
    a b  
    1818      jQuery(document).ready(function($) {
    1919        $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section"));
    2020        $(".foldable").enableFolding(false, true);
     21        $(".trac-target-new").attr("target", "_blank");
    2122      <py:when test="ticket.exists">/*<![CDATA[*/
    2223        $("#attachments").toggleClass("collapsed");
    2324        $("#trac-up-attachments").click(function () {
    ${value}</textarea>  
    359360              </tr>
    360361            </table>
    361362            <p py:if="author_id == 'anonymous'" class="hint">
    362               <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>
     363              <i18n:msg>E-mail address and user name can be saved in the
     364                <a href="${href.prefs()}" class="trac-target-new">Preferences</a>.
     365              </i18n:msg>
    363366            </p>
    364367          </fieldset>
    365368        </div>

In fact, the $(".trac-target-new").attr("target", "_blank"); could go in layout.html, as we've done with trac-focus in #11084 and propose to do with trac-scroll in #11084.

comment:5 by Ryan J Ollos, 11 years ago

Cc: Ryan J Ollos removed
Component: web frontendticket system
Owner: set to Ryan J Ollos
Status: newassigned

comment:6 by Remy Blank, 11 years ago

Heh, I was actually thinking of setting an onclick handler, and opening a new window from JavaScript, but this is a very neat idea. Putting it in layout.html definitely makes sense.

comment:7 by Ryan J Ollos, 11 years ago

I was a bit concerned that this was somehow cheating. I mean, if I add the target=_blank attribute, is it still valid XHTML on the page? Is this somehow okay if/because I'm only changing the DOM, not the page HTML?

comment:8 by Remy Blank, 11 years ago

I had the same thoughts, but I think it's ok. We validate the documents that are sent over the wire, and these are XHTML-Strict compliant. Whatever happens in the browser is another subject, unrelated to XHTML.

I did check that HTML5 still has the target attribute. So at least we're not driving into a dead end.

comment:9 by Ryan J Ollos, 11 years ago

Milestone: next-stable-1.0.x1.0.2
Release Notes: modified (diff)

When I added a line-break to the very long line as shown in comment:4, and regenerated messages.pot, the line changed from:

#: trac/ticket/templates/ticket.html:362
#: trac/wiki/templates/wiki_edit_form.html:46
msgid "E-mail address and user name can be saved in the [1:Preferences]."
msgstr ""

to:

#: trac/ticket/templates/ticket.html:362
msgid ""
"E-mail address and user name can be saved in the\n"
"                  [1:Preferences]."
msgstr ""

Does the addition of the newline and whitespace add more work for translators?

Here is the latest version of the patch:

  • trac/templates/layout.html

     
    4848    <script type="text/javascript">
    4949      jQuery(document).ready(function($) {
    5050        $(".trac-focus").focus();
     51        $(".trac-target-new").attr("target", "_blank");
    5152      });
    5253    </script>
    5354    ${select("*[local-name() != 'title']|text()|comment()")}
  • trac/ticket/templates/ticket.html

     
    359359              </tr>
    360360            </table>
    361361            <p py:if="author_id == 'anonymous'" class="hint">
    362               <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>
     362              <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}" class="trac-target-new">Preferences</a>.</i18n:msg>
    363363            </p>
    364364          </fieldset>
    365365        </div>
  • trac/wiki/templates/wiki_edit_form.html

     
    4343            <input id="author" type="text" name="author" size="30" value="$author" />
    4444          </label>
    4545          <p py:if="author == 'anonymous'" class="hint">
    46             <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}">Preferences</a>.</i18n:msg>
     46            <i18n:msg>E-mail address and user name can be saved in the <a href="${href.prefs()}" class="trac-target-new">Preferences</a>.</i18n:msg>
    4747          </p>
    4848        </div>
    4949        <div class="field">
Note: See TracTickets for help on using tickets.