| 17 |
jQuery(document).ready(function(p){let d=1,a=1,e=!1;function c(n){e=!0,p("#wplng-in-progress-message").hide(),p("#wplng-progress-bar").hide(),p("#wplng-in-progress-error").show(),n="wpLingua error - Load in progress: "+n,console.error(n)}function w(n){p("#wplng-in-progress-percent").html(n),p("#wplng-progress-bar-value").animate({width:n.toString()+"%"},500)}function n(){var n=parseInt(p("#wplng-in-progress-percent").html());n<d&&!e?w(d):n<a&&n<99&&!e&&w(++n)}p("#wplng-in-progress-container").length?"undefined"==typeof wplngLoadInProgressData?(c("Invalide data (wplngLoadInProgressData undefined)."),console.info(wplngLoadInProgressData)):"string"!=typeof wplngLoadInProgressData.urlAjax?(c("Invalide data (wplngLoadInProgressData.urlAjax)."),console.info(wplngLoadInProgressData.urlAjax)):"string"!=typeof wplngLoadInProgressData.urlReload?(c("Invalide data (wplngLoadInProgressData.urlReload)."),console.info(wplngLoadInProgressData.urlReload)):"string"!=typeof wplngLoadInProgressData.nonce||0===wplngLoadInProgressData.nonce.length?(c("Invalide data (wplngLoadInProgressData.nonce)."),console.info(wplngLoadInProgressData.nonce)):"string"!=typeof wplngLoadInProgressData.language||2!==wplngLoadInProgressData.language.length?(c("Invalide data (wplngLoadInProgressData.language)."),console.info(wplngLoadInProgressData.language)):"object"!=typeof wplngLoadInProgressData.chunks||0===wplngLoadInProgressData.chunks.length?(c("Invalide data (wplngLoadInProgressData.chunks)."),console.info(wplngLoadInProgressData.chunks)):function o(r,s,t,l,g){if(!g[r]||"object"!=typeof g[r]||"number"!=typeof g[r].percentage||"object"!=typeof g[r].texts||0===g[r].texts.length)return c("Invalide text chunk."),void console.info(g[r]);let i=g[r].percentage;let n=g[r].texts;a=i;p.ajax({url:s,method:"POST",data:{action:"wplng_load_in_progress",wplng_language:l,wplng_texts:n,wplng_nonce:wplngLoadInProgressData.nonce},success:function(a){if(a.success){d=i;let n=a.data,e=Object.create(null);Array.isArray(n)&&n.forEach(function(n){n&&"string"==typeof n.source&&(e[n.source.trim()]="string"==typeof n.translation?n.translation:"")}),p(".wplng-in-progress-text").each(function(){let n=p(this).text().trim(),a=e[n];"string"==typeof a&&0<a.length&&p(this).replaceWith(a)}),void 0===g[r+1]?(w(100),window.location.href=t):o(r+1,s,t,l,g)}else"object"==typeof a.data&&"string"==typeof a.data.error_message?c("Translation AJAX call fail (message: "+a.data.error_message+")."):c("Translation AJAX call fail (response.success is false, unknow message).")},error:function(n){c("Translation AJAX call fail (callback error).")}})}(0,wplngLoadInProgressData.urlAjax,wplngLoadInProgressData.urlReload,wplngLoadInProgressData.language,wplngLoadInProgressData.chunks):c("Mode loaded without the progress bar container"),p("#wplng-in-progress-error-close").on("click",function(){p("#wplng-in-progress-container").hide(),p("#wpadminbar").show(),"string"==typeof wplngLoadInProgressData.urlReload&&(window.location.href=wplngLoadInProgressData.urlReload)}),n(),p("#wplng-in-progress-percent").length&&setInterval(n,500),p("#wpadminbar").length&&p("#wplng-in-progress-container").length&&p("#wpadminbar").hide()});//# sourceMappingURL=load-in-progress.js.map |