Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: commits

[8541] Got all of the other WYSIWYG editors working with the AJAX

 

 

Bricolage commits RSS feed   Index | Next | Previous | View Threaded


theory at bricolage

Apr 1, 2009, 4:27 PM

Post #1 of 1 (561 views)
Permalink
[8541] Got all of the other WYSIWYG editors working with the AJAX

Revision: 8541
Author: theory
Date: 2009-04-01 16:27:29 -0700 (Wed, 01 Apr 2009)
ViewCVS: http://viewsvn.bricolage.cc/?rev=8541&view=rev

Log Message:
-----------
Got all of the other WYSIWYG editors working with the AJAX interface:

* FCKeditor has its own function interface for repopulating textarea elements. So I added a call to it to `lib.js`. Fortunately, it has no effect if FCKeditor isn't installed.
* I rewrote the way that JS-Quicktags adds the buttons. It uses `document.write()`, which tends to overwrite the entire contents of the window in Ajax requests. The workaround is to temporarily replace `document.write()` and to take the resulting string and insert it using Prototype's DOM tools.
* I updated the comments for WYSIWYG support in bricolage.conf. It didn't mention FCKeditor, for example. The other changes in that file is the elimination of unnecessary white space.
* I rewrote the code for loading the htmlArea stuff, which miraculously still works! It now is more forgiving about working when the SpellChecker plugin can't be found (I couldn't get it to work, anyway), and uses Prototype to determine when to change the fields.
* I documented the JS-Quicktags support in Bric::Admin.

Modified Paths:
--------------
bricolage/trunk/comp/media/js/lib.js
bricolage/trunk/comp/widgets/container_prof/container.html
bricolage/trunk/comp/widgets/profile/displayFormElement.mc
bricolage/trunk/comp/widgets/wysiwyg/fckeditor.html
bricolage/trunk/comp/widgets/wysiwyg/htmlarea.html
bricolage/trunk/comp/widgets/wysiwyg/js-quicktags.html
bricolage/trunk/conf/bricolage.conf
bricolage/trunk/lib/Bric/Admin.pod
bricolage/trunk/lib/Bric/Changes.pod

Modified: bricolage/trunk/comp/media/js/lib.js
===================================================================
--- bricolage/trunk/comp/media/js/lib.js 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/media/js/lib.js 2009-04-01 23:27:29 UTC (rev 8541)
@@ -1438,7 +1438,14 @@
buttons.invoke('disable');

// Be sure to call onsubmit() so the wysiwyg fields can be updated.
- form.onsubmit();
+ if (form.onsubmit) form.onsubmit();
+
+ // Check for FCK fields to submit, too.
+ // http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Troubleshooting#AjaxSubmit
+ for ( i = 0; i < parent.frames.length; ++i )
+ if ( parent.frames[i].FCK )
+ parent.frames[i].FCK.UpdateLinkedField();
+
submitting = false; // Reset this so we can submit again!

// Serialize the form.

