!function(t){"use strict";t.redux=t.redux||{},t(document).ready(function(){t.redux.wbc_importer()}),t.redux.wbc_importer=function(){t(".wrap-importer.theme.not-imported, #wbc-importer-reimport").unbind("click").on("click",function(t){function r(){var t='<div class="wbc-progress-back"><div class="wbc-progress-bar button-primary"><span class="wbc-progress-count">0%</span></div>';o.prepend(t),setTimeout(function(){e(s)},2e3)}function e(t){t.action="redux_wbc_importer_progress",0==d?jQuery.ajax({url:ajaxurl,data:t,success:function(r){var i=jQuery.parseJSON(r);if(r.length>0&&"object"==typeof i){var n=Math.floor(i.imported_count/i.total_post*100);n=n>0?n-1:n,o.find(".wbc-progress-bar").css("width",n+"%"),o.find(".wbc-progress-count").text(n+"%"),setTimeout(function(){e(t)},2e3)}}}):o.find(".wbc-progress-back").remove()}t.preventDefault();var o=jQuery(this),i=!1,n="Import Demo Content?";if("wbc-importer-reimport"==t.target.id&&(i=!0,n="Re-Import Content?",jQuery(this).hasClass("rendered")||(o=jQuery(this).parents(".wrap-importer"))),!o.hasClass("imported")||0!=i){var a=confirm(n);if(0!=a){1==i&&o.removeClass("active imported").addClass("not-imported"),o.find(".spinner").css("display","inline-block"),o.removeClass("active imported"),o.find(".importer-button").hide();var s=jQuery(this).data(),d=!1;return s.action="redux_wbc_importer",s.demo_import_id=o.attr("data-demo-id"),s.nonce=o.attr("data-nonce"),s.type="import-demo-content",s.wbc_import=1==i?"re-importing":" ",o.find(".wbc_image").css("opacity","0.5"),jQuery.post(ajaxurl,s,function(t){if(o.find(".wbc_image").css("opacity","1"),o.find(".spinner").css("display","none"),t.length>0&&t.match(/Have fun!/gi)){if(0==i){o.addClass("rendered").find(".wbc-importer-buttons .importer-button").removeClass("import-demo-data");var r='<div id="wbc-importer-reimport" class="wbc-importer-buttons button-primary import-demo-data importer-button">Re-Import</div>';o.find(".theme-actions .wbc-importer-buttons").append(r)}o.find(".importer-button:not(#wbc-importer-reimport)").removeClass("button-primary").addClass("button").text("Imported").show(),o.find(".importer-button").attr("style",""),o.addClass("imported active").removeClass("not-imported"),d=!0,e(s),location.reload(!0)}else o.find(".import-demo-data").show(),1==i&&(o.find(".importer-button:not(#wbc-importer-reimport)").removeClass("button-primary").addClass("button").text("Imported").show(),o.find(".importer-button").attr("style",""),o.addClass("imported active").removeClass("not-imported")),d=!0,alert("There was an error importing demo content: \n\n"+t.replace(/(<([^>]+)>)/gi,""))}),r(),!1}}})}}(jQuery);