assets/js
account
4 days ago
customize
4 days ago
display
4 days ago
editor
4 days ago
feed
4 days ago
filter
4 days ago
network
4 days ago
support
4 days ago
theme
4 days ago
upgrade
4 days ago
vendor
4 days ago
widget
4 days ago
confirm_dialog.js
4.5 KB
4 days ago
dialog.form.js
10.6 KB
4 days ago
lazyload.js
4.9 KB
4 days ago
loader.js
1.3 KB
4 days ago
tagembed.common.js
25.0 KB
4 days ago
tagembed.deactive.js
9.2 KB
4 days ago
toast.js
3.0 KB
4 days ago
tagembed.common.js in Tagembed: Social Media Feeds and Customer Reviews Widget 7.9, at assets/js/tagembed.common.js
| 1 | /*--Start--Validation : Accept An Identifier Only When It Is Digits Only*/ |
| 2 | /* Validation, as described in the WordPress security handbook : test the value against a |
| 3 | known pattern and treat anything else as invalid. */ |
| 4 | function __tagembed__isValidId(value) { |
| 5 | return /^\d+$/.test(String(value === undefined || value === null ? "" : value).trim()); |
| 6 | } |
| 7 | function __tagembed__validId(value) { |
| 8 | return __tagembed__isValidId(value) ? String(value).trim() : ""; |
| 9 | } |
| 10 | /*--End--Validation*/ |
| 11 | /*--Start--Escaping : WordPress Core @wordpress/escape-html Package*/ |
| 12 | /* wp.escapeHtml is shipped by WordPress core (script handle wp-escape-html). |
| 13 | escapeHTML() is for text between tags, escapeAttribute() is for a double quoted attribute. */ |
| 14 | function __tagembed__escapeText(value) { |
| 15 | let __tagembed__stringValue = String(value === undefined || value === null ? "" : value); |
| 16 | return window.wp.escapeHtml.escapeHTML(__tagembed__stringValue); |
| 17 | } |
| 18 | function __tagembed__escapeAttr(value) { |
| 19 | let __tagembed__stringValue = String(value === undefined || value === null ? "" : value); |
| 20 | return window.wp.escapeHtml.escapeAttribute(__tagembed__stringValue); |
| 21 | } |
| 22 | /*--End--Escaping*/ |
| 23 | /*--Start--Sanitization : DOMPurify, Applied To Every Markup String Before It Reaches The DOM*/ |
| 24 | /* Our own DOMPurify instance is captured as soon as this file loads, so a copy loaded |
| 25 | later by another plugin can never replace the one this plugin uses. */ |
| 26 | var __tagembed__purifier = window.__tagembed__DOMPurify || window.DOMPurify; |
| 27 | function __tagembed__setSafeHtml(element, html) { |
| 28 | if (!element) return; |
| 29 | var __tagembed__sanitizer = __tagembed__purifier || window.__tagembed__DOMPurify || window.DOMPurify; |
| 30 | if (!__tagembed__sanitizer || typeof __tagembed__sanitizer.sanitize !== "function") { |
| 31 | /* Without the sanitizer nothing is rendered, so unsanitized markup can never reach the page. */ |
| 32 | element.textContent = ""; |
| 33 | return; |
| 34 | } |
| 35 | element.innerHTML = __tagembed__sanitizer.sanitize(String(html === undefined || html === null ? "" : html), { USE_PROFILES: { html: true } }); |
| 36 | } |
| 37 | /*--End--Sanitization*/ |
| 38 | /*--Start-- Manage Window Popup In New Tab*/ |
| 39 | /*function __tagmebed__openWindowPopup(url, windowName = "Tagembed") { |
| 40 | __tagmebed__window_popup = window.open(url, '_blank'); |
| 41 | __tagmebed__window_popup.focus(); |
| 42 | var __tagembed__window_pupup_timer = setInterval(function () { |
| 43 | if (__tagmebed__window_popup.closed) { |
| 44 | location.reload(); |
| 45 | clearInterval(__tagembed__window_pupup_timer); |
| 46 | } |
| 47 | }, 250); |
| 48 | }*/ |
| 49 | function __tagmebed__openWindowPopup(url, windowName = "Tagembed") { |
| 50 | __tagmebed__window_popup = window.open(url, windowName, 'height=600,width=600,left=0,top=0,resizable=yes,scrollbars=yes,toolbar=yes,menubar=no,location=no,directories=no, status=yes'); |
| 51 | var __tagembed__window_pupup_timer = setInterval(function () { |
| 52 | if (__tagmebed__window_popup.closed) { |
| 53 | location.reload(); |
| 54 | clearInterval(__tagembed__window_pupup_timer); |
| 55 | } |
| 56 | }, 250); |
| 57 | } |
| 58 | function __tagmebed__closeWindowPopup() { |
| 59 | if (__tagmebed__window_popup) |
| 60 | __tagmebed__window_popup.close(); |
| 61 | } |
| 62 | /*--End-- Create And Manage Window Popup*/ |
| 63 | |
| 64 | /*--Start--Hide/Show Loader During Page Readay State*/ |
| 65 | document.onreadystatechange = function () { |
| 66 | if (document.readyState !== "complete") { |
| 67 | __tagembed__open_loader(); |
| 68 | } else { |
| 69 | __tagembed__close_loader(); |
| 70 | } |
| 71 | }; |
| 72 | /*--End--Hide/Show Loader During Page Readay State*/ |
| 73 | |
| 74 | /*--Start-- Manage Response Message*/ |
| 75 | window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message); |
| 76 | function __tagembed__message() { |
| 77 | let __tagembed__toast = new TagembedToast; |
| 78 | /*--Start-- Manage Redirect Url Error*/ |
| 79 | let urlSearchParams = new URLSearchParams(window.location.search); |
| 80 | let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); |
| 81 | /*--Start-- Manage Show Messaage According Time*/ |
| 82 | let getTime = new Date(); |
| 83 | getTime = getTime.getTime(); /*milliseconds*/ |
| 84 | getTime = Math.floor(getTime / 1000); /*seconds*/ |
| 85 | if (__tagembed__message.hasOwnProperty("status")) { |
| 86 | if (__tagembed__message.status < getTime) |
| 87 | return; |
| 88 | } |
| 89 | /*--End-- Manage Show Messaage According Time*/ |
| 90 | if (__tagembed__message.hasOwnProperty("__tagembed__message")) { |
| 91 | if (__tagembed__message.hasOwnProperty("success")) { |
| 92 | __tagembed__toast.success({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); |
| 93 | } else if (__tagembed__message.hasOwnProperty("info")) { |
| 94 | __tagembed__toast.info({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); |
| 95 | } else if (__tagembed__message.hasOwnProperty("warning")) { |
| 96 | __tagembed__toast.warning({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); |
| 97 | } else { |
| 98 | __tagembed__toast.danger({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' }); |
| 99 | } |
| 100 | /*--Start--Show Popup On Plan Upgrade Time*/ |
| 101 | /* Every query string value is read through one trimmed lookup, so a key that arrives with |
| 102 | no value at all (&paymentId) counts as absent instead of printing a blank box. */ |
| 103 | let __tagembed__queryValue = function (key) { |
| 104 | let __tagembed__raw = __tagembed__message[key]; |
| 105 | return String(__tagembed__raw === undefined || __tagembed__raw === null ? "" : __tagembed__raw).trim(); |
| 106 | }; |
| 107 | let __tagembed__planName = __tagembed__queryValue("planName"); |
| 108 | if (__tagembed__planName) { |
| 109 | let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup"); |
| 110 | /* The popup markup only exists on the upgrade screen, so nothing is built when it is absent. */ |
| 111 | if (!__tagembed__upgrade_account_popup) return; |
| 112 | /* Built with DOM methods. The query string values are inserted as text |
| 113 | nodes only, so no markup can be produced from them. */ |
| 114 | let __tagembed__makeElement = function (tag, className) { |
| 115 | let __tagembed__element = document.createElement(tag); |
| 116 | if (className) __tagembed__element.className = className; |
| 117 | return __tagembed__element; |
| 118 | }; |
| 119 | let __tagembed__makePlanBox = function (label, value) { |
| 120 | let __tagembed__box = __tagembed__makeElement("div", "__tagembed__planbox"); |
| 121 | let __tagembed__label = document.createElement("p"); |
| 122 | __tagembed__label.textContent = label; |
| 123 | let __tagembed__value = document.createElement("span"); |
| 124 | __tagembed__value.textContent = (value === undefined || value === null) ? "" : String(value); |
| 125 | __tagembed__box.appendChild(__tagembed__label); |
| 126 | __tagembed__box.appendChild(__tagembed__value); |
| 127 | return __tagembed__box; |
| 128 | }; |
| 129 | let __tagembed__wrap = __tagembed__makeElement("div", "__tagembed__popupwrap __tagembed__popup_md"); |
| 130 | let __tagembed__closeBtn = __tagembed__makeElement("button", "__tagembed__closebtn"); |
| 131 | __tagembed__closeBtn.setAttribute("id", "__tagembed__upgrade_account_popup_close_btn"); |
| 132 | __tagembed__closeBtn.setAttribute("type", "button"); |
| 133 | __tagembed__closeBtn.addEventListener("click", __tagembed__hide_upgrade_account_popup); |
| 134 | let __tagembed__inn = __tagembed__makeElement("div", "__tagembed__popupinn"); |
| 135 | let __tagembed__body = __tagembed__makeElement("div", "__tagembed__formwbody"); |
| 136 | let __tagembed__thankyou = __tagembed__makeElement("div", "__tagembed__thankyou"); |
| 137 | let __tagembed__checkImg = document.createElement("img"); |
| 138 | __tagembed__checkImg.setAttribute("src", __tagembed__plugin_url_for_js + "assets/images/check-green.png"); |
| 139 | __tagembed__checkImg.setAttribute("alt", "check"); |
| 140 | let __tagembed__heading = document.createElement("h2"); |
| 141 | __tagembed__heading.appendChild(document.createTextNode("Congratulations! ")); |
| 142 | let __tagembed__headingSpan = document.createElement("span"); |
| 143 | /* The popup repeats the message that came back in the query string, so an upgrade and a |
| 144 | downgrade each read correctly instead of both claiming an upgrade. */ |
| 145 | __tagembed__headingSpan.textContent = __tagembed__message.__tagembed__message.replace(/-/g, ' '); |
| 146 | __tagembed__heading.appendChild(__tagembed__headingSpan); |
| 147 | let __tagembed__detail = __tagembed__makeElement("div", "__tagembed__plandetail"); |
| 148 | /* A free plan costs nothing, so a missing or zero amount is left out rather than shown as $0. */ |
| 149 | let __tagembed__amount = __tagembed__queryValue("amount"); |
| 150 | let __tagembed__amountValue = Number(__tagembed__amount); |
| 151 | if (__tagembed__amount && !(isFinite(__tagembed__amountValue) && 0 === __tagembed__amountValue)) |
| 152 | __tagembed__detail.appendChild(__tagembed__makePlanBox("Amount", "$" + __tagembed__amount)); |
| 153 | /* A downgrade carries no payment, so the payment id is shown only when one actually arrived. */ |
| 154 | let __tagembed__paymentId = __tagembed__queryValue("paymentId"); |
| 155 | if (__tagembed__paymentId) |
| 156 | __tagembed__detail.appendChild(__tagembed__makePlanBox("Payment Id", __tagembed__paymentId)); |
| 157 | /* The free plan is the fallback every downgrade lands on, so naming it adds nothing. */ |
| 158 | if ("free" !== __tagembed__planName.toLowerCase()) |
| 159 | __tagembed__detail.appendChild(__tagembed__makePlanBox("Plan", __tagembed__planName)); |
| 160 | __tagembed__thankyou.appendChild(__tagembed__checkImg); |
| 161 | __tagembed__thankyou.appendChild(__tagembed__heading); |
| 162 | /* A free downgrade leaves out every detail, so the empty row is not added at all. */ |
| 163 | if (__tagembed__detail.hasChildNodes()) |
| 164 | __tagembed__thankyou.appendChild(__tagembed__detail); |
| 165 | __tagembed__body.appendChild(__tagembed__thankyou); |
| 166 | __tagembed__inn.appendChild(__tagembed__body); |
| 167 | __tagembed__wrap.appendChild(__tagembed__closeBtn); |
| 168 | __tagembed__wrap.appendChild(__tagembed__inn); |
| 169 | __tagembed__upgrade_account_popup.replaceChildren(__tagembed__wrap); |
| 170 | __tagembed__upgrade_account_popup.style.display = "block"; |
| 171 | } |
| 172 | /*--End--Show Popup On Plan Upgrade Time*/ |
| 173 | } |
| 174 | } |
| 175 | /*--End-- Manage Response Message*/ |
| 176 | /*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 177 | function __tagembed__manageApiCall() { |
| 178 | let urlSearchParams = new URLSearchParams(window.location.search); |
| 179 | let __tagembed__message = Object.fromEntries(urlSearchParams.entries()); |
| 180 | if (__tagembed__message.hasOwnProperty("__tagembed__message")) |
| 181 | return true |
| 182 | return false; |
| 183 | } |
| 184 | /*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/ |
| 185 | /*--Start-- Logout*/ |
| 186 | var __tagembed__logout = document.querySelector("#__tagembed__logout"); |
| 187 | if (__tagembed__logout) { |
| 188 | __tagembed__logout.addEventListener('click', function (event) { |
| 189 | __tagembed__confirmDialog({ title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning' }, function () { |
| 190 | let formData = new FormData(); |
| 191 | formData.append('action', 'tagembed_data'); |
| 192 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 193 | formData.append('__tagembed__ajax_action', '__tagembed__logout'); |
| 194 | __tagembed__open_loader(); |
| 195 | let __tagembed__toast = new TagembedToast; |
| 196 | fetch(__tagembed__ajax_url, { |
| 197 | method: 'POST', |
| 198 | headers: { |
| 199 | 'x-requested-with': 'XMLHttpRequest', |
| 200 | }, |
| 201 | body: formData, |
| 202 | }).then(response => { |
| 203 | return response.json() |
| 204 | }).then(response => { |
| 205 | __tagembed__close_loader(); |
| 206 | if (response.status == true) { |
| 207 | window.location.replace(response.data.redirectUrl); |
| 208 | } else { |
| 209 | if (response.hasOwnProperty("message")) { |
| 210 | __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 211 | } else { |
| 212 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 213 | } |
| 214 | } |
| 215 | }).catch((error) => { |
| 216 | console.log(error); |
| 217 | __tagembed__close_loader(); |
| 218 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 219 | }); |
| 220 | }); |
| 221 | }); |
| 222 | } |
| 223 | /*--End-- Logout*/ |
| 224 | |
| 225 | /*--Start--Manage Tagembed Menue*/ |
| 226 | function __tagembed__menus(__tagembed__menu_id, __tagembed__widgetId = null) { |
| 227 | if (__tagembed__widgetId) |
| 228 | __tagembed__manageActiveWidget(__tagembed__widgetId); |
| 229 | __tagembed__open_loader(); |
| 230 | let __tagembed__toast = new TagembedToast; |
| 231 | let formData = new FormData(); |
| 232 | formData.append('action', 'tagembed_data'); |
| 233 | formData.append('menueId', __tagembed__menu_id); |
| 234 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 235 | formData.append('__tagembed__ajax_action', '__tagembed__menue'); |
| 236 | fetch(__tagembed__ajax_url, { |
| 237 | method: 'POST', |
| 238 | headers: { |
| 239 | 'x-requested-with': 'XMLHttpRequest', |
| 240 | }, |
| 241 | body: formData, |
| 242 | }).then(response => { |
| 243 | return response.json() |
| 244 | }).then(response => { |
| 245 | if (response.status == true) { |
| 246 | return window.location.replace(response.data.redirectUrl); |
| 247 | /*return window.location.href = response.data.redirectUrl;*/ |
| 248 | } else { |
| 249 | __tagembed__close_loader(); |
| 250 | if (response.hasOwnProperty("message")) { |
| 251 | __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 252 | } else { |
| 253 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 254 | } |
| 255 | } |
| 256 | }).catch((error) => { |
| 257 | console.log(error); |
| 258 | __tagembed__close_loader(); |
| 259 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 260 | }); |
| 261 | } |
| 262 | /*--End--Manage Tagembed Menue*/ |
| 263 | /*--Start-- Get Already Exist Auth*/ |
| 264 | function __tagembed__get_already_exist_auth(__tagembed__network_id) { |
| 265 | if (!__tagembed__network_id) |
| 266 | return; |
| 267 | let formData = new FormData(); |
| 268 | formData.append('networkId', __tagembed__network_id); |
| 269 | formData.append('action', 'tagembed_data'); |
| 270 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 271 | formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); |
| 272 | fetch(__tagembed__ajax_url, { |
| 273 | method: 'POST', |
| 274 | headers: { |
| 275 | 'x-requested-with': 'XMLHttpRequest', |
| 276 | }, |
| 277 | body: formData, |
| 278 | }).then(response => { |
| 279 | return response.json() |
| 280 | }).then(response => { |
| 281 | if (response.status == true) |
| 282 | __tagembed__network_already_exist_auth = response.data; |
| 283 | }); |
| 284 | } |
| 285 | /*Note : This Use For Merge Instagram 2/18*/ |
| 286 | function __tagembed__get_already_exist_auth_new(__tagembed__network_id, __tagembed__feed_data) { |
| 287 | if (!__tagembed__network_id) |
| 288 | return; |
| 289 | __tagembed__open_loader(); |
| 290 | let formData = new FormData(); |
| 291 | formData.append('networkId', __tagembed__network_id); |
| 292 | formData.append('action', 'tagembed_data'); |
| 293 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 294 | formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth'); |
| 295 | fetch(__tagembed__ajax_url, { |
| 296 | method: 'POST', |
| 297 | headers: { 'x-requested-with': 'XMLHttpRequest', }, |
| 298 | body: formData, |
| 299 | }).then(response => { |
| 300 | return response.json() |
| 301 | }).then(response => { |
| 302 | if (response.status == true) { |
| 303 | __tagembed__network_already_exist_auth = response.data; |
| 304 | __tagembed__createInstagramBusinessFeed(__tagembed__feed_data); |
| 305 | __tagembed__close_loader(); |
| 306 | } |
| 307 | }); |
| 308 | } |
| 309 | /*--End-- Get Already Exist Auth*/ |
| 310 | /*--Start-- Manage Active Widget*/ |
| 311 | var __tagembed__widgets = document.querySelector("#__tagembed__widgets"); |
| 312 | if (__tagembed__widgets) { |
| 313 | __tagembed__widgets.addEventListener("change", function (event) { |
| 314 | if (typeof __tagembed__get_theme !== 'undefined') |
| 315 | __tagembed__get_theme(); /*Manage Widget Theme According Widget*/ |
| 316 | if (typeof __tagembed__changeIfrmSrc !== 'undefined') |
| 317 | __tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/ |
| 318 | if (typeof __tagembed__manageShotrCode !== 'undefined') |
| 319 | __tagembed__manageShotrCode(); /*Manage Short Code According Widget*/ |
| 320 | if (typeof __tagembed__manageEmbedCode !== 'undefined') |
| 321 | __tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/ |
| 322 | if (typeof __tagembed__getFeed !== 'undefined') |
| 323 | __tagembed__getFeed(); /*Get Feed According Widget*/ |
| 324 | if (typeof __tagembed__changeFilterIfrmSrc !== 'undefined') |
| 325 | __tagembed__changeFilterIfrmSrc(); /*Mange Filter Section According Widget*/ |
| 326 | __tagembed__manageActiveWidget(); /*Manage Active Widget*/ |
| 327 | if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/ |
| 328 | __tagembed__getCustomizationOption(); |
| 329 | }); |
| 330 | } |
| 331 | function __tagembed__manageActiveWidget(__tagembed__widgetId = null) { |
| 332 | if (!__tagembed__widgetId) { |
| 333 | __tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0]; |
| 334 | __tagembed__widgetId = __tagembed__widgetId.value.split('#')[0]; |
| 335 | } |
| 336 | let __tagembed__toast = new TagembedToast; |
| 337 | let formData = new FormData(); |
| 338 | formData.append('action', 'tagembed_data'); |
| 339 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 340 | formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget'); |
| 341 | formData.append('widgetId', __tagembed__widgetId); |
| 342 | if (__tagembed__loader_status) |
| 343 | __tagembed__open_loader(); |
| 344 | fetch(__tagembed__ajax_url, { |
| 345 | method: 'POST', |
| 346 | headers: { |
| 347 | 'x-requested-with': 'XMLHttpRequest', |
| 348 | }, |
| 349 | body: formData, |
| 350 | }).then(response => { |
| 351 | return response.json() |
| 352 | }).then(response => { |
| 353 | if (__tagembed__loader_status) |
| 354 | __tagembed__close_loader(); |
| 355 | if (response.status == true) { |
| 356 | /*--Start--Reload Page For Manage Active Class On Widget Page*/ |
| 357 | if (document.querySelector("#__tagembed__widgetbox0")) |
| 358 | location.reload(); |
| 359 | /*--End--Reload Page For Manage Active Class On Widget Page*/ |
| 360 | } else { |
| 361 | if (response.hasOwnProperty("message")) { |
| 362 | __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 363 | } else { |
| 364 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 365 | } |
| 366 | } |
| 367 | }).catch((error) => { |
| 368 | console.log(error); |
| 369 | __tagembed__close_loader(); |
| 370 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 371 | }); |
| 372 | } |
| 373 | /*--End-- Manage Active Widget*/ |
| 374 | /*--Start--Create Widget*/ |
| 375 | var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form"); |
| 376 | if (__tagembed__widget_create_form) { |
| 377 | __tagembed__widget_create_form.addEventListener("click", function (event) { |
| 378 | __tagembed__dialog_form({ |
| 379 | popupSize: '__tagembed__popup_md', title: 'Create Widget', |
| 380 | form: { method: 'post', buttonText: 'Create' }, |
| 381 | inputs: [{ label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget' }, { label: 'Profanity Filter', type: 'checkbox', name: 'profanity' }], |
| 382 | action: function (event, formData) { |
| 383 | let __tagembed__name_error = document.querySelector("#__tagembed__name_error"); |
| 384 | __tagembed__name_error.style.display = 'none'; |
| 385 | if (!formData.get('name')) { |
| 386 | __tagembed__name_error.style.display = 'block'; |
| 387 | __tagembed__name_error.textContent = "Widget name is required"; |
| 388 | return; |
| 389 | } |
| 390 | __tagembed__open_loader(); |
| 391 | let __tagembed__toast = new TagembedToast; |
| 392 | formData.append('action', 'tagembed_data'); |
| 393 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 394 | formData.append('__tagembed__ajax_action', '__tagembed__create_widget'); |
| 395 | fetch(__tagembed__ajax_url, { |
| 396 | method: 'POST', |
| 397 | headers: { |
| 398 | 'x-requested-with': 'XMLHttpRequest', |
| 399 | }, |
| 400 | body: formData, |
| 401 | }).then(response => { |
| 402 | return response.json(); |
| 403 | }).then(response => { |
| 404 | __tagembed__close_loader(); |
| 405 | if (response.status == true) { |
| 406 | document.querySelector('#__tagembed__dialog_form_id_').remove(); |
| 407 | if (response.data.hasOwnProperty("message")) { |
| 408 | __tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' }); |
| 409 | } |
| 410 | window.location.replace(response.data.redirectUrl); |
| 411 | } else { |
| 412 | if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) { |
| 413 | if (response.data.hasOwnProperty("name")) { |
| 414 | __tagembed__name_error.style.display = 'block'; |
| 415 | __tagembed__name_error.textContent = response.data.name; |
| 416 | } |
| 417 | } else { |
| 418 | if (response.hasOwnProperty("message")) { |
| 419 | __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 420 | } else { |
| 421 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | }).catch((error) => { |
| 426 | console.log(error); |
| 427 | __tagembed__close_loader(); |
| 428 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 429 | }); |
| 430 | } |
| 431 | }); |
| 432 | }); |
| 433 | } |
| 434 | /*--End--Create Widget*/ |
| 435 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 436 | function __tagembed__manageMenueHideShowInMobile() { |
| 437 | let __tagembed__menulist = document.querySelector("#__tagembed__menulist"); |
| 438 | let __tagembed__burger = document.querySelector("#__tagembed__burger"); |
| 439 | if (__tagembed__menulist.style.display === "none") { |
| 440 | __tagembed__menulist.style.display = "block"; |
| 441 | __tagembed__burger.classList.add("__tagembed__addclose"); |
| 442 | } else { |
| 443 | __tagembed__menulist.style.display = "none"; |
| 444 | __tagembed__burger.classList.remove("__tagembed__addclose"); |
| 445 | } |
| 446 | } |
| 447 | /*--Start--Manage Menue Hide Show In Mobile*/ |
| 448 | /*--Start--Manage Toggel On Press Space Button*/ |
| 449 | function __tagembed__manageToggelOnPressSpace() { |
| 450 | let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog"); |
| 451 | if (tagembedConfirmDialog) |
| 452 | return true; |
| 453 | return false; |
| 454 | } |
| 455 | /*--End--Manage Toggel On Press Space Button*/ |
| 456 | /*--Start-- Add And Update Connected Account*/ |
| 457 | function __tageembed__addUpdateAndRefreshAccount(__tagembed__networkId, __tagembed__type, __tagembed__connected_account_id = null, __tagembed__feed_id = null, __tagembed__feed_filter_id = null, __tagembed__other_data = null) { |
| 458 | if (__tagembed__networkId) { |
| 459 | let __tagembed__toast = new TagembedToast; |
| 460 | let formData = new FormData(); |
| 461 | formData.append('action', 'tagembed_data'); |
| 462 | formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones); |
| 463 | formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account'); |
| 464 | formData.append('type', __tagembed__type); |
| 465 | formData.append('connectedAccountId', __tagembed__connected_account_id); |
| 466 | formData.append('feedId', __tagembed__feed_id); |
| 467 | formData.append('networkId', __tagembed__networkId); |
| 468 | formData.append('filterId', __tagembed__feed_filter_id); |
| 469 | formData.append('otherData', __tagembed__other_data); |
| 470 | __tagembed__open_loader(); |
| 471 | fetch(__tagembed__ajax_url, { |
| 472 | method: 'POST', |
| 473 | headers: { |
| 474 | 'x-requested-with': 'XMLHttpRequest', |
| 475 | }, |
| 476 | body: formData, |
| 477 | }).then(response => { |
| 478 | return response.json() |
| 479 | }).then(response => { |
| 480 | if (response.status == true) { |
| 481 | /*window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');*/ |
| 482 | let __tagembed__Url = response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl; |
| 483 | __tagmebed__openWindowPopup(__tagembed__Url); |
| 484 | |
| 485 | } else { |
| 486 | __tagembed__close_loader(); |
| 487 | if (response.hasOwnProperty("message")) { |
| 488 | __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' }); |
| 489 | } else { |
| 490 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 491 | } |
| 492 | } |
| 493 | }).catch((error) => { |
| 494 | console.log(error); |
| 495 | __tagembed__close_loader(); |
| 496 | __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' }); |
| 497 | }); |
| 498 | } |
| 499 | } |
| 500 | /*--End-- Add And Update Connected Account*/ |
| 501 | /*--Start-- Manage Short Code*/ |
| 502 | window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode); |
| 503 | function __tagembed__manageShotrCode() { |
| 504 | let widgetData = document.querySelector("#__tagembed__widgets"); |
| 505 | if (widgetData) { |
| 506 | let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0]; |
| 507 | let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode"); |
| 508 | if (__tagembed__shortCode) |
| 509 | __tagembed__shortCode.textContent = `[tagembed widgetid ${__tagembed__widgetId}]`; |
| 510 | } |
| 511 | } |
| 512 | /*--Start--Copy Short Code*/ |
| 513 | async function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) { |
| 514 | |
| 515 | let ___tagembed__shouldStop = await __tagembed__upgradePlan(); |
| 516 | if (___tagembed__shouldStop) return; |
| 517 | |
| 518 | let __tagembed__toast = new TagembedToast; |
| 519 | let __tagembed__copyEmbedCode = ""; |
| 520 | switch (__tagembed__codeType) { |
| 521 | case "shortCode": |
| 522 | __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).textContent; |
| 523 | break; |
| 524 | case "embedCode": |
| 525 | __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value; |
| 526 | break; |
| 527 | } |
| 528 | navigator.clipboard.writeText(__tagembed__copyEmbedCode); |
| 529 | __tagembed__toast.success({ message: 'copied', position: '__tagembed__is-top-right' }); |
| 530 | } |
| 531 | /*--End--Copy Short Code*/ |
| 532 | |
| 533 |