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
support.js
219 lines
| 1 | var support_data = { |
| 2 | genericText: cff_support.genericText, |
| 3 | articles: cff_support.articles, |
| 4 | system_info: cff_support.system_info, |
| 5 | system_info_n: cff_support.system_info_n, |
| 6 | exportFeed: 'none', |
| 7 | feeds: cff_support.feeds, |
| 8 | supportUrl: cff_support.supportUrl, |
| 9 | socialWallActivated: cff_support.socialWallActivated, |
| 10 | socialWallLinks: cff_support.socialWallLinks, |
| 11 | siteSearchUrl: cff_support.siteSearchUrl, |
| 12 | siteSearchUrlWithArgs: null, |
| 13 | searchKeywords: null, |
| 14 | buttons: cff_support.buttons, |
| 15 | links: cff_support.links, |
| 16 | supportPageUrl: cff_support.supportPageUrl, |
| 17 | systemInfoBtnStatus: 'collapsed', |
| 18 | copyBtnStatus: null, |
| 19 | ajax_handler: cff_support.ajax_handler, |
| 20 | nonce: cff_support.nonce, |
| 21 | icons: cff_support.icons, |
| 22 | images: cff_support.images, |
| 23 | svgIcons : cff_support.svgIcons, |
| 24 | notificationElement : { |
| 25 | type : 'success', // success, error, warning, message |
| 26 | text : '', |
| 27 | shown : null |
| 28 | }, |
| 29 | viewsActive : { |
| 30 | tempLoginAboutPopup : false |
| 31 | }, |
| 32 | //Tenmp User Account |
| 33 | tempUser : cff_support.tempUser, |
| 34 | createStatus : null, |
| 35 | deleteStatus : null, |
| 36 | isSetupPage : false |
| 37 | } |
| 38 | |
| 39 | var cffsupport = new Vue({ |
| 40 | el: "#cff-support", |
| 41 | http: { |
| 42 | emulateJSON: true, |
| 43 | emulateHTTP: true |
| 44 | }, |
| 45 | data: support_data, |
| 46 | methods: { |
| 47 | copySystemInfo: function() { |
| 48 | let self = this; |
| 49 | const el = document.createElement('textarea'); |
| 50 | el.className = 'cff-fb-cp-clpboard'; |
| 51 | el.value = self.system_info_n; |
| 52 | document.body.appendChild(el); |
| 53 | el.select(); |
| 54 | document.execCommand('copy'); |
| 55 | document.body.removeChild(el); |
| 56 | this.notificationElement = { |
| 57 | type : 'success', |
| 58 | text : this.genericText.copiedToClipboard, |
| 59 | shown : "shown" |
| 60 | }; |
| 61 | |
| 62 | setTimeout(function() { |
| 63 | this.notificationElement.shown = "hidden"; |
| 64 | }.bind(self), 3000); |
| 65 | }, |
| 66 | expandSystemInfo: function() { |
| 67 | this.systemInfoBtnStatus = ( this.systemInfoBtnStatus == 'collapsed' ) ? 'expanded' : 'collapsed'; |
| 68 | }, |
| 69 | expandBtnText: function() { |
| 70 | if ( this.systemInfoBtnStatus == 'collapsed' ) { |
| 71 | return this.buttons.expand; |
| 72 | } else if ( this.systemInfoBtnStatus == 'expanded' ) { |
| 73 | return this.buttons.collapse; |
| 74 | } |
| 75 | }, |
| 76 | exportFeedSettings: function() { |
| 77 | // return if no feed is selected |
| 78 | if ( this.exportFeed === 'none' ) { |
| 79 | return; |
| 80 | } |
| 81 | |
| 82 | let url = this.ajax_handler + '?action=cff_export_settings_json&feed_id=' + + this.exportFeed + '&nonce=' + this.nonce; |
| 83 | window.location = url; |
| 84 | }, |
| 85 | searchDoc: function() { |
| 86 | let self = this; |
| 87 | let searchInput = document.getElementById('cff-search-doc-input'); |
| 88 | searchInput.addEventListener('keyup', function ( event ) { |
| 89 | let url = new URL( self.siteSearchUrl ); |
| 90 | let search_params = url.searchParams; |
| 91 | if ( self.searchKeywords ) { |
| 92 | search_params.set('search', self.searchKeywords); |
| 93 | } |
| 94 | search_params.set('plugin', 'facebook'); |
| 95 | url.search = search_params.toString(); |
| 96 | self.siteSearchUrlWithArgs = url.toString(); |
| 97 | |
| 98 | if ( event.key === 'Enter' ) { |
| 99 | window.open( self.siteSearchUrlWithArgs, '_blank'); |
| 100 | } |
| 101 | }) |
| 102 | }, |
| 103 | searchDocStrings: function() { |
| 104 | let self = this; |
| 105 | let url = new URL( this.siteSearchUrl ); |
| 106 | let search_params = url.searchParams; |
| 107 | setTimeout(function() { |
| 108 | search_params.set('search', self.searchKeywords); |
| 109 | search_params.set('plugin', 'facebook'); |
| 110 | url.search = search_params.toString(); |
| 111 | self.siteSearchUrlWithArgs = url.toString(); |
| 112 | }, 10); |
| 113 | }, |
| 114 | goToSearchDocumentation: function() { |
| 115 | if ( this.searchKeywords !== null && this.siteSearchUrlWithArgs !== null ) { |
| 116 | window.open( this.siteSearchUrlWithArgs, '_blank'); |
| 117 | } |
| 118 | }, |
| 119 | /** |
| 120 | * Copy text to clipboard |
| 121 | * |
| 122 | * @since 4.0 |
| 123 | */ |
| 124 | copyToClipBoard : function(value){ |
| 125 | var self = this; |
| 126 | const el = document.createElement('textarea'); |
| 127 | el.className = 'cff-fb-cp-clpboard'; |
| 128 | el.value = value; |
| 129 | document.body.appendChild(el); |
| 130 | el.select(); |
| 131 | document.execCommand('copy'); |
| 132 | document.body.removeChild(el); |
| 133 | self.notificationElement = { |
| 134 | type : 'success', |
| 135 | text : this.genericText.copiedToClipboard, |
| 136 | shown : "shown" |
| 137 | }; |
| 138 | setTimeout(function(){ |
| 139 | self.notificationElement.shown = "hidden"; |
| 140 | }, 3000); |
| 141 | }, |
| 142 | /** |
| 143 | * Activate View |
| 144 | * |
| 145 | * @since 4.0 |
| 146 | */ |
| 147 | activateView : function(viewName){ |
| 148 | var self = this; |
| 149 | self.viewsActive[viewName] = (self.viewsActive[viewName] == false ) ? true : false; |
| 150 | }, |
| 151 | /** |
| 152 | * Create New Temp User |
| 153 | * |
| 154 | * @since 4.0 |
| 155 | */ |
| 156 | createTempUser: function() { |
| 157 | const self = this; |
| 158 | self.createStatus = 'loading'; |
| 159 | let data = new FormData(); |
| 160 | data.append( 'action', 'cff_create_temp_user' ); |
| 161 | data.append( 'nonce', cff_support.nonce ); |
| 162 | fetch(cff_support.ajax_handler, { |
| 163 | method: "POST", |
| 164 | credentials: 'same-origin', |
| 165 | body: data |
| 166 | }) |
| 167 | .then(response => response.json()) |
| 168 | .then(data => { |
| 169 | self.createStatus = null; |
| 170 | if( data.success ){ |
| 171 | self.tempUser = data.user; |
| 172 | } |
| 173 | self.notificationElement = { |
| 174 | type : data.success === true ? 'success' : 'error', |
| 175 | text : data.message, |
| 176 | shown : "shown" |
| 177 | }; |
| 178 | setTimeout(function(){ |
| 179 | self.notificationElement.shown = "hidden"; |
| 180 | }, 5000); |
| 181 | }); |
| 182 | |
| 183 | }, |
| 184 | |
| 185 | /** |
| 186 | * Delete Temp User |
| 187 | * |
| 188 | * @since 4.0 |
| 189 | */ |
| 190 | deleteTempUser: function() { |
| 191 | const self = this; |
| 192 | self.deleteStatus = 'loading'; |
| 193 | let data = new FormData(); |
| 194 | data.append( 'action', 'cff_delete_temp_user' ); |
| 195 | data.append( 'nonce', cff_support.nonce ); |
| 196 | data.append( 'userId', self.tempUser.id ); |
| 197 | fetch(cff_support.ajax_handler, { |
| 198 | method: "POST", |
| 199 | credentials: 'same-origin', |
| 200 | body: data |
| 201 | }) |
| 202 | .then(response => response.json()) |
| 203 | .then(data => { |
| 204 | self.deleteStatus = null; |
| 205 | if( data.success ){ |
| 206 | self.tempUser = null; |
| 207 | } |
| 208 | self.notificationElement = { |
| 209 | type : data.success === true ? 'success' : 'error', |
| 210 | text : data.message, |
| 211 | shown : "shown" |
| 212 | }; |
| 213 | setTimeout(function(){ |
| 214 | self.notificationElement.shown = "hidden"; |
| 215 | }, 5000); |
| 216 | }); |
| 217 | } |
| 218 | }, |
| 219 | }) |