! function($) {
    "use strict";
    var ElectromixAdmin = {
        init: function() {
            $(document).ready(ElectromixAdmin.ready), $(window).on("load", ElectromixAdmin.load), ElectromixAdmin.bindUIActions(), $(document).trigger("electromixReady")
        },
        ready: function() {},
        load: function() {
            window.dispatchEvent(new Event("resize"))
        },
        resize: function() {},
        bindUIActions: function() {
            var $this, $wrap = $("#wpwrap");
            $("body");
            $wrap.on("click", ".plugins .electromix-btn:not(.active)", (function(e) {
                e.preventDefault(), $wrap.find(".plugins .electromix-btn.in-progress").length || ($this = $(this), ElectromixAdmin.pluginAction($this))
            })), $(document).on("wp-plugin-install-success", ElectromixAdmin.pluginInstallSuccess), $(document).on("wp-plugin-install-error", ElectromixAdmin.pluginInstallError)
        },
        pluginAction: function($button) {
            if ($button.addClass("in-progress").attr("disabled", "disabled").html(electromix_strings.texts[$button.data("action") + "-inprogress"]), "install" === $button.data("action")) wp.updates.shouldRequestFilesystemCredentials && !wp.updates.ajaxLocked && (wp.updates.requestFilesystemCredentials(event), $(document).on("credential-modal-cancel", (function() {
                $button.removeAttr("disabled").removeClass("in-progress").html(electromix_strings.texts.install), wp.a11y.speak(wp.updates.l10n.updateCancel, "polite")
            }))), wp.updates.installPlugin({
                slug: $button.data("plugin")
            });
            else {
                var data = {
                    _ajax_nonce: electromix_strings.wpnonce,
                    plugin: $button.data("plugin"),
                    action: "electromix-plugin-" + $button.data("action")
                };
                $.post(electromix_strings.ajaxurl, data, (function(response) {
                    response.success ? $button.data("redirect") ? window.location.href = $button.data("redirect") : location.reload() : $(".plugins .electromix-btn.in-progress").removeAttr("disabled").removeClass("in-progress primary").addClass("secondary").html(electromix_strings.texts.retry)
                }))
            }
        },
        pluginInstallSuccess: function(event, response) {
            event.preventDefault();
            var activatedSlug, $init = jQuery(event.target).data("init");
            activatedSlug = void 0 === $init ? response.slug : $init;
            var $button = $('.plugins a[data-plugin="' + activatedSlug + '"]');
            $button.data("action", "activate"), ElectromixAdmin.pluginAction($button)
        },
        pluginInstallError: function(event, response) {
            event.preventDefault();
            var activatedSlug, $init = jQuery(event.target).data("init");
            activatedSlug = void 0 === $init ? response.slug : $init, $('.plugins a[data-plugin="' + activatedSlug + '"]').attr("disabled", "disabled").removeClass("in-progress primary").addClass("secondary").html(wp.updates.l10n.installFailedShort)
        }
    };
    ElectromixAdmin.init(), window.electromixadmin = ElectromixAdmin
}(jQuery);

(function($) {
    if ($('.electromix-websites .plugin-info a[data-action="activate"]').length > 0) {
        $('.electromix-btn-get-started').addClass('shake');
    } else {
        $('.electromix-btn-get-started').removeClass('shake');
    }
})(jQuery);