Opened 11 years ago
Last modified 11 years ago
#11127 closed enhancement
Open preferences in new window — at Version 9
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 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 , 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.
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">
Should we just add the target=_blank attribute to the link?