PluginProbe ʕ •ᴥ•ʔ
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress / 4.12.0
Smash Balloon Social Post Feed – Simple Social Feeds for WordPress v4.12.0
4.12.0 4.10.0 4.9.0 4.8.1 trunk 1.0 1.1 1.12.1 1.2.3 1.2.4 1.2.5 1.2.7 1.2.8 1.2.9 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.3.7 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.6 1.4.7 1.4.8 1.5 1.5.1 1.5.2 1.5.9 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.4.1 1.6.5 1.6.5.1 1.6.6 1.6.6.1 1.6.6.2 1.6.6.3 1.6.7 1.6.7.1 1.6.8 1.6.8.1 1.6.8.2 1.7.0 1.7.1 1.7.2 1.8.0 1.8.1 1.8.2 1.8.2.1 1.8.2.2 1.8.2.3 1.9.0 1.9.1 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.8.1 1.9.9 1.9.9.1 1.9.9.2 1.9.9.3 2.0 2.0.1 2.1 2.1.1 2.1.2 2.1.3 2.10 2.11 2.11.1 2.12 2.12.1 2.12.2 2.12.3 2.12.4 2.13 2.14 2.14.1 2.15 2.15.1 2.16 2.16.1 2.17 2.17.1 2.18 2.18.1 2.18.2 2.18.3 2.19 2.19.1 2.19.2 2.19.3 2.2 2.2.1 2.3 2.3.1 2.3.10 2.3.2 2.3.3 2.3.4 2.3.6 2.3.7 2.3.8 2.3.9 2.4 2.4.1 2.4.1.1 2.4.1.2 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.5 2.5.1 2.5.2 2.6 2.6.1 2.6.2 2.6.3 2.6.4 2.7 2.7.1 2.7.2 2.8 2.9 2.9.1 4.0 4.0.1 4.0.2 4.0.3 4.0.4 4.0.5 4.1 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.7.5 4.7.6 4.7.7
custom-facebook-feed / admin / assets / js / settings.js
custom-facebook-feed / admin / assets / js Last commit date
about.js 2 weeks ago admin-notifications.js 2 weeks ago builders-preview-handler.js 2 weeks ago callout.js 2 weeks ago cff-admin-scripts.js 2 weeks ago divi-handler.min.js 2 weeks ago extensions.js 2 weeks ago oembeds.js 2 weeks ago settings.js 2 weeks ago smash-usage-session.js 2 weeks ago support.js 2 weeks ago vue.min.js 2 weeks ago
settings.js
954 lines
1 var cffSettings;
2
3 // Declaring as global variable for quick prototyping
4 var settings_data = {
5 adminUrl: cff_settings.admin_url,
6 nonce: cff_settings.nonce,
7 ajaxHandler: cff_settings.ajax_handler,
8 model: cff_settings.model,
9 feeds: cff_settings.feeds,
10 links: cff_settings.links,
11 tooltipName: null,
12 sourcesList : cff_settings.sources,
13 isDevSite: cff_settings.isDevSite,
14 dialogBoxPopupScreen : cff_settings.dialogBoxPopupScreen,
15 selectSourceScreen : cff_settings.selectSourceScreen,
16
17 socialWallActivated: cff_settings.socialWallActivated,
18 socialWallLinks: cff_settings.socialWallLinks,
19 exportFeed: 'none',
20 locales: cff_settings.locales,
21 timezones: cff_settings.timezones,
22 genericText: cff_settings.genericText,
23 generalTab: cff_settings.generalTab,
24 feedsTab: cff_settings.feedsTab,
25 translationTab: cff_settings.translationTab,
26 advancedTab: cff_settings.advancedTab,
27 upgradeUrl: cff_settings.upgradeUrl,
28 footerUpgradeUrl: cff_settings.footerUpgradeUrl,
29 supportPageUrl: cff_settings.supportPageUrl,
30 licenseKey: cff_settings.licenseKey,
31 licenseType: cff_settings.licenseType,
32 licenseStatus: cff_settings.licenseStatus,
33 licenseErrorMsg: cff_settings.licenseErrorMsg,
34 extensionsLicense: cff_settings.extensionsLicense,
35 extensionsLicenseKey: cff_settings.extensionsLicenseKey,
36 extensionFieldHasError: false,
37 cronNextCheck: cff_settings.nextCheck,
38 currentView: null,
39 selected: null,
40 current: 0,
41 sections: ["General", "Feeds", "Translation", "Advanced"],
42 indicator_width: 0,
43 indicator_pos: 0,
44 forwards: true,
45 currentTab: null,
46 import_file: null,
47 gdprInfoTooltip: null,
48 loaderSVG: cff_settings.loaderSVG,
49 checkmarkSVG: cff_settings.checkmarkSVG,
50 uploadSVG: cff_settings.uploadSVG,
51 exportSVG: cff_settings.exportSVG,
52 reloadSVG: cff_settings.reloadSVG,
53 tooltipHelpSvg: cff_settings.tooltipHelpSvg,
54 tooltip : {
55 text : '',
56 hover : false
57 },
58
59 cogSVG: cff_settings.cogSVG,
60 deleteSVG: cff_settings.deleteSVG,
61 svgIcons : cff_settings.svgIcons,
62
63 testConnectionStatus: null,
64 btnStatus: null,
65 uploadStatus: null,
66 clearCacheStatus: null,
67 optimizeCacheStatus: null,
68 dpaResetStatus: null,
69 pressedBtnName: null,
70 loading: false,
71 hasError: cff_settings.hasError,
72 dialogBox : {
73 active : false,
74 type : null,
75 heading : null,
76 description : null
77 },
78 sourceToDelete : {},
79 newManualSourcePopup : cff_settings.newManualSourcePopup,
80 viewsActive : {
81 sourcePopup : false,
82 sourcePopupScreen : 'redirect_1',
83 sourcePopupType : 'creation',
84 instanceSourceActive : null,
85 },
86 //Add New Source
87 newSourceData : cff_settings.newSourceData ? cff_settings.newSourceData : null,
88 sourceConnectionURLs : cff_settings.sourceConnectionURLs,
89 returnedApiSourcesList : [],
90 addNewSource : {
91 typeSelected : 'page',
92 manualSourceID : null,
93 manualSourceToken : null
94 },
95 selectedFeed : 'none',
96 expandedFeedID : null,
97 notificationElement : {
98 type : 'success', // success, error, warning, message
99 text : '',
100 shown : null
101 },
102 selectedSourcesToConnect : [],
103
104 //Loading Bar
105 fullScreenLoader : false,
106 appLoaded : false,
107 previewLoaded : false,
108 loadingBar : true,
109 isSetupPage : false
110 };
111
112 // The tab component
113 Vue.component("tab", {
114 props: ["section", "index"],
115 template: `
116 <button type="button" class="tab" :id="'cff-settings-tab-' + section.toLowerCase().trim()" role="tab" :aria-selected="section === $parent.currentTab ? 'true' : 'false'" :aria-controls="'cff-panel-' + section.toLowerCase().trim()" :tabindex="section === $parent.currentTab ? 0 : -1" @click="emitWidth($el);changeComponent(index);activeTab(section)" @keydown="onTabKeydown">{{section}}</button>
117 `,
118 created: () => {
119 let urlParams = new URLSearchParams(window.location.search);
120 let view = urlParams.get('view');
121 if ( view === null ) {
122 view = 'general';
123 }
124 settings_data.currentView = view;
125 settings_data.currentTab = settings_data.sections[0];
126 settings_data.selected = "app-1";
127 },
128 methods: {
129 emitWidth: function(el) {
130 settings_data.indicator_width = jQuery(el).outerWidth();
131 settings_data.indicator_pos = jQuery(el).position().left;
132 },
133 changeComponent: function(index) {
134 var prev = settings_data.current;
135 if (prev < index) {
136 settings_data.forwards = false;
137 } else if (prev > index) {
138 settings_data.forwards = true;
139 }
140 settings_data.selected = "app-" + (index + 1);
141 settings_data.current = index;
142
143 // get the pro cta banner offset
144 let ctaOffset = jQuery('.cff-settings-cta').offset();
145 // position them to bottom so during change component they don't appear at top
146 jQuery('.cff-settings-cta, .cff-save-button').css({"position": "absolute", "top": ctaOffset.top + 'px'})
147 // remove the added styles shortly after to set it where it should be
148 setTimeout(function() {
149 jQuery('.cff-settings-cta, .cff-save-button').removeAttr('style')
150 }, 400);
151 },
152 activeTab: function(section) {
153 this.setView(section.toLowerCase().trim());
154 settings_data.currentTab = section;
155 },
156 setView: function(section) {
157 history.replaceState({}, null, settings_data.adminUrl + 'admin.php?page=cff-settings&view=' + section);
158 },
159 // WAI-ARIA Authoring Practices tablist keyboard interaction.
160 // Ported from instagram-feed-pro settings.js.
161 onTabKeydown: function (e) {
162 var tabs = Array.prototype.slice.call(
163 document.querySelectorAll('#sb-tabs-container [role="tablist"] [role="tab"]')
164 );
165 var idx = tabs.indexOf(e.currentTarget);
166 if (idx === -1) return;
167 var next = null;
168 if (e.key === 'ArrowRight' || e.keyCode === 39) {
169 next = tabs[(idx + 1) % tabs.length];
170 } else if (e.key === 'ArrowLeft' || e.keyCode === 37) {
171 next = tabs[(idx - 1 + tabs.length) % tabs.length];
172 } else if (e.key === 'Home' || e.keyCode === 36) {
173 next = tabs[0];
174 } else if (e.key === 'End' || e.keyCode === 35) {
175 next = tabs[tabs.length - 1];
176 }
177 if (!next) return;
178 e.preventDefault();
179 next.focus();
180 next.click();
181 }
182 }
183 });
184
185 var cffSettings = new Vue({
186 el: "#cff-settings",
187 http: {
188 emulateJSON: true,
189 emulateHTTP: true
190 },
191 data: settings_data,
192 created: function() {
193 this.$nextTick(function() {
194 let tabEl = document.querySelector('.tab');
195 settings_data.indicator_width = tabEl.offsetWidth;
196 });
197 setTimeout(function(){
198 settings_data.appLoaded = true;
199 },350);
200 },
201 mounted: function(){
202 var self = this;
203 // set the current view page on page load
204 let activeEl = document.querySelector('button.tab#cff-settings-tab-' + settings_data.currentView);
205 // we have to uppercase the first letter
206 let currentView = settings_data.currentView.charAt(0).toUpperCase() + settings_data.currentView.slice(1);
207 let viewIndex = settings_data.sections.indexOf(currentView) + 1;
208 settings_data.indicator_width = activeEl.offsetWidth;
209 settings_data.indicator_pos = activeEl.offsetLeft;
210 settings_data.selected = "app-" + viewIndex;
211 settings_data.current = viewIndex;
212 settings_data.currentTab = currentView;
213
214 setTimeout(function(){
215 settings_data.appLoaded = true;
216 },350);
217
218 if(self.newManualSourcePopup != undefined && self.newManualSourcePopup == true){
219 self.viewsActive.sourcePopupScreen = 'step_3';
220 self.activateView('sourcePopup', 'creation');
221 }
222
223 },
224 computed: {
225 getStyle: function() {
226 return {
227 position: "absolute",
228 bottom: "0px",
229 left: settings_data.indicator_pos + "px",
230 width: settings_data.indicator_width + "px",
231 height: "2px"
232 };
233 },
234 chooseDirection: function() {
235 return "slide-fade";
236 }
237 },
238 methods: {
239 activateLicense: function() {
240 if (this.licenseType === 'free') {
241 this.runOneClickUpgrade();
242 } else {
243 this.activateProLicense();
244 }
245 },
246 activateProLicense: function() {
247 this.hasError = false;
248 this.loading = true;
249 this.pressedBtnName = 'cff';
250
251 let data = new FormData();
252 data.append( 'action', 'cff_activate_license' );
253 data.append( 'license_key', this.licenseKey );
254 data.append( 'nonce', this.nonce );
255 fetch(this.ajaxHandler, {
256 method: "POST",
257 credentials: 'same-origin',
258 body: data
259 })
260 .then(response => response.json())
261 .then(data => {
262 if ( data.success == false ) {
263 this.licenseStatus = 'inactive';
264 this.hasError = true;
265 this.loading = false;
266 return;
267 }
268 if ( data.success == true ) {
269 let licenseData = data.data.licenseData;
270 this.licenseStatus = data.data.licenseStatus;
271 this.loading = false;
272 this.pressedBtnName = null;
273
274 if (
275 data.data.licenseStatus == 'inactive' ||
276 data.data.licenseStatus == 'invalid' ||
277 data.data.licenseStatus == 'expired'
278 ) {
279 this.hasError = true;
280 if( licenseData.error ) {
281 this.licenseErrorMsg = licenseData.errorMsg
282 }
283 }
284 }
285 return;
286 });
287 },
288 runOneClickUpgrade: function() {
289 this.hasError = false;
290 this.loading = true;
291 this.pressedBtnName = 'cff';
292
293 let data = new FormData();
294 data.append( 'action', 'cff_maybe_upgrade_redirect' );
295 data.append( 'license_key', this.licenseKey );
296 data.append( 'nonce', this.nonce );
297 fetch(this.ajaxHandler, {
298 method: "POST",
299 credentials: 'same-origin',
300 body: data
301 })
302 .then(response => response.json())
303 .then(data => {
304 if ( data.success === false ) {
305 this.licenseStatus = 'invalid';
306 this.hasError = true;
307 this.loading = false;
308 if( typeof data.data !== 'undefined' ) {
309 this.licenseErrorMsg = data.data.message
310 }
311 return;
312 }
313 if ( data.success === true ) {
314 window.location.href = data.data.url
315 }
316 return;
317 });
318 },
319 deactivateLicense: function() {
320 this.loading = true;
321 this.pressedBtnName = 'cff';
322 let data = new FormData();
323 data.append( 'action', 'cff_deactivate_license' );
324 data.append( 'nonce', this.nonce );
325 fetch(this.ajaxHandler, {
326 method: "POST",
327 credentials: 'same-origin',
328 body: data
329 })
330 .then(response => response.json())
331 .then(data => {
332 if ( data.success == true ) {
333 this.licenseStatus = data.data.licenseStatus ;
334 this.loading = false;
335 this.pressedBtnName = null;
336 }
337 return;
338 });
339 },
340
341 /**
342 * Activate Extensions License
343 *
344 * @since 4.0
345 *
346 * @param {object} extension
347 */
348 activateExtensionLicense: function( extension ) {
349 let licenseKey = this.extensionsLicenseKey[extension.name];
350 this.extensionFieldHasError = false;
351 this.loading = true;
352 this.pressedBtnName = extension.name;
353 if ( ! licenseKey ) {
354 this.loading = false;
355 this.extensionFieldHasError = true;
356 return;
357 }
358 let data = new FormData();
359 data.append( 'action', 'cff_activate_extension_license' );
360 data.append( 'license_key', licenseKey );
361 data.append( 'extension_name', extension.name );
362 data.append( 'extension_item_name', extension.itemName );
363 data.append( 'nonce', this.nonce );
364 fetch(this.ajaxHandler, {
365 method: "POST",
366 credentials: 'same-origin',
367 body: data
368 })
369 .then(response => response.json())
370 .then(data => {
371 this.loading = false;
372 if ( data.success == true ) {
373 this.extensionFieldHasError = false;
374 this.pressedBtnName = null;
375 if ( data.data.licenseStatus == 'invalid' ) {
376 this.extensionFieldHasError = true;
377 this.notificationElement = {
378 type : 'error',
379 text : this.genericText.invalidLicenseKey,
380 shown : "shown"
381 };
382 }
383 if ( data.data.licenseStatus == 'valid' ) {
384 this.notificationElement = {
385 type : 'success',
386 text : this.genericText.licenseActivated,
387 shown : "shown"
388 };
389 }
390 extension.licenseStatus = data.data.licenseStatus;
391 extension.licenseKey = licenseKey;
392
393 setTimeout(function(){
394 this.notificationElement.shown = "hidden";
395 }.bind(this), 3000);
396 }
397 return;
398 });
399 },
400
401 licenseActiveAction: function(extension) {
402 extension = typeof extension !== 'undefined' ? extension : false;
403 if (this.licenseType === 'free') {
404 this.runOneClickUpgrade();
405 } else {
406 if (typeof extension !== 'undefined') {
407 this.deactivateExtensionLicense(extension);
408 } else {
409 this.deactivateLicense();
410 }
411 }
412
413 },
414
415 /**
416 * Deactivate Extensions License
417 *
418 * @since 4.0
419 *
420 * @param {object} extension
421 */
422 deactivateExtensionLicense: function( extension ) {
423 let licenseKey = this.extensionsLicenseKey[extension.name];
424 this.extensionFieldHasError = false;
425 this.loading = true;
426 this.pressedBtnName = extension.name;
427 let data = new FormData();
428 data.append( 'action', 'cff_deactivate_extension_license' );
429 data.append( 'extension_name', extension.name );
430 data.append( 'extension_item_name', extension.itemName );
431 data.append( 'nonce', this.nonce );
432 fetch(this.ajaxHandler, {
433 method: "POST",
434 credentials: 'same-origin',
435 body: data
436 })
437 .then(response => response.json())
438 .then(data => {
439 this.loading = false;
440 if ( data.success == true ) {
441 this.extensionFieldHasError = false;
442 this.pressedBtnName = null;
443 if ( data.data.licenseStatus == 'deactivated' ) {
444 this.notificationElement = {
445 type : 'success',
446 text : this.genericText.licenseDeactivated,
447 shown : "shown"
448 };
449 }
450 extension.licenseStatus = data.data.licenseStatus;
451 extension.licenseKey = licenseKey;
452
453 setTimeout(function(){
454 this.notificationElement.shown = "hidden";
455 }.bind(this), 3000);
456 }
457 return;
458 });
459 },
460 testConnection: function() {
461 this.testConnectionStatus = 'loading';
462 let data = new FormData();
463 data.append( 'action', 'cff_test_connection' );
464 data.append( 'nonce', this.nonce );
465 fetch(this.ajaxHandler, {
466 method: "POST",
467 credentials: 'same-origin',
468 body: data
469 })
470 .then(response => response.json())
471 .then(data => {
472 if ( data.success == false ) {
473 this.testConnectionStatus = 'error';
474 }
475 if ( data.success == true ) {
476 this.testConnectionStatus = 'success';
477
478 setTimeout(function() {
479 this.testConnectionStatus = null;
480 }.bind(this), 3000);
481 }
482 return;
483 });
484 },
485 testConnectionIcon: function() {
486 if ( this.testConnectionStatus == 'loading' ) {
487 return this.loaderSVG;
488 } else if ( this.testConnectionStatus == 'success' ) {
489 return '<i class="fa fa-check-circle"></i> ' + this.generalTab.licenseBox.connectionSuccessful;
490 } else if ( this.testConnectionStatus == 'error' ) {
491 return `<i class="fa fa-check-circle"></i> ${this.generalTab.licenseBox.connectionFailed} <a href="#">${this.generalTab.licenseBox.viewError}</a>`;
492 }
493 },
494 importFile: function() {
495 document.getElementById("import_file").click();
496 },
497 uploadFile: function( event ) {
498 this.uploadStatus = 'loading';
499 let file = this.$refs.file.files[0];
500 let data = new FormData();
501 data.append( 'action', 'cff_import_settings_json' );
502 data.append( 'nonce', this.nonce );
503 data.append( 'file', file );
504 fetch(this.ajaxHandler, {
505 method: "POST",
506 credentials: 'same-origin',
507 body: data
508 })
509 .then(response => response.json())
510 .then(data => {
511 this.uploadStatus = null;
512 this.$refs.file.files[0] = null;
513 if ( data.success == false ) {
514 this.notificationElement = {
515 type : 'error',
516 text : this.genericText.failedToImportFeed,
517 shown : "shown"
518 };
519 }
520 if ( data.success == true ) {
521 this.feeds = data.data.feeds;
522 this.notificationElement = {
523 type : 'success',
524 text : this.genericText.feedImported,
525 shown : "shown"
526 };
527 }
528 setTimeout(function(){
529 this.notificationElement.shown = "hidden";
530 }.bind(this), 3000);
531 });
532 },
533 exportFeedSettings: function() {
534 // return if no feed is selected
535 if ( this.exportFeed === 'none' ) {
536 return;
537 }
538
539 let url = this.ajaxHandler + '?action=cff_export_settings_json&feed_id=' + this.exportFeed + '&nonce=' + this.nonce;
540 window.location = url;
541 },
542 saveSettings: function() {
543 this.btnStatus = 'loading';
544 let data = new FormData();
545 data.append( 'action', 'cff_save_settings' );
546 data.append( 'nonce', this.nonce );
547 data.append( 'model', JSON.stringify( this.model ) );
548 data.append( 'cff_license_key', this.licenseKey );
549 data.append( 'extensions_license_key', JSON.stringify( this.extensionsLicenseKey ) );
550 fetch(this.ajaxHandler, {
551 method: "POST",
552 credentials: 'same-origin',
553 body: data
554 })
555 .then(response => response.json())
556 .then(data => {
557 if ( data.success == false ) {
558 this.btnStatus = 'error';
559 return;
560 }
561
562 this.cronNextCheck = data.data.cronNextCheck;
563 this.btnStatus = 'success';
564 setTimeout(function() {
565 this.btnStatus = null;
566 }.bind(this), 3000);
567 });
568 },
569 clearCache: function() {
570 this.clearCacheStatus = 'loading';
571 let data = new FormData();
572 data.append( 'action', 'cff_clear_cache' );
573 data.append( 'model', JSON.stringify( this.model ) );
574 data.append( 'nonce', this.nonce );
575 fetch(this.ajaxHandler, {
576 method: "POST",
577 credentials: 'same-origin',
578 body: data
579 })
580 .then(response => response.json())
581 .then(data => {
582 if ( data.success == false ) {
583 this.clearCacheStatus = 'error';
584 return;
585 }
586
587 this.cronNextCheck = data.data.cronNextCheck;
588 this.clearCacheStatus = 'success';
589 setTimeout(function() {
590 this.clearCacheStatus = null;
591 }.bind(this), 3000);
592 });
593 },
594 showTooltip: function( tooltipName ) {
595 this.tooltipName = tooltipName;
596 },
597 hideTooltip: function() {
598 this.tooltipName = null;
599 },
600 gdprOptions: function() {
601 this.gdprInfoTooltip = null;
602 },
603 gdprLimited: function() {
604 this.gdprInfoTooltip = this.gdprInfoTooltip == null ? true : null;
605 },
606 clearImageResizeCache: function() {
607 this.optimizeCacheStatus = 'loading';
608 let data = new FormData();
609 data.append( 'action', 'cff_clear_image_resize_cache' );
610 data.append( 'nonce', this.nonce );
611 fetch(this.ajaxHandler, {
612 method: "POST",
613 credentials: 'same-origin',
614 body: data
615 })
616 .then(response => response.json())
617 .then(data => {
618 if ( data.success == false ) {
619 this.optimizeCacheStatus = 'error';
620 return;
621 }
622 this.optimizeCacheStatus = 'success';
623 setTimeout(function() {
624 this.optimizeCacheStatus = null;
625 }.bind(this), 3000);
626 });
627 },
628 dpaReset: function() {
629 this.dpaResetStatus = 'loading';
630 let data = new FormData();
631 data.append( 'action', 'cff_dpa_reset' );
632 data.append( 'nonce', this.nonce );
633 fetch(this.ajaxHandler, {
634 method: "POST",
635 credentials: 'same-origin',
636 body: data
637 })
638 .then(response => response.json())
639 .then(data => {
640 if ( data.success == false ) {
641 this.dpaResetStatus = 'error';
642 return;
643 }
644 this.dpaResetStatus = 'success';
645 setTimeout(function() {
646 this.dpaResetStatus = null;
647 }.bind(this), 3000);
648 });
649 },
650 dpaResetStatusIcon: function() {
651 if ( this.dpaResetStatus === null ) {
652 return;
653 }
654 if ( this.dpaResetStatus == 'loading' ) {
655 return this.loaderSVG;
656 } else if ( this.dpaResetStatus == 'success' ) {
657 return this.checkmarkSVG;
658 } else if ( this.dpaResetStatus == 'error' ) {
659 return `<i class="fa fa-times-circle"></i>`;
660 }
661 },
662 saveChangesIcon: function() {
663 if ( this.btnStatus == 'loading' ) {
664 return this.loaderSVG;
665 } else if ( this.btnStatus == 'success' ) {
666 return this.checkmarkSVG;
667 } else if ( this.btnStatus == 'error' ) {
668 return `<i class="fa fa-times-circle"></i>`;
669 }
670 },
671 importBtnIcon: function() {
672 if ( this.uploadStatus === null ) {
673 return this.uploadSVG;
674 }
675 if ( this.uploadStatus == 'loading' ) {
676 return this.loaderSVG;
677 } else if ( this.uploadStatus == 'success' ) {
678 return this.checkmarkSVG;
679 } else if ( this.uploadStatus == 'error' ) {
680 return `<i class="fa fa-times-circle"></i>`;
681 }
682 },
683 clearCacheIcon: function() {
684 if ( this.clearCacheStatus === null ) {
685 return this.reloadSVG;
686 }
687 if ( this.clearCacheStatus == 'loading' ) {
688 return this.loaderSVG;
689 } else if ( this.clearCacheStatus == 'success' ) {
690 return this.checkmarkSVG;
691 } else if ( this.clearCacheStatus == 'error' ) {
692 return `<i class="fa fa-times-circle"></i>`;
693 }
694 },
695 clearImageResizeCacheIcon: function() {
696 if ( this.optimizeCacheStatus === null ) {
697 return;
698 }
699 if ( this.optimizeCacheStatus == 'loading' ) {
700 return this.loaderSVG;
701 } else if ( this.optimizeCacheStatus == 'success' ) {
702 return this.checkmarkSVG;
703 } else if ( this.optimizeCacheStatus == 'error' ) {
704 return `<i class="fa fa-times-circle"></i>`;
705 }
706 },
707
708 printUsedInText: function( usedInNumber ){
709 if(usedInNumber == 0){
710 return this.genericText.sourceNotUsedYet;
711 }
712 return this.genericText.usedIn + ' ' + usedInNumber + ' ' +(usedInNumber == 1 ? this.genericText.feed : this.genericText.feeds);
713 },
714
715 /**
716 * Delete Source Ajax
717 *
718 * @since 4.0
719 */
720 deleteSource : function(sourceToDelete){
721 var self = this;
722 let data = new FormData();
723 data.append( 'action', 'cff_feed_saver_manager_delete_source' );
724 data.append( 'nonce', this.nonce );
725 data.append( 'source_id', sourceToDelete.id);
726 fetch(self.ajaxHandler, {
727 method: "POST",
728 credentials: 'same-origin',
729 body: data
730 })
731 .then(response => response.json())
732 .then(data => {
733 self.sourcesList = data;
734 });
735 },
736
737 /**
738 * Check if Value is Empty
739 *
740 * @since 4.0
741 *
742 * @return boolean
743 */
744 checkNotEmpty : function(value){
745 return value != null && value.replace(/ /gi,'') != '';
746 },
747
748 /**
749 * Activate View
750 *
751 * @since 4.0
752 */
753 activateView : function(viewName, sourcePopupType = 'creation', ajaxAction = false){
754 var self = this;
755 self.viewsActive[viewName] = (self.viewsActive[viewName] == false ) ? true : false;
756 if(viewName == 'sourcePopup' && sourcePopupType == 'creationRedirect'){
757 setTimeout(function(){
758 self.$refs.addSourceRef.processFBConnect()
759 },3500);
760 }
761 },
762
763 /**
764 * Switch & Change Feed Screens
765 *
766 * @since 4.0
767 */
768 switchScreen: function(screenType, screenName){
769 this.viewsActive[screenType] = screenName;
770 },
771
772 /**
773 * Parse JSON
774 *
775 * @since 4.0
776 *
777 * @return jsonObject / Boolean
778 */
779 jsonParse : function(jsonString){
780 try {
781 return JSON.parse(jsonString);
782 } catch(e) {
783 return false;
784 }
785 },
786
787
788 /**
789 * Ajax Post Action
790 *
791 * @since 4.0
792 */
793 ajaxPost : function(data, callback){
794 var self = this;
795 data['nonce'] = self.nonce;
796 data['settings_page'] = true;
797
798 self.$http.post(self.ajaxHandler,data).then(callback);
799 },
800
801 /**
802 * Check if Object has Nested Property
803 *
804 * @since 4.0
805 *
806 * @return boolean
807 */
808 hasOwnNestedProperty : function(obj,propertyPath) {
809 if (!propertyPath){return false;}var properties = propertyPath.split('.');
810 for (var i = 0; i < properties.length; i++) {
811 var prop = properties[i];
812 if (!obj || !obj.hasOwnProperty(prop)) {
813 return false;
814 } else {
815 obj = obj[prop];
816 }
817 }
818 return true;
819 },
820
821 /**
822 * Show Tooltip on Hover
823 *
824 * @since 4.0
825 */
826 toggleElementTooltip : function(tooltipText, type, align = 'center'){
827 var self = this,
828 target = window.event.currentTarget,
829 tooltip = (target != undefined && target != null) ? document.querySelector('.sb-control-elem-tltp-content') : null;
830 if(tooltip != null && type == 'show'){
831 self.tooltip.text = tooltipText;
832 var position = target.getBoundingClientRect(),
833 left = position.left + 7,
834 top = position.top - 15;
835 tooltip.style.left = left + 'px';
836 tooltip.style.top = top + 'px';
837 tooltip.style.textAlign = align;
838 self.tooltip.hover = true;
839 }
840 if(type == 'hide'){
841 self.tooltip.hover = false;
842 }
843 },
844
845 /**
846 * Hover Tooltip
847 *
848 * @since 4.0
849 */
850 hoverTooltip : function(type){
851 this.tooltip.hover = type;
852 },
853
854 /**
855 * Open Dialog Box
856 *
857 * @since 4.0
858 */
859 openDialogBox : function(type, args = []){
860 var self = this,
861 heading = self.dialogBoxPopupScreen[type].heading,
862 description = self.dialogBoxPopupScreen[type].description;
863
864 switch (type) {
865 case "deleteSource":
866 self.sourceToDelete = args;
867 heading = heading.replace("#", self.sourceToDelete.username);
868 break;
869 }
870 self.dialogBox = {
871 active : true,
872 type : type,
873 heading : heading,
874 description : description
875 };
876 },
877
878
879 /**
880 * Confirm Dialog Box Actions
881 *
882 * @since 4.0
883 */
884 confirmDialogAction : function(){
885 var self = this;
886 switch (self.dialogBox.type) {
887 case 'deleteSource':
888 self.deleteSource(self.sourceToDelete);
889 break;
890 }
891 },
892
893 /**
894 * Display Feed Sources Settings
895 *
896 * @since 4.0
897 *
898 * @param {object} source
899 * @param {int} sourceIndex
900 */
901 displayFeedSettings: function(source, sourceIndex) {
902 this.expandedFeedID = sourceIndex + 1;
903 },
904
905 /**
906 * Hide Feed Sources Settings
907 *
908 * @since 4.0
909 *
910 * @param {object} source
911 * @param {int} sourceIndex
912 */
913 hideFeedSettings: function() {
914 this.expandedFeedID = null;
915 },
916
917 /**
918 * Copy text to clipboard
919 *
920 * @since 4.0
921 */
922 copyToClipBoard : function(value){
923 var self = this;
924 const el = document.createElement('textarea');
925 el.className = 'cff-fb-cp-clpboard';
926 el.value = value;
927 document.body.appendChild(el);
928 el.select();
929 document.execCommand('copy');
930 document.body.removeChild(el);
931 self.notificationElement = {
932 type : 'success',
933 text : this.genericText.copiedClipboard,
934 shown : "shown"
935 };
936 setTimeout(function(){
937 self.notificationElement.shown = "hidden";
938 }, 3000);
939 },
940
941
942 /**
943 * View Source Instances
944 *
945 * @since 4.0
946 */
947 viewSourceInstances : function(source){
948 var self = this;
949 self.viewsActive.instanceSourceActive = source;
950 },
951 }
952 });
953
954