﻿
// provide support for expand and collapsing demo description
$(function() {
    RehookDescriptionCollapsable();
});

function RehookDescriptionCollapsable() {
    $(document).ready(function() {
        $(function() {
            var demoDescription = $(".demo_description_pg_truncate");
            var hiddenMore = $("#hiddenMore")[0];
            var hiddenLess = $("#hiddenLess")[0];
            if (demoDescription != null && hiddenMore != null && hiddenLess != null) {
                var moreText = hiddenMore.innerHTML;
                var lessText = hiddenLess.innerHTML;
                demoDescription.truncate(175, {
                    chars: /\s/, //tells the plugin to break on the first space character it finds after the max num of characters is reached
                    //trail: ["<a href='#' class='truncate_show'>More...</a>", "<a href='#' class='truncate_hide'>Less...</a>"]
                    trail: ["<a href='#' class='truncate_show'>" + moreText + "</a>", "<a href='#' class='truncate_hide'>" + lessText + "</a>"]
                });
            }
        });
    });
}    