admin.js
3 weeks ago
admin.min.js
3 weeks ago
chart.js
2 years ago
chart.min.js
1 year ago
customize-controls.js
1 year ago
customize-controls.min.js
1 year ago
customize-preview.js
1 year ago
customize-preview.min.js
1 year ago
deactivation-feedback.js
2 years ago
deactivation-feedback.min.js
2 years ago
editor.js
7 years ago
editor.min.js
5 years ago
everest-forms-survey-polls-quiz-builder.js
2 years ago
everest-forms-survey-polls-quiz-builder.min.js
2 years ago
evf-admin-email.js
2 years ago
evf-admin-email.min.js
1 year ago
evf-clipboard.js
7 years ago
evf-clipboard.min.js
7 years ago
evf-enhanced-select.js
3 years ago
evf-enhanced-select.min.js
2 years ago
evf-file-uploader.js
1 year ago
evf-file-uploader.min.js
1 year ago
evf-setup.js
1 year ago
evf-setup.min.js
1 year ago
extensions.js
2 years ago
extensions.min.js
2 years ago
form-builder.js
6 days ago
form-builder.min.js
6 days ago
form-template-controller.js
3 years ago
form-template-controller.min.js
3 years ago
printThis.min.js
2 years ago
progressbar.js
2 years ago
progressbar.min.js
1 year ago
randomColor.js
2 years ago
randomColor.min.js
2 years ago
settings.js
3 weeks ago
settings.min.js
3 weeks ago
shortcode-form-embed.js
2 years ago
shortcode-form-embed.min.js
2 years ago
tool-import-entries.js
2 years ago
tool-import-entries.min.js
2 years ago
tools.js
3 weeks ago
tools.min.js
3 weeks ago
upgrade.js
3 weeks ago
upgrade.min.js
3 weeks ago
evf-setup.js
573 lines
| 1 | /* global evf_setup_params */ |
| 2 | jQuery(function ($) { |
| 3 | /** |
| 4 | * Setup actions. |
| 5 | */ |
| 6 | var evf_setup_actions = { |
| 7 | $setup_form: $(".everest-forms-setup--form"), |
| 8 | $button_install: evf_data.i18n_activating, |
| 9 | init: function () { |
| 10 | this.title_focus(); |
| 11 | |
| 12 | // Template actions. |
| 13 | $(document).on( |
| 14 | "click", |
| 15 | ".everest-forms-template-install-addon", |
| 16 | this.install_addon |
| 17 | ); |
| 18 | $(document).on( |
| 19 | "click", |
| 20 | ".everest-forms-builder-setup .upgrade-modal", |
| 21 | this.message_upgrade |
| 22 | ); |
| 23 | $(document).on( |
| 24 | "click", |
| 25 | ".everest-forms-builder-setup .evf-template-preview", |
| 26 | this.template_preview |
| 27 | ); |
| 28 | |
| 29 | //Active addon. |
| 30 | $(document).on("click", ".activate-now", function (e) { |
| 31 | e.preventDefault(); |
| 32 | if ( |
| 33 | !$(this).closest("body.everest-forms_page_evf-builder") |
| 34 | .length |
| 35 | ) { |
| 36 | return; |
| 37 | } |
| 38 | evf_setup_actions.active_addon_from_buidler($(this)); |
| 39 | }); |
| 40 | |
| 41 | //Install addon. |
| 42 | $(document).on("click", ".install-from-builder", function (e) { |
| 43 | e.preventDefault(); |
| 44 | if ( |
| 45 | !$(this).closest("body.everest-forms_page_evf-builder") |
| 46 | .length |
| 47 | ) { |
| 48 | return; |
| 49 | } |
| 50 | evf_setup_actions.install_now_from_buidler($(this)); |
| 51 | }); |
| 52 | |
| 53 | // Select and apply a template. |
| 54 | this.$setup_form.on( |
| 55 | "click", |
| 56 | ".evf-template-select", |
| 57 | this.template_select |
| 58 | ); |
| 59 | |
| 60 | // Prevent <ENTER> key for setup actions. |
| 61 | $(document.body).on( |
| 62 | "keypress", |
| 63 | ".everest-forms-setup-form-name input", |
| 64 | this.input_keypress |
| 65 | ); |
| 66 | |
| 67 | // <ENTER> key for setup actions. |
| 68 | $(document.body).on( |
| 69 | "keypress", |
| 70 | "input#everest-forms-setup-name", |
| 71 | function (event) { |
| 72 | if (event.key === "Enter") { |
| 73 | event.preventDefault(); |
| 74 | $(this) |
| 75 | .parents("div.jconfirm-content-pane") |
| 76 | .next("div.jconfirm-buttons") |
| 77 | .find( |
| 78 | "button.everest-forms-btn.everest-forms-btn-primary" |
| 79 | ) |
| 80 | .trigger("click"); |
| 81 | } |
| 82 | } |
| 83 | ); |
| 84 | }, |
| 85 | title_focus: function () { |
| 86 | setTimeout(function () { |
| 87 | $("#everest-forms-setup-name").focus(); |
| 88 | }, 100); |
| 89 | }, |
| 90 | install_addon: function (event) { |
| 91 | var pluginsList = $(".plugins-list-table").find("#the-list tr"), |
| 92 | $target = $(event.target), |
| 93 | success = 0, |
| 94 | error = 0, |
| 95 | errorMessages = []; |
| 96 | |
| 97 | wp.updates.maybeRequestFilesystemCredentials(event); |
| 98 | |
| 99 | $(".everest-forms-template-install-addon") |
| 100 | .html( |
| 101 | '<div class="evf-loading evf-loading-active"></div>' + |
| 102 | evf_setup_actions.$button_install |
| 103 | ) |
| 104 | .prop("disabled", true); |
| 105 | |
| 106 | $(document).trigger("wp-plugin-bulk-install", pluginsList); |
| 107 | |
| 108 | // Find all the plugins which are required. |
| 109 | pluginsList.each(function (index, element) { |
| 110 | var $itemRow = $(element); |
| 111 | |
| 112 | // Only add inactive items to the update queue. |
| 113 | if ( |
| 114 | !$itemRow.hasClass("inactive") || |
| 115 | $itemRow.find("notice-error").length |
| 116 | ) { |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | // Add it to the queue. |
| 121 | wp.updates.queue.push({ |
| 122 | action: "everest_forms_install_extension", |
| 123 | data: { |
| 124 | page: pagenow, |
| 125 | name: $itemRow.data("name"), |
| 126 | slug: $itemRow.data("slug"), |
| 127 | is_feature : $itemRow.data('is_feature') |
| 128 | }, |
| 129 | }); |
| 130 | }); |
| 131 | |
| 132 | // Display bulk notification for install of plugin. |
| 133 | $(document).on( |
| 134 | "wp-plugin-bulk-install-success wp-plugin-bulk-install-error", |
| 135 | function (event, response) { |
| 136 | var $itemRow = $('[data-slug="' + response.slug + '"]'), |
| 137 | $bulkActionNotice, |
| 138 | itemName; |
| 139 | |
| 140 | if ( |
| 141 | "wp-" + response.install + "-bulk-install-success" === |
| 142 | event.type |
| 143 | ) { |
| 144 | success++; |
| 145 | } else { |
| 146 | itemName = response.pluginName |
| 147 | ? response.pluginName |
| 148 | : $itemRow.find(".plugin-name").text(); |
| 149 | error++; |
| 150 | errorMessages.push( |
| 151 | itemName + ": " + response.errorMessage |
| 152 | ); |
| 153 | } |
| 154 | |
| 155 | wp.updates.adminNotice = wp.template( |
| 156 | "wp-bulk-installs-admin-notice" |
| 157 | ); |
| 158 | |
| 159 | // Remove previous error messages, if any. |
| 160 | $( |
| 161 | ".everest-forms-recommend-addons .bulk-action-notice" |
| 162 | ).remove(); |
| 163 | |
| 164 | $(".everest-forms-recommend-addons .plugins-info").after( |
| 165 | wp.updates.adminNotice({ |
| 166 | id: "bulk-action-notice", |
| 167 | className: "bulk-action-notice notice-alt", |
| 168 | successes: success, |
| 169 | errors: error, |
| 170 | errorMessages: errorMessages, |
| 171 | type: response.install, |
| 172 | }) |
| 173 | ); |
| 174 | |
| 175 | $bulkActionNotice = $("#bulk-action-notice").on( |
| 176 | "click", |
| 177 | "button", |
| 178 | function () { |
| 179 | // $( this ) is the clicked button, no need to get it again. |
| 180 | $(this) |
| 181 | .toggleClass("bulk-action-errors-collapsed") |
| 182 | .attr( |
| 183 | "aria-expanded", |
| 184 | !$(this).hasClass( |
| 185 | "bulk-action-errors-collapsed" |
| 186 | ) |
| 187 | ); |
| 188 | // Show the errors list. |
| 189 | $bulkActionNotice |
| 190 | .find(".bulk-action-errors") |
| 191 | .toggleClass("hidden"); |
| 192 | } |
| 193 | ); |
| 194 | |
| 195 | if (!wp.updates.queue.length) { |
| 196 | if (error > 0) { |
| 197 | $target |
| 198 | .removeClass("updating-message") |
| 199 | .text($target.data("originaltext")); |
| 200 | } |
| 201 | } |
| 202 | |
| 203 | if (0 === wp.updates.queue.length) { |
| 204 | $(".everest-forms-template-install-addon").remove(); |
| 205 | $( |
| 206 | ".everest-forms-builder-setup .jconfirm-buttons button" |
| 207 | ).show(); |
| 208 | } |
| 209 | } |
| 210 | ); |
| 211 | |
| 212 | // Check the queue, now that the event handlers have been added. |
| 213 | wp.updates.queueChecker(); |
| 214 | }, |
| 215 | message_upgrade: function (e) { |
| 216 | var templateName = $(this).data("template-name-raw"); |
| 217 | |
| 218 | e.preventDefault(); |
| 219 | |
| 220 | $.alert({ |
| 221 | title: templateName + " " + evf_setup_params.upgrade_title, |
| 222 | theme: "jconfirm-modern jconfirm-everest-forms", |
| 223 | icon: "dashicons dashicons-lock", |
| 224 | backgroundDismiss: false, |
| 225 | scrollToPreviousElement: false, |
| 226 | content: evf_setup_params.upgrade_message, |
| 227 | type: "red", |
| 228 | boxWidth: "565px", |
| 229 | buttons: { |
| 230 | confirm: { |
| 231 | text: evf_setup_params.upgrade_button, |
| 232 | btnClass: "btn-confirm", |
| 233 | keys: ["enter"], |
| 234 | action: function () { |
| 235 | window.open(evf_setup_params.upgrade_url, "_blank"); |
| 236 | }, |
| 237 | }, |
| 238 | cancel: { |
| 239 | text: evf_data.i18n_ok, |
| 240 | }, |
| 241 | }, |
| 242 | }); |
| 243 | }, |
| 244 | template_preview: function () { |
| 245 | var $this = $(this), |
| 246 | previewLink = $this.data("preview-link"); |
| 247 | |
| 248 | $this |
| 249 | .closest(".everest-forms-setup--form") |
| 250 | .find(".evf-template-preview-iframe #frame") |
| 251 | .attr("src", previewLink); |
| 252 | }, |
| 253 | template_select: function (event) { |
| 254 | var $this = $(this), |
| 255 | template = $this.data("template"), |
| 256 | templateName = $this.data("template-name-raw"), |
| 257 | formName = "", |
| 258 | namePrompt = evf_setup_params.i18n_form_name, |
| 259 | nameField = |
| 260 | '<input autofocus="" type="text" id="everest-forms-setup-name" class="everest-forms-setup-name" placeholder="' + |
| 261 | evf_setup_params.i18n_form_placeholder + |
| 262 | '">', |
| 263 | nameError = |
| 264 | '<p class="error">' + |
| 265 | evf_setup_params.i18n_form_error_name + |
| 266 | "</p>"; |
| 267 | |
| 268 | event.preventDefault(); |
| 269 | |
| 270 | $target = $(event.target); |
| 271 | |
| 272 | if ( |
| 273 | $target.hasClass("disabled") || |
| 274 | $target.hasClass("updating-message") |
| 275 | ) { |
| 276 | return; |
| 277 | } |
| 278 | |
| 279 | $.confirm({ |
| 280 | title: evf_setup_params.i18n_form_title, |
| 281 | theme: "jconfirm-modern jconfirm-everest-forms-left", |
| 282 | backgroundDismiss: false, |
| 283 | scrollToPreviousElement: false, |
| 284 | content: function () { |
| 285 | // Fire AJAX. |
| 286 | var self = this, |
| 287 | button = evf_data.i18n_install_only; |
| 288 | |
| 289 | if ( |
| 290 | $target |
| 291 | .closest(".evf-template") |
| 292 | .find("span.everest-forms-badge").length |
| 293 | ) { |
| 294 | var data = { |
| 295 | action: "everest_forms_template_licence_check", |
| 296 | plan: $this |
| 297 | .attr("data-licence-plan") |
| 298 | .replace("-lifetime", "") |
| 299 | .replace("lifetime", ""), |
| 300 | slug: $this.attr("data-template"), |
| 301 | security: |
| 302 | evf_setup_params.template_licence_check_nonce, |
| 303 | }; |
| 304 | |
| 305 | return $.ajax({ |
| 306 | url: evf_email_params.ajax_url, |
| 307 | data: data, |
| 308 | type: "POST", |
| 309 | }).done(function (response) { |
| 310 | self.setContentAppend( |
| 311 | namePrompt + |
| 312 | nameField + |
| 313 | nameError + |
| 314 | response.data.html |
| 315 | ); |
| 316 | |
| 317 | if (response.data.activate) { |
| 318 | $( |
| 319 | ".everest-forms-builder-setup .jconfirm-buttons button" |
| 320 | ).show(); |
| 321 | } else { |
| 322 | if ( |
| 323 | response.data.html.includes("install-now") |
| 324 | ) { |
| 325 | button = evf_data.i18n_install_activate; |
| 326 | evf_setup_actions.$button_install = |
| 327 | evf_data.i18n_installing; |
| 328 | } |
| 329 | var installButton = |
| 330 | '<a href="#" class="everest-forms-btn everest-forms-btn-primary everest-forms-template-install-addon">' + |
| 331 | button + |
| 332 | "</a>"; |
| 333 | $( |
| 334 | ".everest-forms-builder-setup .jconfirm-buttons" |
| 335 | ).append(installButton); |
| 336 | } |
| 337 | }); |
| 338 | } else { |
| 339 | $( |
| 340 | ".everest-forms-builder-setup .jconfirm-buttons button" |
| 341 | ).show(); |
| 342 | return namePrompt + nameField + nameError; |
| 343 | } |
| 344 | }, |
| 345 | buttons: { |
| 346 | Continue: { |
| 347 | isHidden: true, // Hide the button. |
| 348 | btnClass: "everest-forms-btn everest-forms-btn-primary", |
| 349 | action: function () { |
| 350 | var $formName = $("#everest-forms-setup-name"), |
| 351 | overlay = $(".everest-forms-loader-overlay"); |
| 352 | console.log($formName.val()); |
| 353 | |
| 354 | // Check that form title is provided. |
| 355 | if ( |
| 356 | !$formName.val() || |
| 357 | "" === $formName.val().trim() |
| 358 | ) { |
| 359 | formName = templateName; |
| 360 | var error = this.$content.find(".error"); |
| 361 | $(".everest-forms-setup-name") |
| 362 | .addClass("everest-forms-required") |
| 363 | .focus(); |
| 364 | error.show(); |
| 365 | return false; |
| 366 | } else { |
| 367 | formName = $formName.val(); |
| 368 | } |
| 369 | |
| 370 | overlay.show(); |
| 371 | |
| 372 | var data = { |
| 373 | title: formName, |
| 374 | action: "everest_forms_create_form", |
| 375 | template: template, |
| 376 | security: evf_setup_params.create_form_nonce, |
| 377 | }; |
| 378 | |
| 379 | $.post( |
| 380 | evf_setup_params.ajax_url, |
| 381 | data, |
| 382 | function (response) { |
| 383 | if (response.success) { |
| 384 | window.location.href = |
| 385 | response.data.redirect; |
| 386 | } else { |
| 387 | overlay.hide(); |
| 388 | $(".everest-forms-setup-name") |
| 389 | .addClass("everest-forms-required") |
| 390 | .focus(); |
| 391 | window.console.log(response); |
| 392 | } |
| 393 | } |
| 394 | ).fail(function (xhr) { |
| 395 | window.console.log(xhr.responseText); |
| 396 | }); |
| 397 | }, |
| 398 | }, |
| 399 | }, |
| 400 | }); |
| 401 | }, |
| 402 | input_keypress: function (e) { |
| 403 | var button = e.keyCode || e.which; |
| 404 | |
| 405 | $(this).removeClass("everest-forms-required"); |
| 406 | |
| 407 | // Enter key. |
| 408 | if (13 === button && e.target.tagName.toLowerCase() === "input") { |
| 409 | e.preventDefault(); |
| 410 | return false; |
| 411 | } |
| 412 | }, |
| 413 | /** |
| 414 | *Active the addon from form builder. |
| 415 | * |
| 416 | * @param {any} node |
| 417 | */ |
| 418 | active_addon_from_buidler: function (node) { |
| 419 | var url = $(node).attr("href"); |
| 420 | var plugin = $(node).data("plugin"); |
| 421 | var activating = $.alert({ |
| 422 | title: evf_setup_params.activate_title, |
| 423 | theme: "jconfirm-modern jconfirm-everest-forms", |
| 424 | icon: "dashicons dashicons-success", |
| 425 | buttons: false, |
| 426 | content: evf_setup_params.activate_message, |
| 427 | type: "green", |
| 428 | }); |
| 429 | $.ajax({ |
| 430 | type: "POST", |
| 431 | url: evf_setup_params.ajax_url, |
| 432 | data: { |
| 433 | action: "everest_forms_active_addons", |
| 434 | plugin_file: plugin, |
| 435 | security: evf_setup_params.evf_active_nonce, |
| 436 | }, |
| 437 | success: function (res) { |
| 438 | activating.close(); |
| 439 | if (res.success === true) { |
| 440 | $.confirm({ |
| 441 | title: evf_setup_params.active_confirmation_title, |
| 442 | theme: "jconfirm-modern jconfirm-everest-forms", |
| 443 | icon: "success", |
| 444 | backgroundDismiss: false, |
| 445 | scrollToPreviousElement: false, |
| 446 | type: "green", |
| 447 | content: |
| 448 | evf_setup_params.active_confirmation_message, |
| 449 | buttons: { |
| 450 | confirm: { |
| 451 | text: evf_setup_params.save_changes_text, |
| 452 | btnClass: "btn-warning", |
| 453 | action: function () { |
| 454 | $(".everest-forms-save-button").trigger( |
| 455 | "click" |
| 456 | ); |
| 457 | location.reload(true); |
| 458 | }, |
| 459 | }, |
| 460 | cancel: { |
| 461 | text: evf_setup_params.reload_text, |
| 462 | btnClass: "btn-warning", |
| 463 | action: function () { |
| 464 | location.reload(true); |
| 465 | }, |
| 466 | }, |
| 467 | }, |
| 468 | }); |
| 469 | } else { |
| 470 | $.alert({ |
| 471 | title: evf_setup_params.activate_title, |
| 472 | theme: "jconfirm-modern jconfirm-everest-forms", |
| 473 | icon: "dashicons dashicons-warning", |
| 474 | buttons: false, |
| 475 | content: res.data.message, |
| 476 | type: "red", |
| 477 | }); |
| 478 | } |
| 479 | }, |
| 480 | }); |
| 481 | }, |
| 482 | |
| 483 | /** |
| 484 | *Install the addon from form builder. |
| 485 | * |
| 486 | * @param {any} event |
| 487 | */ |
| 488 | install_now_from_buidler: function (event) { |
| 489 | var alertInstance = $.alert({ |
| 490 | title: evf_setup_params.installing_title, |
| 491 | icon: "success", |
| 492 | buttons: false, |
| 493 | content: evf_setup_params.installing_message, |
| 494 | type: "green", |
| 495 | }); |
| 496 | wp.updates.maybeRequestFilesystemCredentials(event); |
| 497 | evf_setup_actions.$button_install = |
| 498 | evf_setup_params.i18n_installing; |
| 499 | $(event) |
| 500 | .html( |
| 501 | evf_setup_actions.$button_install + |
| 502 | '<div class="ur-spinner"></div>' |
| 503 | ) |
| 504 | .closest("button") |
| 505 | .prop("disabled", true); |
| 506 | |
| 507 | wp.updates.queue.push({ |
| 508 | action: "everest_forms_install_extension", |
| 509 | data: { |
| 510 | page: pagenow, |
| 511 | name: $(event).data("name"), |
| 512 | slug: $(event).data("slug"), |
| 513 | is_feature : $( event ).data( 'is_feature' ) |
| 514 | }, |
| 515 | }); |
| 516 | |
| 517 | $(document).on( |
| 518 | "wp-plugin-install-success wp-plugin-install-error", |
| 519 | function (event, response) { |
| 520 | alertInstance.close(); |
| 521 | if ( |
| 522 | typeof response.errorMessage !== "undefined" && |
| 523 | response.errorMessage.length > 0 |
| 524 | ) { |
| 525 | $.alert({ |
| 526 | title: response.errorMessage, |
| 527 | content: evf_setup_params.download_failed, |
| 528 | icon: "error", |
| 529 | }); |
| 530 | } else { |
| 531 | if (0 === wp.updates.queue.length) { |
| 532 | $.alert({ |
| 533 | title: evf_setup_params.install_confirmation_title, |
| 534 | theme: "jconfirm-modern jconfirm-everest-forms", |
| 535 | icon: "success", |
| 536 | backgroundDismiss: false, |
| 537 | scrollToPreviousElement: false, |
| 538 | content: |
| 539 | evf_setup_params.install_confirmation_message, |
| 540 | buttons: { |
| 541 | confirm: { |
| 542 | text: evf_setup_params.save_changes_text, |
| 543 | btnClass: "btn-warning", |
| 544 | action: function () { |
| 545 | $( |
| 546 | ".everest-forms-save-button" |
| 547 | ).trigger("click"); |
| 548 | location.reload(); |
| 549 | }, |
| 550 | }, |
| 551 | cancel: { |
| 552 | text: evf_setup_params.reload_text, |
| 553 | btnClass: "btn-warning", |
| 554 | action: function () { |
| 555 | location.reload(); |
| 556 | }, |
| 557 | }, |
| 558 | }, |
| 559 | type: "green", |
| 560 | }); |
| 561 | } |
| 562 | } |
| 563 | } |
| 564 | ); |
| 565 | |
| 566 | // Check the queue, now that the event handlers have been added. |
| 567 | wp.updates.queueChecker(); |
| 568 | }, |
| 569 | }; |
| 570 | |
| 571 | evf_setup_actions.init(); |
| 572 | }); |
| 573 |