Modified: bricolage/trunk/comp/widgets/container_prof/container.html
===================================================================
--- bricolage/trunk/comp/widgets/container_prof/container.html 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/widgets/container_prof/container.html 2009-04-01 23:27:29 UTC (rev 8541)
@@ -1,4 +1,4 @@
-% if (lc WYSIWYG_EDITOR eq 'xinha') {
+% if (ENABLE_WYSIWYG && lc WYSIWYG_EDITOR ne 'js-quicktags') {
<script>
editors = new Array();
</script>
@@ -8,10 +8,16 @@
element => $element,
parent => $parent,
&>
-% if (lc WYSIWYG_EDITOR eq 'xinha') {
+% if (ENABLE_WYSIWYG && lc WYSIWYG_EDITOR ne 'js-quicktags') {
<script>
+% if (lc WYSIWYG_EDITOR eq 'xinha') {
var xinha_editors = Xinha.makeEditors(editors, xinha_config, xinha_plugins);
Xinha.startEditors(xinha_editors);
+% } elsif (lc WYSIWYG_EDITOR eq 'fckeditor') {
+ fckCallback();
+% } elsif (lc WYSIWYG_EDITOR eq 'htmlarea') {
+ inithtmlareas();
+% }
</script>
% }
<%once>

Modified: bricolage/trunk/comp/widgets/profile/displayFormElement.mc
===================================================================
--- bricolage/trunk/comp/widgets/profile/displayFormElement.mc 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/widgets/profile/displayFormElement.mc 2009-04-01 23:27:29 UTC (rev 8541)
@@ -379,23 +379,15 @@

$out .= qq{ <div class="input">\n} if $useTable;
if (!$readOnly) {
- if (lc(WYSIWYG_EDITOR) eq 'js-quicktags') {
- $out .= qq{
- <script type="text/javascript">
- edToolbar('$key');
- </script>
-}
- }
$js = $js ? " $js" : '';
$out .= qq{ <textarea name="$key" id="$key" rows="$rows" cols="$cols" width="200"}
. qq{ wrap="soft" class="textArea"$js>$value</textarea><br />\n};

- if (lc(WYSIWYG_EDITOR) eq 'xinha' || lc(WYSIWYG_EDITOR) eq 'htmlarea') {
- $out .= qq{
- <script type="text/javascript">
- editors.push("$key");
- </script>
-}
+ if (ENABLE_WYSIWYG) {
+ my $code = lc WYSIWYG_EDITOR eq 'js-quicktags'
+ ? "edToolbarBric('$key');"
+ : "editors.push('$key');";
+ $out .= qq{<script type="text/javascript">$code</script>\n};
}
} else {
$out .= $value;

Modified: bricolage/trunk/comp/widgets/wysiwyg/fckeditor.html
===================================================================
--- bricolage/trunk/comp/widgets/wysiwyg/fckeditor.html 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/widgets/wysiwyg/fckeditor.html 2009-04-01 23:27:29 UTC (rev 8541)
@@ -1,12 +1,13 @@
<script type="text/javascript" src="/media/wysiwyg/fckeditor/fckeditor.js"></script>
<script type="text/javascript">
var editors = new Array();
- Event.observe(window, 'load', function() {
+ var fckCallback = function () {
$A(editors).each(function(editor) {
var oFCKeditor = new FCKeditor(editor);
oFCKeditor.BasePath = '/media/wysiwyg/fckeditor/';
oFCKeditor.Config['CustomConfigurationsPath'] = '/widgets/wysiwyg/fckconfig.js';
oFCKeditor.ReplaceTextarea();
})
- });
+ };
+ Event.observe(window, 'load', fckCallback);
</script>

Modified: bricolage/trunk/comp/widgets/wysiwyg/htmlarea.html
===================================================================
--- bricolage/trunk/comp/widgets/wysiwyg/htmlarea.html 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/widgets/wysiwyg/htmlarea.html 2009-04-01 23:27:29 UTC (rev 8541)
@@ -6,22 +6,17 @@
<script type="text/javascript" src="/media/wysiwyg/htmlarea/lang/en.js"></script>
<script type="text/javascript" src="/media/wysiwyg/htmlarea/dialog.js"></script>
<script type="text/javascript">
-
- HTMLArea.loadPlugin("SpellChecker");
-
- var editors = new Array();
-
- function inithtmlareas() {
+HTMLArea.loadPlugin('SpellChecker');
+var editors = new Array();
+function inithtmlareas() {
var tmp;
-
while (tmp = editors.pop()){
- var editor = new HTMLArea(tmp);
-% my $htmlareatoolbar = HTMLAREA_TOOLBAR;
- editor.config.toolbar = <% $htmlareatoolbar %>;
- editor.registerPlugin(SpellChecker);
- editor.generate();
- }
- }
-
- setTimeout('inithtmlareas();',1000);
+ var editor = new HTMLArea(tmp);
+ if (typeof SpellChecker != 'undefined')
+ editor.registerPlugin(SpellChecker);
+ editor.config.toolbar = <% HTMLAREA_TOOLBAR %>;
+ editor.generate();
+ }
+}
+Event.observe(window, "load", inithtmlareas);
</script>

Modified: bricolage/trunk/comp/widgets/wysiwyg/js-quicktags.html
===================================================================
--- bricolage/trunk/comp/widgets/wysiwyg/js-quicktags.html 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/comp/widgets/wysiwyg/js-quicktags.html 2009-04-01 23:27:29 UTC (rev 8541)
@@ -1 +1,13 @@
<script type="text/javascript" src="/media/wysiwyg/js-quicktags/js_quicktags.js"></script>
+<script type="text/javascript">
+// Function to override document.write(), as it tends to completely replac the
+// window contents when using Ajax call.
+function edToolbarBric (e) {
+ var orig = document.write;
+ var html = '';
+ document.write = function(str) { html += str };
+ edToolbar(e);
+ document.write = orig;
+ Element.insert($(e), { before: html });
+}
+</script>

Modified: bricolage/trunk/conf/bricolage.conf
===================================================================
--- bricolage/trunk/conf/bricolage.conf 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/conf/bricolage.conf 2009-04-01 23:27:29 UTC (rev 8541)
@@ -102,7 +102,7 @@
BURN_ROOT = /usr/local/bricolage/data/burn
INCLUDE_XML_WRITER = No
XML_WRITER_ARGS = NEWLINES => 1, UNSAFE => 1, DATA_MODE => 1, DATA_INDENT => 4
-# MASON_INTERP_ARGS =
+# MASON_INTERP_ARGS =
# TT_OPTIONS = PRE_CHOMP => 1, POST_CHOMP => 1, TRIM => 1

# Authentication settings. AUTH_TTL is the amount of time, in seconds, a user
@@ -177,7 +177,7 @@
# the WebDAV protocol. Both are disabled by default. Using either the SFTP or
# the WebDAV mover requires some manual installation; perldoc Bric::Admin for
# details. If you enable SFTP, set SFTP_HOME to a directory containing your
-# SSH keys and with permisssions appropriate for SYS_USER to access.
+# SSH keys and with permisssions appropriate for SYS_USER to access.
# Setting SFTP_MOVER_CIPHER will force the SFTP mover to use that cipher when
# distributing resources via SFTP. Consult the Net::SSH2 documentation
# for a current list of ciphers. If it is set to 0, the default cipher will be
@@ -328,8 +328,8 @@

ENABLE_OC_ASSET_ASSOCIATION = Yes

-# Output Channel URI format. Occasionally it may be required to allow the uri
-# of Output Channels not have a %{categories} section. This is not the
+# Output Channel URI format. Occasionally it may be required to allow the uri
+# of Output Channels not have a %{categories} section. This is not the
# recommended behavior and should be used with caution if required.

ALLOW_URIS_WITHOUT_CATEGORIES = No
@@ -439,7 +439,7 @@
# media files. When this directive is enabled Bricolage will generate a unique
# eight-character MD5 hash for the file name instead of the file name as
# uploaded. The file name suffix will be retained as it was loaded.
-#
+#
# MEDIA_FILENAME_PREFIX specifies that all file names have a prefix prepended
# to their file names.
#
@@ -469,30 +469,30 @@

# Bricolage supports several "what you see is what you get" (WYSIWYG) text
# editors, which can be used in place of traditional textareas. These fields
-# allow word processor-like editing, but introduce HTML formatting into the
-# content, which some consider to be a Bad Thing. Due to the licenses of these
-# editors, you will need to download and install (read: untar) the editors
+# allow word processor-like editing, but introduce HTML formatting into the
+# content, which some consider to be a Bad Thing. Due to the licenses of these
+# editors, you will need to download and install (read: untar) the editors
# yourself. Download the latest version from the URLs below and extract them
-# into the corresponding folders.
+# into the corresponding folders.
#
-# The currently supported editors are "htmlArea" (discontinued),
-# JS-Quicktags (more of an HTML tag helper), and "Xinha" (recommended).
-# htmlArea and Xinha have further configuration options below.
+# The currently supported editors are "htmlArea" (discontinued), JS-Quicktags
+# (more of an HTML tag helper), "Xinha" (recommended), and FCKeditor. All but
+# JS-Quicktags have further configuration options below.
#
-# Xinha - Download: http://www.xinha.org/
-# Unzip into: comp/media/wysiwyg/xinha/
+# Xinha - Download: http://www.xinha.org/
+# Unzip into: comp/media/wysiwyg/xinha/
#
-# FCKeditor - Download: http://www.fckeditor.net/
-# Unzip into: comp/media/wysiwyg/fckeditor/
+# FCKeditor - Download: http://www.fckeditor.net/
+# Unzip into: comp/media/wysiwyg/fckeditor/
#
-# htmlArea - Download: http://www.dynarch.com/projects/htmlarea/
-# Unzip into: comp/media/wysiwyg/htmlarea/
+# htmlArea - Download: http://www.dynarch.com/projects/htmlarea/
+# Unzip into: comp/media/wysiwyg/htmlarea/
#
# JS-Quicktags - Download: http://alexking.org/projects/js-quicktags
# Unzip into: comp/media/wysiwyg/js-quicktags/

ENABLE_WYSIWYG = No
-WYSIWYG_EDITOR = Xinha # or: "htmlArea", "JS-Quicktags"
+WYSIWYG_EDITOR = Xinha # or htmlArea, JS-Quicktags, or FCKeditor

#
# Xinha Configuration
@@ -558,8 +558,8 @@
##
## HACKER SETTINGS
##
-
-# Uncomment these for debugging and profiling. See Bric::Hacker for more
+
+# Uncomment these for debugging and profiling. See Bric::Hacker for more
# details on these directives.

# NO_TOOLBAR = 1

Modified: bricolage/trunk/lib/Bric/Admin.pod
===================================================================
--- bricolage/trunk/lib/Bric/Admin.pod 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/lib/Bric/Admin.pod 2009-04-01 23:27:29 UTC (rev 8541)
@@ -578,6 +578,10 @@

=item *

+JS-Quicktags WYSIWYG editor (optional)
+
+=item *
+
GNU Aspell 0.50 or later (optional)

=back
@@ -1387,6 +1391,17 @@

chmod +x comp/media/wysiwyg/fckeditor/editor/dialog/fck_spellerpages/spellerpages/server-scripts/spellchecker.pl

+=head2 JS-Quicktags (Optional)
+
+To install JS-Quicktags, an optional JavaScript libary that off buttons to
+make adding tags to text eadier in the Bricolage UI, simply download it from
+L<http://alexking.org/projects/js-quicktags/>, decompress the files, and move
+them to the F<comp/media/wysiwyg/js-quicktags> directory in your Bricolage
+root.
+
+You will also need to enable the C<ENABLE_WYSIWYG> and C<WYSIWYG_EDITOR>
+F<bricolage.conf> directives (see L<UI Configuration|/"UI Configuration">).
+
=head2 GNU Aspell (Optional)

To use the spell-checking feature of htmlArea, the GNU Aspell library must be

Modified: bricolage/trunk/lib/Bric/Changes.pod
===================================================================
--- bricolage/trunk/lib/Bric/Changes.pod 2009-04-01 22:49:40 UTC (rev 8540)
+++ bricolage/trunk/lib/Bric/Changes.pod 2009-04-01 23:27:29 UTC (rev 8541)
@@ -423,7 +423,8 @@

=item *

-Xinha works again. Reported by John Durkin and Matt Rolf (Bug #1429). [David]
+All of the WYSIWYG editors (Xinha, htmlArea, FCKeditor, and JS-Quicktags) work
+again. Reported by John Durkin and Matt Rolf (Bug #1429). [David]

=item *

Bricolage commits RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.