#11127 closed enhancement (fixed)
Open preferences in new window — at Version 11
Reported by: | 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 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 (11)
comment:1 by , 11 years ago
Cc: | added |
---|
comment:2 by , 11 years ago
There's no target
attribute on links in XHTML. So you would have to do this with JavaScript.
comment:3 by , 11 years ago
Milestone: | → next-stable-1.0.x |
---|
Thanks, I will investigate a JavaScript implementation after 1.0.2.
comment:4 by , 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 18 18 jQuery(document).ready(function($) { 19 19 $("div.description").find("h1,h2,h3,h4,h5,h6").addAnchor(_("Link to this section")); 20 20 $(".foldable").enableFolding(false, true); 21 $(".trac-target-new").attr("target", "_blank"); 21 22 <py:when test="ticket.exists">/*<![CDATA[*/ 22 23 $("#attachments").toggleClass("collapsed"); 23 24 $("#trac-up-attachments").click(function () { … … ${value}</textarea> 359 360 </tr> 360 361 </table> 361 362 <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> 363 366 </p> 364 367 </fieldset> 365 368 </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 , 11 years ago
Cc: | removed |
---|---|
Component: | web frontend → ticket system |
Owner: | set to |
Status: | new → assigned |
comment:6 by , 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 , 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 , 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.
follow-up: 10 comment:9 by , 11 years ago
Milestone: | next-stable-1.0.x → 1.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
48 48 <script type="text/javascript"> 49 49 jQuery(document).ready(function($) { 50 50 $(".trac-focus").focus(); 51 $(".trac-target-new").attr("target", "_blank"); 51 52 }); 52 53 </script> 53 54 ${select("*[local-name() != 'title']|text()|comment()")} -
trac/ticket/templates/ticket.html
359 359 </tr> 360 360 </table> 361 361 <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> 363 363 </p> 364 364 </fieldset> 365 365 </div> -
trac/wiki/templates/wiki_edit_form.html
43 43 <input id="author" type="text" name="author" size="30" value="$author" /> 44 44 </label> 45 45 <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> 47 47 </p> 48 48 </div> 49 49 <div class="field">
follow-up: 11 comment:10 by , 11 years ago
Replying to rjollos:
Does the addition of the newline and whitespace add more work for translators?
Yes, it does. However, the translation systems are usually fairly good at identifying the old translation, so the translator usually only has to make the corresponding whitespace fixes (if at all).
comment:11 by , 11 years ago
Release Notes: | modified (diff) |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
Replying to rblank:
Yes, it does. However, the translation systems are usually fairly good at identifying the old translation, so the translator usually only has to make the corresponding whitespace fixes (if at all).
Thanks, I'll leave it as is now then; the line is not too insanely long yet.
Committed to 1.0-stable in [12119], and merged to trunk in [12120].
Should we just add the target=_blank attribute to the link?