function showToolBarAlert(e,t,r){var i=jQuery("li.shortpixel-toolbar-processing");switch(e){case ShortPixel.STATUS_QUOTA_EXCEEDED:if(window.location.href.search("wp-short-pixel-bulk")>0&&0==jQuery(".sp-quota-exceeded-alert").length)return;i.addClass("shortpixel-alert"),i.addClass("shortpixel-quota-exceeded"),jQuery("a",i).attr("href","options-general.php?page=wp-shortpixel-settings"),jQuery("a div",i).attr("title","ShortPixel quota exceeded. Click for details.");break;case ShortPixel.STATUS_SKIP:case ShortPixel.STATUS_FAIL:i.addClass("shortpixel-alert shortpixel-processing"),jQuery("a div",i).attr("title",t),void 0!==r&&jQuery("a",i).attr("href","post.php?post="+r+"&action=edit");break;case ShortPixel.STATUS_NO_KEY:i.addClass("shortpixel-alert"),i.addClass("shortpixel-quota-exceeded"),jQuery("a",i).attr("href","options-general.php?page=wp-shortpixel-settings"),jQuery("a div",i).attr("title","Get API Key");break;case ShortPixel.STATUS_SUCCESS:case ShortPixel.STATUS_RETRY:i.addClass("shortpixel-processing"),i.removeClass("shortpixel-alert"),jQuery("a",i).removeAttr("target"),jQuery("a",i).attr("href",jQuery("a img",i).attr("success-url"))}i.removeClass("shortpixel-hide")}function hideToolBarAlert(e){var t=jQuery("li.shortpixel-toolbar-processing.shortpixel-processing");ShortPixel.STATUS_EMPTY_QUEUE==e&&(t.hasClass("shortpixel-alert")||t.hasClass("shortpixel-quota-exceeded"))||t.addClass("shortpixel-hide")}function hideQuotaExceededToolBarAlert(){jQuery("li.shortpixel-toolbar-processing.shortpixel-quota-exceeded").addClass("shortpixel-hide")}function checkQuotaExceededAlert(){"undefined"!=typeof shortPixelQuotaExceeded&&(1==shortPixelQuotaExceeded?showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED):hideQuotaExceededToolBarAlert())}function checkBulkProgress(){var e=function(e){return t?"/":(t=!0,e)},t=!1,r=window.location.href.toLowerCase().replace(/\/\//g,e);t=!1;var i=ShortPixel.WP_ADMIN_URL.toLowerCase().replace(/\/\//g,e);if(r.search(i)<0&&(r=ShortPixel.convertPunycode(r),i=ShortPixel.convertPunycode(i)),1==ShortPixel.bulkProcessor&&window.location.href.search("wp-short-pixel-bulk")<0&&void 0!==localStorage.bulkPage&&localStorage.bulkPage>0&&(ShortPixel.bulkProcessor=!1),window.location.href.search("wp-short-pixel-bulk")>=0&&(ShortPixel.bulkProcessor=!0,localStorage.bulkTime=Date.now(),localStorage.bulkPage=1,ShortPixel.BULK_SECRET=!1),!1!==ShortPixel.BULK_SECRET&&ShortPixel.BULK_SECRET!=localStorage.bulkSecret)return clearBulkProcessor(),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-processing"),void jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-hide");1==ShortPixel.bulkProcessor||void 0===localStorage.bulkTime||Date.now()-localStorage.bulkTime>1e4?(ShortPixel.bulkProcessor=!0,localStorage.bulkPage=window.location.href.search("wp-short-pixel-bulk")>=0?1:0,localStorage.bulkTime=Date.now(),null==localStorage.getItem("bulkSecret")&&(localStorage.bulkSecret=Math.random().toString(36).substring(7)),checkBulkProcessingCallApi()):setBulkTimer(2e4)}function setBulkTimer(e){window.clearTimeout(bulkTimer),e>0&&(bulkTimer=window.setTimeout(checkBulkProgress,e))}function checkBulkProcessingCallApi(){var e={action:"shortpixel_image_processing","bulk-secret":localStorage.bulkSecret};jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:e,success:function(e){if(e.length>0){t=null;try{var t=JSON.parse(e)}catch(e){return void ShortPixel.retry(e.message)}ShortPixel.retries=0;var r=t.ImageID,i=jQuery("div.short-pixel-bulk-page").length>0;switch(t.Status&&t.Status!=ShortPixel.STATUS_SEARCHING&&(ShortPixel.returnedStatusSearching>=2&&jQuery(".bulk-notice-msg.bulk-searching").hide(),ShortPixel.returnedStatusSearching=0),t.Status){case ShortPixel.STATUS_NO_KEY:setCellMessage(r,t.Message,'<a class=\'button button-smaller button-primary\' href="https://shortpixel.com/wp-apikey" target="_blank">'+_spTr.getApiKey+"</a>"),showToolBarAlert(ShortPixel.STATUS_NO_KEY);break;case ShortPixel.STATUS_QUOTA_EXCEEDED:setCellMessage(r,t.Message,'<a class=\'button button-smaller button-primary\' href="https://shortpixel.com/login/" target="_blank">'+_spTr.extendQuota+"</a><a class='button button-smaller' href='javascript:ShortPixel.checkQuota()'>"+_spTr.check__Quota+"</a>"),showToolBarAlert(ShortPixel.STATUS_QUOTA_EXCEEDED),0==t.Stop&&setBulkTimer(5e3),ShortPixel.otherMediaUpdateActions(r,["quota","view"]);break;case ShortPixel.STATUS_FAIL:setCellMessage(r,t.Message,"<a class='button button-smaller button-primary' href=\"javascript:manualOptimization('"+r+"', true)\">"+_spTr.retry+"</a>"),showToolBarAlert(ShortPixel.STATUS_FAIL,t.Message,r),i&&(ShortPixel.bulkShowError(r,t.Message,t.Filename,t.CustomImageLink),t.BulkPercent&&progressUpdate(t.BulkPercent,t.BulkMsg),ShortPixel.otherMediaUpdateActions(r,["retry","view"])),console.log(t.Message),setBulkTimer(5e3);break;case ShortPixel.STATUS_EMPTY_QUEUE:console.log(t.Message),clearBulkProcessor(),hideToolBarAlert(t.Status);var s=jQuery("#bulk-progress");i&&s.length&&"2"!=t.BulkStatus&&(progressUpdate(100,"Bulk finished!"),jQuery("a.bulk-cancel").attr("disabled","disabled"),hideSlider(),setTimeout(function(){window.location.reload()},3e3));break;case ShortPixel.STATUS_SUCCESS:i&&(ShortPixel.bulkHideLengthyMsg(),ShortPixel.bulkHideMaintenanceMsg());var o=t.PercentImprovement;showToolBarAlert(ShortPixel.STATUS_SUCCESS,"");var a=ShortPixel.isCustomImageId(r)?"":ShortPixel.successActions(r,t.Type,t.ThumbsCount,t.ThumbsTotal,t.BackupEnabled,t.Filename);if(setCellMessage(r,ShortPixel.successMsg(r,o,t.Type,t.ThumbsCount,t.RetinasCount),a),jQuery("#post-"+r).length>0&&jQuery("#post-"+r).find(".filename").text(t.Filename),jQuery(".misc-pub-filename strong").length>0&&jQuery(".misc-pub-filename strong").text(t.Filename),ShortPixel.isCustomImageId(r)&&t.TsOptimized&&t.TsOptimized.length>0){n=jQuery(".list-overview .item-"+r);jQuery(n).children(".date").text(t.TsOptimized),jQuery(n).find(".row-actions .action-optimize").remove()}var l=jQuery(["restore","view","redolossy","redoglossy","redolossless"]).not(["redo"+t.Type]).get();ShortPixel.otherMediaUpdateActions(r,l);new PercentageAnimator("#sp-msg-"+r+" span.percent",o).animate(o),i&&void 0!==t.Thumb&&(t.BulkPercent&&progressUpdate(t.BulkPercent,t.BulkMsg),t.Thumb.length>0&&(sliderUpdate(r,t.Thumb,t.BkThumb,t.PercentImprovement,t.Filename),void 0!==t.AverageCompression&&0+t.AverageCompression>0&&(jQuery("#sp-avg-optimization").html('<input type="text" class="dial" value="'+Math.round(t.AverageCompression)+'"/>'),ShortPixel.percentDial("#sp-avg-optimization .dial",60)))),console.log("Server response: "+e),i&&void 0!==t.BulkPercent&&progressUpdate(t.BulkPercent,t.BulkMsg),setBulkTimer(5e3);break;case ShortPixel.STATUS_SKIP:1!==t.Silent&&ShortPixel.bulkShowError(r,t.Message,t.Filename,t.CustomImageLink);case ShortPixel.STATUS_ERROR:void 0!==t.Message&&(showToolBarAlert(ShortPixel.STATUS_SKIP,t.Message+" Image ID: "+r),setCellMessage(r,t.Message,"")),ShortPixel.otherMediaUpdateActions(r,["retry","view"]);case ShortPixel.STATUS_RETRY:console.log("Server response: "+e),showToolBarAlert(ShortPixel.STATUS_RETRY,""),i&&void 0!==t.BulkPercent&&progressUpdate(t.BulkPercent,t.BulkMsg),i&&t.Count>3&&ShortPixel.bulkShowLengthyMsg(r,t.Filename,t.CustomImageLink),setBulkTimer(5e3);break;case ShortPixel.STATUS_SEARCHING:console.log("Server response: "+e),ShortPixel.returnedStatusSearching++,ShortPixel.returnedStatusSearching>=2&&jQuery(".bulk-notice-msg.bulk-searching").show(),setBulkTimer(2500);break;case ShortPixel.STATUS_MAINTENANCE:ShortPixel.bulkShowMaintenanceMsg("maintenance"),setBulkTimer(6e4);break;case ShortPixel.STATUS_QUEUE_FULL:ShortPixel.bulkShowMaintenanceMsg("queue-full"),setBulkTimer(6e4);break;default:ShortPixel.retry("Unknown status "+t.Status+". Retrying...")}if(void 0!==r&&ShortPixel.isCustomImageId(r)){var n=jQuery(".list-overview .item-"+r);jQuery(n).find(".row-actions .action-optimize").remove(),t.actions&&jQuery(n).children(".actions").html(t.actions)}}},error:function(e){ShortPixel.retry(e.statusText)}})}function clearBulkProcessor(){ShortPixel.bulkProcessor=!1,localStorage.bulkTime=Date.now(),setBulkTimer(0),window.location.href.search("wp-short-pixel-bulk")>=0&&(localStorage.bulkPage=0)}function setCellMessage(e,t,r){var i=jQuery("#sp-msg-"+e);i.length>0&&(i.html("<div class='sp-column-actions'>"+r+"</div><div class='sp-column-info'>"+t+"</div>"),i.css("color","")),(i=jQuery("#sp-cust-msg-"+e)).length>0&&i.html("<div class='sp-column-info'>"+t+"</div>")}function manualOptimization(e,t){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' class='sp-loading-small'>Image waiting to be processed",""),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide"),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-alert"),jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var r={action:"shortpixel_manual_optimization",image_id:e,cleanup:t};jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:r,success:function(t){var r=JSON.parse(t);r.Status==ShortPixel.STATUS_SUCCESS?(setBulkTimer(2e3),ShortPixel.BULK_SECRET=!1):setCellMessage(e,void 0!==r.Message?r.Message:_spTr.thisContentNotProcessable,"")},error:function(t){r.action="shortpixel_check_status",jQuery.ajax({type:"GET",url:ShortPixel.AJAX_URL,data:r,success:function(t){var r=JSON.parse(t);r.Status!==ShortPixel.STATUS_SUCCESS&&setCellMessage(e,void 0!==r.Message?r.Message:_spTr.thisContentNotProcessable,"")}})}})}function reoptimize(e,t){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' class='sp-loading-small'>Image waiting to be reprocessed",""),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide"),jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var r={action:"shortpixel_redo",attachment_ID:e,type:t};jQuery.get(ShortPixel.AJAX_URL,r,function(t){(r=JSON.parse(t)).Status==ShortPixel.STATUS_SUCCESS?(setBulkTimer(2e3),ShortPixel.BULK_SECRET=!1):($msg=void 0!==r.Message?r.Message:_spTr.thisContentNotProcessable,setCellMessage(e,$msg,""),showToolBarAlert(ShortPixel.STATUS_FAIL,$msg))})}function optimizeThumbs(e){setCellMessage(e,"<img src='"+ShortPixel.WP_PLUGIN_URL+"/res/img/loading.gif' alt='"+_spTr.loading+"' class='sp-loading-small'>"+_spTr.imageWaitOptThumbs,""),jQuery("li.shortpixel-toolbar-processing").removeClass("shortpixel-hide"),jQuery("li.shortpixel-toolbar-processing").addClass("shortpixel-processing");var t={action:"shortpixel_optimize_thumbs",attachment_ID:e};jQuery.get(ShortPixel.AJAX_URL,t,function(r){(t=JSON.parse(r)).Status==ShortPixel.STATUS_SUCCESS?(setBulkTimer(2e3),ShortPixel.BULK_SECRET=!1):setCellMessage(e,void 0!==t.Message?t.Message:_spTr.thisContentNotProcessable,"")})}function dismissShortPixelNotice(e){jQuery("#short-pixel-notice-"+e).hide();var t={action:"shortpixel_dismiss_notice",notice_id:e};jQuery.get(ShortPixel.AJAX_URL,t,function(e){(t=JSON.parse(e)).Status==ShortPixel.STATUS_SUCCESS&&console.log("dismissed")})}function dismissFileError(){jQuery(".shortpixel-alert").hide();var e={action:"shortpixel_dismissFileError"};jQuery.get(ShortPixel.AJAX_URL,e,function(t){(e=JSON.parse(t)).Status==ShortPixel.STATUS_SUCCESS&&console.log("dismissed")})}function PercentageAnimator(e,t){this.animationSpeed=10,this.increment=2,this.curPercentage=0,this.targetPercentage=t,this.outputSelector=e,this.animate=function(e){this.targetPercentage=e,setTimeout(PercentageTimer.bind(null,this),this.animationSpeed)}}function PercentageTimer(e){e.curPercentage-e.targetPercentage<-e.increment?e.curPercentage+=e.increment:e.curPercentage-e.targetPercentage>e.increment?e.curPercentage-=e.increment:e.curPercentage=e.targetPercentage,jQuery(e.outputSelector).text(e.curPercentage+"%"),e.curPercentage!=e.targetPercentage&&setTimeout(PercentageTimer.bind(null,e),e.animationSpeed)}function progressUpdate(e,t){var r=jQuery("#bulk-progress");r.length&&(jQuery(".progress-left",r).css("width",e+"%"),jQuery(".progress-img",r).css("left",e+"%"),e>24?(jQuery(".progress-img span",r).html(""),jQuery(".progress-left",r).html(e+"%")):(jQuery(".progress-img span",r).html(e+"%"),jQuery(".progress-left",r).html("")),jQuery(".bulk-estimate").html(t))}function sliderUpdate(e,t,r,i,s){var o=jQuery(".bulk-slider div.bulk-slide:first-child");if(0!==o.length){"empty-slide"!=o.attr("id")&&o.hide(),o.css("z-index",1e3),jQuery(".bulk-img-opt",o).attr("src",""),void 0===r&&(r=""),r.length>0&&jQuery(".bulk-img-orig",o).attr("src","");var a=o.clone();a.attr("id","slide-"+e),jQuery(".bulk-img-opt",a).attr("src",t),r.length>0?(jQuery(".img-original",a).css("display","inline-block"),jQuery(".bulk-img-orig",a).attr("src",r)):jQuery(".img-original",a).css("display","none"),jQuery(".bulk-opt-percent",a).html('<input type="text" class="dial" value="'+i+'"/>'),jQuery(".bulk-slider").append(a),ShortPixel.percentDial("#"+a.attr("id")+" .dial",100),jQuery(".bulk-slider-container span.filename").html("&nbsp;&nbsp;"+s),"empty-slide"==o.attr("id")?(o.remove(),jQuery(".bulk-slider-container").css("display","block")):o.animate({left:o.width()+o.position().left},"slow","swing",function(){o.remove(),a.fadeIn("slow")})}}function hideSlider(){jQuery(".bulk-slider-container").css("display","none")}function showStats(){jQuery(".bulk-stats").length}function SPstringFormat(){var e=Array.prototype.slice.call(arguments);if(0!==e.length){var t=e.shift();for(i=0;i<e.length;i++)t=t.replace(new RegExp("\\{"+i+"\\}","gm"),e[i]);return t}}jQuery(document).ready(function(){ShortPixel.init()});var bulkTimer,ShortPixel=function(){function e(e){jQuery(e).is(":checked")?(jQuery("#width,#height").removeAttr("disabled"),SpioResize.lastW=!1,jQuery(".resize-type-wrap").show(800,window.SpioResize.run)):(jQuery("#width,#height").attr("disabled","disabled"),window.SpioResize.hide(),jQuery(".resize-type-wrap").hide(800))}function t(){jQuery("#shortpixel-hs-button-blind").remove(),jQuery("#shortpixel-hs-tools").remove(),jQuery("#hs-beacon").remove(),jQuery("#botbutton").remove(),jQuery("#shortpixel-hs-blind").remove()}return jQuery("#key").keypress(function(e){13==e.which&&jQuery("#valid").val("validate")}),{init:function(){void 0===ShortPixel.API_IS_ACTIVE&&(jQuery("table.wp-list-table.media").length>0&&jQuery('select[name^="action"] option:last-child').before('<option value="short-pixel-bulk">'+_spTr.optimizeWithSP+'</option><option value="short-pixel-bulk-lossy"> → '+_spTr.redoLossy+'</option><option value="short-pixel-bulk-glossy"> → '+_spTr.redoGlossy+'</option><option value="short-pixel-bulk-lossless"> → '+_spTr.redoLossless+'</option><option value="short-pixel-bulk-restore"> → '+_spTr.restoreOriginal+"</option>"),ShortPixel.setOptions(ShortPixelConstants[0]),jQuery("#backup-folder-size").length&&jQuery("#backup-folder-size").html(ShortPixel.getBackupSize()),"todo"==ShortPixel.MEDIA_ALERT&&jQuery("div.media-frame.mode-grid").length>0&&jQuery("div.media-frame.mode-grid").before('<div id="short-pixel-media-alert" class="notice notice-warning"><p>'+SPstringFormat(_spTr.changeMLToListMode,'<a href="upload.php?mode=list" class="view-list"><span class="screen-reader-text">'," </span>",'</a><a class="alignright" href="javascript:ShortPixel.dismissMediaAlert();">',"</a>")+"</p></div>"),jQuery(window).on("beforeunload",function(){1==ShortPixel.bulkProcessor&&clearBulkProcessor()}),checkQuotaExceededAlert(),checkBulkProgress())},setOptions:function(e){for(var t in e)ShortPixel[t]=e[t]},isEmailValid:function(e){return/^\w+([\.+-]?\w+)*@\w+([\.-]?\w+)*(\.\w{1,63})+$/.test(e)},updateSignupEmail:function(){var e=jQuery("#pluginemail").val();ShortPixel.isEmailValid(e)&&jQuery("#request_key").removeClass("disabled"),jQuery("#request_key").attr("href",jQuery("#request_key").attr("href").split("?")[0]+"?pluginemail="+e)},validateKey:function(e){jQuery("#valid").val("validate"),jQuery(e).parents("form").submit()},enableResize:e,setupGeneralTab:function(){var t=0;void 0!==document.wp_shortpixel_options&&(t=document.wp_shortpixel_options.compressionType);for(var r=0,i=null;r<t.length;r++)t[r].onclick=function(){this!==i&&(i=this),void 0===ShortPixel.setupGeneralTabAlert&&(alert(_spTr.alertOnlyAppliesToNewImages),ShortPixel.setupGeneralTabAlert=1)};ShortPixel.enableResize("#resize"),jQuery("#resize").change(function(){e(this)}),jQuery(".resize-sizes").blur(function(e){var t=jQuery(e.target);if(ShortPixel.resizeSizesAlert!=t.val()){ShortPixel.resizeSizesAlert=t.val();var r=jQuery("#min-"+t.attr("name")).val(),i=jQuery("#min-"+t.attr("name")).data("nicename");t.val()<Math.min(r,1024)?(r>1024?alert(SPstringFormat(_spTr.pleaseDoNotSetLesser1024,i)):alert(SPstringFormat(_spTr.pleaseDoNotSetLesserSize,i,i,r)),e.preventDefault(),t.focus()):this.defaultValue=t.val()}}),jQuery(".shortpixel-confirm").click(function(e){return!!confirm(e.target.getAttribute("data-confirm"))||(e.preventDefault(),!1)}),jQuery('input[name="removeExif"], input[name="png2jpg"]').on("change",function(){ShortPixel.checkExifWarning()}),ShortPixel.checkExifWarning(),jQuery('input[name="backupImages"]').on("change",function(){ShortPixel.checkBackUpWarning()}),ShortPixel.checkBackUpWarning()},apiKeyChanged:function(){jQuery(".wp-shortpixel-options .shortpixel-key-valid").css("display","none"),jQuery(".wp-shortpixel-options button#validate").css("display","inline-block")},setupAdvancedTab:function(){jQuery("input.remove-folder-button").click(function(){var e=jQuery(this).data("value"),t=jQuery(this).data("name");1==confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,t))&&(jQuery("#removeFolder").val(e),jQuery("#wp_shortpixel_options").submit())}),jQuery("input.recheck-folder-button").click(function(){var e=jQuery(this).data("value");1==confirm(SPstringFormat(_spTr.areYouSureStopOptimizing,e))&&(jQuery("#recheckFolder").val(e),jQuery("#wp_shortpixel_options").submit())})},checkThumbsUpdTotal:function(e){var t=jQuery("#"+(e.checked?"total":"main")+"ToProcess").val();jQuery("div.bulk-play span.total").text(t),jQuery("#displayTotal").text(t)},initSettings:function(){ShortPixel.adjustSettingsTabs(),ShortPixel.setupGeneralTab(),jQuery(window).resize(function(){ShortPixel.adjustSettingsTabs()}),jQuery("article.sp-tabs a.tab-link").click(function(e){var t=jQuery(e.target).data("id");ShortPixel.switchSettingsTab(t)}),jQuery("input[type=radio][name=deliverWebpType]").change(function(){"deliverWebpAltered"==this.value?window.confirm(_spTr.alertDeliverWebPAltered)?0==jQuery("input[type=radio][name=deliverWebpAlteringType]:checked").length&&jQuery("#deliverWebpAlteredWP").prop("checked",!0):jQuery(this).prop("checked",!1):"deliverWebpUnaltered"==this.value&&window.alert(_spTr.alertDeliverWebPUnaltered)})},switchSettingsTab:function(e){var t=e.replace("tab-",""),r="",i=jQuery("section#"+e);jQuery('input[name="display_part"]').val(t);var s=window.location.href.toString();if(s.indexOf("?")>0){var o=s.substring(0,s.indexOf("?"));o+="?"+jQuery.param({page:"wp-shortpixel-settings",part:t}),window.history.replaceState({},document.title,o)}if(i.length>0&&(jQuery("section").removeClass("sel-tab"),jQuery("section .wp-shortpixel-tab-content").fadeOut(50),jQuery(i).addClass("sel-tab"),jQuery(i).find(".wp-shortpixel-tab-content").fadeIn(50,ShortPixel.adjustSettingsTabs)),"undefined"!=typeof HS&&void 0!==HS.beacon.suggest){switch(t){case"settings":r=shortpixel_suggestions_settings;break;case"adv-settings":r=shortpixel_suggestions_adv_settings;break;case"cloudflare":case"stats":r=shortpixel_suggestions_cloudflare}HS.beacon.suggest(r)}},adjustSettingsTabs:function(){jQuery(".wso.banner").css("opacity",1)},onBulkThumbsCheck:function(e){e.checked?(jQuery("#with-thumbs").css("display","inherit"),jQuery("#without-thumbs").css("display","none")):(jQuery("#without-thumbs").css("display","inherit"),jQuery("#with-thumbs").css("display","none"))},dismissMediaAlert:function(){var e={action:"shortpixel_dismiss_media_alert"};jQuery.get(ShortPixel.AJAX_URL,e,function(t){"success"==(e=JSON.parse(t)).Status&&jQuery("#short-pixel-media-alert").hide()})},closeHelpPane:t,dismissHelpPane:function(){t(),dismissShortPixelNotice("help")},checkQuota:function(){var e={action:"shortpixel_check_quota",nonce:ShortPixelActions.nonce_check_quota,return_json:!0};jQuery.post(ShortPixel.AJAX_URL,e,function(e){console.log("quota refreshed"),console.log(e),window.location.href=e.redirect})},percentDial:function(e,t){jQuery(e).knob({readOnly:!0,width:t,height:t,fgColor:"#1CAECB",format:function(e){return e+"%"}})},successMsg:function(e,t,r,i,s){return(t>0?"<div class='sp-column-info'>"+_spTr.reducedBy+" <strong><span class='percent'>"+t+"%</span></strong> ":"")+(t>0&&t<5?"<br>":"")+(t<5?_spTr.bonusProcessing:"")+(r.length>0?" ("+r+")":"")+(0+i>0?"<br>"+SPstringFormat(_spTr.plusXthumbsOpt,i):"")+(0+s>0?"<br>"+SPstringFormat(_spTr.plusXretinasOpt,s):"")+"</div>"},successActions:function(e,t,r,i,s,o){if(1==s){var a=jQuery(".sp-column-actions-template").clone();if(!a.length)return!1;var l;return l=0==t.length?["lossy","lossless"]:["lossy","glossy","lossless"].filter(function(e){return!(e==t)}),a.html(a.html().replace(/__SP_ID__/g,e)),"pdf"==o.substr(o.lastIndexOf(".")+1).toLowerCase()&&jQuery(".sp-action-compare",a).remove(),0==r&&i>0?a.html(a.html().replace("__SP_THUMBS_TOTAL__",i)):(jQuery(".sp-action-optimize-thumbs",a).remove(),jQuery(".sp-dropbtn",a).removeClass("button-primary")),a.html(a.html().replace(/__SP_FIRST_TYPE__/g,l[0])),a.html(a.html().replace(/__SP_SECOND_TYPE__/g,l[1])),a.html()}return""},otherMediaUpdateActions:function(e,t){if(e=e.substring(2),jQuery(".shortpixel-other-media").length){for(var r=["optimize","retry","restore","redo","quota","view"],i=0,s=r.length;i<s;i++)jQuery("#"+r[i]+"_"+e).css("display","none");for(var i=0,s=t.length;i<s;i++)jQuery("#"+t[i]+"_"+e).css("display","")}},retry:function(e){ShortPixel.retries++,isNaN(ShortPixel.retries)&&(ShortPixel.retries=1),ShortPixel.retries<6?(console.log("Invalid response from server (Error: "+e+"). Retrying pass "+(ShortPixel.retries+1)+"..."),setBulkTimer(5e3)):(ShortPixel.bulkShowError(-1,"Invalid response from server received 6 times. Please retry later by reloading this page, or <a href='https://shortpixel.com/contact' target='_blank'>contact support</a>. (Error: "+e+")",""),console.log("Invalid response from server 6 times. Giving up."))},initFolderSelector:function(){jQuery(".select-folder-button").click(function(){jQuery(".sp-folder-picker-shade").fadeIn(100),jQuery(".shortpixel-modal.modal-folder-picker").show();var e=jQuery(".sp-folder-picker");e.parent().css("margin-left",-e.width()/2),e.fileTree({script:ShortPixel.browseContent,multiFolder:!1})}),jQuery(".shortpixel-modal input.select-folder-cancel, .sp-folder-picker-shade").click(function(){jQuery(".sp-folder-picker-shade").fadeOut(100),jQuery(".shortpixel-modal.modal-folder-picker").hide()}),jQuery(".shortpixel-modal input.select-folder").click(function(e){if(t=jQuery("UL.jqueryFileTree LI.directory.selected"),0==jQuery(t).length)var t=jQuery("UL.jqueryFileTree LI.selected").parents(".directory");var r=jQuery(t).children("a").attr("rel");if(void 0!==r)if(r=r.trim()){var i=jQuery("#customFolderBase").val()+r;i=i.replace(/\/\//,"/"),console.debug("FullPath"+i),jQuery("#addCustomFolder").val(i),jQuery("#addCustomFolderView").val(i),jQuery(".sp-folder-picker-shade").fadeOut(100),jQuery(".shortpixel-modal.modal-folder-picker").css("display","none"),jQuery("#saveAdvAddFolder").removeClass("hidden")}else alert("Please select a folder from the list.")})},browseContent:function(e){e.action="shortpixel_browse_content";var t="";return jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:e,success:function(e){t=e},async:!1}),t},getBackupSize:function(){var e="";return jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_backup_size"},success:function(t){e=t},async:!1}),e},newApiKey:function(e){if(!jQuery("#tos").is(":checked"))return e.preventDefault(),jQuery("#tos-robo").fadeIn(400,function(){jQuery("#tos-hand").fadeIn()}),void jQuery("#tos").click(function(){jQuery("#tos-robo").css("display","none"),jQuery("#tos-hand").css("display","none")});if(jQuery("#request_key").addClass("disabled"),jQuery("#pluginemail_spinner").addClass("is-active"),ShortPixel.updateSignupEmail(),ShortPixel.isEmailValid(jQuery("#pluginemail").val())){jQuery("#pluginemail-error").css("display","none");var t={action:"shortpixel_new_api_key",email:jQuery("#pluginemail").val()};jQuery.ajax({type:"POST",async:!1,url:ShortPixel.AJAX_URL,data:t,success:function(t){data=JSON.parse(t),"success"==data.Status?(e.preventDefault(),window.location.reload()):"invalid"==data.Status&&(jQuery("#pluginemail-error").html("<b>"+data.Details+"</b>"),jQuery("#pluginemail-error").css("display",""),jQuery("#pluginemail-info").css("display","none"),e.preventDefault())}}),jQuery("#request_key").removeAttr("onclick")}else jQuery("#pluginemail-error").css("display",""),jQuery("#pluginemail-info").css("display","none"),e.preventDefault();jQuery("#request_key").removeClass("disabled"),jQuery("#pluginemail_spinner").removeClass("is-active")},proposeUpgrade:function(){jQuery("#shortPixelProposeUpgrade .sp-modal-body").addClass("sptw-modal-spinner"),jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(""),jQuery("#shortPixelProposeUpgradeShade").css("display","block"),jQuery("#shortPixelProposeUpgrade").removeClass("shortpixel-hide"),jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_propose_upgrade"},success:function(e){jQuery("#shortPixelProposeUpgrade .sp-modal-body").removeClass("sptw-modal-spinner"),jQuery("#shortPixelProposeUpgrade .sp-modal-body").html(e)}})},closeProposeUpgrade:function(){jQuery("#shortPixelProposeUpgradeShade").css("display","none"),jQuery("#shortPixelProposeUpgrade").addClass("shortpixel-hide"),ShortPixel.toRefresh&&ShortPixel.checkQuota()},bulkShowLengthyMsg:function(e,t,r){var i=jQuery(".bulk-notice-msg.bulk-lengthy");if(0!=i.length){var s=jQuery("a",i);s.text(t),r?s.attr("href",r):s.attr("href",s.data("href").replace("__ID__",e)),i.css("display","block")}},bulkHideLengthyMsg:function(){jQuery(".bulk-notice-msg.bulk-lengthy").css("display","none")},bulkShowMaintenanceMsg:function(e){var t=jQuery(".bulk-notice-msg.bulk-"+e);0!=t.length&&t.css("display","block")},bulkHideMaintenanceMsg:function(e){jQuery(".bulk-notice-msg.bulk-"+e).css("display","none")},bulkShowError:function(e,t,r,i){var s=jQuery("#bulk-error-template");if(0!=s.length){var o=s.clone();o.attr("id","bulk-error-"+e),-1==e?(jQuery("span.sp-err-title",o).remove(),o.addClass("bulk-error-fatal")):(jQuery("img",o).remove(),jQuery("#bulk-error-".id).remove()),jQuery("span.sp-err-content",o).html(t);var a=jQuery("a.sp-post-link",o);i?a.attr("href",i):a.attr("href",a.attr("href").replace("__ID__",e)),a.text(r),s.after(o),o.css("display","block")}},confirmBulkAction:function(e,t){return!!confirm(_spTr["confirmBulk"+e])||(t.stopPropagation(),t.preventDefault(),!1)},checkRandomAnswer:function(e){var t=jQuery(e.target).val(),r=jQuery('input[name="random_answer"]').val(),i=jQuery('input[name="random_answer"]').data("target");t==r?(jQuery(i).removeClass("disabled").prop("disabled",!1),jQuery(i).removeAttr("aria-disabled")):jQuery(i).addClass("disabled").prop("disabled",!0)},removeBulkMsg:function(e){jQuery(e).parent().parent().remove()},isCustomImageId:function(e){return"C-"==e.substring(0,2)},openImageMenu:function(e){e.preventDefault(),this.menuCloseEvent||(jQuery(window).click(function(e){e.target.matches(".sp-dropbtn")||jQuery(".sp-dropdown.sp-show").removeClass("sp-show")}),this.menuCloseEvent=!0);var t=e.target.parentElement.classList.contains("sp-show");jQuery(".sp-dropdown.sp-show").removeClass("sp-show"),t||e.target.parentElement.classList.add("sp-show")},menuCloseEvent:!1,loadComparer:function(e){this.comparerData.origUrl=!1,!1===this.comparerData.cssLoaded&&(jQuery("<link>").appendTo("head").attr({type:"text/css",rel:"stylesheet",href:this.WP_PLUGIN_URL+"/res/css/twentytwenty.min.css"}),this.comparerData.cssLoaded=2),!1===this.comparerData.jsLoaded&&(jQuery.getScript(this.WP_PLUGIN_URL+"/res/js/jquery.twentytwenty.min.js",function(){ShortPixel.comparerData.jsLoaded=2,ShortPixel.comparerData.origUrl.length>0&&ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}),this.comparerData.jsLoaded=1),!1===this.comparerData.origUrl&&(jQuery.ajax({type:"POST",url:ShortPixel.AJAX_URL,data:{action:"shortpixel_get_comparer_data",id:e},success:function(e){data=JSON.parse(e),jQuery.extend(ShortPixel.comparerData,data),2==ShortPixel.comparerData.jsLoaded&&ShortPixel.displayComparerPopup(ShortPixel.comparerData.width,ShortPixel.comparerData.height,ShortPixel.comparerData.origUrl,ShortPixel.comparerData.optUrl)}}),this.comparerData.origUrl="")},displayComparerPopup:function(e,t,r,i){var s=e,o=t<150||e<350,a=jQuery(o?"#spUploadCompareSideBySide":"#spUploadCompare"),l=jQuery(".sp-modal-shade");o||jQuery("#spCompareSlider").html('<img alt="'+_spTr.originalImage+'" class="spUploadCompareOriginal"/><img alt="'+_spTr.optimizedImage+'" class="spUploadCompareOptimized"/>'),e=Math.max(350,Math.min(800,e<350?2*(e+25):t<150?e+25:e)),t=Math.max(150,o?s>350?2*(t+45):t+45:t*e/s);var n="-"+Math.round(e/2);jQuery(".sp-modal-body",a).css("width",e),jQuery(".shortpixel-slider",a).css("width",e),a.css("width",e),a.css("marginLeft",n+"px"),jQuery(".sp-modal-body",a).css("height",t),a.show(),l.show(),o||jQuery("#spCompareSlider").twentytwenty({slider_move:"mousemove"}),jQuery(".sp-close-button").on("click",ShortPixel.closeComparerPopup),jQuery(document).on("keyup.sp_modal_active",ShortPixel.closeComparerPopup),jQuery(".sp-modal-shade").on("click",ShortPixel.closeComparerPopup);var u=jQuery(".spUploadCompareOptimized",a);jQuery(".spUploadCompareOriginal",a).attr("src",r),setTimeout(function(){jQuery(window).trigger("resize")},1e3),u.load(function(){jQuery(window).trigger("resize")}),u.attr("src",i)},closeComparerPopup:function(e){jQuery("#spUploadCompareSideBySide").hide(),jQuery("#spUploadCompare").hide(),jQuery(".sp-modal-shade").hide(),jQuery(document).unbind("keyup.sp_modal_active"),jQuery(".sp-modal-shade").off("click"),jQuery(".sp-close-button").off("click")},convertPunycode:function(e){var t=document.createElement("a");return t.href=e,e.indexOf(t.protocol+"//"+t.hostname)<0?t.href:e.replace(t.protocol+"//"+t.hostname,t.protocol+"//"+t.hostname.split(".").map(function(e){return sp_punycode.toASCII(e)}).join("."))},checkExifWarning:function(){!jQuery('input[name="removeExif"]').is(":checked")&&jQuery('input[name="png2jpg"]').is(":checked")?jQuery(".exif_warning").fadeIn():jQuery(".exif_warning").fadeOut(),!jQuery('input[name="removeExif"]').is(":checked")&&jQuery(".exif_imagick_warning").data("imagick")<=0?jQuery(".exif_imagick_warning").fadeIn():jQuery(".exif_imagick_warning").fadeOut()},checkBackUpWarning:function(){jQuery('input[name="backupImages"]').is(":checked")?jQuery(".backup_warning").fadeOut():jQuery(".backup_warning").fadeIn()},comparerData:{cssLoaded:!1,jsLoaded:!1,origUrl:!1,optUrl:!1,width:0,height:0},toRefresh:!1,resizeSizesAlert:!1,returnedStatusSearching:0,optInHelp:function(e,t){var r={action:"shortpixel_helpscoutOptin",toggle:e.currentTarget.toggleParam},i=jQuery(e.target);jQuery.post(ShortPixel.AJAX_URL,r,function(e){"success"==e.Status&&i.parents(".shortpixel.notice").fadeOut()})}}}();!function(e,t,r){t.SpioResize={image:{width:0,height:0},lag:2e3,step1:!1,step2:!1,step3:!1,sizeRule:null,initialized:!1,lastW:!1,lastH:!1,lastType:!1},SpioResize.hide=function(){e(".presentation-wrap").css("opacity",0)},SpioResize.animate=function(e,t,r,i,s){e.animate(t,1e3,"swing",function(){SpioResize.step3=setTimeout(function(){document.styleSheets[0].deleteRule(SpioResize.sizeRule),r.animate(i,1e3,"swing",function(){SpioResize.sizeRule=document.styleSheets[0].insertRule(s)})},600)})},SpioResize.run=function(){if(!SpioResize.initialized){var t=e(r);t.on("input change",'input[name="resizeWidth"], input[name="resizeHeight"]',function(e){clearTimeout(SpioResize.change),SpioResize.changeDone=!0,SpioResize.changeFired=!1,SpioResize.change=setTimeout(function(){SpioResize.changeFired=!0,SpioResize.run()},1500)}),t.on("blur",'input[name="resizeWidth"], input[name="resizeHeight"]',function(e){SpioResize.changeFired||(clearTimeout(SpioResize.change),SpioResize.change=setTimeout(function(){SpioResize.run()},1500))}),t.on("change",'input[name="resizeType"]',function(e){SpioResize.run()}),SpioResize.initialized=!0}var i=e("#width").val(),s=e("#height").val();if(i&&s){var o=e("#resize_type_outer").is(":checked")?"outer":"inner";if(i!==SpioResize.lastW||s!==SpioResize.lastH||o!==SpioResize.lastType){SpioResize.hide(),SpioResize.lastW=i,SpioResize.lastH=s,SpioResize.lastType=o;var a=Math.round(120*Math.sqrt(i/s)),l=Math.round(120*Math.sqrt(s/i)),n=a/l;a>280&&(a=280,l=Math.round(280/n)),l>150&&(l=150,a=Math.round(150*n));var u=e("img.spai-resize-img");u.css("width",""),u.css("height",""),u.css("margin","0px");var c=e("div.spai-resize-frame");c.css("display","none"),c.css("width",a+"px"),c.css("height",l+"px"),c.css("margin",Math.round((156-l)/2)+"px auto 0"),clearTimeout(SpioResize.step1),clearTimeout(SpioResize.step2),clearTimeout(SpioResize.step3),u.stop(),c.stop(),null!==SpioResize.sizeRule&&(document.styleSheets[0].deleteRule(SpioResize.sizeRule),SpioResize.sizeRule=null),SpioResize.sizeRule=document.styleSheets[0].insertRule('.spai-resize-frame:after { content: "'+i+" × "+s+'"; }'),c.addClass("spai-resize-frame"),e(".presentation-wrap").animate({opacity:1},500,"swing",function(){c.css("display","block"),SpioResize.step2=setTimeout(function(){if("outer"==o)if(15/8>n)var e={height:l+"px",margin:Math.round((160-l)/2)+"px 0px"},t=l*(15/8),r={width:Math.round(t)+"px"},p='.spai-resize-frame:after { content: "'+Math.round(t*i/a)+" × "+s+'"; }';else var e={width:a+"px",margin:Math.round((160-a/(15/8))/2)+"px 0px"},h=a/(15/8),r={height:Math.round(h)+"px",margin:Math.round((156-h)/2)+"px auto 0"},p='.spai-resize-frame:after { content: "'+i+" × "+Math.round(h*i/a)+'"; }';else if(15/8>n)var e={width:a,margin:Math.round((160-a/(15/8))/2)+"px 0px"},h=a/(15/8),r={height:Math.round(h)+"px",margin:Math.round((156-h)/2)+"px auto 0"},p='.spai-resize-frame:after { content: "'+i+" × "+Math.round(h*i/a)+'"; }';else var e={height:l,margin:Math.round((160-l)/2)+"px 0px"},t=l*(15/8),r={width:Math.round(t)+"px"},p='.spai-resize-frame:after { content: "'+Math.round(t*i/a)+" × "+s+'"; }';SpioResize.animate(u,e,c,r,p)},1e3)})}}},e(function(){e("#resize").is("checked")&&SpioResize.run()})}(jQuery,window,document);