[Rt-commit] rt branch, 3.999-trunk, updated. da10368ce727bb907c9b3fd2a8efedf554ad7a35
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Tue Sep 22 20:58:24 EDT 2009
The branch, 3.999-trunk has been updated
via da10368ce727bb907c9b3fd2a8efedf554ad7a35 (commit)
from dab10faf3b520fd0a5a102d744b4ff2686f8893c (commit)
Summary of changes:
share/html/Elements/HeaderJavascript | 47 +++-------------------------------
share/web/static/js/util.js | 40 ++++++++++++++++++++++++++++
2 files changed, 44 insertions(+), 43 deletions(-)
- Log -----------------------------------------------------------------
commit da10368ce727bb907c9b3fd2a8efedf554ad7a35
Author: sunnavy <sunnavy at bestpractical.com>
Date: Wed Sep 23 08:57:57 2009 +0800
refactor a bit: move ReplaceAllTextareas to util.js
diff --git a/share/html/Elements/HeaderJavascript b/share/html/Elements/HeaderJavascript
index 00756bf..5200d11 100644
--- a/share/html/Elements/HeaderJavascript
+++ b/share/html/Elements/HeaderJavascript
@@ -58,50 +58,11 @@ $onload => undef
% }
% if ( RT->config->get('message_box_rich_text', Jifty->web->current_user)) {
- function ReplaceAllTextareas() {
-
- // replace all content and signature message boxes
- var allTextAreas = document.getElementsByTagName("textarea");
-
- for (var i=0; i < allTextAreas.length; i++) {
- var textArea = allTextAreas[i];
- if ( (textArea.getAttribute('class') == 'messagebox')
- || (textArea.getAttribute('className') == 'messagebox')) {
- // Turn the original plain text content into HTML
-
-%# Special case - when we re-edit a textarea, don't re-encode it
-% if (!$m->request_args->{'WYZZEncoded'}) {
- textArea.value = textArea.value.replace(
- /&/g, "&"
- ).replace(
- /</g, "<"
- ).replace(
- />/g, ">"
- ).replace(
- /\n/g, "\n<br />"
- );
-% }
-
-%# for this template..
- var WYZZEncoded = document.createElement('input');
- WYZZEncoded.setAttribute('type', 'hidden');
- WYZZEncoded.setAttribute('name', 'WYZZEncoded');
- WYZZEncoded.setAttribute('value', '1');
- textArea.parentNode.appendChild(WYZZEncoded);
-
-%# for WYZZ..
-
- var typeField = document.createElement('input');
- typeField.setAttribute('type', 'hidden');
- typeField.setAttribute('name', textArea.name + '_type');
- typeField.setAttribute('value', 'text/html');
- textArea.parentNode.appendChild(typeField);
-
- make_wyzz(textArea.id);
- }
- }
+ function WrapReplaceAllTextareas() {
+ ReplaceAllTextareas( <% $m->request_args->{'RichEncoded'} ? 1 : 0 %> );
}
- doOnLoad(ReplaceAllTextareas);
+
+ doOnLoad(WrapReplaceAllTextareas);
% }
% if ( $onload ) {
doOnLoad(<% $onload |n %>);
diff --git a/share/web/static/js/util.js b/share/web/static/js/util.js
index 027fdf4..40306d3 100644
--- a/share/web/static/js/util.js
+++ b/share/web/static/js/util.js
@@ -220,3 +220,43 @@ function checkboxToInput(target,checkbox,val){
}
}
+
+function ReplaceAllTextareas( encoded ) {
+
+ // replace all content and signature message boxes
+ var allTextAreas = document.getElementsByTagName("textarea");
+
+ for (var i=0; i < allTextAreas.length; i++) {
+ var textArea = allTextAreas[i];
+ if ( (textArea.getAttribute('class') == 'messagebox')
+ || (textArea.getAttribute('className') == 'messagebox')) {
+ // Turn the original plain text content into HTML
+
+ if ( encoded == 0 ) {
+ textArea.value = textArea.value.replace(
+ /&/g, "&"
+ ).replace(
+ /</g, "<"
+ ).replace(
+ />/g, ">"
+ ).replace(
+ /\n/g, "\n<br />"
+ );
+ }
+
+ var RichEncoded = document.createElement('input');
+ RichEncoded.setAttribute('type', 'hidden');
+ RichEncoded.setAttribute('name', 'RichEncoded');
+ RichEncoded.setAttribute('value', '1');
+ textArea.parentNode.appendChild(RichEncoded);
+
+ var typeField = document.createElement('input');
+ typeField.setAttribute('type', 'hidden');
+ typeField.setAttribute('name', textArea.name + '_type');
+ typeField.setAttribute('value', 'text/html');
+ textArea.parentNode.appendChild(typeField);
+
+ make_wyzz(textArea.id);
+ }
+ }
+}
-----------------------------------------------------------------------
More information about the Rt-commit
mailing list