"undefined"==typeof jQuery.migrateMute&&(jQuery.migrateMute=!0),function(t){"use strict";"function"==typeof define&&define.amd?define(["jquery"],function(e){return t(e,window)}):"object"==typeof module&&module.exports?module.exports=t(require("jquery"),window):t(jQuery,window)}(function(s,n){"use strict";function e(e){return 0<=function(e,t){for(var r=/^(\d+)\.(\d+)\.(\d+)/,n=r.exec(e)||[],o=r.exec(t)||[],a=1;a<=3;a++){if(+o[a]<+n[a])return 1;if(+n[a]<+o[a])return-1}return 0}(s.fn.jquery,e)}s.migrateVersion="3.4.1";var t=Object.create(null);s.migrateDisablePatches=function(){for(var e=0;e<arguments.length;e++)t[arguments[e]]=!0},s.migrateEnablePatches=function(){for(var e=0;e<arguments.length;e++)delete t[arguments[e]]},s.migrateIsPatchEnabled=function(e){return!t[e]},n.console&&n.console.log&&(s&&e("3.0.0")&&!e("5.0.0")||n.console.log("JQMIGRATE: jQuery 3.x-4.x REQUIRED"),s.migrateWarnings&&n.console.log("JQMIGRATE: Migrate plugin loaded multiple times"),n.console.log("JQMIGRATE: Migrate is installed"+(s.migrateMute?"":" with logging active")+", version "+s.migrateVersion));var o={};function u(e,t){var r=n.console;!s.migrateIsPatchEnabled(e)||s.migrateDeduplicateWarnings&&o[t]||(o[t]=!0,s.migrateWarnings.push(t+" ["+e+"]"),r&&r.warn&&!s.migrateMute&&(r.warn("JQMIGRATE: "+t),s.migrateTrace&&r.trace&&r.trace()))}function r(e,t,r,n,o){Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get:function(){return u(n,o),r},set:function(e){u(n,o),r=e}})}function a(e,t,r,n,o){var a=e[t];e[t]=function(){return o&&u(n,o),(s.migrateIsPatchEnabled(n)?r:a||s.noop).apply(this,arguments)}}function c(e,t,r,n,o){if(!o)throw new Error("No warning message provided");return a(e,t,r,n,o),0}function i(e,t,r,n){return a(e,t,r,n),0}s.migrateDeduplicateWarnings=!0,s.migrateWarnings=[],void 0===s.migrateTrace&&(s.migrateTrace=!0),s.migrateReset=function(){o={},s.migrateWarnings.length=0},"BackCompat"===n.document.compatMode&&u("quirks","jQuery is not compatible with Quirks Mode");var d,l,p,f={},m=s.fn.init,y=s.find,h=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/,g=/\[(\s*[-\w]+\s*)([~|^$*]?=)\s*([-\w#]*?#[-\w#]*)\s*\]/g,v=/^[\s\uFEFF\xA0]+|([^\s\uFEFF\xA0])[\s\uFEFF\xA0]+$/g;for(d in i(s.fn,"init",function(e){var t=Array.prototype.slice.call(arguments);return s.migrateIsPatchEnabled("selector-empty-id")&&"string"==typeof e&&"#"===e&&(u("selector-empty-id","jQuery('#') is not a valid selector"),t[0]=[]),m.apply(this,t)},"selector-empty-id"),s.fn.init.prototype=s.fn,i(s,"find",function(t){var r=Array.prototype.slice.call(arguments);if("string"==typeof t&&h.test(t))try{n.document.querySelector(t)}catch(e){t=t.replace(g,function(e,t,r,n){return"["+t+r+'"'+n+'"]'});try{n.document.querySelector(t),u("selector-hash","Attribute selector with '#' must be quoted: "+r[0]),r[0]=t}catch(e){u("selector-hash","Attribute selector with '#' was not fixed: "+r[0])}}return y.apply(this,r)},"selector-hash"),y)Object.prototype.hasOwnProperty.call(y,d)&&(s.find[d]=y[d]);c(s.fn,"size",function(){return this.length},"size","jQuery.fn.size() is deprecated and removed; use the .length property"),c(s,"parseJSON",function(){return JSON.parse.apply(null,arguments)},"parseJSON","jQuery.parseJSON is deprecated; use JSON.parse"),c(s,"holdReady",s.holdReady,"holdReady","jQuery.holdReady is deprecated"),c(s,"unique",s.uniqueSort,"unique","jQuery.unique is deprecated; use jQuery.uniqueSort"),r(s.expr,"filters",s.expr.pseudos,"expr-pre-pseudos","jQuery.expr.filters is deprecated; use jQuery.expr.pseudos"),r(s.expr,":",s.expr.pseudos,"expr-pre-pseudos","jQuery.expr[':'] is deprecated; use jQuery.expr.pseudos"),e("3.1.1")&&c(s,"trim",function(e){return null==e?"":(e+"").replace(v,"$1")},"trim","jQuery.trim is deprecated; use String.prototype.trim"),e("3.2.0")&&(c(s,"nodeName",function(e,t){return e.nodeName&&e.nodeName.toLowerCase()===t.toLowerCase()},"nodeName","jQuery.nodeName is deprecated"),c(s,"isArray",Array.isArray,"isArray","jQuery.isArray is deprecated; use Array.isArray")),e("3.3.0")&&(c(s,"isNumeric",function(e){var t=typeof e;return("number"==t||"string"==t)&&!isNaN(e-parseFloat(e))},"isNumeric","jQuery.isNumeric() is deprecated"),s.each("Boolean Number String Function Array Date RegExp Object Error Symbol".split(" "),function(e,t){f["[object "+t+"]"]=t.toLowerCase()}),c(s,"type",function(e){return null==e?e+"":"object"==typeof e||"function"==typeof e?f[Object.prototype.toString.call(e)]||"object":typeof e},"type","jQuery.type is deprecated"),c(s,"isFunction",function(e){return"function"==typeof e},"isFunction","jQuery.isFunction() is deprecated"),c(s,"isWindow",function(e){return null!=e&&e===e.window},"isWindow","jQuery.isWindow() is deprecated")),s.ajax&&(l=s.ajax,p=/(=)\?(?=&|$)|\?\?/,i(s,"ajax",function(){var e=l.apply(this,arguments);return e.promise&&(c(e,"success",e.done,"jqXHR-methods","jQXHR.success is deprecated and removed"),c(e,"error",e.fail,"jqXHR-methods","jQXHR.error is deprecated and removed"),c(e,"complete",e.always,"jqXHR-methods","jQXHR.complete is deprecated and removed")),e},"jqXHR-methods"),e("4.0.0")||s.ajaxPrefilter("+json",function(e){!1!==e.jsonp&&(p.test(e.url)||"string"==typeof e.data&&0===(e.contentType||"").indexOf("application/x-www-form-urlencoded")&&p.test(e.data))&&u("jsonp-promotion","JSON-to-JSONP auto-promotion is deprecated")}));var j=s.fn.removeAttr,b=s.fn.toggleClass,w=/\S+/g;function x(e){return e.replace(/-([a-z])/g,function(e,t){return t.toUpperCase()})}i(s.fn,"removeAttr",function(e){var r=this,n=!1;return s.each(e.match(w),function(e,t){s.expr.match.bool.test(t)&&r.each(function(){if(!1!==s(this).prop(t))return!(n=!0)}),n&&(u("removeAttr-bool","jQuery.fn.removeAttr no longer sets boolean properties: "+t),r.prop(t,!1))}),j.apply(this,arguments)},"removeAttr-bool"),i(s.fn,"toggleClass",function(t){return void 0!==t&&"boolean"!=typeof t?b.apply(this,arguments):(u("toggleClass-bool","jQuery.fn.toggleClass(boolean) is deprecated"),this.each(function(){var e=this.getAttribute&&this.getAttribute("class")||"";e&&s.data(this,"__className__",e),this.setAttribute&&this.setAttribute("class",!e&&!1!==t&&s.data(this,"__className__")||"")}))},"toggleClass-bool");var Q,A,R=!1,C=/^[a-z]/,N=/^(?:Border(?:Top|Right|Bottom|Left)?(?:Width|)|(?:Margin|Padding)?(?:Top|Right|Bottom|Left)?|(?:Min|Max)?(?:Width|Height))$/;s.swap&&s.each(["height","width","reliableMarginRight"],function(e,t){var r=s.cssHooks[t]&&s.cssHooks[t].get;r&&(s.cssHooks[t].get=function(){var e;return R=!0,e=r.apply(this,arguments),R=!1,e})}),i(s,"swap",function(e,t,r,n){var o,a,i={};for(a in R||u("swap","jQuery.swap() is undocumented and deprecated"),t)i[a]=e.style[a],e.style[a]=t[a];for(a in o=r.apply(e,n||[]),t)e.style[a]=i[a];return o},"swap"),e("3.4.0")&&"undefined"!=typeof Proxy&&(s.cssProps=new Proxy(s.cssProps||{},{set:function(){return u("cssProps","jQuery.cssProps is deprecated"),Reflect.set.apply(this,arguments)}})),e("4.0.0")?(A={animationIterationCount:!0,columnCount:!0,fillOpacity:!0,flexGrow:!0,flexShrink:!0,fontWeight:!0,gridArea:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnStart:!0,gridRow:!0,gridRowEnd:!0,gridRowStart:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,widows:!0,zIndex:!0,zoom:!0},"undefined"!=typeof Proxy?s.cssNumber=new Proxy(A,{get:function(){return u("css-number","jQuery.cssNumber is deprecated"),Reflect.get.apply(this,arguments)},set:function(){return u("css-number","jQuery.cssNumber is deprecated"),Reflect.set.apply(this,arguments)}}):s.cssNumber=A):A=s.cssNumber,Q=s.fn.css,i(s.fn,"css",function(e,t){var r,n,o=this;return e&&"object"==typeof e&&!Array.isArray(e)?(s.each(e,function(e,t){s.fn.css.call(o,e,t)}),this):("number"==typeof t&&(r=x(e),n=r,C.test(n)&&N.test(n[0].toUpperCase()+n.slice(1))||A[r]||u("css-number",'Number-typed values are deprecated for jQuery.fn.css("'+e+'", value)')),Q.apply(this,arguments))},"css-number");var S,P,k,H,E=s.data;i(s,"data",function(e,t,r){var n,o,a;if(t&&"object"==typeof t&&2===arguments.length){for(a in n=s.hasData(e)&&E.call(this,e),o={},t)a!==x(a)?(u("data-camelCase","jQuery.data() always sets/gets camelCased names: "+a),n[a]=t[a]):o[a]=t[a];return E.call(this,e,o),t}return t&&"string"==typeof t&&t!==x(t)&&(n=s.hasData(e)&&E.call(this,e))&&t in n?(u("data-camelCase","jQuery.data() always sets/gets camelCased names: "+t),2<arguments.length&&(n[t]=r),n[t]):E.apply(this,arguments)},"data-camelCase"),s.fx&&(k=s.Tween.prototype.run,H=function(e){return e},i(s.Tween.prototype,"run",function(){1<s.easing[this.easing].length&&(u("easing-one-arg","'jQuery.easing."+this.easing.toString()+"' should use only one argument"),s.easing[this.easing]=H),k.apply(this,arguments)},"easing-one-arg"),S=s.fx.interval,P="jQuery.fx.interval is deprecated",n.requestAnimationFrame&&Object.defineProperty(s.fx,"interval",{configurable:!0,enumerable:!0,get:function(){return n.document.hidden||u("fx-interval",P),s.migrateIsPatchEnabled("fx-interval")&&void 0===S?13:S},set:function(e){u("fx-interval",P),S=e}}));var M=s.fn.load,q=s.event.add,O=s.event.fix;s.event.props=[],s.event.fixHooks={},r(s.event.props,"concat",s.event.props.concat,"event-old-patch","jQuery.event.props.concat() is deprecated and removed"),i(s.event,"fix",function(e){var t,r=e.type,n=this.fixHooks[r],o=s.event.props;if(o.length){u("event-old-patch","jQuery.event.props are deprecated and removed: "+o.join());while(o.length)s.event.addProp(o.pop())}if(n&&!n._migrated_&&(n._migrated_=!0,u("event-old-patch","jQuery.event.fixHooks are deprecated and removed: "+r),(o=n.props)&&o.length))while(o.length)s.event.addProp(o.pop());return t=O.call(this,e),n&&n.filter?n.filter(t,e):t},"event-old-patch"),i(s.event,"add",function(e,t){return e===n&&"load"===t&&"complete"===n.document.readyState&&u("load-after-event","jQuery(window).on('load'...) called after load event occurred"),q.apply(this,arguments)},"load-after-event"),s.each(["load","unload","error"],function(e,t){i(s.fn,t,function(){var e=Array.prototype.slice.call(arguments,0);return"load"===t&&"string"==typeof e[0]?M.apply(this,e):(u("shorthand-removed-v3","jQuery.fn."+t+"() is deprecated"),e.splice(0,0,t),arguments.length?this.on.apply(this,e):(this.triggerHandler.apply(this,e),this))},"shorthand-removed-v3")}),s.each("blur focus focusin focusout resize scroll click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select submit keydown keypress keyup contextmenu".split(" "),function(e,r){c(s.fn,r,function(e,t){return 0<arguments.length?this.on(r,null,e,t):this.trigger(r)},"shorthand-deprecated-v3","jQuery.fn."+r+"() event shorthand is deprecated")}),s(function(){s(n.document).triggerHandler("ready")}),s.event.special.ready={setup:function(){this===n.document&&u("ready-event","'ready' event is deprecated")}},c(s.fn,"bind",function(e,t,r){return this.on(e,null,t,r)},"pre-on-methods","jQuery.fn.bind() is deprecated"),c(s.fn,"unbind",function(e,t){return this.off(e,null,t)},"pre-on-methods","jQuery.fn.unbind() is deprecated"),c(s.fn,"delegate",function(e,t,r,n){return this.on(t,e,r,n)},"pre-on-methods","jQuery.fn.delegate() is deprecated"),c(s.fn,"undelegate",function(e,t,r){return 1===arguments.length?this.off(e,"**"):this.off(t,e||"**",r)},"pre-on-methods","jQuery.fn.undelegate() is deprecated"),c(s.fn,"hover",function(e,t){return this.on("mouseenter",e).on("mouseleave",t||e)},"pre-on-methods","jQuery.fn.hover() is deprecated");function T(e){var t=n.document.implementation.createHTMLDocument("");return t.body.innerHTML=e,t.body&&t.body.innerHTML}var F=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([a-z][^\/\0>\x20\t\r\n\f]*)[^>]*)\/>/gi;s.UNSAFE_restoreLegacyHtmlPrefilter=function(){s.migrateEnablePatches("self-closed-tags")},i(s,"htmlPrefilter",function(e){var t,r;return(r=(t=e).replace(F,"<$1></$2>"))!==t&&T(t)!==T(r)&&u("self-closed-tags","HTML tags must be properly nested and closed: "+t),e.replace(F,"<$1></$2>")},"self-closed-tags"),s.migrateDisablePatches("self-closed-tags");var D,W,_,I=s.fn.offset;return i(s.fn,"offset",function(){var e=this[0];return!e||e.nodeType&&e.getBoundingClientRect?I.apply(this,arguments):(u("offset-valid-elem","jQuery.fn.offset() requires a valid DOM element"),arguments.length?this:void 0)},"offset-valid-elem"),s.ajax&&(D=s.param,i(s,"param",function(e,t){var r=s.ajaxSettings&&s.ajaxSettings.traditional;return void 0===t&&r&&(u("param-ajax-traditional","jQuery.param() no longer uses jQuery.ajaxSettings.traditional"),t=r),D.call(this,e,t)},"param-ajax-traditional")),c(s.fn,"andSelf",s.fn.addBack,"andSelf","jQuery.fn.andSelf() is deprecated and removed, use jQuery.fn.addBack()"),s.Deferred&&(W=s.Deferred,_=[["resolve","done",s.Callbacks("once memory"),s.Callbacks("once memory"),"resolved"],["reject","fail",s.Callbacks("once memory"),s.Callbacks("once memory"),"rejected"],["notify","progress",s.Callbacks("memory"),s.Callbacks("memory")]],i(s,"Deferred",function(e){var a=W(),i=a.promise();function t(){var o=arguments;return s.Deferred(function(n){s.each(_,function(e,t){var r="function"==typeof o[e]&&o[e];a[t[1]](function(){var e=r&&r.apply(this,arguments);e&&"function"==typeof e.promise?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[t[0]+"With"](this===i?n.promise():this,r?[e]:arguments)})}),o=null}).promise()}return c(a,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),c(i,"pipe",t,"deferred-pipe","deferred.pipe() is deprecated"),e&&e.call(a,a),a},"deferred-pipe"),s.Deferred.exceptionHook=W.exceptionHook),s});
(function(factory){
if(typeof define==='function'&&define.amd){
define(['jquery'], factory);
}else if(typeof module==='object'&&module.exports){
var $=require('jquery');
factory($);
module.exports=$;
}else{
factory(jQuery);
}})(function($){
function CircleProgress(config){
this.init(config);
}
CircleProgress.prototype={
value: 0.0,
size: 100.0,
startAngle: -Math.PI,
thickness: 'auto',
fill: {
gradient: ['#3aeabb', '#fdd250']
},
emptyFill: 'rgba(0, 0, 0, .1)',
animation: {
duration: 1200,
easing: 'circleProgressEasing'
},
animationStartValue: 0.0,
reverse: false,
lineCap: 'butt',
insertMode: 'prepend',
constructor: CircleProgress,
el: null,
canvas: null,
ctx: null,
radius: 0.0,
arcFill: null,
lastFrameValue: 0.0,
init: function(config){
$.extend(this, config);
this.radius=this.size / 2;
this.initWidget();
this.initFill();
this.draw();
this.el.trigger('circle-inited');
},
initWidget: function(){
if(!this.canvas)
this.canvas=$('<canvas>')[this.insertMode=='prepend' ? 'prependTo':'appendTo'](this.el)[0];
var canvas=this.canvas;
canvas.width=this.size;
canvas.height=this.size;
this.ctx=canvas.getContext('2d');
if(window.devicePixelRatio > 1){
var scaleBy=window.devicePixelRatio;
canvas.style.width=canvas.style.height=this.size + 'px';
canvas.width=canvas.height=this.size * scaleBy;
this.ctx.scale(scaleBy, scaleBy);
}},
initFill: function(){
var self=this,
fill=this.fill,
ctx=this.ctx,
size=this.size;
if(!fill)
throw Error("The fill is not specified!");
if(typeof fill=='string')
fill={color: fill};
if(fill.color)
this.arcFill=fill.color;
if(fill.gradient){
var gr=fill.gradient;
if(gr.length==1){
this.arcFill=gr[0];
}else if(gr.length > 1){
var ga=fill.gradientAngle||0,
gd=fill.gradientDirection||[
size / 2 * (1 - Math.cos(ga)),
size / 2 * (1 + Math.sin(ga)),
size / 2 * (1 + Math.cos(ga)),
size / 2 * (1 - Math.sin(ga))
];
var lg=ctx.createLinearGradient.apply(ctx, gd);
for (var i=0; i < gr.length; i++){
var color=gr[i],
pos=i / (gr.length - 1);
if($.isArray(color)){
pos=color[1];
color=color[0];
}
lg.addColorStop(pos, color);
}
this.arcFill=lg;
}}
if(fill.image){
var img;
if(fill.image instanceof Image){
img=fill.image;
}else{
img=new Image();
img.src=fill.image;
}
if(img.complete)
setImageFill();
else
img.onload=setImageFill;
}
function setImageFill(){
var bg=$('<canvas>')[0];
bg.width=self.size;
bg.height=self.size;
bg.getContext('2d').drawImage(img, 0, 0, size, size);
self.arcFill=self.ctx.createPattern(bg, 'no-repeat');
self.drawFrame(self.lastFrameValue);
}},
draw: function(){
if(this.animation)
this.drawAnimated(this.value);
else
this.drawFrame(this.value);
},
drawFrame: function(v){
this.lastFrameValue=v;
this.ctx.clearRect(0, 0, this.size, this.size);
this.drawEmptyArc(v);
this.drawArc(v);
},
drawArc: function(v){
if(v===0)
return;
var ctx=this.ctx,
r=this.radius,
t=this.getThickness(),
a=this.startAngle;
ctx.save();
ctx.beginPath();
if(!this.reverse){
ctx.arc(r, r, r - t / 2, a, a + Math.PI * 2 * v);
}else{
ctx.arc(r, r, r - t / 2, a - Math.PI * 2 * v, a);
}
ctx.lineWidth=t;
ctx.lineCap=this.lineCap;
ctx.strokeStyle=this.arcFill;
ctx.stroke();
ctx.restore();
},
drawEmptyArc: function(v){
var ctx=this.ctx,
r=this.radius,
t=this.getThickness(),
a=this.startAngle;
if(v < 1){
ctx.save();
ctx.beginPath();
if(v <=0){
ctx.arc(r, r, r - t / 2, 0, Math.PI * 2);
}else{
if(!this.reverse){
ctx.arc(r, r, r - t / 2, a + Math.PI * 2 * v, a);
}else{
ctx.arc(r, r, r - t / 2, a, a - Math.PI * 2 * v);
}}
ctx.lineWidth=t;
ctx.strokeStyle=this.emptyFill;
ctx.stroke();
ctx.restore();
}},
drawAnimated: function(v){
var self=this,
el=this.el,
canvas=$(this.canvas);
canvas.stop(true, false);
el.trigger('circle-animation-start');
canvas
.css({animationProgress: 0})
.animate({animationProgress: 1}, $.extend({}, this.animation, {
step: function(animationProgress){
var stepValue=self.animationStartValue * (1 - animationProgress) + v * animationProgress;
self.drawFrame(stepValue);
el.trigger('circle-animation-progress', [animationProgress, stepValue]);
}}))
.promise()
.always(function(){
el.trigger('circle-animation-end');
});
},
getThickness: function(){
return $.isNumeric(this.thickness) ? this.thickness:this.size / 14;
},
getValue: function(){
return this.value;
},
setValue: function(newValue){
if(this.animation)
this.animationStartValue=this.lastFrameValue;
this.value=newValue;
this.draw();
}};
$.circleProgress={
defaults: CircleProgress.prototype
};
$.easing.circleProgressEasing=function(x){
if(x < 0.5){
x=2 * x;
return 0.5 * x * x * x;
}else{
x=2 - 2 * x;
return 1 - 0.5 * x * x * x;
}};
$.fn.circleProgress=function(configOrCommand, commandArgument){
var dataName='circle-progress',
firstInstance=this.data(dataName);
if(configOrCommand=='widget'){
if(!firstInstance)
throw Error('Calling "widget" method on not initialized instance is forbidden');
return firstInstance.canvas;
}
if(configOrCommand=='value'){
if(!firstInstance)
throw Error('Calling "value" method on not initialized instance is forbidden');
if(typeof commandArgument=='undefined'){
return firstInstance.getValue();
}else{
var newValue=arguments[1];
return this.each(function(){
$(this).data(dataName).setValue(newValue);
});
}}
return this.each(function(){
var el=$(this),
instance=el.data(dataName),
config=$.isPlainObject(configOrCommand) ? configOrCommand:{};
if(instance){
instance.init(config);
}else{
var initialConfig=$.extend({}, el.data());
if(typeof initialConfig.fill=='string')
initialConfig.fill=JSON.parse(initialConfig.fill);
if(typeof initialConfig.animation=='string')
initialConfig.animation=JSON.parse(initialConfig.animation);
config=$.extend(initialConfig, config);
config.el=el;
instance=new CircleProgress(config);
el.data(dataName, instance);
}});
};});
jQuery(function (){
if(jQuery(".bwg-container").length){
var html='<div class="twb_admin_bar_menu_header">';
html +='<img class="twb_menu_logo" src="' + twb.plugin_url + '/assets/images/logo_white.svg" />';
html +='<div class="twb_menu_logo">Optimize Images</div>';
html +='</div>';
jQuery(".twb_admin_bar_menu").html(html).on("click", function (){
window.open(twb.href, '_blank');
});
jQuery(".twb_admin_bar_menu_main").remove();
}
twb_inprogress=false;
jQuery(".twb-notoptimized").each(function (){
if(jQuery(this).data("status")=='inprogress'){
twb_disable_check();
}});
jQuery(".twb-notoptimized .twb_check_score_button").on("click", function (){
if(!twb_inprogress){
twb_check_score(this);
}});
jQuery("th[id^='twb-speed-']").hover(function (){
jQuery(this).find(".twb-dismiss-container").removeClass("twb-hidden");
},
function (){
jQuery(this).find(".twb-dismiss-container").addClass("twb-hidden");
});
jQuery(".twb-see-score").hover(function (){
jQuery(this).parent().parent().find(".twb-score-container").removeClass("twb-hidden");
},
function (){
jQuery(this).parent().parent().find(".twb-score-container").addClass("twb-hidden");
});
jQuery(".twb-score-container:not(.twb_admin_bar_menu_content .twb-score-container), .twb-score-disabled-container").hover(function (){
jQuery(this).removeClass("twb-hidden");
},
function (){
jQuery(this).addClass("twb-hidden");
});
jQuery(".twb-score-circle").each(function (){
twb_draw_score_circle(this);
});
jQuery("#wp-admin-bar-twb_adminbar_info").mouseenter(function(){
jQuery(".twb_admin_bar_menu_main .twb-score-container").removeClass("twb-hidden");
jQuery(".twb_admin_bar_menu_main").removeClass("twb-hidden");
}).mouseleave(function(){
jQuery(".twb_admin_bar_menu_main").addClass("twb-hidden");
});
jQuery('.twb-score-circle').each(function (){
twb_draw_score_circle(this);
});
if(jQuery(".twb_admin_bar_menu.twb_backend span").hasClass("twb_backend_optimizing_logo")){
twb_run_notif_check=setInterval(twb_run_notif_check, 30000);
}});
function twb_run_notif_check(){
jQuery.ajax({
type: "POST",
url: twb.ajax_url,
data: {
action: "twb_notif_check",
twb_nonce: twb.nonce,
}}).success(function (results){
var result=jQuery.parseJSON(results);
if(result.html!=""){
if(result.changeLogo==1){
jQuery(".twb_admin_bar_menu_header span").addClass("twb_counted");
}
jQuery("#wp-admin-bar-twb_adminbar_info").append(result.html);
jQuery(".twb_admin_bar_menu_content .twb-score-container").removeClass("twb-hidden");
jQuery(".twb_admin_bar_menu_content .twb-score-container .twb-score-circle").each(function (){
twb_draw_score_circle(this);
});
clearInterval(twb_run_notif_check);
}}).error(function (){
clearInterval(twb_run_notif_check);
});
}
function twb_disable_check(){
twb_inprogress=true;
jQuery(".twb-notoptimized").hover(function (){
jQuery(this).parent().find(".twb-score-disabled-container").removeClass("twb-hidden");
},
function (){
jQuery(this).parent().find(".twb-score-disabled-container").addClass("twb-hidden");
});
}
function twb_check_score(that){
var post_id=jQuery(that).data("post_id");
var parent=jQuery(that).parent().parent().parent();
jQuery(".twb_admin_bar_menu.twb_frontend").addClass("twb_score_inprogress");
if(parent.find(".twb-optimized").hasClass("twb-hidden")){
parent.find(".twb-optimizing").removeClass("twb-hidden");
}else{
parent.find(".twb-score-overlay").removeClass("twb-hidden");
parent.find(".twb-score-overlay div").removeClass("twb-reload").addClass("twb-loader");
}
parent.find(".twb-notoptimized").addClass("twb-hidden");
if(parent.hasClass("twb_elementor_settings_content")){
jQuery(".twb_elementor_control_title").text(twb.checking).removeClass("twb_not_optimized").prepend("<span class='twb_inprogress'></span>");
}
twb_disable_check();
jQuery.ajax({
url: twb.ajax_url,
type: "POST",
dataType: 'json',
data: {
action: "twb_check_score",
post_id: post_id,
twb_nonce: twb.nonce
},
success: function (data){
if(data.error){
parent.find(".twb-score-overlay").removeClass("twb-hidden");
parent.find(".twb-score-overlay div").removeClass("twb-loader").addClass("twb-reload");
}else{
parent.find(".twb-score-overlay").addClass("twb-hidden");
var desktop=parent.find(".twb-score-desktop").find(".twb-score-circle");
desktop.data({
"score": data.desktop_score,
"tti": data.desktop_tti,
});
twb_draw_score_circle(desktop);
var mobile=parent.find(".twb-score-mobile").find(".twb-score-circle");
mobile.data({
"score": data.mobile_score,
"tti": data.mobile_tti,
});
twb_draw_score_circle(mobile);
}},
error: function (xhr, textStatus, errorThrown){
parent.find(".twb-score-overlay").removeClass("twb-hidden");
parent.find(".twb-score-overlay div").removeClass("twb-loader").addClass("twb-reload");
},
complete: function (xhr, textStatus){
parent.find(".twb-optimizing").addClass("twb-hidden");
parent.find(".twb-optimized").removeClass("twb-hidden");
jQuery("#wpadminbar .twb-optimized .twb-score-container").removeClass("twb-hidden");
jQuery("#wpadminbar .twb_admin_bar_menu").removeClass("twb_score_inprogress");
jQuery("#wpadminbar .twb_menu_logo").remove();
jQuery("#wpadminbar .twb_not_optimized_logo").removeClass("twb-hidden");
jQuery("#wpadminbar .twb_admin_bar_menu_header").addClass("twb_not_optimized");
twb_inprogress=false;
jQuery(".twb-notoptimized").hover(function (){
jQuery(this).parent().find(".twb-score-disabled-container").addClass("twb-hidden");
});
if(parent.hasClass("twb_elementor_settings_content")){
jQuery(".twb_elementor_control_title").text(twb.notoptimized).remove("span.twb_inprogress").addClass("twb_not_optimized");
}}
});
}
function twb_draw_score_circle(that){
var score=parseInt(jQuery(that).data('score'));
var size=parseInt(jQuery(that).data('size'));
var thickness=parseInt(jQuery(that).data('thickness'));
var color=score <=49 ? "rgb(253, 60, 49)":(score >=90 ? "rgb(12, 206, 107)":"rgb(255, 164, 0)");
jQuery(that).parent().find('.twb-load-time').html(jQuery(that).data('tti'));
var _this=that;
if(typeof jQuery(_this).circleProgress!='function'){
return;
}
jQuery(_this).circleProgress({
value: score / 100,
size: size,
startAngle: -Math.PI / 4 * 2,
lineCap: 'round',
emptyFill: "rgba(255, 255, 255, 0)",
thickness: thickness,
fill: {
color: color
}}).on('circle-animation-progress', function (event, progress){
var content='<span class="twb-score0"></span>';
if(score!=0){
content=Math.round(score * progress);
}
jQuery(that).find('.twb-score-circle-animated').html(content).css({"color": color});
jQuery(that).find('canvas').html(Math.round(score * progress));
});
}
function twb_add_elementor_button(){
window.elementor.modules.layouts.panel.pages.menu.Menu.addItem({
name: twb.title,
icon: "twb-element-menu-icon",
title: twb.title,
type: "page",
callback: ()=> {
try {
window.$e.route("panel/page-settings/twb_optimize")
} catch (e){
window.$e.route("panel/page-settings/settings"), window.$e.route("panel/page-settings/twb_optimize")
}}
}, "more")
}
jQuery(window).on("elementor:init", ()=> {
window.elementor.on("panel:init", ()=> {
setTimeout(twb_add_elementor_button)
})
});