<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -81,14 +81,13 @@
 
 &lt;div id=&quot;respond&quot;&gt;
 
-   &lt;h3&gt;Leave a Reply&lt;/h3&gt;
+   &lt;form action=&quot;demo.html&quot; method=&quot;post&quot; id=&quot;commentform&quot; class=&quot;encouraged-form&quot;&gt;
+      &lt;h3&gt;Leave a Reply&lt;/h3&gt;
 
-   &lt;div class=&quot;cancel-comment-reply&quot;&gt;
-      &lt;small&gt;&lt;a rel=&quot;nofollow&quot; id=&quot;cancel-comment-reply-link&quot; href=&quot;/PERSONAL/DontTrustThisGuy.com/dttg/wordpress/?p=14#respond&quot; style=&quot;display:none;&quot;&gt;Click here to cancel reply.&lt;/a&gt;&lt;/small&gt;
-   &lt;/div&gt;
-
-
-   &lt;form action=&quot;demo.html&quot; method=&quot;post&quot; id=&quot;commentform&quot;&gt;
+      &lt;div class=&quot;cancel-comment-reply&quot;&gt;
+         &lt;small&gt;&lt;a rel=&quot;nofollow&quot; id=&quot;cancel-comment-reply-link&quot; href=&quot;/PERSONAL/DontTrustThisGuy.com/dttg/wordpress/?p=14#respond&quot; style=&quot;display:none;&quot;&gt;Click here to cancel reply.&lt;/a&gt;&lt;/small&gt;
+      &lt;/div&gt;
+      
       &lt;p&gt;&lt;input type=&quot;text&quot; name=&quot;author&quot; id=&quot;author&quot; value=&quot;Jon Doe&quot; size=&quot;22&quot; tabindex=&quot;1&quot; aria-required='true' /&gt;
       &lt;label for=&quot;author&quot;&gt;&lt;small&gt;Name (required)&lt;/small&gt;&lt;/label&gt;&lt;/p&gt;
 
@@ -114,8 +113,8 @@
 &lt;!-- end --&gt;
 
 &lt;/div&gt;
-      &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js&quot;&gt;&lt;/script&gt;
+      &lt;script type=&quot;text/javascript&quot; charset=&quot;utf-8&quot; src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js&quot;&gt;&lt;/script&gt;
       &lt;script src=&quot;javascript/jquery/jquery.scrollTo-min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
-      &lt;script src=&quot;javascript/jquery/encouraged-commentary-min.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
+      &lt;script src=&quot;javascript/jquery/encouraged-commentary.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
    &lt;/body&gt;
 &lt;/html&gt;
\ No newline at end of file</diff>
      <filename>demo.html</filename>
    </modified>
    <modified>
      <diff>@@ -30,7 +30,8 @@
       margin: 0.5em 0;
    }
    
-   .comment blockquote {
+   .comment blockquote,
+   #encouraged-preview blockquote {
       border-left: 2px solid #666;
       color: #999;
       font-size: 0.875em;
@@ -42,4 +43,19 @@
    
    a {
       color: #f90;
+   }
+   
+   textarea {
+      width: 450px;
+      height: 150px;
+   }
+   
+   #respond {
+      position: relative;
+   }
+   
+   #comment-lightbox h3 {
+      color:#000000;
+      font-size:1em;
+      margin: 0 0 0.5em 0;
    }
\ No newline at end of file</diff>
      <filename>demo/demo.css</filename>
    </modified>
    <modified>
      <diff>@@ -13,8 +13,34 @@
 * http://github.com/jimjeffers/encouraged-commentary/tree/master
 */
 
