$(function () {
    $('.teaser-button').textfill();
});
(function($) {
    $.fn.textfill = function(options) {
        return this.each(function() {
            var outer = $(this);

            var inner = $('span', outer);

            var fontSize = parseFloat(outer.css('font-size'));
            var maxHeight = outer.height();
            var maxWidth = outer.width();
            var textHeight = inner.height();
            var textWidth = inner.width();

            do {
                inner.css('font-size', fontSize);
                textHeight = inner.height();
                textWidth = inner.width();
                fontSize = fontSize - 1;
            } while ((textHeight > maxHeight || textWidth > maxWidth) && fontSize > 3);
        });
    }
})(jQuery);
