# HG changeset patch # User Franck Deroche # Date 1253279825 -7200 # Node ID 9e27e0aca323c9bb48949167a7a08fb6cebdfe87 # Parent bb510db429c9a657de309f0d85588094b28ab39f 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. diff -r bb510db429c9 -r 9e27e0aca323 js/dnd-library.js --- 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 = '

' + Drupal.settings.dndEditorRepresentations[representation_id].body + '

'; + var rep = Drupal.settings.dndEditorRepresentations[representation_id]; + var snippet = '
' + rep.body + '
'; + 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('

' + representation + '

'); + var snip = '
' + representation + '
'; + if (legend) { + snip += legend; + } + $block.after(snip); // The active target block should be empty if ($('#target-block:dnd_empty', $target.contents()).length > 0) {