#11127 closed enhancement (fixed)
Open preferences in new window
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: |
The |
||
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.
Attachments (0)
Change History (15)
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).
follow-up: 13 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].
comment:12 by , 11 years ago
API Changes: | modified (diff) |
---|
comment:13 by , 11 years ago
Replying to rjollos:
I'll leave it as is now then; the line is not too insanely long yet.
We have two ways to insert line-breaks with no changes for the extracted messages, but not elegant. I like the extracted messages with no line-breaks from Genshi templates because changes of the indents will lead changes of the messages.
- Inserting line-breaks in the tag
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index ea4e3c8..ae2e92c 100644
a b ${value}</textarea> 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()}" class="trac-target-new">Preferences</a>.</i18n:msg> 362 <i18n:msg>E-mail address and user name can be saved in the <a 363 href="${href.prefs()}" class="trac-target-new" 364 >Preferences</a>.</i18n:msg> 363 365 </p> 364 366 </fieldset> 365 367 </div>
-
- Using comment of Genshi template with line-breaks
-
trac/ticket/templates/ticket.html
diff --git a/trac/ticket/templates/ticket.html b/trac/ticket/templates/ticket.html index ea4e3c8..4b0aac1 100644
a b ${value}</textarea> 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()}" class="trac-target-new">Preferences</a>.</i18n:msg> 362 <i18n:msg>E-mail address and user name can be saved in <!--! 363 -->the <a href="${href.prefs()}" class="trac-target-new"><!--! 364 -->Preferences</a>.</i18n:msg> 363 365 </p> 364 366 </fieldset> 365 367 </div>
-
comment:14 by , 11 years ago
I like the use of the comment marker, since it will probably be more obvious to most developers that something is being done there for "some sort of reason", and the hint could be documented in the TracDev/CodingStyle. If the tag is split across the line, it is not obvious why that would be needed, and more likely that some dummy like me would come along and try to "clean it up" later on.
comment:15 by , 11 years ago
In [bbf16363/rjollos.git#file3] I utilized the comment marker to insert a line break into a line of translatable text and updated the catalog to confirm that it works. Thanks for the hint Jun!
There seem to be more than a few strings that have quite a bit of whitespace. Maybe in the future it would be good to fix those up on the trunk.
Should we just add the target=_blank attribute to the link?