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.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / assets / js / tutor-template-import-script.js
tutor / assets / js Last commit date
images 10 months ago lazy-chunks 5 months ago tutor-addon-list.js 7 months ago tutor-admin.js 8 months ago tutor-coupon.js 5 months ago tutor-course-builder.js 5 months ago tutor-front.js 5 months ago tutor-gutenberg.js 10 months ago tutor-import-export.js 7 months ago tutor-order-details.js 6 months ago tutor-payment-settings.js 7 months ago tutor-setup.js 8 months ago tutor-tax-settings.js 7 months ago tutor-template-import-script.js 7 months ago tutor.js 5 months ago
tutor-template-import-script.js
41 lines
1 (()=>{"use strict";var e={};/************************************************************************/// The module cache
2 var t={};// The require function
3 function r(o){// Check if module is in cache
4 var a=t[o];if(a!==undefined){return a.exports}// Create a new module (and put it into the cache)
5 var i=t[o]={exports:{}};// Execute the module function
6 e[o](i,i.exports,r);// Return the exports of the module
7 return i.exports}/************************************************************************/// webpack/runtime/rspack_version
8 (()=>{r.rv=()=>"1.4.11"})();// webpack/runtime/rspack_unique_id
9 (()=>{r.ruid="bundler=rspack@1.4.11"})();/************************************************************************/;// CONCATENATED MODULE: ./node_modules/@swc/helpers/esm/_async_to_generator.js
10 function o(e,t,r,o,a,i,n){try{var l=e[i](n);var d=l.value}catch(e){r(e);return}if(l.done)t(d);else Promise.resolve(d).then(o,a)}function a(e){return function(){var t=this,r=arguments;return new Promise(function(a,i){var n=e.apply(t,r);function l(e){o(n,a,i,l,d,"next",e)}function d(e){o(n,a,i,l,d,"throw",e)}l(undefined)})}};// CONCATENATED MODULE: ./assets/react/admin-dashboard/template-import-script.js
11 /**
12 * Template Import Script
13 *
14 * This file contains utilities and high-level documentation for the template import
15 * workflow and the live preview UI. It describes behavior implemented below:
16 * - tutor course data import (supports .zip and JSON import via chunked job)
17 * - plugin installation and template import flow (fetch/AJAX POSTs, processing loop)
18 * - preview modal management (open/close, shimmer loading state)
19 * - device preview switching and iframe resizing/scale handling
20 * - communication with the preview iframe (postMessage) for Droip color presets and mode
21 *
22 * Notes:
23 * - This script relies on a global _tutorobject (nonce, ajax URL, site_url, etc.).
24 * - Keep DOM selectors and event handlers idempotent because the admin UI may be re-rendered.
25 *
26 * @file template-import-script.js
27 * @since v3.9.2
28 */document.addEventListener("DOMContentLoaded",function(){var e=document.querySelector(".tutor-template-import-area");var t=document.querySelector(".tutor-template-preview-modal");var r=document.querySelector(".tutor-template-preview-iframe-parent");var o=document.getElementById("tutor-template-preview-iframe");var a=document.querySelector(".tutor-template-preview-modal-back-link");var n=document.querySelectorAll(".tutor-template-preview-device-switcher li");var l=document.querySelector(".tutor-preview-template-name");var d=document.querySelector(".tutor-template-shimmer-effect");var s=document.querySelector(".tutor-template-import-btn");var c=document.getElementById("tutor_template_course_data_url");var u=document.getElementById("droip-color-presets");var v=document.querySelector(".tutor-droip-color-presets-heading");if(e){// Open live preview modal
29 e.addEventListener("click",e=>{if(e.target.closest(".tutor-template-preview-btn")){document.body.style.overflow="hidden";d.style.display="block";r.classList.remove("tutor-divider");t.style.display="flex";l.innerText=e.target.dataset.template_name;if(c){c.value=e.target.dataset.template_course_data_url}o.src=e.target.dataset.template_url;s.setAttribute("data-import_template_id",e.target.dataset.template_id)}});// Hide loading indicator when iframe is fully loaded
30 o.addEventListener("load",function(){d.style.display="none";r.classList.add("tutor-divider")});a===null||a===void 0?void 0:a.addEventListener("click",function(){p();var e=s.querySelector("i");s.classList.remove("is-loading");s.classList.add("tutor-template-import-btn");s.classList.remove("tutor-template-view-template-btn");e.classList.add("tutor-icon-import");e.classList.remove("tutor-icon-circle-mark")});// Device switcher
31 n.forEach(e=>{e.addEventListener("click",function(){m(n);e.classList.add("active");var t=this.getAttribute("data-width");o.style.width=t+"px";i()})});// Reset preview modal
32 function p(){t.style.display="none";o.src="";m(n);n[0].classList.add("active");d.style.display="none";document.body.style.overflow="visible";o.style.width="1400px";o.style.transformOrigin="left top";u.style.display="none";v.style.display="none"}// Remove active class from device list
33 function m(e){e.forEach(e=>{e.classList.remove("active")})}}});function i(){var e=document.querySelector(".tutor-template-preview-iframe-parent");var t=e.querySelector(".tutor-template-preview-iframe-parent iframe");var r=document.querySelector(".tutor-template-preview-device-switcher li.active");var o=r.getAttribute("data-width")||1400;var a=e.offsetWidth;if(a<Number(o)){var i=a/Number(o);if(i>0){t.style.transform="scale(".concat(i,")");t.style.transformOrigin="left top";t.style.height="".concat(100/i,"%")}}else{t.style.transformOrigin="center top"}}window.addEventListener("resize",i);document.addEventListener("DOMContentLoaded",function(){var{__}=wp.i18n;var e=document.querySelector(".tutor-template-import-area");var t=document.querySelector(".tutor-template-import-btn");var r=document.getElementById("include-demo-courses");var o;var i=false;if(e){document.addEventListener("click",e=>{if(e.target.closest(".tutor-template-import-btn")){t.classList.add("is-loading");t.setAttribute("disabled","disabled");var r=t.querySelector("i");t.innerHTML="".concat(r.outerHTML," Importing");l()}});document.addEventListener("click",e=>{if(e.target.closest(".tutor-template-view-template-btn")){window.open(_tutorobject.site_url,"_blank")}});var n=["tutorbase","droip"];// install required plugin.
34 function l(){return a(function*(){i=false;for(var e=0;e<n.length;e++){try{var r=new FormData;r.append("action","tutor_template_required_plugin_install");r.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);r.append("plugin_name",n[e]);var a=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:r});var l=yield a.json();if(200===l.status_code){i=true}else{u();tutor_toast(__("Error","tutor-pro"),l===null||l===void 0?void 0:l.message,"error");return}}catch(e){u();tutor_toast(__("Something went wrong!","tutor-pro"),"","error");return}}// if plugin installation done start importing template content.
35 if(i){o=t.getAttribute("data-import_template_id");try{var c=yield d();var v=yield c.json();if(c.ok&&200===v.status_code){s()}else{throw new Error((v===null||v===void 0?void 0:v.message)||__("Template import failed!","tutor-pro"))}}catch(e){u();tutor_toast(__("Error","tutor-pro"),__(e===null||e===void 0?void 0:e.message,"tutor-pro"),"error");return}}})()}// import template zip file.
36 var d=()=>a(function*(){var e;var t=(e=document.querySelector(".color-palette.active"))===null||e===void 0?void 0:e.getAttribute("data-mode");if(!t)t="default";var r=new FormData;r.append("action","import_droip_template");r.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);r.append("template_id",o);r.append("selected_mode",t);var a=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:r});return a})();// import template content.
37 var s=()=>a(function*(){var e=new FormData;e.append("action","process_droip_template");e.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);try{var t=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:e});var o=yield t.json();if(200===o.status_code){var a=o===null||o===void 0?void 0:o.data;if(a.status==="importing"){setTimeout(()=>{s()},10)}else if(a.status==="done"){if(r){var i=r.checked;if(i){yield c()}}v();tutor_toast(__("Success","tutor-pro"),__("Template imported successfully.","tutor-pro"),"success");return true}}}catch(e){u();tutor_toast(__("Error","tutor-pro"),__("Error while processing imported template!","tutor-pro"),"error");return false}})();var c=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:0;return a(function*(){var t=document.getElementById("tutor_template_course_data_url");var r=t===null||t===void 0?void 0:t.value;if(!r)return false;var o=new FormData;o.append("job_id",e);o.append("action","tutor_pro_import");o.append(_tutorobject.nonce_key,_tutorobject._tutor_nonce);if(!e){var a=r.toLowerCase().endsWith(".zip");var i=yield fetch(r);var n=yield i.blob();if(a){var l=r.split("/").pop()||"importer.zip";o.append("data",n,l)}else{o.append("data",n,"importer.json")}}var d=yield fetch(_tutorobject.ajaxurl,{method:"POST",body:o,credentials:"same-origin"});if(d.ok){var s=yield d.json();if(s.status_code==200){var u=s.data.job_id;var v=s.data.job_progress;if(v!=100){yield c(u)}if(v==100){return true}}}else{return false}})()};function u(){var e=t.querySelector("i");t.classList.remove("is-loading");t.classList.add("tutor-template-import-btn");t.classList.remove("tutor-template-view-template-btn");t.removeAttribute("disabled");e.classList.add("tutor-icon-import");e.classList.remove("tutor-icon-circle-mark")}function v(){var e=t.querySelector("i");t.classList.remove("is-loading");t.classList.remove("tutor-template-import-btn");t.removeAttribute("disabled");t.classList.add("tutor-template-view-template-btn");e.classList.remove("tutor-icon-import");e.classList.add("tutor-icon-circle-mark");t.innerHTML="".concat(e.outerHTML," View Template")}}});(function(){var e=document.querySelector("#tutor-template-preview-iframe");var t=document.getElementById("droip-color-presets");document.addEventListener("DOMContentLoaded",()=>{// Wait for the iframe to load before interacting with it
38 e.addEventListener("load",()=>{i();window.addEventListener("message",r);var e=document.querySelector(".tutor-template-preview-import-area .tutor-template-shimmer-effect-2");e.style.display="none";n();// Safe to send message now
39 l()})});var r=e=>{var{type:r}=e.data;switch(r){case"RETURN_DROIP_VARIABLE_DATA":{var a,i,n;if(((n=e.data.droipCSSVariable)===null||n===void 0?void 0:(i=n.data)===null||i===void 0?void 0:(a=i[0])===null||a===void 0?void 0:a.modes.length)>1){var l=document.querySelector(".tutor-droip-color-presets-heading");l.style.display="block";var c=document.querySelector("#droip-color-modes");c.style.display="block";var u=e.data.droipCSSVariable.data[0];var v=u.modes;// Hide #color-preset if 1 or fewer modes
40 t=document.getElementById("droip-color-presets");if(c&&t){if(v.length<=1){t.style.display="none"}else{t.style.display="flex";t.style.justifyContent="center";t.style.alignItems="center"}}var p=document.createElement("div");p.classList.add("all-colors-wrapper");p.style.display="flex";v.forEach((e,t)=>{var r=s(e.key,u);var o=document.createElement("div");o.classList.add("color-palette");o.setAttribute("data-mode",e.key);r.forEach((e,t)=>{if(t<3){var r='<div style="background-color:'.concat(e,';" data-index="').concat(t,'"></div>');o.innerHTML+=r}});p.append(o)});document.querySelector("#droip-color-modes").innerHTML=p.outerHTML;document.querySelectorAll(".color-palette").forEach(e=>{e.addEventListener("click",()=>{var t=e.getAttribute("data-mode");d(t);o(t)})})}break}case"RETURN_DROIP_ACTIVE_MODE":{var m;var f=(e===null||e===void 0?void 0:(m=e.data)===null||m===void 0?void 0:m.activeMode)||"default";o(f);break}}};var o=e=>{var t,r;var o=document.querySelectorAll(".color-palette");if(!o)return;o.forEach(e=>{e.classList.remove("active")});(r=document.querySelector('[data-mode="'+e+'"]'))===null||r===void 0?void 0:(t=r.classList)===null||t===void 0?void 0:t.add("active")};var a=t=>{e.contentWindow.postMessage(t,"*");// You can replace '*' with the exact origin
41 };var n=()=>{a({type:"GET_DROIP_VARIABLE_DATA"})};var l=()=>{a({type:"GET_DROIP_ACTIVE_MODE"})};var d=e=>{a({type:"APPLY_DROIP_VARIABLE_PALETTE",mode:e})};var s=(e,t)=>{if(!t||!t.variables){return[]}var r=t.variables.filter(e=>e.type==="color").map(t=>{var r,o;if((r=t.value)===null||r===void 0?void 0:r[e]){return t.value[e]}if((o=t.value)===null||o===void 0?void 0:o.default){return t.value.default}return"#000000"});return r}})()})();