changeset 38:9e27e0aca323

Allow the library to specify a possible legend for the element. This legend will be placed *outside* the atom representation, which means that it's freely editable in the rich text and won't be taken over by Scald.
author Franck Deroche <franck@defr.org>
date Fri, 18 Sep 2009 15:17:05 +0200
parents bb510db429c9
children 3a8422ac941c
files js/dnd-library.js
diffstat 1 files changed, 12 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/js/dnd-library.js	Fri Sep 18 15:14:00 2009 +0200
+++ b/js/dnd-library.js	Fri Sep 18 15:17:05 2009 +0200
@@ -170,7 +170,11 @@
       // Update element count
       Drupal.behaviors.dndLibrary.countElements.call(target, representation_id);
 
-      var snippet = '<p class="dnd-drop-wrapper">' + Drupal.settings.dndEditorRepresentations[representation_id].body + '</p>';
+      var rep = Drupal.settings.dndEditorRepresentations[representation_id];
+      var snippet = '<div class="dnd-drop-wrapper">' + rep.body + '</div>';
+      if (rep.meta.legend) {
+        snippet += rep.meta.legend;
+      }
       $target.replaceSelection(snippet, true);
     }
   }, settings);
@@ -224,6 +228,7 @@
     processIframeDrop: function(drop, id_selector) {
       var representation_id = id_selector.call(this, drop);
       var representation = Drupal.settings.dndEditorRepresentations[representation_id].body;
+      var legend = Drupal.settings.dndEditorRepresentations[representation_id].meta.legend;
       var target = this, $target = $(target), $drop = $(drop), block;
 
       // Update element count
@@ -242,7 +247,7 @@
       $drop.remove();
 
       // Create an element to insert
-      var insert = dom.create('p', {'class' : 'dnd-drop-wrapper', 'id' : 'dnd-inserted'}, representation);
+      var insert = dom.create('div', {'class' : 'dnd-drop-wrapper', 'id' : 'dnd-inserted'}, representation);
 
       // The no-parent case
       if ($(block).is('body')) {
@@ -254,7 +259,11 @@
         $block = $('#target-block', $target.contents());
 
         // @TODO is finding the parent broken in safari??
-        $block.after('<p class="dnd-drop-wrapper" id="dnd-inserted">' + representation + '</p>');
+        var snip = '<div class="dnd-drop-wrapper" id="dnd-inserted">' + representation + '</div>';
+        if (legend) {
+          snip += legend;
+        }
+        $block.after(snip);
 
         // The active target block should be empty
         if ($('#target-block:dnd_empty', $target.contents()).length > 0) {