/*
 * abbreviate 2.0 - jQuery plugin for abbreviating text
 *
 * Copyright (c) 2014 David Maicher (http://blog.dmaicher.de)
 * Licensed under MIT (http://opensource.org/licenses/MIT)
 */
(function ($) {
    $.fn.abbreviate = function (options) {

        options = $.extend({
            length: 15,
            moreText: "more",
            lessText: "less",
            ellipsis: ".."
        }, options);

        /**
         * traverses node tree recursively and shortens/removes nodes
         */
        var abbreviateNode = function (node, acc) {

            //limit already reached?
            if(acc.length >= options.length) {
                node.remove();
                return;
            }

            //is textnode?
            if (node[0].nodeType == 3) {
                acc.length = acc.length + node[0].nodeValue.length;
                if(acc.length > options.length) {
                    var endIndex = node[0].nodeValue.length - (acc.length - options.length);
                    node[0].nodeValue = node[0].nodeValue.slice(0, endIndex);
                }
                return;
            }

            //work on copy of array
            var children = node.contents().slice();
            for (var i = 0; i < children.length; i++) {
                abbreviateNode($(children[i]), acc);
            }
        };

        return this.each(function () {
            var node = $(this);

            //no abbreviation necessary?
            if(node.text().length <= options.length) {
                return;
            }

            var fullContent = node.html();
            if(options.lessText){
                fullContent += " <a href='#' class='abbreviate_less'>"+options.lessText+"</a>";
            }

            abbreviateNode(node, {'length' : 0});

            var shortContent = node.html();
            shortContent += options.ellipsis+"<a href='#' class='abbreviate_more'>"+options.moreText+"</a>";

            node.html(shortContent);
            node.on('click', '.abbreviate_less', function(){ node.html(shortContent); return false; });
            node.on('click', '.abbreviate_more', function(){ node.html(fullContent); return false; });
        });
    }
})(jQuery);

@@ -100,24 +100,31 @@
 http
+s
 ://
-blog.
+github.com/
 dmaicher
 .de)
@@ -123,11 +123,8 @@
 cher
-.de
 )%0A *
@@ -771,24 +771,87 @@
 ype == 3) %7B%0A
+                node%5B0%5D.nodeValue = $.trim(node%5B0%5D.nodeValue);%0A
             
@@ -1535,16 +1535,23 @@
      if(
+$.trim(
 node.tex
@@ -1553,16 +1553,17 @@
 e.text()
+)
 .length 
@@ -1657,32 +1657,32 @@
  = node.html();%0A
-
             if(o
@@ -1696,16 +1696,23 @@
 lessText
+.length
 )%7B%0A     

trim node contents