IchHabRecht icon

[JS] Flexible jQuery tabs

IchHabRecht | PRO | 09/16/14 04:08:31 PM UTC | 0 ⭐ | 456 👁️ | Never ⏰ | []
JavaScript |

1.05 KB

|

None

|

0 👍

/

0 👎

jQuery(document).ready(function($) {
    jQuery('div.tx-jfmulticontent-pi1 > div.ui-tabs').each(function() {
        var $navigation = jQuery('ul.ui-tabs-nav', this);
        var $listItems = jQuery('li.ui-state-default', $navigation);
        var width = $navigation.width();
        var staticWidth = 0;
        $listItems.each(function() {
            var $this = jQuery(this);
            if ($this.text().indexOf(' ') > -1) {
                $this.addClass('flexible');
            } else {
                $this.addClass('static');
                staticWidth += $this.width();
            }
            width -= $this.outerWidth() - $this.width();
        });
        var $flexibleListItems = $listItems.filter('.flexible');
        var $staticListItems = $listItems.filter('.static');
        if ($flexibleListItems.length && $staticListItems.length) {
            width = (width - staticWidth) / $flexibleListItems.length;
            $flexibleListItems.width(width);
        } else {
            width = width / $listItems.length;
            $listItems.width(width);
        }
        var height = Math.max.apply(null, $listItems.map(function() {
            return jQuery(this).height();
        }));
        $listItems.height(height);
    })
});

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