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