return function () {
    $self = url('/@object/@action/' . urlencode('html/dialog_keys'));
    $ui = _class('admin_ui');
    $colors = ['red' => 'Red', 'green' => 'Green', 'blue' => 'Blue'];
    if (isset($_GET['frag']) && is_ajax()) {
        no_graphics(true);
        echo '<form id="dk-edit-form" action="' . $self . '" method="post">'
            . '<div class="form-group mb-2"><label for="dk-title">' . t('Title') . '</label><input type="text" id="dk-title" name="title" value="Apples" class="' . $ui->input_class() . '"></div>'
            . '<div class="form-group mb-2"><label for="dk-kind">' . t('Kind') . '</label><select id="dk-kind" name="kind" class="' . $ui->input_class() . '"><option>' . t('Fruit') . '</option><option>' . t('Vegetable') . '</option></select></div>'
            . '<button type="submit" class="' . $ui->btn_class('primary') . '">' . t('Save') . '</button></form>';
        exit;
    }
    asset('jquery');
    asset('jquery-ui');
    asset('yf_js_admin');
    asset('yf_select');
    _class('admin_ui')->confirm_assets();
    $html = html();

    $intro = '<p class="docs-demo-intro">' . t('Esc closes the dialog on top: the ajax edit modal of a list row (<code>.ajax_edit</code>), a page modal (<code>html()->modal()</code>), a jQuery UI dialog. An open dropdown in the dialog takes the Esc first; a changed form asks <q>Discard changes?</q>; a confirm over a modal closes alone; the focus goes back to the button that opened the dialog. Asset <code>yf_dialog_keys</code>, loaded by <code>yf_js_admin</code>.') . '</p>';
    $row = '<table class="' . $ui->table_class() . '"><tbody><tr><td>1</td><td>Apples</td><td>'
        . '<a id="dk-edit" class="ajax_edit ' . $ui->btn_class('default', ['icon_only' => true]) . '" href="' . $self . '?frag=1" title="' . t('Edit') . '" aria-label="' . t('Edit') . '"><i class="fa fa-edit" aria-hidden="true"></i></a>'
        . '</td></tr></tbody></table>';
    $body = '<div class="form-group mb-2"><label for="dk-color">' . t('Colour') . '</label>' . $html->tom_select_box('dk_color', $colors, 'red', ['id' => 'dk-color']) . '</div>'
        . '<div class="form-group mb-2"><label for="dk-note">' . t('Note') . '</label><input type="text" id="dk-note" name="note" value="" class="' . $ui->input_class() . '"></div>'
        . '<button type="button" id="dk-ask" class="' . $ui->btn_class() . '">' . t('Ask') . '</button>';
    $modal = $html->modal_button(t('Page modal'), 'dk-modal', ['id' => 'dk-open', 'class' => $ui->btn_class()])
        . $html->modal(['id' => 'dk-modal', 'header' => t('Page modal'), 'body' => '<form id="dk-modal-form">' . $body . '</form>', 'show_close' => 1, 'fade' => 1]);
    $dialog = '<button type="button" id="dk-ui-open" class="' . $ui->btn_class() . '">' . t('jQuery UI dialog') . '</button>'
        . '<div id="dk-ui" title="' . t('jQuery UI dialog') . '" hidden><input type="text" id="dk-ui-text" value="" class="' . $ui->input_class() . '"></div>';
    js(<<<'JS'
(function () {
    jQuery(function ($) {
        $('#dk-ui').prop('hidden', false).dialog({ autoOpen: false, modal: true });
        $('#dk-ui-open').on('click', function () {
            $('#dk-ui').dialog('open');
        });
        $('#dk-ask').on('click', function () {
            yf.confirm('Go on?');
        });
    });
})();
JS);
    return $intro . '<div class="yf-ui-toolbar">' . $row . $modal . ' ' . $dialog . '</div>';
};

Esc закриває верхній діалог: модальне вікно ajax-редагування рядка списку (.ajax_edit), модальне вікно сторінки (html()->modal()), діалог jQuery UI. Відкрите випадне меню в діалозі першим отримує Esc; змінена форма питає Відкинути зміни?; підтвердження поверх модального вікна закривається саме; фокус повертається до кнопки, яка відкрила діалог. Ресурс yf_dialog_keys, його завантажує yf_js_admin.

1Apples