| 1 |
<template> |
| 2 |
<div> |
| 3 |
<div class="create-funnel-loader-overlay" id="create-funnel-loader" v-if="loader"> |
| 4 |
<span class="wpfnl-loader"></span> |
| 5 |
</div> |
| 6 |
|
| 7 |
<div id="template-library-modal" class="template-library-modal" style="display: none"> |
| 8 |
<div id="wpfnl-create-funnel__inner-content" class="wpfnl-create-funnel__inner-content"> |
| 9 |
|
| 10 |
<div id="wpfnl-create-funnel__template-wrapper" class="wpfnl-create-funnel__templates-wrapper"> |
| 11 |
<div class="funnel-templates-header"> |
| 12 |
<div class="template-library-filter-wrapper"> |
| 13 |
<span class="back-form-modal wpfnl-modal-close" title="Back to Funnel list" v-show="!showStepsPreview"> |
| 14 |
<DoubleAngleLeft/> |
| 15 |
</span> |
| 16 |
|
| 17 |
<span class="back-form-modal back-to-templates" title="Back to Template" v-show="showStepsPreview" @click="backToTemplates"> |
| 18 |
<DoubleAngleLeft/> |
| 19 |
</span> |
| 20 |
|
| 21 |
<h1 class="header-title">Find your templates</h1> |
| 22 |
|
| 23 |
<select class="template-type-filter" v-if="template_type.length" v-show="!showStepsPreview" v-model="type" @change="doTemplateCatFilter"> |
| 24 |
<option data-filter="woocommerce" v-for="(tempalateType, index) in template_type" :key="index" :value="tempalateType.slug" :selected="tempalateType.slug == type"> |
| 25 |
{{tempalateType.label}} |
| 26 |
</option> |
| 27 |
</select> |
| 28 |
|
| 29 |
<ul class="pro-free__filter" v-if="template_type.length > 0 && showProFilter" v-show="!showStepsPreview"> |
| 30 |
<li data-filter="all" :class="templatesType == 'all' ? 'active' : '' " @click="doFreeProFilter('all')"> |
| 31 |
all |
| 32 |
</li> |
| 33 |
|
| 34 |
<li data-filter="free" :class="templatesType == 'free' ? 'active' : '' " @click="doFreeProFilter('free')"> |
| 35 |
free |
| 36 |
</li> |
| 37 |
|
| 38 |
<li data-filter="pro" :class="templatesType == 'pro' ? 'active' : '' " @click="doFreeProFilter('pro')"> |
| 39 |
<svg width="20" height="14" fill="none" viewBox="0 0 20 14" xmlns="http://www.w3.org/2000/svg">><path fill-rule="evenodd" stroke="#7A8B9A" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" d="M10 1l4 6 5-4-2 10H3L1 3l5 4 4-6z" clip-rule="evenodd"/></svg> |
| 40 |
Premium |
| 41 |
</li> |
| 42 |
</ul> |
| 43 |
|
| 44 |
<!-- <div class="import-funnel-name" v-show="showStepsPreview" v-if="!isAddNewFunnelButtonDisabled"> |
| 45 |
<input type="text" name="import-funnel-name" :value="this.activeTemplate ? this.activeTemplate.title : '' " placeholder="Write Funnel Name"> |
| 46 |
</div> --> |
| 47 |
|
| 48 |
<div class="funnel-global-import" v-show="showStepsPreview"> |
| 49 |
<a |
| 50 |
href="#" |
| 51 |
class="btn-default" |
| 52 |
id="funnel-global-import" |
| 53 |
@click="startImportTemplate" |
| 54 |
v-bind:style='{"pointer-events" : (disabled? "none" : "" )}' |
| 55 |
v-if="!isAddNewFunnelButtonDisabled" |
| 56 |
v-show="(isProActivated && activeTemplate.is_pro) || !activeTemplate.is_pro" |
| 57 |
> |
| 58 |
<span class="global-import-progress" |
| 59 |
v-bind:style="{ width: globalImportProgress }"></span> |
| 60 |
<span class="btn-text">{{loaderMessage}}</span> |
| 61 |
</a> |
| 62 |
</div> |
| 63 |
</div> |
| 64 |
</div> |
| 65 |
<!-- /.funnel-templates-header --> |
| 66 |
|
| 67 |
<div class="funnel-templates-body" :class="showStepsPreview ? 'no-sidebar': '' "> |
| 68 |
<div class="funnel-templates-sidebar" v-if="!showStepsPreview"> |
| 69 |
<div class="sidebar-tab-nav"> |
| 70 |
<span class="funnel-templates" :class="{ active: activeTab === 'templates' }" @click="onActivateTab('templates')">Templates</span> |
| 71 |
</div> |
| 72 |
|
| 73 |
<div class="sidebar-tab-content templates-content" v-if="activeTab === 'templates'"> |
| 74 |
<CategoryNav v-if="template_type.length > 0 && !showStepsPreview" :categories="categories" :activeCategory="activeCategory" @doCatFilter="doCatFilter"/> |
| 75 |
</div> |
| 76 |
|
| 77 |
</div> |
| 78 |
<!-- /.funnel-templates-sidebar --> |
| 79 |
|
| 80 |
<div class="funnel-templates-content"> |
| 81 |
<div v-if="activeTab === 'templates'"> |
| 82 |
<div class="not-clickable-overlay"></div> |
| 83 |
|
| 84 |
<!-- funnel name modal. this modal will show when create from scratch --> |
| 85 |
<div class="create-funnel-name-modal"> |
| 86 |
<div class="modal-header"> |
| 87 |
<h3 class="title">Enter Your Funnel Name</h3> |
| 88 |
<span class="close" @click="closeFunnelNameModal"> |
| 89 |
<svg width="22" height="22" fill="none" viewBox="0 0 22 22" xmlns="http://www.w3.org/2000/svg">><g stroke="#7A8B9A" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" clip-path="url(#clip0_407_3318)"><path d="M16.5 5.5l-11 11m0-11l11 11"/></g><defs><clipPath id="clip0_407_3318"><path fill="#fff" d="M0 0h22v22H0z"/></clipPath></defs></svg> |
| 90 |
</span> |
| 91 |
</div> |
| 92 |
|
| 93 |
<div class="modal-body"> |
| 94 |
<form action=""> |
| 95 |
<input type="text" name="funnel-name" placeholder="Enter funnel name" v-model="funnelName"/> |
| 96 |
<button type="submit" @click="createFunnel" :disabled='disabled'> |
| 97 |
{{createFunnelTitle}} |
| 98 |
</button> |
| 99 |
</form> |
| 100 |
</div> |
| 101 |
</div> |
| 102 |
|
| 103 |
<div class="templates-title-wrapper" v-if="!showStepsPreview"> |
| 104 |
<h2 class="title">{{totalTemplates > 1 ? totalTemplates + ' Templates' : totalTemplates + ' Template'}}</h2> |
| 105 |
</div> |
| 106 |
|
| 107 |
<div class="wpfnl-create-funnel__templates"> |
| 108 |
<div class="template-cat-filter-loader" :class="templateCatFilterLoader ? 'show-loader' : '' "> |
| 109 |
<!-- <span class="loader-item-1"></span> |
| 110 |
<span class="loader-item-2"></span> |
| 111 |
<span class="loader-item-3"></span> |
| 112 |
<span class="loader-item-4"></span> |
| 113 |
<span class="loader-item-5"></span> --> |
| 114 |
<span class="wpfnl-loader"></span> |
| 115 |
</div> |
| 116 |
|
| 117 |
<div v-show="loader" class="wpfnl-create-funnel__loader"> |
| 118 |
<!-- <span class="wpfnl-loader" v-show="templateCatFilterLoader"></span> --> |
| 119 |
</div> |
| 120 |
|
| 121 |
<div class="create-funnel__single-template create__from-scratch" |
| 122 |
v-if="showProFilter && !showStepsPreview"> |
| 123 |
<a id="wpfnl-create-funnel" href="#" class="btn-default" @click="showFunnelNameModal" |
| 124 |
v-if="!isAddNewFunnelButtonDisabled"> <PlusIcon /> Start From scratch </a> |
| 125 |
|
| 126 |
<div class="funnel-limit-notice" v-if="isAddNewFunnelButtonDisabled"> |
| 127 |
<p><b>You have reached your limit and built 3/3 funnels!</b><br/><br/> |
| 128 |
To create unlimited funnels, please upgrade to Pro. |
| 129 |
</p> |
| 130 |
</div> |
| 131 |
|
| 132 |
<div class="wpfnl-single-remote-wrapper"> |
| 133 |
<div class="wpfnl-single-remote-template"> |
| 134 |
<div class="template-image-wrapper"></div> |
| 135 |
</div> |
| 136 |
<div class="funnel-template-info"> |
| 137 |
<span class="title">title</span> |
| 138 |
</div> |
| 139 |
</div> |
| 140 |
</div> |
| 141 |
|
| 142 |
<template v-if="isAnyPluginMissing == 'no'"> |
| 143 |
<SingleTemplate |
| 144 |
v-for="(data, index) in templates" |
| 145 |
:templatedata="data" |
| 146 |
:active-category="activeCategory" |
| 147 |
:isPro="data.is_pro" |
| 148 |
:type="type" |
| 149 |
:key="index" |
| 150 |
:isAddNewFunnelButtonDisabled="isAddNewFunnelButtonDisabled" |
| 151 |
@toggleStepsPreview="toggleStepsPreview" |
| 152 |
@initSteps="initSteps" |
| 153 |
@setActiveTemplate="setActiveTemplate" |
| 154 |
v-if="!showStepsPreview" |
| 155 |
/> |
| 156 |
</template> |
| 157 |
|
| 158 |
<div class="create-funnel__single-template wpfnl-missing-plugin-notice" v-else> |
| 159 |
<div v-if="builder === 'gutenberg'"> |
| 160 |
<h4 class="wpfnl-notice-title">Oops! It looks like {{dependencyPlugins[builder].name}} is inactive.</h4> |
| 161 |
<div class="wpfnl-notice-notice-body"> |
| 162 |
<p> |
| 163 |
It seems like you have selected {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} as your preferred page builder, but you |
| 164 |
do not have {{dependencyPlugins[builder].name}} activated on your site. You see, we create funnel templates for |
| 165 |
{{ builder.charAt(0).toUpperCase() + builder.slice(1) }} using {{dependencyPlugins[builder].name}}. |
| 166 |
<br>Please install and activate {{dependencyPlugins[builder].name}} to import funnel templates for {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} |
| 167 |
<a href="#" @click="pluginInstallationAction"> |
| 168 |
Click here to install & activate {{dependencyPlugins[builder].name}} |
| 169 |
<span class="dot-wrapper" v-if="pluginInstallLoader"> |
| 170 |
<span class="dot-one">.</span> |
| 171 |
<span class="dot-two">.</span> |
| 172 |
<span class="dot-three">.</span> |
| 173 |
</span> |
| 174 |
</a> |
| 175 |
</p> |
| 176 |
<p>If you want to create & design funnel pages without using {{dependencyPlugins[builder].name}}, then don't worry. |
| 177 |
<b>You can go ahead and create funnels from scratch using any page builder/editor. It will work just fine.</b></p> |
| 178 |
|
| 179 |
<span class="wpfnl-plugin-installation-error" |
| 180 |
v-html="pluginInstallationErrorMessage"></span> |
| 181 |
</div> |
| 182 |
</div> |
| 183 |
|
| 184 |
<div v-else-if="builder === 'elementor'"> |
| 185 |
<h4 class="wpfnl-notice-title">Oops! It looks like the page builder you selected is inactive.</h4> |
| 186 |
<div class="wpfnl-notice-notice-body"> |
| 187 |
<p> |
| 188 |
It seems like you have selected {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} as your preferred page builder, but you do not have |
| 189 |
the plugin {{dependencyPlugins[builder].name}} activated on your site. <br> |
| 190 |
|
| 191 |
Please install and activate {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} to import ready funnel templates. |
| 192 |
<a href="#" @click="pluginInstallationAction"> |
| 193 |
Click here to install & activate {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} |
| 194 |
<span class="dot-wrapper" v-if="pluginInstallLoader"> |
| 195 |
<span class="dot-one">.</span> |
| 196 |
<span class="dot-two">.</span> |
| 197 |
<span class="dot-three">.</span> |
| 198 |
</span> |
| 199 |
</a> |
| 200 |
</p> |
| 201 |
|
| 202 |
<p>If you want to create & design funnel pages without using {{dependencyPlugins[builder].name}}, then |
| 203 |
don't worry. <b>You can go ahead and create funnels from scratch using any page builder/editor. It will work just fine.</b></p> |
| 204 |
|
| 205 |
|
| 206 |
<span class="wpfnl-plugin-installation-error" |
| 207 |
v-html="pluginInstallationErrorMessage"></span> |
| 208 |
</div> |
| 209 |
</div> |
| 210 |
|
| 211 |
<div v-else-if="builder === 'divi-builder'"> |
| 212 |
<h4 class="wpfnl-notice-title">Oops! It looks like the page builder you selected is inactive.</h4> |
| 213 |
<div class="wpfnl-notice-notice-body"> |
| 214 |
<p> |
| 215 |
It seems like you have selected {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} as your preferred page builder, but you do not have |
| 216 |
the plugin {{dependencyPlugins[builder].name}} activated on your site. <br> |
| 217 |
|
| 218 |
Please install and activate {{ builder.charAt(0).toUpperCase() + builder.slice(1) }} to import ready funnel templates. |
| 219 |
</p> |
| 220 |
|
| 221 |
<p>If you want to create & design funnel pages without using {{dependencyPlugins[builder].name}}, then |
| 222 |
don't worry. <b>You can go ahead and create funnels from scratch using any page builder/editor. It will work just fine.</b></p> |
| 223 |
|
| 224 |
|
| 225 |
<span class="wpfnl-plugin-installation-error" |
| 226 |
v-html="pluginInstallationErrorMessage"></span> |
| 227 |
</div> |
| 228 |
</div> |
| 229 |
|
| 230 |
<div v-else-if="builder === 'oxygen'"> |
| 231 |
<h4 class="wpfnl-notice-title">Oops! It looks like the page builder you selected is inactive.</h4> |
| 232 |
<div class="wpfnl-notice-notice-body"> |
| 233 |
<p> |
| 234 |
It seems like you have selected Oxygen builder as your preferred page builder, but you do not have |
| 235 |
the plugin Oxygen builder activated on your site. <br> |
| 236 |
|
| 237 |
Please install and activate Oxygen builder to import ready funnel templates. |
| 238 |
</p> |
| 239 |
|
| 240 |
<p>If you want to create & design funnel pages without using Oxygen builder, then |
| 241 |
don't worry. <b>You can go ahead and create funnels from scratch using any page builder/editor. It will work just fine.</b></p> |
| 242 |
|
| 243 |
|
| 244 |
<span class="wpfnl-plugin-installation-error" |
| 245 |
v-html="pluginInstallationErrorMessage"></span> |
| 246 |
</div> |
| 247 |
</div> |
| 248 |
</div> |
| 249 |
|
| 250 |
<div class="steps-preview-wrapper" v-if="showStepsPreview"> |
| 251 |
<SingleStepPreview |
| 252 |
v-for="(step, index) in this.steps" |
| 253 |
:step="step" |
| 254 |
:key="index" |
| 255 |
:image="step.featured_image" |
| 256 |
:isAddNewFunnelButtonDisabled="isAddNewFunnelButtonDisabled" |
| 257 |
:previewLink="step.link" |
| 258 |
/> |
| 259 |
|
| 260 |
<div class="step-title-wrapper"> |
| 261 |
<h2 class="title">{{steps.length > 1 ? steps.length + ' Steps' : steps.length + ' Step'}}</h2> |
| 262 |
</div> |
| 263 |
</div> |
| 264 |
</div> |
| 265 |
</div> |
| 266 |
</div> |
| 267 |
<!-- /.funnel-templates-content --> |
| 268 |
</div> |
| 269 |
<!-- /.funnel-templates-body --> |
| 270 |
|
| 271 |
</div> |
| 272 |
</div> |
| 273 |
|
| 274 |
</div> |
| 275 |
</div> |
| 276 |
</template> |
| 277 |
|
| 278 |
<script> |
| 279 |
import SingleTemplate from './SingleTemplate.vue' |
| 280 |
import CategoryNav from './CategoryNav.vue' |
| 281 |
import SingleStep from './SingleStep.vue' |
| 282 |
import SingleStepPreview from './SingleStepPreview.vue' |
| 283 |
import StepImporter from './StepImporter.vue' |
| 284 |
import apiFetch from '@wordpress/api-fetch' |
| 285 |
import {addQueryArgs} from "@wordpress/url"; |
| 286 |
import DoubleAngleLeft from '../../../src/components/icons/DoubleAngleLeft.vue' |
| 287 |
import PlusIcon from '../../../src/components/icons/PlusIcon.vue' |
| 288 |
|
| 289 |
var j = jQuery.noConflict() |
| 290 |
const nonce = window.template_library_object.nonce |
| 291 |
apiFetch.use(apiFetch.createNonceMiddleware(nonce)) |
| 292 |
|
| 293 |
export default { |
| 294 |
name: 'TemplatesLibrary', |
| 295 |
components: { |
| 296 |
SingleTemplate, |
| 297 |
CategoryNav, |
| 298 |
StepImporter, |
| 299 |
SingleStepPreview, |
| 300 |
DoubleAngleLeft, |
| 301 |
SingleStep, |
| 302 |
PlusIcon, |
| 303 |
}, |
| 304 |
data: function () { |
| 305 |
return { |
| 306 |
showModal: j('#template-library-modal').attr('data-modal-visibility'), |
| 307 |
proUrl: window.template_library_object.pro_url, |
| 308 |
templates: [], |
| 309 |
activeTemplate: '', |
| 310 |
allTemplates: [], |
| 311 |
categories: [], |
| 312 |
stepCategories: [], |
| 313 |
steps: [], |
| 314 |
allSteps: [], |
| 315 |
totalTemplates: 0, |
| 316 |
loader: true, |
| 317 |
templateCatFilterLoader: false, |
| 318 |
message: '', |
| 319 |
isProTemplateSelected: false, |
| 320 |
loaderMessage: 'Import', |
| 321 |
activeCategory: 'all', |
| 322 |
activeStepCategory: 'all', |
| 323 |
activeStep: 'landing', |
| 324 |
templatesType: 'all', |
| 325 |
templatesCatType: 'woocommerce', |
| 326 |
selectedStep: 'landing', |
| 327 |
stepTemplateType: 'all', |
| 328 |
showProFilter: true, |
| 329 |
showStepsPreview: false, |
| 330 |
image_path: window.template_library_object.image_path, |
| 331 |
globalImportProgress: '', |
| 332 |
supportedSteps : window.template_library_object.supported_steps, |
| 333 |
disabled: false, |
| 334 |
templateNewName: '', |
| 335 |
funnelName: '', |
| 336 |
isPro : window.template_library_object.is_pro, |
| 337 |
createFunnelTitle: 'Create Funnel', |
| 338 |
totalFunnels: window.WPFunnelVars.totalFunnels, |
| 339 |
totalAllowedFunnels: window.WPFunnelVars.totalAllowedFunnels, |
| 340 |
dependencyPlugins: window.WPFunnelVars.dependencyPlugins, |
| 341 |
isAnyPluginMissing: window.WPFunnelVars.isAnyPluginMissing, |
| 342 |
isProActivated: window.WPFunnelVars.isProActivated, |
| 343 |
isWcActivated: window.WPFunnelVars.is_wc_installed, |
| 344 |
isLmsActivated: window.WPFunnelVars.isLmsActivated, |
| 345 |
builder: window.WPFunnelVars.builder, |
| 346 |
pluginInstallLoader: false, |
| 347 |
pluginInstallationErrorMessage: '', |
| 348 |
isRemoteFunnel: false, |
| 349 |
funnelType: window.WPFunnelVars.global_funnel_type, |
| 350 |
type: 'lead' == window.WPFunnelVars.global_funnel_type ? 'lead' : window.WPFunnelVars.is_wc_installed === 'yes' ? 'wc' : 'lms', |
| 351 |
selectedType: 'lead' == window.WPFunnelVars.global_funnel_type ? 'lead' : window.WPFunnelVars.is_wc_installed === 'yes' ? 'wc' : 'lms', |
| 352 |
tempalateTypes : [], |
| 353 |
template_type : window.template_library_object.template_type, |
| 354 |
activeTab : 'templates' |
| 355 |
} |
| 356 |
|
| 357 |
}, |
| 358 |
|
| 359 |
computed: { |
| 360 |
isAddNewFunnelButtonDisabled: function () { |
| 361 |
if (!this.isProActivated) { |
| 362 |
if (this.totalFunnels >= this.totalAllowedFunnels) { |
| 363 |
return true |
| 364 |
} |
| 365 |
} |
| 366 |
return false |
| 367 |
} |
| 368 |
}, |
| 369 |
mounted() { |
| 370 |
j(document).on( |
| 371 |
'wp-plugin-install-success', |
| 372 |
this.pluginInstalledSuccess |
| 373 |
); |
| 374 |
|
| 375 |
j(document).on( |
| 376 |
'wp-plugin-install-error', |
| 377 |
this.pluginInstalledError |
| 378 |
); |
| 379 |
if(!this.$store.isRemoteFunnel) { |
| 380 |
this.getTemplate(); |
| 381 |
} else { |
| 382 |
this.loader = false |
| 383 |
} |
| 384 |
|
| 385 |
}, |
| 386 |
|
| 387 |
methods: { |
| 388 |
|
| 389 |
getTemplate: function (){ |
| 390 |
|
| 391 |
if( this.selectedType ){ |
| 392 |
apiFetch({ |
| 393 |
path: addQueryArgs( `${window.template_library_object.rest_api_url}wpfunnels/v1/templates/get_templates`, { |
| 394 |
type: this.selectedType |
| 395 |
} ), |
| 396 |
method: 'GET' |
| 397 |
}).then(response => { |
| 398 |
if (response.success) { |
| 399 |
this.templates = response.templates |
| 400 |
this.allTemplates = response.templates |
| 401 |
this.steps = response.steps |
| 402 |
this.allSteps = response.steps |
| 403 |
this.templatesType = 'all' |
| 404 |
this.categories = response.categories |
| 405 |
this.stepCategories = response.categories |
| 406 |
this.loader = false |
| 407 |
this.templateCatFilterLoader = false; |
| 408 |
if (response.templates) { |
| 409 |
this.totalTemplates = this.isAnyPluginMissing === 'yes' ? 0 : response.templates.length |
| 410 |
} |
| 411 |
|
| 412 |
} |
| 413 |
|
| 414 |
}) |
| 415 |
} |
| 416 |
|
| 417 |
}, |
| 418 |
|
| 419 |
createFunnel: function (e) { |
| 420 |
e.preventDefault(); |
| 421 |
this.disabled = true; |
| 422 |
this.createFunnelTitle = "Creating Funnel..." |
| 423 |
var payload = { |
| 424 |
funnelName: this.funnelName, |
| 425 |
type : this.type, |
| 426 |
}; |
| 427 |
wpAjaxHelperRequest("create-funnel", payload) |
| 428 |
.success(function (response) { |
| 429 |
window.location.href = response.redirectUrl; |
| 430 |
this.disabled = false; |
| 431 |
}) |
| 432 |
.error(function (response) { |
| 433 |
|
| 434 |
}); |
| 435 |
}, |
| 436 |
|
| 437 |
createFunnelWithSingleStep: function () { |
| 438 |
|
| 439 |
this.disabled = true; |
| 440 |
this.createFunnelTitle = "Creating Funnel..." |
| 441 |
var payload = { |
| 442 |
funnelName: this.funnelName, |
| 443 |
type : this.type, |
| 444 |
}; |
| 445 |
wpAjaxHelperRequest("create-funnel", payload) |
| 446 |
.success(function (response) { |
| 447 |
window.location.href = response.redirectUrl; |
| 448 |
this.disabled = false; |
| 449 |
}) |
| 450 |
.error(function (response) { |
| 451 |
|
| 452 |
}); |
| 453 |
}, |
| 454 |
|
| 455 |
showFunnelNameModal: function (e) { |
| 456 |
e.preventDefault() |
| 457 |
|
| 458 |
j('.wpfnl-create-funnel__templates-wrapper .not-clickable-overlay').fadeIn(); |
| 459 |
j('.wpfnl-create-funnel__templates-wrapper .create-funnel-name-modal').addClass('show'); |
| 460 |
}, |
| 461 |
|
| 462 |
closeFunnelNameModal: function (e) { |
| 463 |
e.preventDefault() |
| 464 |
j('.wpfnl-create-funnel__templates-wrapper .not-clickable-overlay').fadeOut(); |
| 465 |
j('.wpfnl-create-funnel__templates-wrapper .create-funnel-name-modal').removeClass('show'); |
| 466 |
}, |
| 467 |
|
| 468 |
startImportTemplate: function (e) { |
| 469 |
e.preventDefault(); |
| 470 |
if (this.isAddNewFunnelButtonDisabled) return false; |
| 471 |
|
| 472 |
this.disabled = true; |
| 473 |
|
| 474 |
let data = { |
| 475 |
action : 'wpfunnel_import_funnel', |
| 476 |
steps : this.steps, |
| 477 |
name : j('.import-funnel-name input').val() ? j('.import-funnel-name input').val() : this.activeTemplate.title, |
| 478 |
source : 'remote', |
| 479 |
remoteID: this.activeTemplate.ID, |
| 480 |
type : this.type, |
| 481 |
}, |
| 482 |
that = this; |
| 483 |
|
| 484 |
that.loaderMessage = 'Please Wait...', |
| 485 |
this.activeTemplate.title = data.name; |
| 486 |
|
| 487 |
wpAjaxHelperRequest("wpfunnel-import-funnel", data) |
| 488 |
.success(function (response) { |
| 489 |
let looper = j.Deferred().resolve(), |
| 490 |
first_step_id = 0; |
| 491 |
j.when.apply(j, j.map(that.steps, function (step, index) { |
| 492 |
looper = looper.then(function () { |
| 493 |
return that.createStep(step, response.funnelID, index, that); |
| 494 |
}); |
| 495 |
return looper; |
| 496 |
})).then(function () { |
| 497 |
that.afterFunnelCreationRedirect(response.funnelID); |
| 498 |
}); |
| 499 |
}) |
| 500 |
.error(function (response) { |
| 501 |
console.log("Uh, oh!"); |
| 502 |
console.log(response.statusText); |
| 503 |
}); |
| 504 |
}, |
| 505 |
|
| 506 |
createStep: function (step, funnelID, index, that, funnelData) { |
| 507 |
let deferred = j.Deferred(), |
| 508 |
payload = { |
| 509 |
'step' : step, |
| 510 |
'funnelID' : funnelID, |
| 511 |
'source' : 'remote', |
| 512 |
'funnelData': JSON.stringify(funnelData), |
| 513 |
'importType': 'templates', |
| 514 |
}; |
| 515 |
apiFetch({ |
| 516 |
path: `${window.WPFunnelVars.rest_api_url}wpfunnels/v1/steps/wpfunnel-import-step`, |
| 517 |
method: 'POST', |
| 518 |
data: payload |
| 519 |
}) |
| 520 |
.then(function(response) { |
| 521 |
that.loaderMessage = `Importing Step: ` + (parseInt(index) + 1) |
| 522 |
deferred.resolve(response) |
| 523 |
}) |
| 524 |
.catch(function(error) { |
| 525 |
deferred.reject(response) |
| 526 |
}) |
| 527 |
return deferred.promise(); |
| 528 |
}, |
| 529 |
|
| 530 |
afterFunnelCreationRedirect: function (funnelId) { |
| 531 |
var payload = { |
| 532 |
'funnelID': funnelId, |
| 533 |
'source': 'remote' |
| 534 |
}; |
| 535 |
wpAjaxHelperRequest("wpfunnel-after-funnel-creation", payload) |
| 536 |
.success(function (response) { |
| 537 |
window.location = response.redirectLink |
| 538 |
}) |
| 539 |
.error(function (response) { |
| 540 |
console.log(response) |
| 541 |
}); |
| 542 |
}, |
| 543 |
|
| 544 |
doCatFilter: function (value) { |
| 545 |
this.activeCategory = value === '' ? 'all' : value |
| 546 |
|
| 547 |
if (value !== '') { |
| 548 |
this.templates = this.allTemplates.filter(function (template) { |
| 549 |
if( null !== template.wpf_funnel_industry ) { |
| 550 |
if( 'slug' in template.wpf_funnel_industry ){ |
| 551 |
if( 'all' === value ){ |
| 552 |
return true; |
| 553 |
}else{ |
| 554 |
return template.wpf_funnel_industry.slug === value; |
| 555 |
} |
| 556 |
} |
| 557 |
} |
| 558 |
|
| 559 |
}); |
| 560 |
}else { |
| 561 |
this.templates = this.allTemplates |
| 562 |
} |
| 563 |
this.totalTemplates = this.templates.length |
| 564 |
}, |
| 565 |
|
| 566 |
doStepCatFilter: function (value) { |
| 567 |
this.activeStepCategory = value === '' ? 'all' : value |
| 568 |
let activeStep = this.activeStep |
| 569 |
if (value !== '') { |
| 570 |
this.steps = this.allSteps.filter(function (step) { |
| 571 |
return step.industry.slug === value && step.step_type === activeStep; |
| 572 |
}); |
| 573 |
} else { |
| 574 |
this.steps = this.allSteps |
| 575 |
} |
| 576 |
}, |
| 577 |
|
| 578 |
setActiveStep: function (value) { |
| 579 |
this.activeStep = value; |
| 580 |
}, |
| 581 |
|
| 582 |
doStepFilter: function (value) { |
| 583 |
this.activeStep = value |
| 584 |
// this.steps = this.allSteps.filter(function (step) { |
| 585 |
// return step.step_type === value; |
| 586 |
// }); |
| 587 |
}, |
| 588 |
|
| 589 |
doStepFreeProFilter: function (value) { |
| 590 |
this.stepTemplateType = value |
| 591 |
this.steps = this.allSteps.filter(function (step) { |
| 592 |
return value === 'pro' ? step.is_pro : !step.is_pro; |
| 593 |
}); |
| 594 |
}, |
| 595 |
|
| 596 |
doFreeProFilter: function (value) { |
| 597 |
this.templatesType = value |
| 598 |
let activeCategory = this.activeCategory |
| 599 |
this.templates = this.allTemplates.filter(function (template) { |
| 600 |
return ( activeCategory !== 'all' ? template.wpf_funnel_industry?.slug === activeCategory : 1) && ( value === 'pro' && template.is_pro ? 1 : value === 'all' ? 1 : value === 'free' && !template.is_pro ? 1 : 0 ); |
| 601 |
}); |
| 602 |
this.totalTemplates = this.templates.length |
| 603 |
}, |
| 604 |
|
| 605 |
doTemplateCatFilter: function (e) { |
| 606 |
this.loader = true; |
| 607 |
this.templateCatFilterLoader = true; |
| 608 |
|
| 609 |
this.selectedType = this.type |
| 610 |
// this.doCatFilter('') |
| 611 |
this.getTemplate(); |
| 612 |
|
| 613 |
}, |
| 614 |
|
| 615 |
toggleLoader: function (e) { |
| 616 |
this.loader = !this.loader |
| 617 |
}, |
| 618 |
|
| 619 |
showLoaderMessage: function (e, message) { |
| 620 |
this.message = message |
| 621 |
}, |
| 622 |
|
| 623 |
getBackBtnValue: function (params) { |
| 624 |
this.showBackBtn = params; |
| 625 |
}, |
| 626 |
|
| 627 |
hideProFilter: function () { |
| 628 |
this.showProFilter = !this.showProFilter |
| 629 |
}, |
| 630 |
|
| 631 |
toggleStepsPreview: function () { |
| 632 |
this.showStepsPreview = !this.showStepsPreview; |
| 633 |
}, |
| 634 |
|
| 635 |
initSteps: function (steps) { |
| 636 |
this.steps = steps; |
| 637 |
}, |
| 638 |
|
| 639 |
backToTemplates: function (e) { |
| 640 |
this.showStepsPreview = false |
| 641 |
}, |
| 642 |
|
| 643 |
funnelNewName: function (data) { |
| 644 |
this.templateNewName = j('.import-funnel-name input').val(); |
| 645 |
}, |
| 646 |
|
| 647 |
setActiveTemplate: function (data) { |
| 648 |
this.activeTemplate = data; |
| 649 |
// if(data.is_pro && this.isProActivated) { |
| 650 |
// this.isProTemplateSelected = true; |
| 651 |
// } else if(!data.isPro) { |
| 652 |
// this.isProTemplateSelected = true; |
| 653 |
// }else { |
| 654 |
// this.isProTemplateSelected = false; |
| 655 |
// } |
| 656 |
}, |
| 657 |
|
| 658 |
activatePlugin: function (payload, that) { |
| 659 |
wpAjaxHelperRequest("wpfunnels-activate-plugin", payload) |
| 660 |
.success(function (response) { |
| 661 |
that.isAnyPluginMissing = 'no' |
| 662 |
}) |
| 663 |
.error(function (response) { |
| 664 |
|
| 665 |
}); |
| 666 |
}, |
| 667 |
|
| 668 |
pluginInstallationAction: function (e) { |
| 669 |
e.preventDefault(); |
| 670 |
|
| 671 |
this.pluginInstallLoader = true; |
| 672 |
|
| 673 |
var plugin = this.dependencyPlugins[this.builder], |
| 674 |
pluginFile = plugin.plugin_file, |
| 675 |
payload = { |
| 676 |
pluginFile: pluginFile |
| 677 |
}, |
| 678 |
action = this.dependencyPlugins[this.builder].action, |
| 679 |
that = this; |
| 680 |
if (action == 'activate') { |
| 681 |
this.activatePlugin(payload, that); |
| 682 |
} else { |
| 683 |
wp.updates.queue.push({ |
| 684 |
action: 'install-plugin', |
| 685 |
data: { |
| 686 |
slug: plugin.slug, |
| 687 |
}, |
| 688 |
}); |
| 689 |
wp.updates.queueChecker(); |
| 690 |
} |
| 691 |
|
| 692 |
}, |
| 693 |
|
| 694 |
pluginInstalledSuccess: function (e, response) { |
| 695 |
e.preventDefault(); |
| 696 |
var plugin = this.dependencyPlugins[this.builder], |
| 697 |
pluginFile = plugin.plugin_file, |
| 698 |
payload = { |
| 699 |
pluginFile: pluginFile |
| 700 |
}, |
| 701 |
that = this; |
| 702 |
this.activatePlugin(payload, that); |
| 703 |
}, |
| 704 |
|
| 705 |
pluginInstalledError: function (e, response) { |
| 706 |
e.preventDefault(); |
| 707 |
this.pluginInstallLoader = false; |
| 708 |
this.pluginInstallationErrorMessage = response.errorMessage |
| 709 |
}, |
| 710 |
|
| 711 |
onActivateTab(tabId) { |
| 712 |
this.activeTab = tabId; |
| 713 |
} |
| 714 |
|
| 715 |
} |
| 716 |
} |
| 717 |
</script> |