Sha256: f0f0921023085d5c808d03b6e128423d3c88c4555c4c30ab7b90c03f5b116854

Contents?: true

Size: 1.15 KB

Versions: 3

Compression:

Stored size: 1.15 KB

Contents

$(() => {
    // Menu button handling
    $('.bw-open').click(() => {
        $('.bw-app').addClass('scroll-lock')
        $('.bw-back-container').addClass('visible')
        $('.bw-front').addClass('slided')
    })
    $('.bw-close').click(() => {
        $('.bw-front')
            .removeClass('slided')
            .one('transitionend', () => {
                $('.bw-app').removeClass('scroll-lock')
                $('.bw-back-container').removeClass('visible')
            })
    })

    // Dynamic Tables
    $('.bw-front table').each((_, table) => {
        // Find longest
        let longest = $(table)
            .find('th,td')
            .map((_, elem) => $(elem).text())
            .get()
            .reduce((a, b) => a.length >= b.length ? a : b, '')

        // Get length of longest
        let font = $(table).find('td').css('font')
        let canvas = document.createElement('canvas')
        let ctx = canvas.getContext('2d')
        ctx.font = font
        let length = ctx.measureText(longest).width

        // Set table cell lengths to length of longest
        $(table).find('th,td').css('width', length)
    })
})

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jekyll-theme-backwhite-2.1.1 assets/js/backwhite.js
jekyll-theme-backwhite-2.1.0 assets/js/backwhite.js
jekyll-theme-backwhite-2.0.0 assets/js/backwhite.js