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
extensions.js
130 lines
| 1 | var extensions_data = { |
| 2 | genericText: cff_extensions.genericText, |
| 3 | extentions_bundle: cff_extensions.extentions_bundle, |
| 4 | links: cff_extensions.links, |
| 5 | extensions: cff_extensions.extensions_info, |
| 6 | socialWallActivated: cff_extensions.socialWallActivated, |
| 7 | socialWallLinks: cff_extensions.socialWallLinks, |
| 8 | plugins: cff_extensions.pluginsInfo, |
| 9 | supportPageUrl: cff_extensions.supportPageUrl, |
| 10 | social_wall: cff_extensions.social_wall, |
| 11 | ajax_handler: cff_extensions.ajax_handler, |
| 12 | nonce: cff_extensions.nonce, |
| 13 | buttons: cff_extensions.buttons, |
| 14 | icons: cff_extensions.icons, |
| 15 | btnClicked: null, |
| 16 | btnStatus: null, |
| 17 | btnName: null, |
| 18 | } |
| 19 | |
| 20 | var cffExtensions = new Vue({ |
| 21 | el: "#cff-extensions", |
| 22 | http: { |
| 23 | emulateJSON: true, |
| 24 | emulateHTTP: true |
| 25 | }, |
| 26 | data: extensions_data, |
| 27 | methods: { |
| 28 | activatePlugin: function( plugin, name, index, type ) { |
| 29 | this.btnClicked = index + 1; |
| 30 | this.btnStatus = 'loading'; |
| 31 | this.btnName = name; |
| 32 | |
| 33 | let data = new FormData(); |
| 34 | data.append( 'action', 'cff_activate_addon' ); |
| 35 | data.append( 'nonce', this.nonce ); |
| 36 | data.append( 'plugin', plugin ); |
| 37 | data.append( 'type', 'plugin' ); |
| 38 | if ( this.extentions_bundle && type == 'extension' ) { |
| 39 | data.append( 'extensions_bundle', this.extentions_bundle ); |
| 40 | } |
| 41 | fetch(this.ajax_handler, { |
| 42 | method: "POST", |
| 43 | credentials: 'same-origin', |
| 44 | body: data |
| 45 | }) |
| 46 | .then(response => response.json()) |
| 47 | .then(data => { |
| 48 | if( data.success == true ) { |
| 49 | if ( name === 'social_wall' ) { |
| 50 | this.social_wall.activated = true; |
| 51 | } else if ( type === 'extension' ) { |
| 52 | this.extensions[name].activated = true; |
| 53 | } else { |
| 54 | this.plugins[name].activated = true; |
| 55 | } |
| 56 | this.btnClicked = null; |
| 57 | this.btnStatus = null; |
| 58 | this.btnName = null; |
| 59 | } |
| 60 | }); |
| 61 | }, |
| 62 | deactivatePlugin: function( plugin, name, index, type ) { |
| 63 | this.btnClicked = index + 1; |
| 64 | this.btnStatus = 'loading'; |
| 65 | this.btnName = name; |
| 66 | |
| 67 | let data = new FormData(); |
| 68 | data.append( 'action', 'cff_deactivate_addon' ); |
| 69 | data.append( 'nonce', this.nonce ); |
| 70 | data.append( 'plugin', plugin ); |
| 71 | data.append( 'type', 'plugin' ); |
| 72 | if ( this.extentions_bundle && type == 'extension' ) { |
| 73 | data.append( 'extensions_bundle', this.extentions_bundle ); |
| 74 | } |
| 75 | fetch(this.ajax_handler, { |
| 76 | method: "POST", |
| 77 | credentials: 'same-origin', |
| 78 | body: data |
| 79 | }) |
| 80 | .then(response => response.json()) |
| 81 | .then(data => { |
| 82 | if( data.success == true ) { |
| 83 | if ( name === 'social_wall' ) { |
| 84 | this.social_wall.activated = false; |
| 85 | } else if ( type === 'extension' ) { |
| 86 | this.extensions[name].activated = false; |
| 87 | } else { |
| 88 | this.plugins[name].activated = false; |
| 89 | } |
| 90 | this.btnClicked = null; |
| 91 | this.btnName = null; |
| 92 | this.btnStatus = null; |
| 93 | } |
| 94 | return; |
| 95 | }); |
| 96 | }, |
| 97 | installPlugin: function( plugin, name, index ) { |
| 98 | this.btnClicked = index + 1; |
| 99 | this.btnStatus = 'loading'; |
| 100 | this.btnName = name; |
| 101 | |
| 102 | let data = new FormData(); |
| 103 | data.append( 'action', 'cff_install_addon' ); |
| 104 | data.append( 'nonce', this.nonce ); |
| 105 | data.append( 'plugin', plugin ); |
| 106 | data.append( 'type', 'plugin' ); |
| 107 | fetch(this.ajax_handler, { |
| 108 | method: "POST", |
| 109 | credentials: 'same-origin', |
| 110 | body: data |
| 111 | }) |
| 112 | .then(response => response.json()) |
| 113 | .then(data => { |
| 114 | if( data.success == true ) { |
| 115 | this.plugins[name].installed = true; |
| 116 | this.plugins[name].open = true; |
| 117 | this.btnClicked = null; |
| 118 | this.btnName = null; |
| 119 | this.btnStatus = null; |
| 120 | } |
| 121 | return; |
| 122 | }); |
| 123 | }, |
| 124 | buttonIcon: function() { |
| 125 | if ( this.btnStatus == 'loading' ) { |
| 126 | return this.icons.loaderSVG |
| 127 | } |
| 128 | }, |
| 129 | } |
| 130 | }) |