(function ($) {
    'use strict';

    var $themeSelect = $('#maca_dish_menu_theme');
    var $layoutSelect = $('#maca_dish_menu_layout');
    var $shell = $('#maca-dish-menu-theme-preview-shell');

    if (!$shell.length) {
        return;
    }

    function syncPreviewShell() {
        var theme = ($themeSelect.val() || 'light');
        var layout = ($layoutSelect.length ? $layoutSelect.val() : 'rows') || 'rows';

        $shell.attr(
            'class',
            'maca-dish-menu-shell maca-dish-menu-shell--theme-' + theme + ' maca-dish-menu-shell--layout-' + layout
        );
    }

    if ($themeSelect.length) {
        $themeSelect.on('change', syncPreviewShell);
    }

    if ($layoutSelect.length) {
        $layoutSelect.on('change', syncPreviewShell);
    }

    syncPreviewShell();
}(jQuery));
