/**
 * Popup-контейнер для виртуальной клавиатуры
 */

(function($, Lego) {

    Lego.block['b-keyboard-popup'] = function(params) {
        var $body = $(document.body);

        var markup = '<div class="b-keyboard-popup__gap"></div>' +
                     '<div class="b-keyboard-popup">' +
                        '<div class="b-keyboard-popup__bar">' +
                            '<a class="b-keyboard-popup__bar-link b-keyboard-popup__close" href="#"><i class="b-keyboard-popup__bar-link__ic"></i>закрыть</a>' +
                        '</div>' +
                        '<div class="b-keyboard g-js" onclick="return {name: \'b-keyboard\', fake: false, lang: \'' + params.lang + '\'};"></div>' +
                     '</div>';

        $body.append(markup);

        $('.b-keyboard-popup__close').click(function() {
            $body.find('.b-keyboard-popup').addClass('g-hidden');
            $body.find('.b-keyboard-popup__gap').addClass('g-hidden');
            $body.css('overflow', 'auto');
            $(window).trigger('keyboardClosed');
            $(document).trigger('popupsClose.lego');
            return false;
        });
    };

})(jQuery, window.Lego);
