| 1 |
/*--Start-- Get Social Accounts*/ |
| 2 |
window.addEventListener ? window.addEventListener("load", __tagembed__get_theme, false) : window.attachEvent && window.attachEvent("onload", __tagembed__get_theme); |
| 3 |
function __tagembed__get_theme() { |
| 4 |
let widgetId = document.querySelector("#__tagembed__widgets"); |
| 5 |
if (!widgetId) |
| 6 |
return; |
| 7 |
widgetId = widgetId.selectedOptions[0]; |
| 8 |
widgetId = widgetId.value.split('#')[0]; |
| 9 |
let __tagembed__theme = document.querySelector("#__tagembed__theme"); |
| 10 |
let __tagembed__toast = new TagembedToast; |
| 11 |
let formData = new FormData(); |
| 12 |
formData.append('action', 'data'); |
| 13 |
formData.append('widgetId', widgetId); |
| 14 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 15 |
formData.append('__tagembed__ajax_action', '__tagembed__get_themes'); |
| 16 |
__tagembed__open_loader(); |
| 17 |
fetch(__tagembed__ajax_url, { |
| 18 |
method: 'POST', |
| 19 |
headers: { |
| 20 |
'x-requested-with': 'XMLHttpRequest', |
| 21 |
}, |
| 22 |
body: formData, |
| 23 |
}).then(response => { |
| 24 |
return response.json() |
| 25 |
}).then(response => { |
| 26 |
__tagembed__close_loader(); |
| 27 |
if (response.status == true) { |
| 28 |
let elemHTML = ""; |
| 29 |
if (typeof response.data !== 'undefined' && response.data.length > 0) { |
| 30 |
for (let index in response.data) { |
| 31 |
elemHTML = `${elemHTML}<li>`; |
| 32 |
elemHTML = `${elemHTML}<label class="${response.data[index].active == 1 ? "__tagembed__themeactive" : ""} ">`; |
| 33 |
elemHTML = `${elemHTML}<span class="__tagembed__theme-img">`; |
| 34 |
/*elemHTML = `${elemHTML}<img src="${__tagembed__plugin_url_for_js}assets/images/theme/themeThumb${response.data[index].themeId}.png" alt="modern fall" />`;*/ |
| 35 |
elemHTML = `${elemHTML}<img class="lazyload" src="${__tagembed__plugin_url_for_js}assets/images/blur-img.gif" data-src="${__tagembed__plugin_url_for_js}assets/images/theme/themeThumb${response.data[index].themeId}.png" alt="theme-image" />`; |
| 36 |
elemHTML = `${elemHTML}</span>`; |
| 37 |
elemHTML = `${elemHTML}<span class="__tagembed__themename"> ${response.data[index].name} </span>`; |
| 38 |
elemHTML = `${elemHTML}<input type="radio" onclick="__tagembed__editTheme(${response.data[index].themeId});" class="__tagembed__theme_radio_button" name="themeId" value="${response.data[index].themeId}" ${response.data[index].active == 1 ? "checked" : ""} />`; |
| 39 |
elemHTML = `${elemHTML}</label>`; |
| 40 |
elemHTML = `${elemHTML}</li>`; |
| 41 |
} |
| 42 |
} |
| 43 |
__tagembed__theme.innerHTML = elemHTML; |
| 44 |
__tagembed__image__lazy_loading()/*Image Lazy Loader*/ |
| 45 |
} else { |
| 46 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 47 |
} |
| 48 |
}).catch((error) => { |
| 49 |
console.log(error); |
| 50 |
__tagembed__close_loader(); |
| 51 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 52 |
}); |
| 53 |
} |
| 54 |
/*--End-- Get Social Accounts*/ |
| 55 |
/*--Start--Image Lazy Loadin*/ |
| 56 |
function __tagembed__image__lazy_loading() { |
| 57 |
let images = document.querySelectorAll(".lazyload"); |
| 58 |
lazyload(images); |
| 59 |
} |
| 60 |
/*--End--Image Lazy Loadin*/ |
| 61 |
/*--Start--Edit Theme*/ |
| 62 |
function __tagembed__editTheme(__tagembed__theme_id) { |
| 63 |
let __tagembed__widget_id = document.querySelector("#__tagembed__widgets").selectedOptions[0]; |
| 64 |
__tagembed__widget_id = __tagembed__widget_id.value.split('#')[0]; |
| 65 |
let __tagembed__toast = new TagembedToast; |
| 66 |
if (!__tagembed__widget_id || !__tagembed__theme_id) |
| 67 |
return __tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 68 |
let formData = new FormData(); |
| 69 |
formData.append('action', 'data'); |
| 70 |
formData.append('widgetId', __tagembed__widget_id); |
| 71 |
formData.append('themeId', __tagembed__theme_id); |
| 72 |
formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 73 |
formData.append('__tagembed__ajax_action', '__tagembed__edit_themes'); |
| 74 |
__tagembed__open_loader(); |
| 75 |
fetch(__tagembed__ajax_url, { |
| 76 |
method: 'POST', |
| 77 |
headers: { |
| 78 |
'x-requested-with': 'XMLHttpRequest', |
| 79 |
}, |
| 80 |
body: formData, |
| 81 |
}).then(response => { |
| 82 |
return response.json(); |
| 83 |
}).then(response => { |
| 84 |
__tagembed__close_loader(); |
| 85 |
if (response.status == true) { |
| 86 |
__tagembed__toast.success({message: "Theme Updated.", position: '__tagembed__is-top-right'}); |
| 87 |
} else { |
| 88 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 89 |
} |
| 90 |
}).catch((error) => { |
| 91 |
console.log(error); |
| 92 |
__tagembed__close_loader(); |
| 93 |
__tagembed__toast.danger({message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right'}); |
| 94 |
}); |
| 95 |
|
| 96 |
} |
| 97 |
/*--End--Edit Theme*/ |