PluginProbe
Tagembed: Social Media Feeds and Customer Reviews Widget / 7.4
Tagembed: Social Media Feeds and Customer Reviews Widget v7.4
7.8 7.5 7.6 7.7 7.4 trunk 3.10 3.9 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 5.0 5.1 5.2 5.3 5.4 5.5 5.6 All 43 releases
tagembed-widget / assets / js / tagembed.common.js

tagembed.common.js in Tagembed: Social Media Feeds and Customer Reviews Widget 7.4, at assets/js/tagembed.common.js

450 lines 20.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /*--Start-- Manage Window Popup In New Tab*/
2 /*function __tagmebed__openWindowPopup(url, windowName = "Tagembed") {
3 __tagmebed__window_popup = window.open(url, '_blank');
4 __tagmebed__window_popup.focus();
5 var __tagembed__window_pupup_timer = setInterval(function () {
6 if (__tagmebed__window_popup.closed) {
7 location.reload();
8 clearInterval(__tagembed__window_pupup_timer);
9 }
10 }, 250);
11 }*/
12 function __tagmebed__openWindowPopup(url, windowName = "Tagembed") {
13 __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');
14 var __tagembed__window_pupup_timer = setInterval(function () {
15 if (__tagmebed__window_popup.closed) {
16 location.reload();
17 clearInterval(__tagembed__window_pupup_timer);
18 }
19 }, 250);
20 }
21 function __tagmebed__closeWindowPopup() {
22 if (__tagmebed__window_popup)
23 __tagmebed__window_popup.close();
24 }
25 /*--End-- Create And Manage Window Popup*/
26
27 /*--Start--Hide/Show Loader During Page Readay State*/
28 document.onreadystatechange = function () {
29 if (document.readyState !== "complete") {
30 __tagembed__open_loader();
31 } else {
32 __tagembed__close_loader();
33 }
34 };
35 /*--End--Hide/Show Loader During Page Readay State*/
36
37 /*--Start-- Manage Response Message*/
38 window.addEventListener ? window.addEventListener("load", __tagembed__message, false) : window.attachEvent && window.attachEvent("onload", __tagembed__message);
39 function __tagembed__message() {
40 let __tagembed__toast = new TagembedToast;
41 /*--Start-- Manage Redirect Url Error*/
42 let urlSearchParams = new URLSearchParams(window.location.search);
43 let __tagembed__message = Object.fromEntries(urlSearchParams.entries());
44 /*--Start-- Manage Show Messaage According Time*/
45 let getTime = new Date();
46 getTime = getTime.getTime(); /*milliseconds*/
47 getTime = Math.floor(getTime / 1000); /*seconds*/
48 if (__tagembed__message.hasOwnProperty("status")) {
49 if (__tagembed__message.status < getTime)
50 return;
51 }
52 /*--End-- Manage Show Messaage According Time*/
53 if (__tagembed__message.hasOwnProperty("__tagembed__message")) {
54 if (__tagembed__message.hasOwnProperty("success")) {
55 __tagembed__toast.success({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' });
56 } else if (__tagembed__message.hasOwnProperty("info")) {
57 __tagembed__toast.info({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' });
58 } else if (__tagembed__message.hasOwnProperty("warning")) {
59 __tagembed__toast.warning({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' });
60 } else {
61 __tagembed__toast.danger({ message: __tagembed__message.__tagembed__message.replace(/-/g, ' '), position: '__tagembed__is-top-right' });
62 }
63 /*--Start--Show Popup On Plan Upgrade Time*/
64 if (__tagembed__message.hasOwnProperty("planName") && __tagembed__message.hasOwnProperty("amount") && __tagembed__message.hasOwnProperty("paymentId")) {
65 let __tagembed__upgrade_account_popup = document.querySelector("#__tagembed__upgrade_account_popup");
66 let elemHTML = `<div class="__tagembed__popupwrap __tagembed__popup_md">`;
67 elemHTML = `${elemHTML}<button id="__tagembed__upgrade_account_popup_close_btn" onclick="__tagembed__hide_upgrade_account_popup();" type="button" class="__tagembed__closebtn"></button>`;
68 elemHTML = `${elemHTML}<div class="__tagembed__popupinn">`;
69 elemHTML = `${elemHTML}<div class="__tagembed__formwbody">`;
70 elemHTML = `${elemHTML}<div class="__tagembed__thankyou">`;
71 elemHTML = `${elemHTML}<img src="${__tagembed__plugin_url_for_js}assets/images/check-green.png" alt="check">`;
72 elemHTML = `${elemHTML}<h2>Congratulations! <span>Your account has been upgraded</span></h2>`;
73 elemHTML = `${elemHTML}<div class="__tagembed__plandetail">`;
74 elemHTML = `${elemHTML}<div class="__tagembed__planbox">`;
75 elemHTML = `${elemHTML}<p>Amount</p>`;
76 elemHTML = `${elemHTML}<span>$${__tagembed__message.amount}</span>`;
77 elemHTML = `${elemHTML}</div>`;
78 elemHTML = `${elemHTML}<div class="__tagembed__planbox">`;
79 elemHTML = `${elemHTML}<p>Payment Id</p>`;
80 elemHTML = `${elemHTML}<span>${__tagembed__message.paymentId}</span>`;
81 elemHTML = `${elemHTML}</div>`;
82 elemHTML = `${elemHTML}<div class="__tagembed__planbox">`;
83 elemHTML = `${elemHTML}<p>Plan</p>`;
84 elemHTML = `${elemHTML}<span>${__tagembed__message.planName}</span>`;
85 elemHTML = `${elemHTML}</div></div></div></div></div></div>`;
86 __tagembed__upgrade_account_popup.innerHTML = elemHTML;
87 __tagembed__upgrade_account_popup.style.display = "block";
88 }
89 /*--End--Show Popup On Plan Upgrade Time*/
90 }
91 }
92 /*--End-- Manage Response Message*/
93 /*--Start--Manage Windiow Onload Function When Response Message Exist In Query String*/
94 function __tagembed__manageApiCall() {
95 let urlSearchParams = new URLSearchParams(window.location.search);
96 let __tagembed__message = Object.fromEntries(urlSearchParams.entries());
97 if (__tagembed__message.hasOwnProperty("__tagembed__message"))
98 return true
99 return false;
100 }
101 /*--End--Manage Windiow Onload Function When Response Message Exist In Query String*/
102 /*--Start-- Logout*/
103 var __tagembed__logout = document.querySelector("#__tagembed__logout");
104 if (__tagembed__logout) {
105 __tagembed__logout.addEventListener('click', function (event) {
106 confirmDialog({ title: 'Yes, sign out', message: 'Are you sure! do you want to sign out?', buttonText: 'Sign Out', type: 'warning' }, function () {
107 let formData = new FormData();
108 formData.append('action', 'data');
109 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
110 formData.append('__tagembed__ajax_action', '__tagembed__logout');
111 __tagembed__open_loader();
112 let __tagembed__toast = new TagembedToast;
113 fetch(__tagembed__ajax_url, {
114 method: 'POST',
115 headers: {
116 'x-requested-with': 'XMLHttpRequest',
117 },
118 body: formData,
119 }).then(response => {
120 return response.json()
121 }).then(response => {
122 __tagembed__close_loader();
123 if (response.status == true) {
124 window.location.replace(response.data.redirectUrl);
125 } else {
126 if (response.hasOwnProperty("message")) {
127 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
128 } else {
129 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
130 }
131 }
132 }).catch((error) => {
133 console.log(error);
134 __tagembed__close_loader();
135 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
136 });
137 });
138 });
139 }
140 /*--End-- Logout*/
141
142 /*--Start--Manage Tagembed Menue*/
143 function __tagembed__menus(__tagembed__menu_id, __tagembed__widgetId = null) {
144 if (__tagembed__widgetId)
145 __tagembed__manageActiveWidget(__tagembed__widgetId);
146 __tagembed__open_loader();
147 let __tagembed__toast = new TagembedToast;
148 let formData = new FormData();
149 formData.append('action', 'data');
150 formData.append('menueId', __tagembed__menu_id);
151 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
152 formData.append('__tagembed__ajax_action', '__tagembed__menue');
153 fetch(__tagembed__ajax_url, {
154 method: 'POST',
155 headers: {
156 'x-requested-with': 'XMLHttpRequest',
157 },
158 body: formData,
159 }).then(response => {
160 return response.json()
161 }).then(response => {
162 if (response.status == true) {
163 return window.location.replace(response.data.redirectUrl);
164 /*return window.location.href = response.data.redirectUrl;*/
165 } else {
166 __tagembed__close_loader();
167 if (response.hasOwnProperty("message")) {
168 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
169 } else {
170 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
171 }
172 }
173 }).catch((error) => {
174 console.log(error);
175 __tagembed__close_loader();
176 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
177 });
178 }
179 /*--End--Manage Tagembed Menue*/
180 /*--Start-- Get Already Exist Auth*/
181 function __tagembed__get_already_exist_auth(__tagembed__network_id) {
182 if (!__tagembed__network_id)
183 return;
184 let formData = new FormData();
185 formData.append('networkId', __tagembed__network_id);
186 formData.append('action', 'data');
187 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
188 formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth');
189 fetch(__tagembed__ajax_url, {
190 method: 'POST',
191 headers: {
192 'x-requested-with': 'XMLHttpRequest',
193 },
194 body: formData,
195 }).then(response => {
196 return response.json()
197 }).then(response => {
198 if (response.status == true)
199 __tagembed__network_already_exist_auth = response.data;
200 });
201 }
202 /*Note : This Use For Merge Instagram 2/18*/
203 function __tagembed__get_already_exist_auth_new(__tagembed__network_id, __tagembed__feed_data) {
204 if (!__tagembed__network_id)
205 return;
206 __tagembed__open_loader();
207 let formData = new FormData();
208 formData.append('networkId', __tagembed__network_id);
209 formData.append('action', 'data');
210 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
211 formData.append('__tagembed__ajax_action', '__tagembed__get_already_exist_auth');
212 fetch(__tagembed__ajax_url, {
213 method: 'POST',
214 headers: { 'x-requested-with': 'XMLHttpRequest', },
215 body: formData,
216 }).then(response => {
217 return response.json()
218 }).then(response => {
219 if (response.status == true) {
220 __tagembed__network_already_exist_auth = response.data;
221 __tagembed__createInstagramBusinessFeed(__tagembed__feed_data);
222 __tagembed__close_loader();
223 }
224 });
225 }
226 /*--End-- Get Already Exist Auth*/
227 /*--Start-- Manage Active Widget*/
228 var __tagembed__widgets = document.querySelector("#__tagembed__widgets");
229 if (__tagembed__widgets) {
230 __tagembed__widgets.addEventListener("change", function (event) {
231 if (typeof __tagembed__get_theme !== 'undefined')
232 __tagembed__get_theme(); /*Manage Widget Theme According Widget*/
233 if (typeof __tagembed__changeIfrmSrc !== 'undefined')
234 __tagembed__changeIfrmSrc(); /*Manage Widget Display Preview According Widget*/
235 if (typeof __tagembed__manageShotrCode !== 'undefined')
236 __tagembed__manageShotrCode(); /*Manage Short Code According Widget*/
237 if (typeof __tagembed__manageEmbedCode !== 'undefined')
238 __tagembed__manageEmbedCode(); /*Manage Embed Code According Widget*/
239 if (typeof __tagembed__getFeed !== 'undefined')
240 __tagembed__getFeed(); /*Get Feed According Widget*/
241 if (typeof __tagembed__changeFilterIfrmSrc !== 'undefined')
242 __tagembed__changeFilterIfrmSrc(); /*Mange Filter Section According Widget*/
243 __tagembed__manageActiveWidget(); /*Manage Active Widget*/
244 if (typeof __tagembed__getCustomizationOption !== 'undefined')/*Call Get Customization Options*/
245 __tagembed__getCustomizationOption();
246 });
247 }
248 function __tagembed__manageActiveWidget(__tagembed__widgetId = null) {
249 if (!__tagembed__widgetId) {
250 __tagembed__widgetId = document.querySelector("#__tagembed__widgets").selectedOptions[0];
251 __tagembed__widgetId = __tagembed__widgetId.value.split('#')[0];
252 }
253 let __tagembed__toast = new TagembedToast;
254 let formData = new FormData();
255 formData.append('action', 'data');
256 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
257 formData.append('__tagembed__ajax_action', '__tagembed__manage_active_widget');
258 formData.append('widgetId', __tagembed__widgetId);
259 if (__tagembed__loader_status)
260 __tagembed__open_loader();
261 fetch(__tagembed__ajax_url, {
262 method: 'POST',
263 headers: {
264 'x-requested-with': 'XMLHttpRequest',
265 },
266 body: formData,
267 }).then(response => {
268 return response.json()
269 }).then(response => {
270 if (__tagembed__loader_status)
271 __tagembed__close_loader();
272 if (response.status == true) {
273 /*--Start--Reload Page For Manage Active Class On Widget Page*/
274 if (document.querySelector("#__tagembed__widgetbox0"))
275 location.reload();
276 /*--End--Reload Page For Manage Active Class On Widget Page*/
277 } else {
278 if (response.hasOwnProperty("message")) {
279 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
280 } else {
281 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
282 }
283 }
284 }).catch((error) => {
285 console.log(error);
286 __tagembed__close_loader();
287 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
288 });
289 }
290 /*--End-- Manage Active Widget*/
291 /*--Start--Create Widget*/
292 var __tagembed__widget_create_form = document.querySelector("#__tagembed__widget_create_form");
293 if (__tagembed__widget_create_form) {
294 __tagembed__widget_create_form.addEventListener("click", function (event) {
295 __tagembed__dialog_form({
296 popupSize: '__tagembed__popup_md', title: 'Create Widget',
297 form: { method: 'post', buttonText: 'Create' },
298 inputs: [{ label: 'Widget Name', type: 'text', name: 'name', placeholder: 'Enter your widget name e.g. mywidget' }, { label: 'Profanity Filter', type: 'checkbox', name: 'profanity' }],
299 action: function (event, formData) {
300 let __tagembed__name_error = document.querySelector("#__tagembed__name_error");
301 __tagembed__name_error.style.display = 'none';
302 if (!formData.get('name')) {
303 __tagembed__name_error.style.display = 'block';
304 __tagembed__name_error.textContent = "Widget name is required";
305 return;
306 }
307 __tagembed__open_loader();
308 let __tagembed__toast = new TagembedToast;
309 formData.append('action', 'data');
310 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
311 formData.append('__tagembed__ajax_action', '__tagembed__create_widget');
312 fetch(__tagembed__ajax_url, {
313 method: 'POST',
314 headers: {
315 'x-requested-with': 'XMLHttpRequest',
316 },
317 body: formData,
318 }).then(response => {
319 return response.json();
320 }).then(response => {
321 __tagembed__close_loader();
322 if (response.status == true) {
323 document.querySelector('#__tagembed__dialog_form_id_').remove();
324 if (response.data.hasOwnProperty("message")) {
325 __tagembed__toast.success({ message: response.data.message, position: '__tagembed__is-top-right' });
326 }
327 window.location.replace(response.data.redirectUrl);
328 } else {
329 if (response.hasOwnProperty("data") && Object.keys(response.data).length > 0) {
330 if (response.data.hasOwnProperty("name")) {
331 __tagembed__name_error.style.display = 'block';
332 __tagembed__name_error.textContent = response.data.name;
333 }
334 } else {
335 if (response.hasOwnProperty("message")) {
336 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
337 } else {
338 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
339 }
340 }
341 }
342 }).catch((error) => {
343 console.log(error);
344 __tagembed__close_loader();
345 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
346 });
347 }
348 });
349 });
350 }
351 /*--End--Create Widget*/
352 /*--Start--Manage Menue Hide Show In Mobile*/
353 function __tagembed__manageMenueHideShowInMobile() {
354 let __tagembed__menulist = document.querySelector("#__tagembed__menulist");
355 let __tagembed__burger = document.querySelector("#__tagembed__burger");
356 if (__tagembed__menulist.style.display === "none") {
357 __tagembed__menulist.style.display = "block";
358 __tagembed__burger.classList.add("__tagembed__addclose");
359 } else {
360 __tagembed__menulist.style.display = "none";
361 __tagembed__burger.classList.remove("__tagembed__addclose");
362 }
363 }
364 /*--Start--Manage Menue Hide Show In Mobile*/
365 /*--Start--Manage Toggel On Press Space Button*/
366 function __tagembed__manageToggelOnPressSpace() {
367 let tagembedConfirmDialog = document.querySelector("#tagembedConfirmDialog");
368 if (tagembedConfirmDialog)
369 return true;
370 return false;
371 }
372 /*--End--Manage Toggel On Press Space Button*/
373 /*--Start-- Add And Update Connected Account*/
374 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) {
375 if (__tagembed__networkId) {
376 let __tagembed__toast = new TagembedToast;
377 let formData = new FormData();
378 formData.append('action', 'data');
379 formData.append('__tagembed__ajax_call_nones', __tagembed__ajax_call_nones);
380 formData.append('__tagembed__ajax_action', '__tagembed__add_or_update_account');
381 formData.append('type', __tagembed__type);
382 formData.append('connectedAccountId', __tagembed__connected_account_id);
383 formData.append('feedId', __tagembed__feed_id);
384 formData.append('networkId', __tagembed__networkId);
385 formData.append('filterId', __tagembed__feed_filter_id);
386 formData.append('otherData', __tagembed__other_data);
387 __tagembed__open_loader();
388 fetch(__tagembed__ajax_url, {
389 method: 'POST',
390 headers: {
391 'x-requested-with': 'XMLHttpRequest',
392 },
393 body: formData,
394 }).then(response => {
395 return response.json()
396 }).then(response => {
397 if (response.status == true) {
398 /*window.open(response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl, '_self');*/
399 let __tagembed__Url = response.data.redirectUrl + '?__tagembed__feedData=' + response.data.__tagembed__feedData + '&__tagembed__requestCallBackUrl=' + response.data.__tagembed__requestCallBackUrl;
400 __tagmebed__openWindowPopup(__tagembed__Url);
401
402 } else {
403 __tagembed__close_loader();
404 if (response.hasOwnProperty("message")) {
405 __tagembed__toast.danger({ message: response.message, position: '__tagembed__is-top-right' });
406 } else {
407 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
408 }
409 }
410 }).catch((error) => {
411 console.log(error);
412 __tagembed__close_loader();
413 __tagembed__toast.danger({ message: "Something went wrong. Please try after sometime", position: '__tagembed__is-top-right' });
414 });
415 }
416 }
417 /*--End-- Add And Update Connected Account*/
418 /*--Start-- Manage Short Code*/
419 window.addEventListener ? window.addEventListener("load", __tagembed__manageShotrCode, false) : window.attachEvent && window.attachEvent("onload", __tagembed__manageShotrCode);
420 function __tagembed__manageShotrCode() {
421 let widgetData = document.querySelector("#__tagembed__widgets");
422 if (widgetData) {
423 let __tagembed__widgetId = widgetData.selectedOptions[0].value.split('#')[0];
424 let __tagembed__shortCode = document.querySelector("#__tagembed__shortCode");
425 if (__tagembed__shortCode)
426 __tagembed__shortCode.innerHTML = `[tagembed widgetid ${__tagembed__widgetId}]`;
427 }
428 }
429 /*--Start--Copy Short Code*/
430 async function __tagembed__copyCodeEmbed(__tagembed__codeType, __tagembed__copyEmbedId) {
431
432 let ___tagembed__shouldStop = await __tagembed__upgradePlan();
433 if (___tagembed__shouldStop) return;
434
435 let __tagembed__toast = new TagembedToast;
436 let __tagembed__copyEmbedCode = "";
437 switch (__tagembed__codeType) {
438 case "shortCode":
439 __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).innerHTML;
440 break;
441 case "embedCode":
442 __tagembed__copyEmbedCode = document.querySelector(`#${__tagembed__copyEmbedId}`).value;
443 break;
444 }
445 navigator.clipboard.writeText(__tagembed__copyEmbedCode);
446 __tagembed__toast.success({ message: 'copied', position: '__tagembed__is-top-right' });
447 }
448 /*--End--Copy Short Code*/
449
450