Edgewall Software
Modify

Opened 7 years ago

Closed 6 years ago

Last modified 6 years ago

#11127 closed enhancement (fixed)

Open preferences in new window

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 a new window or tab when JavaScript is enabled.

API Changes:

The trac-target-new class can be added to a link element to cause a new window or tab to be opened when the link is clicked (the target=_blank attribute is added to the element).

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 Ryan J Ollos, 6 years ago

Cc: Ryan J Ollos added

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

comment:2 by Remy Blank, 6 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, 6 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, 6 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, 6 years ago

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

comment:6 by Remy Blank, 6 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, 6 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, 6 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, 6 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">

in reply to:  9 ; comment:10 by Remy Blank, 6 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).

in reply to:  10 ; comment:11 by Ryan J Ollos, 6 years ago

Release Notes: modified (diff)
Resolution: fixed
Status: assignedclosed

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 Ryan J Ollos, 6 years ago

API Changes: modified (diff)

in reply to:  11 comment:13 by Jun Omae, 6 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>  
      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()}" 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>
      363365            </p>
      364366          </fieldset>
      365367        </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>  
      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()}" 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>
      363365            </p>
      364366          </fieldset>
      365367        </div>

comment:14 by Ryan J Ollos, 6 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 Ryan J Ollos, 6 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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to as closed The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.