+//
+// Global vars. Should really grab all of the vars including the ones initialized in the ready block below into a dedicated
+// global object. That would be a smarter method.
+//
+var form;
+var commentList;
+var lightbox;
+var lightboxBackground;
+var quote;
+var preview;
+var noLightbox;
+var noPreview;
+
 $(document).ready( function() {   
    //
+   // Check for vars within the dom.
+   //
+   form = $($('.encouraged-form').get(0));
+   commentList = $($('.commentlist').get(0));
+   var sortedCommentary = commentList.hasClass('sorted-commentary');
+   var noRelatives = commentList.hasClass('no-relatives');
+   var noReplies = commentList.hasClass('no-replies');
+   noPreview = commentList.hasClass('no-preview');
+   var noQuoteControl = commentList.hasClass('no-quote-control');
+   var noReplyControl = commentList.hasClass('no-reply-control');
+   noLightbox = commentList.hasClass('no-lightbox');
+   
+   //
    // Text highlighted comments.
    //
    $(document.body).append(&quot;&lt;span id=\&quot;comment-respond\&quot;&gt;Respond&lt;/span&gt;&quot;);
@@ -24,7 +50,6 @@ $(document).ready( function() {
 
    var permalink = &quot;&quot;;
    var author = &quot;&quot;;
-   var quote = &quot;&quot;;
    
    $('.commentlist &gt; .comment, .quotable').each( function() {
       $(this).mouseup(function(e){
@@ -60,8 +85,22 @@ $(document).ready( function() {
       if(permalink &amp;&amp; author) {
          directive = &quot;&lt;p&gt;&lt;a href=\&quot;&quot;+permalink+&quot;\&quot;&gt;@&quot;+author+&quot;&lt;/a&gt;:&lt;/p&gt;\n&quot;
       }
-      $('#comment').val(directive+&quot;&lt;blockquote&gt;&quot;+quote+&quot;&lt;/blockquote&gt;\n&lt;p&gt;\n&lt;!-- Start your comment below this line. --&gt;\n\n&lt;/p&gt;&quot;);
-      $.scrollTo('#comment', {duration: 1000});
+      quote = directive+&quot;&lt;blockquote&gt;&quot;+quote+&quot;&lt;/blockquote&gt;\n&lt;p&gt;\n&quot;;
+      if(noLightbox) {
+         if(!form) {
+            $('#comment').val(quote+&quot;&lt;!-- Start your comment below this line. --&gt;\n\n&lt;/p&gt;&quot;);
+         }
+         $.scrollTo('#comment', {duration: 1000});
+      } else {
+         setupLightbox();
+      }
+      
+      if(!noPreview) {
+         preview.html(quote);
+      }
+      
+      addOrShowDeleteQuoteControl(directive);
+      
       $(this).fadeTo(1,0);
       widget.hide();
    });
@@ -82,13 +121,11 @@ $(document).ready( function() {
    //
    // Comment traversing utilities :: related comments &amp; replies trick.
    //
-   var commentList = $($('.commentlist').get(0));
    var relatedComments = new Array();
    var relatedReplies = new Array();
-   var sortedCommentary = commentList.hasClass('sorted-commentary');
    $('.commentlist .comment p:first-child a:first-child').each(function() { 
-      if(this.text.substring(1,-1) == &quot;@&quot;) {
-         var targetAuthor = this.text.substring(1,this.text.length);
+      if($(this).text().substring(1,-1) == &quot;@&quot;) {
+         var targetAuthor = $(this).text().substring(1,$(this).text().length);
          var replyComment = findCommentFor(this);
          var replyAuthor = findAuthorFor(replyComment);
          var replyPermalink = findPermalinkFor(replyComment);
@@ -110,10 +147,10 @@ $(document).ready( function() {
    });
    
    var quoteReplyControls = '';
-   if(!commentList.hasClass('no-quote-control')) {
+   if(!noQuoteControl) {
       quoteReplyControls += '&lt;a href=&quot;#&quot; class=&quot;comment-quote&quot;&gt;Quote&lt;/a&gt;'
    }
-   if(!commentList.hasClass('no-reply-control')) {
+   if(!noReplyControl) {
       quoteReplyControls += '&lt;a href=&quot;#&quot; class=&quot;comment-reply&quot;&gt;Reply&lt;/a&gt;'
    }
    $('.commentlist &gt; .comment').each( function() {
@@ -138,12 +175,12 @@ $(document).ready( function() {
          function(){
             if(relatedComments[currentAuthor.text].length &gt; 1 || relatedReplies[currentAnchor]) {
                if($(this).find('div.comment-controls div.related-replies, div.comment-controls div.related-comments').length &lt; 1) {
-                  if(relatedReplies[currentAnchor] &amp;&amp; !commentList.hasClass('no-replies')){
+                  if(relatedReplies[currentAnchor] &amp;&amp; !noReplies){
                      var wording = &quot;&quot;;
                      (relatedReplies[currentAnchor].length &gt; 1) ? wording = &quot;replies&quot; : wording = &quot;reply&quot;;
                      commentControls.append('&lt;div class=&quot;related-replies&quot;&gt;&lt;h6&gt;'+(relatedReplies[currentAnchor].length)+' '+wording+' to this comment&lt;/h6&gt;&lt;ol&gt;'+printReplies(relatedReplies[currentAnchor])+'&lt;/ol&gt;&lt;/div&gt;');
                   }
-                  if(relatedComments[currentAuthor.text].length &gt; 1 &amp;&amp; !commentList.hasClass('no-relatives')){
+                  if(relatedComments[currentAuthor.text].length &gt; 1 &amp;&amp; !noRelatives){
                      var wording = &quot;&quot;;
                      (relatedComments[currentAuthor.text].length-1 &gt; 1) ? wording = &quot;comments&quot; : wording = &quot;comment&quot;;
                      commentControls.append('&lt;div class=&quot;related-comments&quot;&gt;&lt;h6&gt;'+(relatedComments[currentAuthor.text].length-1)+' other '+wording+' from '+currentAuthor.text+'&lt;/h6&gt;&lt;ol&gt;'+printRelatives(relatedComments[currentAuthor.text],reference)+'&lt;/ol&gt;&lt;/div&gt;');
@@ -182,6 +219,48 @@ $(document).ready( function() {
             }
          });
    });
+   
+   //
+   // Comment form handler.
+   //
+   if(form) {
+      if(form.find('input[type=&quot;submit&quot;]').get(0)) {
+         $(form.find('input[type=&quot;submit&quot;]').get(0)).removeAttr(&quot;disabled&quot;); 
+      }
+      $(form.find('input[type=&quot;submit&quot;]').get(0)).attr(&quot;disabled&quot;,false);
+      if(!noPreview){
+         form.append('&lt;div id=&quot;encouraged-preview&quot;&gt;&amp;nbsp;&lt;/div&gt;');
+         preview = $($('#encouraged-preview').get(0));
+         var comment = $($('#comment').get(0));
+      
+         comment.keyup(function(){
+            preview.html(quote+fixWhiteSpace(comment.val()));
+            if(comment.val().length &gt; 400 &amp;&amp; !comment.hasClass('extended')) {
+               comment.addClass('extended');
+            } else if(comment.val().length &lt; 400 &amp;&amp; comment.hasClass('extended')) {
+               comment.removeClass('extended');
+            }
+         });
+      }
+   }
+   
+   if(!noLightbox) {
+      $(&quot;body&quot;).append('&lt;div id=&quot;comment-lightbox&quot;&gt;&lt;/div&gt;&lt;div id=&quot;comment-lightbox-background&quot;&gt;&lt;/div&gt;');
+      lightbox = $('#comment-lightbox').hide();
+      lightboxBackground = $('#comment-lightbox-background').hide();
+      lightboxBackground.click(hideLightbox);
+   }
+   
+   //
+   // Handle form submission.
+   //
+   form.submit(function(){
+      $($('#comment').get(0)).val(preview.html());
+      if(form.find('input[type=&quot;submit&quot;]').get(0)) {
+         $(form.find('input[type=&quot;submit&quot;]').get(0)).attr(&quot;disabled&quot;,true);
+      };
+      return true;
+   });
 });
 
 /*
@@ -268,21 +347,48 @@ function getAnchor(href){
 
 /*
    FUNCTION:
+   SetupLightbox()
+   Grabs the HTML comment form and leaves an invisible anchor in it's place.
+*/
+function setupLightbox() {
+   if(!$('#encouraged-comment-form-anchor').get(0)) {
+      lightbox.after('&lt;a href=&quot;#&quot; id=&quot;encouraged-comment-form-anchor&quot;&gt;&lt;/a&gt;');
+   }
+   lightbox.html(form);
+   lightbox.append('&lt;a href=&quot;#&quot; id=&quot;encouraged-comment-lightbox-toggle&quot;&gt;Close&lt;/a&gt;');
+   $('#encouraged-comment-lightbox-toggle').click(hideLightbox);
+   lightbox.fadeIn(&quot;normal&quot;);
+   lightboxBackground.show().fadeTo(&quot;slow&quot;,0.3);
+};
+
+/*
+   FUNCTION:
+   HideLightbox()
+   Fade out the lightbox and put the comment form back in it's place.
+*/
+function hideLightbox() {
+   lightbox.hide();
+   $($('#encouraged-comment-form-anchor').get(0)).after(form);
+   lightboxBackground.fadeOut(&quot;slow&quot;);
+};
+
+/*
+   FUNCTION:
    SetupComment(HTML object, string)
    Sets up a comment body in the comment form based off the target.
    - This method is used by the automated respond or quote buttons. 
    - The text highlight and respond works slightly differently.
 */
-function setupComment(target,quote) {
+function setupComment(target,quoted) {
    var comment = findCommentFor(target);
    var directive = '&lt;p&gt;&lt;a href=&quot;'+findPermalinkFor(comment).href+'&quot;&gt;@'+findAuthorFor(comment).text+'&lt;/a&gt;&lt;/p&gt;';
-   if(quote) {
+   if(quoted) {
       quote = &quot;&lt;blockquote&gt;&quot;;
       if(comment.find('.entry-content &gt; p').length &gt; 0) {
          comment.find('.entry-content &gt; p').each(function() {
             var directivePresent = false;
             if($(this).find(&quot;a:first-child&quot;).length &gt; 0) {
-               if($(this).find(&quot;a:first-child&quot;).get(0).text.substring(1,-1) == &quot;@&quot;) {
+               if($($(this).find(&quot;a:first-child&quot;).get(0)).text().substring(1,-1) == &quot;@&quot;) {
                   directivePresent = true;
                }
             }
@@ -300,8 +406,52 @@ function setupComment(target,quote) {
    } else {
       quote = &quot;&quot;;
    }
-   $('#comment').val(directive+quote+&quot;\n&lt;p&gt;\n&lt;!-- Start your comment below this line. --&gt;\n\n&lt;/p&gt;&quot;);
-   $.scrollTo('#comment', {duration: 1000});
+   
+   quote = directive + quote;
+   
+   if(noLightbox) {
+      if(noPreview) {
+         $('#comment').val(quote+&quot;\n&lt;p&gt;\n&lt;!-- Start your comment below this line. --&gt;\n\n&lt;/p&gt;&quot;);
+      }
+      $.scrollTo('#comment', {duration: 1000});
+   } else {
+      setupLightbox();
+   }
+   
+   if(!noPreview) {
+      preview.html(quote);
+   }
+};
+
+/*
+   FUNCTION:
+   AddOrShowDeleteQuoteControl(String)
+*/
+function addOrShowDeleteQuoteControl(directive){
+   var deleteCommentControl = form.find('#encouraged-comment-delete').get(0);
+   if(directive == &quot;&quot;) {
+      directive = &quot;Article&quot;;
+   } else {
+      if($(directive).find('a').get(0)){
+         directive = $($(directive).find('a').get(0)).text().replace('@','');
+      }
+   }
+   
+   if(!deleteCommentControl) {
+      form.append('&lt;a href=&quot;#&quot; id=&quot;encouraged-comment-delete&quot;&gt;Quoting: '+directive+' (click to cancel)&lt;/a&gt;');
+      deleteCommentControl = $(form.find('#encouraged-comment-delete').get(0));
+      deleteCommentControl.click(function(){
+         $(this).hide();
+         quote = &quot;&quot;;
+         if(!noPreview){
+            preview.html(fixWhiteSpace($('#comment').val()));
+         }
+         return false;
+      });
+   } else {
+      $(deleteCommentControl).show();
+      $(deleteCommentControl).html(&quot;Quoting: &quot;+directive+&quot; (click to cancel)&quot;);
+   }
 };
 
 /*
@@ -325,9 +475,18 @@ function getSelText()
       txt = document.selection.createRange().text;
    } else return;
    if(String(txt).length &gt; 2) {
-      txt = String(txt).replace(/\n\n/g,&quot;&lt;/p&gt;&lt;p&gt;&quot;).replace(/\n/g,&quot;&lt;br/&gt;&quot;);
-      return &quot;&lt;p&gt;&quot;+txt+&quot;&lt;/p&gt;&quot;;
+      return fixWhiteSpace(txt);
    } else {
       return false;
    }
+};
+
+/*
+   FUNCTION:
+   FixWhiteSpace(String)
+   Converts whitespace in strings to html.
+*/
+function fixWhiteSpace(str) {
+   str = String(str).replace(/\n\n/g,&quot;&lt;/p&gt;&lt;p&gt;&quot;).replace(/\n/g,&quot;&lt;br/&gt;&quot;);
+   return &quot;&lt;p&gt;&quot;+str+&quot;&lt;/p&gt;&quot;;
 };
\ No newline at end of file</diff>
      <filename>javascript/jquery/encouraged-commentary.js</filename>
    </modified>
    <modified>
      <diff>@@ -145,3 +145,100 @@ into your own stylesheet and enhance them to your own taste.
       background: #f90;
       color: #333;
    }
+   
+   
+   /* Styles for the preview container. */
+   #encouraged-preview {
+      color: #999;
+      font-size: 0.875em;
+      line-height: 1.25em;
+      left: 470px;
+      position: absolute;
+      top: 133px;
+      width: 400px;
+   }
+   
+   /* Alternate height for large comments. */
+   .extended {
+      height: 300px;
+   }
+   
+   /* Kind of important if you are using the preview with or without the lightbox */
+   .encouraged-form {
+      position: relative;
+   }
+   
+   /* This is to style the opt out of quoting button. */
+   #encouraged-comment-delete {
+      left: 470px;
+      position: absolute;
+      top: 90px;
+   }
+   
+   /* Lightbox Styles */
+   #comment-lightbox {
+      background: #fff;
+      border: 10px solid #000;
+      height: 480px;
+      left: 50%;
+      margin-left: -320px;
+      margin-top: -240px;
+      overflow: hidden;
+      position: fixed;
+      top: 50%;
+      width: 640px;
+      z-index: 2001;
+   }
+   
+   /* This layer is the fade behind the lightbox */
+   #comment-lightbox-background {
+      background: #000;
+      height: 100%;
+      left: 0;
+      position: fixed;
+      top: 0;
+      width: 100%;
+      z-index: 2000;
+   }
+   
+   /* All of the work below here is to restyle the comment form when it is pulled into the lightbox. */
+   #comment-lightbox .encouraged-form {
+      padding: 10px;
+   }
+   
+   #comment-lightbox .encouraged-form label {
+      color: #000;
+      font-size: 0.75em;
+   }
+   
+   #comment-lightbox .encouraged-form #comment {
+      height: 290px;
+      width: 290px;
+   }
+   
+   #comment-lightbox .encouraged-form #encouraged-preview {
+      background: #fff;
+      height: 430px;
+      left: 330px;
+      overflow: auto;
+      padding: 10px;
+      top: 30px;
+      width: 290px;
+   }
+   
+   #comment-lightbox #encouraged-comment-delete {
+      padding: 4px 0 0 0;
+      top: 0;
+      left: 330px;
+   }
+   
+   /* This styling is applied to the close button that is automatically generated when the lightbox is called. */
+   #encouraged-comment-lightbox-toggle {
+      background: #000;
+      color: #fff;
+      display: block;
+      right: 0;
+      position: absolute;
+      padding: 0 0 4px 4px;
+      top: 0;
+   }
\ No newline at end of file</diff>
      <filename>stylesheets/base.css</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b30b1ccfa3f74fbdfc8b0d4ba54a2fe01c9b8fc5</id>
    </parent>
  </parents>
  <author>
    <name>Jimmy Jeffers</name>
    <email>jim@sumocreations.com</email>
  </author>
  <url>http://github.com/jimjeffers/encouraged-commentary/commit/0bf09cc99d45775350d0b8af8590d165e1b12b97</url>
  <id>0bf09cc99d45775350d0b8af8590d165e1b12b97</id>
  <committed-date>2009-01-17T19:03:30-08:00</committed-date>
  <authored-date>2009-01-17T19:03:30-08:00</authored-date>
  <message>Added live preview, lightbox, and separation of HTML from comment text.</message>
  <tree>8f0aabb7d5cc6ce7c5b42f272f94e7b29fe050e4</tree>
  <committer>
    <name>Jimmy Jeffers</name>
    <email>jim@sumocreations.com</email>
  </committer>
</commit>
