Better "multi spawn" JS functionality for plugins that have more than one HTML nugget.
authorgarvinhicking <garvinhicking>
Wed, 27 Jul 2005 10:12:40 +0000 (10:12 +0000)
committergarvinhicking <garvinhicking>
Wed, 27 Jul 2005 10:12:40 +0000 (10:12 +0000)
This only creates the calling function once instead of many, many, many times. :)
Thanks to FLorian Solcher for this patch.

include/admin/plugins.inc.php
include/functions_entries.inc.php

index f5f843a3aa87456b293266122fb80494d78dc233..f32c8a9300a642c2dee6005fe8499ef3c4008c91 100644 (file)
@@ -472,14 +472,14 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
         <tr>
             <td colspan="2">
                 <div>
-                    <textarea class="direction_<?php echo $lang_direction; ?>" style="width: 100%" id="nugget<?php echo $elcount; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
+                    <textarea class="direction_<?php echo $lang_direction; ?>" style="width: 100%" id="nuggets<?php echo $elcount; ?>" name="serendipity[plugin][<?php echo $config_item; ?>]" rows="20" cols="80"><?php echo $hvalue; ?></textarea>
                 </div>
             </td>
         </tr>
 <?php
                 if ($cbag->get('type') == 'html') {
                     $htmlnugget[] = $elcount;
-                    serendipity_emit_htmlarea_code('nugget' . $elcount, 'nugget' . $elcount);
+                    serendipity_emit_htmlarea_code('nuggets', 'nuggets', true);
                 }
                 break;
 
@@ -512,7 +512,7 @@ if (isset($_GET['serendipity']['plugin_to_conf'])) {
     <script type="text/javascript">
     function Spawnnugget() {
         <?php foreach($htmlnugget AS $htmlnuggetid) { ?>
-        Spawnnugget<?php echo $htmlnuggetid; ?>();
+        Spawnnuggets('<?php echo $htmlnuggetid; ?>');
         <?php } ?>
     }
     </script>
index f91668235c5f4b7ab48c16c3a6b21691958e3758..d28803c8ebb1a9a047b888a7431b84adf1a3306c 100644 (file)
@@ -1599,10 +1599,14 @@ if (!$serendipity['wysiwyg']) {
     echo '    <script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>';
 }
 
-function serendipity_emit_htmlarea_code($item, $jsname) {
+function serendipity_emit_htmlarea_code($item, $jsname, $spawnMulti = false) {
     static $init = false;
     global $serendipity;
 
+    if ($init && $spawnMulti) {
+        return true;
+    }
+
     if (isset($serendipity['wysiwyg']) && $serendipity['wysiwyg']) {
 
         $eventData = array(
@@ -1655,8 +1659,8 @@ function serendipity_emit_htmlarea_code($item, $jsname) {
 
     // HTMLArea.loadPlugin("SpellChecker"); // [SPELLCHECK]
     var editor<?php echo $jsname; ?> = null; var config<?php echo $jsname; ?> = null;
-    function Spawn<?php echo $jsname; ?>() {
-        var editor<?php echo $jsname; ?>    = new HTMLArea("<?php echo $item; ?>");
+    function Spawn<?php echo $jsname; ?>(<?php echo $spawnMulti ? 'id' : ''; ?>) {
+        var editor<?php echo $jsname; ?>    = new HTMLArea("<?php echo $item; ?>"<?php echo $spawnMulti ? ' + id' : ''; ?>);
         var config<?php echo $jsname; ?>    = editor<?php echo $jsname; ?>.config;
         config<?php echo $jsname; ?>.registerButton('image_selector', '<?PHP echo MANAGE_IMAGES; ?>', 'htmlarea/images/ed_s9yimage.gif', false,
             function(editor, id) {