Skip to content

Commit

Permalink
Use specific selector for copying text to simplify things.
Browse files Browse the repository at this point in the history
  • Loading branch information
julen committed Jun 28, 2012
1 parent 0c571ce commit 5e0ec34
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 13 deletions.
6 changes: 4 additions & 2 deletions pootle/apps/pootle_misc/templatetags/cleanhtml.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def fancy_escape(text):
"""replace special chars with entities, and highlight xml tags and
whitespaces"""
def replace(match):
escape_highlight = '<span class="highlight-escape">%s</span>'
html_highlight = '<span class="highlight-html">&lt;%s&gt;</span>'
escape_highlight = '<span class="highlight-escape ' \
'js-editor-copytext">%s</span>'
html_highlight = '<span class="highlight-html js-editor-copytext">' \
'&lt;%s&gt;</span>'
submap = {
'\r\n': (escape_highlight % '\\r\\n') + '<br/>\n',
'\r': (escape_highlight % '\\r') + '<br/>\n',
Expand Down
4 changes: 2 additions & 2 deletions pootle/apps/pootle_store/templates/unit/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div id="tm" class="sidebar" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
<div class="sidetitle" lang="{{ LANGUAGE_CODE }}">{% trans "Terminology:" %}</div>
{% for term in terms %}
<div class="tm-unit writetm" title="{% trans 'Click to insert the translated term into the editor' %}">
<div class="tm-unit js-editor-copytext" title="{% trans 'Click to insert the translated term into the editor' %}">
<span class="tm-original" dir="{{ source_language.get_direction }}" lang="{{ source_language.code }}">{{ term.source }}</span>
<span class="tm-translation" dir="{{ language.get_direction }}" lang="{{ language.code }}">{{ term.target }}</span>
</div>
Expand Down Expand Up @@ -137,7 +137,7 @@
<div class="translate-specialchars-block" lang="{{ language.code }}">
{% for specialchar in language.specialchars %}
{% if not specialchar.isspace %}
<a class="writespecial" title="{% trans 'Click to insert this symbol into the editor' %}">{{ specialchar }}</a>
<a class="editor-specialchar js-editor-copytext" title="{% trans 'Click to insert this symbol into the editor' %}">{{ specialchar }}</a>
{% else %}
<span class="extraspace"> </span>
{% endif %}
Expand Down
4 changes: 2 additions & 2 deletions pootle/apps/pootle_store/templates/unit/term_edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<div id="tm" class="sidebar" dir="{% if LANGUAGE_BIDI %}rtl{% else %}ltr{% endif %}">
<div class="sidetitle" lang="{{ LANGUAGE_CODE }}">{% trans "Terminology:" %}</div>
{% for term in terms %}
<div class="tm-unit writetm" title="{% trans 'Click to insert the translated term into the editor' %}">
<div class="tm-unit js-editor-copytext" title="{% trans 'Click to insert the translated term into the editor' %}">
<span class="tm-original" dir="{{ source_language.get_direction }}" lang="{{ source_language.code }}">{{ term.source }}</span>
<span class="tm-translation" dir="{{ language.get_direction }}" lang="{{ language.code }}">{{ term.target }}</span>
</div>
Expand Down Expand Up @@ -118,7 +118,7 @@
<div class="translate-specialchars-block" lang="{{ language.code }}">
{% for specialchar in language.specialchars %}
{% if not specialchar.isspace %}
<a class="writespecial" title="{% trans 'Click to insert this symbol into the editor' %}">{{ specialchar }}</a>
<a class="editor-specialchar js-editor-copytext" title="{% trans 'Click to insert this symbol into the editor' %}">{{ specialchar }}</a>
{% else %}
<span class="extraspace"> </span>
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion pootle/static/js/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
});

/* Write TM results, special chars... into the currently focused element */
$(document).on("click", ".writetm, .writespecial, .translate-full .highlight-escape, .translate-full .highlight-html", this.copyText);
$(document).on("click", ".js-editor-copytext", this.copyText);

/* Copy original translation */
$(document).on("click", "a.copyoriginal", function () {
Expand Down
9 changes: 3 additions & 6 deletions pootle/static/translate.css
Original file line number Diff line number Diff line change
Expand Up @@ -930,10 +930,7 @@ div.translation-text-headers[dir="rtl"] a.report-bug
a.copyoriginal,
a.report-bug
a.translate-mt,
a.writespecial,
a.morecontext,
.translate-full .highlight-escape,
.translate-full .highlight-html
.js-editor-copytext
{
cursor: pointer;
}
Expand All @@ -956,7 +953,7 @@ a.report-bug:hover {
opacity: 1;
}

a.writespecial
a.editor-specialchar
{
border: 1px dotted #999;
padding: 0 0.2em;
Expand All @@ -966,7 +963,7 @@ a.writespecial
display: inline-block;
}

a.writespecial:hover
a.editor-specialchar:hover
{
background-color: #fff;
text-decoration: none;
Expand Down

0 comments on commit 5e0ec34

Please sign in to comment.