$container.slideDown('slow');\r
$add_comment_link.fadeOut('slow');\r
$textarea.focus();\r
- window.setInterval(function() {\r
+ interval = window.setInterval(function() {\r
process_form_changes();\r
}, 200);\r
}\r
return false;\r
});\r
});\r
+\r
+ if ($('#editor').length) {\r
+ var $editor = $('#editor');\r
+ var $previewer = $('#previewer');\r
+ var $container = $('#editor-metrics');\r
+\r
+ var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;\r
+ var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;\r
+ var editor_interval = null;\r
+\r
+ $editor.focus(function() {\r
+ if (editor_interval == null) {\r
+ editor_interval = window.setInterval(function() {\r
+ recalc_metrics();\r
+ }, 200);\r
+ }\r
+ });\r
+\r
+ function recalc_metrics() {\r
+ var text = $previewer.text();\r
+\r
+ var char_count = text.length;\r
+ var fullStr = text + " ";\r
+ var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");\r
+ var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");\r
+ var splitString = cleanedStr.split(" ");\r
+ var word_count = splitString.length - 1;\r
+\r
+ var metrics = char_count + " " + (char_count == 1 ? messages.character : messages.characters);\r
+ metrics += " / " + word_count + " " + (word_count == 1 ? messages.word : messages.words);\r
+ $container.html(metrics);\r
+ }\r
+ }\r
});\r
\r
//var scriptUrl, interestingTags, ignoredTags, tags, $;\r
<span class="form-error"></span>
<div class="preview-toggle"><span id="pre-collapse"
title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
+ <span style="text-align: right; margin-left: 200px;" id="editor-metrics"></span>
{% if settings.WIKI_ON %}
<div style="float:right;">
{{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
<td>
<span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
</td>
+ <td style="text-align: right;" id="editor-metrics"></td>
{% if settings.WIKI_ON %}
<td class="tright">
{{ form.wiki }} <span class="help_text" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
cancel: "{% trans "Cancel" %}",
close: "{% trans "Close" %}",
ok: "{% trans "Ok" %}",
- matching_tags_url: "{% url matching_tags %}"
+ matching_tags_url: "{% url matching_tags %}",
+ word: "{% trans "word" %}",
+ words: "{% trans "words" %}",
+ character: "{% trans "character" %}",
+ characters: "{% trans "characters" %}"
}
/* ]] */
</script>
margin-right: 12px;
}
- #result_list tr.row1 td.deleted {
+ #result_list tr td.deleted {
background-color: #FDD;
+ border-bottom: 1px solid #a9a9a9;
}
- #result_list tr.row2 td.deleted {
- background-color: #FEE;
- }
-
- #result_list tr.row1 td.accepted {
+ #result_list tr td.accepted {
background-color: #DFD;
- }
-
- #result_list tr.row2 td.accepted {
- background-color: #EFD;
+ border-bottom: 1px solid #a9a9a9;
}
span.question-deleted {
<option selected="selected" value="">---------</option>
<option value="delete_selected">{% trans "Mark deleted" %}</option>
<option value="undelete_selected">{% trans "Undelete" %}</option>
- <option value="hard_delete_selected">{% trans "Delete completelly" %}</option>
+ <option value="hard_delete_selected">{% trans "Delete completely" %}</option>
<option value="close_selected">{% trans "Close (questions only)" %}</option>
</select>
</label>
{% trans "toggle preview" %}\r
</span>\r
</td>\r
+ <td style="text-align: right;" id="editor-metrics"></td>\r
{% if settings.WIKI_ON %}\r
<td style="text-align:right;">\r
{{ answer.wiki }} \r
<td>
<span id="pre-collapse" title="{% trans "Toggle the real time Markdown editor preview" %}">{% trans "toggle preview" %}</span>
</td>
+ <td style="text-align: right;" id="editor-metrics"></td>
{% if settings.WIKI_ON %}
<td style="text-align:right;">
{{ form.wiki }} <span style="color:#000;cursor:help" title="{{form.wiki.help_text}}">{{ form.wiki.label_tag }} </span>
from datetime import datetime, timedelta\r
+import re\r
\r
from forum.models import Question, Action\r
-from django.utils.translation import ugettext as _\r
+from django.utils.translation import ungettext, ugettext as _\r
+from django.utils.html import strip_tags\r
+from django.utils.safestring import mark_safe\r
from django.core.urlresolvers import reverse\r
from django import template\r
from forum.actions import *\r
menu.append(post_control(_('convert to comment'), reverse('convert_to_comment', kwargs={'id': post.id}),\r
command=True, withprompt=True))\r
\r
+ if user.is_superuser or user.is_staff:\r
+ plain_text = strip_tags(post.html)\r
+\r
+ char_count = len(plain_text)\r
+ fullStr = plain_text + " "\r
+ left_trimmedStr = re.sub(re.compile(r"^[^\w]+", re.IGNORECASE), "", fullStr)\r
+ cleanedStr = re.sub(re.compile(r"[^\w]+", re.IGNORECASE), " ", left_trimmedStr)\r
+ splitString = cleanedStr.split(" ")\r
+ word_count = len(splitString) - 1\r
+\r
+ metrics = mark_safe("<b>%s %s / %s %s</b>" % (char_count, ungettext('character', 'characters', char_count),\r
+ word_count, ungettext('word', 'words', word_count)))\r
+\r
+ menu.append(post_control(metrics, "#", command=False, withprompt=False))\r
+\r
return {'controls': controls, 'menu': menu, 'post': post, 'user': user}\r
\r
@register.inclusion_tag('node/comments.html')\r