JSFiddle - React, Tailwind, and code Playground

by Роман Захаров

JavaScript

[JS](function($) {

    var GeoIPModuleDialog = function(o, el) {
        this.o = $.extend({autoOpen: false}, o);
        this.el = el;
        this.prefix = 'geoip-';

        this.modal = $('<div class="' + this.prefix + 'modal ' + this.prefix + 'fade"></div>');
        this.backdrop = $('<div class="' + this.prefix + 'backdrop ' + this.prefix + 'fade"></div>').height($(window).height());
        this.dialog = $('<div class="' + this.prefix + 'modal-dialog"></div>');
        this.content = $('<div class="' + this.prefix + 'modal-content"></div>');
        var close = $('<div class="' + this.prefix + 'close">&times;</div>');
        this.content.append(close);
        $('body').append(this.modal.append(this.backdrop, this.dialog.append(this.content.append(el))));

        var self = this;

        $(window).resize(function() {
            self.backdrop.height($(window).height());
        });

        if (this.o.autoOpen) {
            this.open();
        } else {
            this.close();
        }

        close.click(function() {
            self.close();
        });

        this.backdrop.click(function() {
            self.close();
        });

        $(document).keydown(function(e) {
            if (e.which == 27) {
                self.close();
            }
        });
    };

    GeoIPModuleDialog.prototype.open = function() {
        $('body').addClass(this.prefix + 'modal-open');
        this.modal.addClass(this.prefix + 'in').show();
        this.backdrop.addClass(this.prefix + 'in');

        if (this.o.open) {
            this.o.open.apply(this);
        }
    };

    GeoIPModuleDialog.prototype.close = function() {
        $('body').removeClass(this.prefix + 'modal-open');
        this.modal.removeClass(this.prefix + 'in').hide();
        this.backdrop.removeClass(this.prefix + 'in');
    };

    var methods = {
        init: function(o) {
            return this.each(function() {
                var self = $(this),
                    data =...