0byt3m1n1
Path:
/
var
/
lib
/
vz
/
www
/
clients
/
client6
/
web11
/
web
/
wp-content
/
plugins
/
wp-optimize
/
js
/
[
Home
]
File: smush.min.js
jQuery(document).ready(function(s){WP_Optimize_Smush=WP_Optimize_Smush()});var WP_Optimize_Smush=function(){function s(s){var s="undefined"==typeof s||s,e={use_cache:s};console.log("Loading information about uncompressed images."),I.html("..."),z.hide(),d(!0),y("get_ui_update",e,function(s){console.log("Information about uncompressed images loaded."),k(s,m),p(),d(!1)})}function e(){x("#wpo_smush_images_grid input:checked").each(function(){X.push(x(this).val())}),data={optimization_id:"smush",selected_images:X,smush_options:{compression_server:x("input[name='compression_server']:checked").val(),image_quality:x("#image_quality").val(),lossy_compression:x("#smush-lossy-compression").is(":checked"),back_up_original:x("#smush-backup-original").is(":checked"),preserve_exif:x("#smush-preserve-exif").is(":checked")}},r(),y("process_bulk_smush",data)}function o(){x("#wpo_smush_images_save_options_spinner").show().delay(3e3).fadeOut(),x("#enable_custom_compression").is(":checked")?(image_quality=x("#custom_compression_slider").val(),lossy_compression=image_quality<100):(image_quality=x("#enable_lossy_compression").is(":checked")?90:100,lossy_compression=image_quality<100);var s={compression_server:x("input[name='compression_server']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:x("#smush-backup-original").is(":checked"),preserve_exif:x("#smush-preserve-exif").is(":checked"),autosmush:x("#smush-automatically").is(":checked")};y("update_smush_options",s,function(s){x("#wpo_smush_images_save_options_spinner").hide(),s.hasOwnProperty("saved")&&s.saved?(x("#wpo_smush_images_save_options_done").show().delay(3e3).fadeOut(),U.hide()):(x("#wpo_smush_images_save_options_fail").show().delay(3e3).fadeOut(),U.show())})}function a(){L=!0,Q++,seconds=Q%60+""<10?"0"+Q%60:Q%60,minutes=parseInt(Q/60)+""<10?"0"+parseInt(Q/60):parseInt(Q/60),x("#smush_stats_timer").text(minutes+":"+seconds),n(Q)}function n(s){0==s%3&&t(),0==s%60&&y("process_pending_images",{},function(s){k(s,_)})}function t(s){data={update_ui:!0,use_cache:!1},y("get_ui_update",data,function(s){k(s,_)})}function m(s){if(O.html(""),s&&s.hasOwnProperty("unsmushed_images")){s.unsmushed_images,s.pending_tasks;0==s.unsmushed_images.length&&0==s.pending_tasks&&O.text(wposmush.all_images_compressed).wrapInner("<h2 class='center'> </h2>"),0!=s.pending_tasks&&z.show().find(".red").text(s.pending);var e="post.php?post=",o="&action=edit";for(blog_id in s.unsmushed_images)for(i in s.unsmushed_images[blog_id])s.unsmushed_images[blog_id].hasOwnProperty(i)&&(image=s.unsmushed_images[blog_id][i],h(image,s.admin_urls[blog_id]+e+image.id+o))}}function r(){L||(v(x("#wpo_smush_images_information_container")),service=x('.compression_server input[type="radio"]:checked + label small').text(),x("#wpo_smush_images_information_server").html(service),x("#smush_stats_pending_images").html("..."),x("#smush_stats_completed_images").html("..."),x("#smush_stats_bytes_saved").html("..."),x("#smush_stats_percent_saved").html("..."),x("#smush_stats_timer").html("..."),R=window.setInterval(a,1e3),d(!0))}function _(s){x("#smush_stats_pending_images").html(s.pending_tasks),x("#smush_stats_completed_images").html(s.completed_task_count),x("#smush_stats_bytes_saved").html(s.bytes_saved),x("#smush_stats_percent_saved").html(s.percent_saved),1==s.smush_complete&&setTimeout(u,1500)}function u(){data={update_ui:!0,use_cache:!1,image_list:X},y("get_ui_update",data,function(s){summary=s.session_stats,0!=s.completed_task_count&&(summary+="<hr>"+s.summary),c(summary)})}function c(s){B||(x("#summary-message").html(s),l(),v(x("#smush-complete-summary")),B=!0)}function l(){Q=0,L=!1,B=!1,X=[],window.clearInterval(R),d(!1)}function h(s,e){image_html='<div class="wpo_smush_image" data-filesize="'+s.filesize+'">',image_html+='<a class="button" href="'+e+'" target="_blank"> '+wposmush.view_image+" </a>",image_html+='<input id="wpo_smush_'+s.id+'" type="checkbox" class="wpo_smush_image__input" value="'+s.id+'">',image_html+='<label for="wpo_smush_'+s.id+'"></a>',image_html+='<div class="thumbnail">',image_html+='<img class="lazyload" src="'+s.thumb_url+'">',image_html+="</div></label></div>",O.append(image_html)}function p(){features=wposmush.features,service=x("input[name^='compression_server']:checked").val();for(feature in features[service])x("."+feature).prop("disabled",!features[service][feature]),x("."+feature).prop("checked",features[service][feature]);x(".wpo_smush_image").each(function(){x(this).data("filesize")>wposmush.features[service].max_filesize?x(this).hide():x(this).show()})}function d(s){x.each([W,j,J,U,S,q],function(e,o){o.prop("disabled",s)}),s?(x("#wpo_smush_images_refresh").hide(),x(".wpo_smush_images_loader").show()):(x("#wpo_smush_images_refresh").show(),x(".wpo_smush_images_loader").hide())}function g(s,e){0!=s.length&&(data={selected_image:s,smush_options:e},v(wposmush.compress_single_image_dialog),y("compress_single_image",data,function(s){k(s,w)}))}function f(s){0!=s.length&&(v(wposmush.please_wait,x.unblockUI),data={selected_image:s},y("restore_single_image",data,function(s){k(s,w)}))}function w(s){s.hasOwnProperty("success")&&s.success?(x("#smush-information").text(s.summary),v(x("#smush-information-modal"),x.unblockUI),"compress"==s.operation?(x(".wpo_smush_single_image").hide(),x(".wpo_restore_single_image").show(),x("#smush_info").text(s.summary),s.restore_possible?x(".restore_possible").show():x(".restore_possible").hide()):(x(".wpo_smush_single_image").show(),x(".wpo_restore_single_image").hide())):(x("#smush-information").text(s.error_message),v(x("#smush-information-modal"),x.unblockUI))}function v(s,e){x.blockUI({message:s,onOverlayClick:e,css:{width:"400px",padding:"20px",cursor:"pointer"}})}function k(s,e){s&&s.hasOwnProperty("status")&&s.status?e&&e(s):(alert(wposmush.error_unexpected_response),console.log(s))}function b(s){s.charAt(0),s.charAt(s.length-1);try{var e=JSON.parse(s);return e}catch(o){console.log("WPO: Exception when trying to parse JSON (1) - will attempt to fix/re-parse"),console.log(s)}var i=s.indexOf("{"),a=s.lastIndexOf("}");if(i>-1&&a>-1){var n=s.slice(i,a+1);try{var t=JSON.parse(n);return console.log("WPO: JSON re-parse successful"),t}catch(o){throw console.log("WPO: Exception when trying to parse JSON (2)"),o}}throw"WPO: could not parse the JSON"}function y(s,e,o,i){i="undefined"==typeof i||i,e=x.isEmptyObject(e)?{use_cache:!1}:e;var a={action:"updraft_smush_ajax",subaction:s,nonce:wposmush.smush_ajax_nonce,data:e},n={type:"POST",url:ajaxurl,data:a,success:function(s){if(i){try{var e=b(s)}catch(a){console.log("smush_manager_send_command JSON parse error"),console.log(a),console.log(s),alert(wposmush.error_unexpected_response)}"undefined"!=typeof o&&o(e)}else"undefined"!=typeof o&&o(s)},error:function(s,e,i){console.log("smush_manager_send_command AJAX parse error: "+e+" ("+i+")"),"undefined"!=typeof o?o(s):(console.log(s),alert(wposmush.error_unexpected_response))},dataType:"text"};x.ajax(n)}var x=jQuery,O=(x("#wp-optimize-images-nav-tab-smush"),x("#wpo_smush_images_grid")),I=x("#smush_info_images"),z=x("#wpo_smush_images_pending_tasks_container"),q=x("#wpo_smush_images_pending_tasks_button"),P=x("#wpo_smush_images_pending_tasks_cancel_button"),U=x(".wpo-fieldgroup #wpo_smush_images_save_options_button"),S=x("#wpo_smush_images_refresh"),j=x("#wpo_smush_images_select_all"),J=x("#wpo_smush_images_select_none"),N=x("#wpo_smush_clear_stats_btn"),W=x("#wpo_smush_images_btn"),A=x(".wpo_smush_single_image .button"),T=x(".wpo_restore_single_image .button"),C=x(".wpo_smush_get_logs"),E=x(".compression_server"),Q=0,L=!1,R=0,X=[],B=!1;x("#wp-optimize-nav-tab-wrapper .nav-tab").on("click",function(){x("#wp-optimize-nav-tab-wrapper .nav-tab-active").is("#wp-optimize-nav-tab-wpo_images-smush")&&s()}),x("#wp-optimize-nav-tab-wrapper .nav-tab-active").is("#wp-optimize-nav-tab-wpo_images-smush")&&s(),x("#smush-metabox").length>0&&p(),E.on("change",function(s){p(),o()}),W.off().on("click",function(){return 0==x('#wpo_smush_images_grid input[type="checkbox"]:checked').length?(x("#smush-information-modal #smush-information").text(wposmush.please_select_images),void v(x("#smush-information-modal"),x.unblockUI)):(x("#smush-information-modal #smush-information").text(wposmush.server_check),v(x("#smush-information-modal")),data={server:x("input[name='compression_server']:checked").val()},void y("check_server_status",data,function(s){s.online?e():(s.error?(error_message=s.error+"<br>"+wposmush.server_error,x("#smush-information-modal #smush-information").html(error_message)):x("#smush-information-modal #smush-information").text(wposmush.server_error),v(x("#smush-information-modal"),x.unblockUI))}))}),S.off().on("click",function(){s()}),j.off().on("click",function(){x('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!0)}),J.off().on("click",function(){x('#wpo_smush_images_grid input[type="checkbox"]').prop("checked",!1)}),C.off().on("click",function(){x("#log-panel").text("Please wait, fetching logs."),y("get_smush_logs",{},function(s){x.blockUI({message:x("#smush-log-modal"),onOverlayClick:x.unblockUI(),css:{width:"80%",height:"80%",top:"15%",left:"15%"}}),x("#log-panel").html("<pre>"+s+"</pre>"),download_link=ajaxurl+"?action=updraft_smush_ajax&subaction=get_smush_logs&nonce="+wposmush.smush_ajax_nonce,x("#smush-log-modal a").attr("href",download_link),console.log(download_link)},!1)}),U.off().on("click",function(s){o()}),N.off().on("click",function(s){x("#wpo_smush_images_clear_stats_spinner").show().delay(3e3).fadeOut(),y("clear_smush_stats",{},function(s){x("#wpo_smush_images_clear_stats_spinner").hide(),x("#wpo_smush_images_clear_stats_done").show().delay(3e3).fadeOut()})}),q.off().on("click",function(s){x("#smush-information-modal #smush-information").text(wposmush.server_check),v(x("#smush-information-modal"),x.unblockUI),data={server:x("input[name='compression_server']:checked").val()},y("check_server_status",data,function(s){s.online?(r(),y("process_pending_images",{},function(s){k(s,_)})):(s.error?(error_message=s.error+"<br>"+wposmush.server_error,x("#smush-information-modal #smush-information").html(error_message)):x("#smush-information-modal #smush-information").text(wposmush.server_error),v(x("#smush-information-modal"),x.unblockUI))})}),P.on("click",function(s){y("clear_pending_images",{},function(s){s.status&&z.delay(3e3).fadeOut()})}),A.on("click",function(){var s=x(this).attr("id");s&&(image_id=s.substring(15),x("#enable_custom_compression").is(":checked")?(image_quality=x("#custom_compression_slider").val(),lossy_compression=image_quality<100):(image_quality=x("#enable_lossy_compression").is(":checked")?90:100,lossy_compression=image_quality<100),smush_options={compression_server:x("input[name='compression_server_"+image_id+"']:checked").val(),image_quality:image_quality,lossy_compression:lossy_compression,back_up_original:x("#smush_backup_"+image_id).is(":checked"),preserve_exif:x("#smush_exif_"+image_id).is(":checked")},console.log("Compressing Image : "+image_id),data={server:x("input[name='compression_server_"+image_id+"']:checked").val()},v(wposmush.server_check),y("check_server_status",data,function(s){s.online?g(image_id,smush_options):s.error?(error_message=s.error+"<br>"+wposmush.server_error,v(error_message,x.unblockUI)):v(wposmush.server_error,x.unblockUI)}))}),T.on("click",function(){var s=x(this).attr("id");s&&(image_id=s.substring(25),console.log("Restoring Image : "+image_id),f(image_id))}),x("#smush-log-modal .close, #smush-information-modal .information-modal-close").on("click",function(){x.unblockUI()}),x(".wpo_smush_stats_cta_btn, .wpo_smush_get_logs, #smush-complete-summary .close").on("click",function(){x.unblockUI(),s(),setTimeout(l,500)}),x(".toggle-smush-advanced").on("click",function(){x(".smush-advanced").toggle("fast")}),x(".wpo-fieldgroup .autosmush input, .wpo-fieldgroup .compression_level, .wpo-fieldgroup .image_options").on("change",function(){o()}),x(".smush-options.compression_level").change(function(){x("#enable_custom_compression").is(":checked")?x(".smush-options.custom_compression").show():x(".smush-options.custom_compression").hide()})};