diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6e2698771b31deb8f26d95e44f2c33f8851bebe5..ee46e7f53c4b506f6bb855b220f1deac394d186f 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,7 @@ $Id$
-- 2008-10-09 version 6.x-1.x-dev
* #310988 Extended default exclusion list, added hack for module developers allowing to disable fckeditor on specific textareas
* #318540 Fixed: formatting output doesn't format properly
+* #240230 Another attempt to fix issues with teaser brake
-- 2008-10-08 version 6.x-1.x-dev
* Added upgrading instructions
diff --git a/fckeditor.module b/fckeditor.module
index fafec95a20732025d44784be02d759d52d3acdbe..c3afc140d135ce51af05eedaac257799016484fd 100644
--- a/fckeditor.module
+++ b/fckeditor.module
@@ -634,8 +634,12 @@ function fckeditor_is_enabled($excl_mode, $excl_fields, $excl_paths, $element_id
function fckeditor_process_textarea($element) {
static $is_running = FALSE;
static $num = 1;
+ static $id2id = array();
+ static $processed_elements = array();
global $user, $fckeditor_simple_toolbar_ids;
+ $processed = in_array($element['#id'], $processed_elements);
+
//hack for module developers that want to disable FCKeditor on their textareas
if (key_exists('#fckeditor', $element) && !$element['#fckeditor']) {
return $element;
@@ -700,7 +704,13 @@ function fckeditor_process_textarea($element) {
$element['#resizable'] = FALSE;
}
- $js_id = 'oFCK_'. $num++;
+ if (in_array($element['#id'], $processed_elements)) {
+ $js_id = $id2id[$element['#id']];
+ }
+ else {
+ $js_id = 'oFCK_'. $num++;
+ $id2id[$element['#id']] = $js_id;
+ }
$fckeditor_on = ($conf['default']=='t') ? 1 : 0 ;
$content = "";
@@ -712,7 +722,7 @@ function fckeditor_process_textarea($element) {
$wysiwyg_link .= "";
$wysiwyg_link .= $fckeditor_on ? t("Switch to plain text editor") : t("Switch to rich text editor");
$wysiwyg_link .= "";
- if ($conf['show_toggle'] == 't') {
+ if ($conf['show_toggle'] == 't' && !$processed) {
drupal_add_js('if (Drupal.jsEnabled) {$(document).ready(function() {CreateToggle("'.$element['#id'].'","'.$js_id.'", '.$fckeditor_on.');});}', 'inline');
}
//settings are saved as strings, not booleans
@@ -886,17 +896,21 @@ function fckeditor_process_textarea($element) {
$js .= $js_id .".Config['EditorAreaCSS'] = \"". str_replace(array('%h', '%t'), array($host, $host . $themepath), $conf['css_path']) .",". $module_full_path ."/fckeditor.css\";";
}
- drupal_add_js('var '. $js_id .';if (Drupal.jsEnabled) {$(document).ready(function() {'. $js .'});}', 'inline');
+ if (!$processed) {
+ drupal_add_js('var '. $js_id .';if (Drupal.jsEnabled) {$(document).ready(function() {'. $js .'});}', 'inline');
+ }
if ($conf['popup']=="t") {
// Add the script file with the popup open function.
- drupal_add_js($module_drupal_path .'/fckeditor.popup.js');
+ if (!$processed) {
+ drupal_add_js($module_drupal_path .'/fckeditor.popup.js');
+ }
$element['#suffix'] .= " ";
}
else {
// if no popup mode, add the editor initialization to the footer
// this obviously needs print($closure) in page.tpl.php
- if ($fckeditor_on) {
+ if ($fckeditor_on && !$processed) {
drupal_add_js('if (Drupal.jsEnabled) {$(document).ready(function() {if (typeof ('. $js_id .') != "undefined") {
if ($("#edit-teaser-js").size() && $("#edit-teaser-js").val().length){
$("#edit-body").val($("#edit-teaser-js").val() + "" + $("#edit-body").val());
@@ -914,6 +928,8 @@ function fckeditor_process_textarea($element) {
'!path' => $_GET['q'],
)) .'';
}
+
+ $processed_elements[] = $element['#id'];
return $element;
}