From 2b8c4a933f8551df22fb896fbe3174e61593aa10 Mon Sep 17 00:00:00 2001
From: callison <callison@49429-no-reply.drupal.org>
Date: Sun, 6 Mar 2011 18:02:31 +0700
Subject: [PATCH] Issue #1082348 by callison: Fix pullquote rendering when inside a contained/embedded HTML element.

---
 pullquote.js |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/pullquote.js b/pullquote.js
index 813ee8a..e8403ef 100644
--- a/pullquote.js
+++ b/pullquote.js
@@ -1,16 +1,22 @@
-// $Id: pullquote.js,v 1.1 2010/09/07 21:40:30 stuckagain Exp $ 
 (function ($) {
 
 Drupal.behaviors.pullquote = {
   attach: function(context) {
-    $('span.pullquote:not(.pullquote-processed)', context).each(function () {
+    $('.pullquote:not(.pullquote-processed)', context).each(function () {
       var $span = $(this).addClass('pullquote-processed');
-      // For now, paragraphs only. May be extended later on. (simply add ',div')
-      var $parent = $span.parent('p');
+      // May be extended later on. (simply add ',div')
+      var $parent = $span.parent();
       if ($parent.length) {
+        // In the case of a pullquote inside any of the above contained/nested elements
+        var $elements = ['LI','UL','OL','BLOCKQUOTE', 'TD','TR','TBODY','TABLE'];
+        while( jQuery.inArray($parent.get(0).tagName, $elements ) > -1 ) {
+          $parent = $parent.parent();
+        }
         // Apply conditional pullquote container styling.
         $parent.addClass('pullquote-container');
+        $text = $span.text();
         $span.clone()
+          .replaceWith('<span class="pullquote-processed">' + $text + '</span>')
           .addClass('pullquote-quote')
           .prependTo($parent);
       }
-- 
1.7.3.1.msysgit.0

