Index: bueditor.js
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bueditor/bueditor.js,v
retrieving revision 1.20.2.3
diff -u -r1.20.2.3 bueditor.js
--- bueditor.js	16 Feb 2009 19:33:08 -0000	1.20.2.3
+++ bueditor.js	18 Feb 2009 14:49:34 -0000
@@ -1,10 +1,22 @@
 // $Id: bueditor.js,v 1.20.2.3 2009/02/16 19:33:08 ufku Exp $
 
 //Global container
-var BUE = {'preset': [], 'instances': [], 'popups': {}, 'dialog': {}, 'templates': {}, 'mode': (window.getSelection || document.getSelection) ? 1 : (document.selection && document.selection.createRange ? 2 : 0 )};
+var BUE = {'preset': {}, 'instances': [], 'popups': {}, 'dialog': {}, 'templates': {}, 'mode': (window.getSelection || document.getSelection) ? 1 : (document.selection && document.selection.createRange ? 2 : 0 )};
 
 //process textareas that were preset
-Drupal.behaviors.BUE = function(context) {$.each(BUE.preset, function() {BUE.processTextarea(this[0], this[1])});};
+Drupal.behaviors.BUE = function(context) {
+  if (Drupal.settings.BUE) {
+    $.each(Drupal.settings.BUE.templates||{}, function (id, tpl) {
+      BUE.templates[id] = BUE.templates[id] || $.extend({}, tpl);
+    });
+    Drupal.settings.BUE.templates = {};
+    $.each(Drupal.settings.BUE.preset||{}, function (id, tplid) {
+      BUE.preset[id] = BUE.preset[id] || tplid;
+    });
+    Drupal.settings.BUE.preset = {};
+  }
+  $.each(BUE.preset, BUE.processTextarea);
+};
 
 //editor settle.
 BUE.initiate = function () {
Index: bueditor.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/bueditor/bueditor.module,v
retrieving revision 1.14.2.2
diff -u -r1.14.2.2 bueditor.module
--- bueditor.module	10 Jun 2008 07:47:09 -0000	1.14.2.2
+++ bueditor.module	18 Feb 2009 14:50:05 -0000
@@ -117,7 +117,12 @@
  * Integrate the editor into textareas.
  */
 function bueditor_textarea($element) {
-  static $editors;
+  static $editors, $textareas = array();
+
+  if (isset($textareas[$element['#id']])) {
+    return $element;
+  }
+  $textareas[$element['#id']] = 1;
 
   //get editors
   if (!isset($editors)) {
@@ -142,7 +147,8 @@
 function bueditor_preset_textarea($tid, $editor) {
   if ($editor && !bueditor_check_match($editor->excludes, $tid)) {
     bueditor_settle($editor);
-    drupal_add_js('BUE.preset.push(["'. $tid .'", "e'. $editor->eid .'"]);', 'inline');
+    $settings['BUE']['preset'][$tid] = 'e'. $editor->eid;
+    drupal_add_js($settings, 'setting');
     return TRUE;
   }
   return FALSE;
@@ -163,9 +169,11 @@
     drupal_add_css($path .'/bueditor.css');
     drupal_add_js($path .'/bueditor.js');
     bueditor_js_library($editor->librarypath);//load library files.
-    $buttons = drupal_to_js(bueditor_processed_buttons($editor->eid));
-    $js = 'BUE.templates.e'. $editor->eid .' = {"iconpath": "'. base_path() . $editor->iconpath .'", "buttons": '. $buttons .'}';
-    drupal_add_js($js, 'inline');
+    $settings['BUE']['templates']['e'. $editor->eid] = array(
+      'iconpath' => base_path() . $editor->iconpath,
+      'buttons' => bueditor_processed_buttons($editor->eid),
+    );
+    drupal_add_js($settings, 'setting');
     $settled[$editor->eid] = TRUE;
     return TRUE;
   }

