tour-1-26-4.min.js
3 weeks ago
tour.js
2 years ago
updraft-admin-restore-1-26-4.min.js
3 weeks ago
updraft-admin-restore.js
1 month ago
updraftplus-deactivation-1-26-4.min.js
3 weeks ago
updraftplus-deactivation.js
2 months ago
tour.js
602 lines
| 1 | (function ($) { |
| 2 | |
| 3 | $(function() { |
| 4 | /* |
| 5 | Plugins page |
| 6 | splash screen on activation |
| 7 | */ |
| 8 | |
| 9 | $('.updraftplus-welcome .close').on('click', function(e) { |
| 10 | e.preventDefault(); |
| 11 | $(this).closest('.updraftplus-welcome').remove(); |
| 12 | }); |
| 13 | |
| 14 | /* |
| 15 | Updraftplus page tour |
| 16 | */ |
| 17 | |
| 18 | // if Shepherd is undefined, exit. |
| 19 | if (!window.Shepherd) return; |
| 20 | |
| 21 | var button_classes = 'button button-primary'; |
| 22 | var plugins_page_tour = window.updraft_plugins_page_tour = new Shepherd.Tour(); |
| 23 | var main_tour = window.updraft_main_tour = new Shepherd.Tour(); |
| 24 | |
| 25 | // Set up the defaults for each step |
| 26 | main_tour.options.defaults = plugins_page_tour.options.defaults = { |
| 27 | classes: 'shepherd-theme-arrows-plain-buttons shepherd-main-tour', |
| 28 | showCancelLink: true, |
| 29 | scrollTo: false, |
| 30 | tetherOptions: { |
| 31 | constraints: [ |
| 32 | { |
| 33 | to: 'scrollParent', |
| 34 | attachment: 'together', |
| 35 | pin: false |
| 36 | } |
| 37 | ] |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | /* |
| 42 | Plugins page |
| 43 | */ |
| 44 | |
| 45 | plugins_page_tour.addStep('intro', { |
| 46 | title: updraftplus_tour_i18n.plugins_page.title, |
| 47 | text: updraftplus_tour_i18n.plugins_page.text, |
| 48 | attachTo: '.js-updraftplus-settings top', |
| 49 | buttons: [ |
| 50 | { |
| 51 | classes: button_classes, |
| 52 | text: updraftplus_tour_i18n.plugins_page.button.text, |
| 53 | action: function() { |
| 54 | window.location = updraftplus_tour_i18n.plugins_page.button.url; |
| 55 | } |
| 56 | } |
| 57 | ], |
| 58 | tetherOptions: { |
| 59 | constraints: [ |
| 60 | { |
| 61 | to: 'scrollParent', |
| 62 | attachment: 'together', |
| 63 | pin: false |
| 64 | } |
| 65 | ], |
| 66 | offset: '20px 0' |
| 67 | }, |
| 68 | when: { |
| 69 | show: function() { |
| 70 | $('body').addClass('highlight-udp'); |
| 71 | var popup = $(this.el); |
| 72 | // var target = $(this.tether.target); |
| 73 | $('body, html').animate({ |
| 74 | scrollTop: popup.offset().top - 50 |
| 75 | }, 500, function() { |
| 76 | window.scrollTo(0, popup.offset().top - 50); |
| 77 | }); |
| 78 | }, |
| 79 | hide: function() { |
| 80 | $('body').removeClass('highlight-udp'); |
| 81 | } |
| 82 | } |
| 83 | }); |
| 84 | |
| 85 | /* |
| 86 | Main Tour steps |
| 87 | */ |
| 88 | |
| 89 | // 1. Your first backup |
| 90 | main_tour.addStep('backup_now', { |
| 91 | title: updraftplus_tour_i18n.backup_now.title, |
| 92 | text: updraftplus_tour_i18n.backup_now.text, |
| 93 | attachTo: '#updraft-backupnow-button bottom', |
| 94 | buttons: [ |
| 95 | { |
| 96 | classes: 'udp-tour-end', |
| 97 | text: updraftplus_tour_i18n.end_tour, |
| 98 | action: main_tour.cancel |
| 99 | }, |
| 100 | { |
| 101 | classes: button_classes, |
| 102 | text: updraftplus_tour_i18n.next, |
| 103 | action: function() { |
| 104 | $('#updraft-navtab-settings').trigger('click'); |
| 105 | } |
| 106 | } |
| 107 | ] |
| 108 | }); |
| 109 | |
| 110 | // Manual backup options |
| 111 | main_tour.addStep('backup_options', { |
| 112 | title: updraftplus_tour_i18n.backup_options.title, |
| 113 | text: updraftplus_tour_i18n.backup_options.text, |
| 114 | classes: 'shepherd-theme-arrows-plain-buttons shepherd-main-tour super-index', |
| 115 | attachTo: '#backupnow_includedb left', |
| 116 | tetherOptions: { |
| 117 | offset: '-15px 25px' |
| 118 | }, |
| 119 | buttons: [ |
| 120 | { |
| 121 | classes: 'udp-tour-back', |
| 122 | text: updraftplus_tour_i18n.back, |
| 123 | action: function() { |
| 124 | $('#updraft-backupnow-modal').dialog('close'); |
| 125 | } |
| 126 | }, |
| 127 | { |
| 128 | classes: button_classes, |
| 129 | text: updraftplus_tour_i18n.next, |
| 130 | action: main_tour.next |
| 131 | } |
| 132 | ] |
| 133 | }); |
| 134 | |
| 135 | // Backup Now button |
| 136 | main_tour.addStep('backup_now_btn', { |
| 137 | title: updraftplus_tour_i18n.backup_now_btn.title, |
| 138 | text: updraftplus_tour_i18n.backup_now_btn.text, |
| 139 | classes: 'shepherd-theme-arrows-plain-buttons shepherd-main-tour super-index', |
| 140 | attachTo: '.js-tour-backup-now-button top', |
| 141 | buttons: [ |
| 142 | { |
| 143 | classes: 'udp-tour-back', |
| 144 | text: updraftplus_tour_i18n.back, |
| 145 | action: function() { |
| 146 | main_tour.back(); |
| 147 | } |
| 148 | }, |
| 149 | { |
| 150 | classes: button_classes, |
| 151 | text: updraftplus_tour_i18n.backup_now_btn.btn_text, |
| 152 | action: function() { |
| 153 | $('#updraft-backupnow-modal').dialog('close'); |
| 154 | $('#updraft-navtab-settings').trigger('click'); |
| 155 | } |
| 156 | } |
| 157 | ] |
| 158 | }); |
| 159 | |
| 160 | // Congratulations - Shows when a user clicks "backup now" in the modal |
| 161 | main_tour.addStep('backup_now_btn_success', { |
| 162 | title: updraftplus_tour_i18n.backup_now_btn_success.title, |
| 163 | text: updraftplus_tour_i18n.backup_now_btn_success.text, |
| 164 | attachTo: '#updraft_activejobs_table top', |
| 165 | buttons: [ |
| 166 | { |
| 167 | classes: 'udp-tour-back', |
| 168 | text: updraftplus_tour_i18n.back, |
| 169 | action: function() { |
| 170 | $('#updraft-backupnow-button').trigger('click'); |
| 171 | main_tour.show('backup_now_btn'); |
| 172 | } |
| 173 | }, |
| 174 | { |
| 175 | classes: button_classes, |
| 176 | text: updraftplus_tour_i18n.backup_now_btn_success.btn_text, |
| 177 | action: function() { |
| 178 | $('#updraft-navtab-settings').trigger('click'); |
| 179 | } |
| 180 | } |
| 181 | ], |
| 182 | when: { |
| 183 | show: function() { |
| 184 | setTimeout(function() { |
| 185 | $(window).trigger('scroll'); |
| 186 | }) |
| 187 | |
| 188 | } |
| 189 | } |
| 190 | }) |
| 191 | |
| 192 | // Settings - timing |
| 193 | main_tour.addStep('settings_timing', { |
| 194 | title: updraftplus_tour_i18n.settings_timing.title, |
| 195 | text: updraftplus_tour_i18n.settings_timing.text, |
| 196 | attachTo: '.retain-files right', |
| 197 | buttons: [ |
| 198 | { |
| 199 | classes: 'udp-tour-back', |
| 200 | text: updraftplus_tour_i18n.back, |
| 201 | action: function() { |
| 202 | $('#updraft-navtab-backups').trigger('click'); |
| 203 | } |
| 204 | }, |
| 205 | { |
| 206 | classes: button_classes, |
| 207 | text: updraftplus_tour_i18n.next, |
| 208 | action: main_tour.next |
| 209 | } |
| 210 | ], |
| 211 | tetherOptions: $.extend({}, main_tour.options.defaults.tetherOptions, { |
| 212 | offset: '-33px -15px' |
| 213 | }), |
| 214 | when: { |
| 215 | show: function() { |
| 216 | scroll_to_popup(); |
| 217 | } |
| 218 | } |
| 219 | }); |
| 220 | |
| 221 | // Settings - Remote storage + vault |
| 222 | main_tour.addStep('settings_remote_storage', { |
| 223 | title: updraftplus_tour_i18n.settings_remote_storage.title, |
| 224 | text: updraftplus_tour_i18n.settings_remote_storage.text, |
| 225 | attachTo: { |
| 226 | element: 'label[for=updraft_servicecheckbox_updraftvault]', |
| 227 | on: 'top' |
| 228 | }, |
| 229 | buttons: [ |
| 230 | { |
| 231 | classes: 'udp-tour-back', |
| 232 | text: updraftplus_tour_i18n.back, |
| 233 | action: function() { |
| 234 | main_tour.back(); |
| 235 | } |
| 236 | }, |
| 237 | { |
| 238 | classes: button_classes, |
| 239 | text: updraftplus_tour_i18n.next, |
| 240 | action: function() { |
| 241 | if ($('#updraft_servicecheckbox_updraftvault').is(':checked')) { |
| 242 | main_tour.show('vault_selected') |
| 243 | } else { |
| 244 | main_tour.next(); |
| 245 | } |
| 246 | } |
| 247 | } |
| 248 | ], |
| 249 | when: { |
| 250 | show: function(p) { |
| 251 | $('label[for=updraft_servicecheckbox_updraftvault]').addClass('emphasize'); |
| 252 | scroll_to_popup(); |
| 253 | }, |
| 254 | hide: function(p) { |
| 255 | $('label[for=updraft_servicecheckbox_updraftvault]').removeClass('emphasize'); |
| 256 | } |
| 257 | } |
| 258 | }); |
| 259 | |
| 260 | // Settings - more + updraftcentral |
| 261 | main_tour.addStep('settings_more', { |
| 262 | title: updraftplus_tour_i18n.settings_more.title, |
| 263 | text: updraftplus_tour_i18n.settings_more.text, |
| 264 | attachTo: '.js-tour-settings-more top', |
| 265 | scrollTo: false, |
| 266 | tetherOptions: {}, |
| 267 | buttons: [ |
| 268 | { |
| 269 | classes: 'udp-tour-back', |
| 270 | text: updraftplus_tour_i18n.back, |
| 271 | action: function() { |
| 272 | main_tour.back(); |
| 273 | } |
| 274 | }, |
| 275 | { |
| 276 | classes: button_classes, |
| 277 | text: updraftplus_tour_i18n.next, |
| 278 | action: main_tour.next |
| 279 | } |
| 280 | ], |
| 281 | when: { |
| 282 | show: function() { |
| 283 | scroll_to_popup(); |
| 284 | } |
| 285 | } |
| 286 | }); |
| 287 | |
| 288 | // Save settings |
| 289 | main_tour.addStep('settings_save', { |
| 290 | title: updraftplus_tour_i18n.settings_save.title, |
| 291 | text: updraftplus_tour_i18n.settings_save.text, |
| 292 | attachTo: '#updraftplus-settings-save top', |
| 293 | scrollTo: false, |
| 294 | buttons: [ |
| 295 | { |
| 296 | classes: 'udp-tour-back', |
| 297 | text: updraftplus_tour_i18n.back, |
| 298 | action: function() { |
| 299 | main_tour.back(); |
| 300 | } |
| 301 | }, |
| 302 | { |
| 303 | classes: button_classes, |
| 304 | text: updraftplus_tour_i18n.next, |
| 305 | action: function() { |
| 306 | if ($('#updraftcentral_cloud_connect_container').length) { |
| 307 | main_tour.show('updraft_central'); |
| 308 | } else { |
| 309 | $('#updraft-navtab-addons').trigger('click'); |
| 310 | } |
| 311 | } |
| 312 | } |
| 313 | ], |
| 314 | when: { |
| 315 | show: function() { |
| 316 | scroll_to_popup(); |
| 317 | } |
| 318 | } |
| 319 | }); |
| 320 | |
| 321 | // UDCentral |
| 322 | main_tour.addStep('updraft_central', { |
| 323 | title: updraftplus_tour_i18n.updraft_central.title, |
| 324 | text: updraftplus_tour_i18n.updraft_central.text, |
| 325 | attachTo: '#updraftcentral_cloud_connect_container top', |
| 326 | scrollTo: false, |
| 327 | buttons: [ |
| 328 | { |
| 329 | classes: 'udp-tour-back', |
| 330 | text: updraftplus_tour_i18n.back, |
| 331 | action: function() { |
| 332 | main_tour.back(); |
| 333 | } |
| 334 | }, |
| 335 | { |
| 336 | classes: button_classes, |
| 337 | text: updraftplus_tour_i18n.next, |
| 338 | action: function() { |
| 339 | $('#updraft-navtab-addons').trigger('click'); |
| 340 | } |
| 341 | } |
| 342 | ], |
| 343 | when: { |
| 344 | show: function() { |
| 345 | scroll_to_popup(); |
| 346 | } |
| 347 | } |
| 348 | }); |
| 349 | |
| 350 | // Premium + addons |
| 351 | main_tour.addStep('premium', { |
| 352 | title: updraftplus_tour_i18n.premium.title, |
| 353 | text: updraftplus_tour_i18n.premium.text, |
| 354 | attachTo: updraftplus_tour_i18n.premium.attach_to, |
| 355 | scrollTo: false, |
| 356 | buttons: [ |
| 357 | { |
| 358 | classes: 'udp-tour-back', |
| 359 | text: updraftplus_tour_i18n.back, |
| 360 | action: function() { |
| 361 | main_tour.going_somewhere = true; |
| 362 | $('#updraft-navtab-settings').trigger('click'); |
| 363 | if ($('#updraftcentral_cloud_connect_container').length) { |
| 364 | main_tour.show('updraft_central'); |
| 365 | } else { |
| 366 | main_tour.show('settings_save'); |
| 367 | } |
| 368 | scroll_to_popup(); |
| 369 | |
| 370 | } |
| 371 | }, |
| 372 | { |
| 373 | classes: button_classes, |
| 374 | text: updraftplus_tour_i18n.premium.button, |
| 375 | action: main_tour.cancel |
| 376 | } |
| 377 | ], |
| 378 | when: { |
| 379 | show: function() { |
| 380 | window.scroll(0, 0) |
| 381 | } |
| 382 | } |
| 383 | }); |
| 384 | |
| 385 | // EXTRA STEPS |
| 386 | |
| 387 | // Premium + addons |
| 388 | main_tour.addStep('vault_selected', { |
| 389 | title: updraftplus_tour_i18n.vault_selected.title, |
| 390 | text: updraftplus_tour_i18n.vault_selected.text, |
| 391 | attachTo: '#updraftvault_settings_cell top', |
| 392 | scrollTo: false, |
| 393 | buttons: [ |
| 394 | { |
| 395 | classes: 'udp-tour-back', |
| 396 | text: updraftplus_tour_i18n.back, |
| 397 | action: function() { |
| 398 | main_tour.show('settings_remote_storage'); |
| 399 | } |
| 400 | }, |
| 401 | { |
| 402 | classes: button_classes, |
| 403 | text: updraftplus_tour_i18n.next, |
| 404 | action: function() { |
| 405 | main_tour.show('settings_more'); |
| 406 | } |
| 407 | } |
| 408 | ], |
| 409 | when: { |
| 410 | show: function(p) { |
| 411 | scroll_to_popup(); |
| 412 | } |
| 413 | } |
| 414 | }); |
| 415 | |
| 416 | // Saved settings |
| 417 | main_tour.addStep('settings_saved', { |
| 418 | title: updraftplus_tour_i18n.settings_saved.title, |
| 419 | text: updraftplus_tour_i18n.settings_saved.text, |
| 420 | attachTo: '#updraftplus-settings-save top', |
| 421 | scrollTo: false, |
| 422 | buttons: [ |
| 423 | { |
| 424 | classes: 'udp-tour-back', |
| 425 | text: updraftplus_tour_i18n.back, |
| 426 | action: function() { |
| 427 | main_tour.show('settings_more'); |
| 428 | } |
| 429 | }, |
| 430 | { |
| 431 | classes: button_classes, |
| 432 | text: updraftplus_tour_i18n.next, |
| 433 | action: function() { |
| 434 | if ($('#updraftcentral_cloud_connect_container').length) { |
| 435 | main_tour.show('updraft_central'); |
| 436 | } else { |
| 437 | $('#updraft-navtab-addons').trigger('click'); |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | ], |
| 442 | when: { |
| 443 | show: function() { |
| 444 | scroll_to_popup(); |
| 445 | } |
| 446 | } |
| 447 | }); |
| 448 | |
| 449 | main_tour.steps.forEach(function(step) { |
| 450 | step.once('show', function() { |
| 451 | // Adds a Close label near the (x) |
| 452 | var close_btn = $(this.el).find('header .shepherd-cancel-link'); |
| 453 | close_btn.attr('data-btntext', updraftplus_tour_i18n.close); |
| 454 | |
| 455 | // opens the settings tab |
| 456 | $(this.el).find('.js--go-to-settings').on('click', function(e) { |
| 457 | e.preventDefault(); |
| 458 | $('#updraft-navtab-settings').trigger('click'); |
| 459 | }); |
| 460 | }) |
| 461 | }); |
| 462 | |
| 463 | // on Cancel |
| 464 | main_tour.on('cancel', cancel_tour); |
| 465 | plugins_page_tour.on('cancel', cancel_tour); |
| 466 | |
| 467 | /** |
| 468 | * Cancel tour |
| 469 | */ |
| 470 | function cancel_tour() { |
| 471 | // The tour is either finished or [x] was clicked |
| 472 | main_tour.canceled = true; |
| 473 | var data = { |
| 474 | current_step: this.getCurrentStep().id |
| 475 | }; |
| 476 | |
| 477 | if ('function' === typeof updraft_send_command) { |
| 478 | updraft_send_command( |
| 479 | 'set_tour_status', |
| 480 | data, |
| 481 | function(response) { |
| 482 | console.log('Successfully deactivated tour'); |
| 483 | }, |
| 484 | { alert_on_error: false } |
| 485 | ); |
| 486 | } else { |
| 487 | jQuery.ajax({ |
| 488 | url: ajaxurl, |
| 489 | type: 'POST', |
| 490 | data: { |
| 491 | action: 'updraft_ajax', |
| 492 | subaction: 'set_tour_status', |
| 493 | nonce: updraftplus_tour_i18n.nonce, |
| 494 | current_step: this.getCurrentStep().id |
| 495 | } |
| 496 | }); |
| 497 | } |
| 498 | }; |
| 499 | |
| 500 | /** |
| 501 | * Scroll to Popup |
| 502 | * |
| 503 | * @param {Object} step |
| 504 | */ |
| 505 | var scroll_to_popup = function(step) { |
| 506 | main_tour.going_somewhere = false; |
| 507 | if (!step) { |
| 508 | step = main_tour.getCurrentStep(); |
| 509 | } |
| 510 | var popup = $(step.el); |
| 511 | var target = $(step.tether.target); |
| 512 | $('body, html').animate({ |
| 513 | scrollTop: popup.offset().top - 50 |
| 514 | }, 500, function() { |
| 515 | window.scrollTo(0, popup.offset().top - 50); |
| 516 | }); |
| 517 | |
| 518 | } |
| 519 | |
| 520 | // If $('#updraft-backupnow-button'), start tour |
| 521 | if ($('#updraft-backupnow-button').length) { |
| 522 | /* |
| 523 | Setup other events |
| 524 | */ |
| 525 | |
| 526 | // Backup now |
| 527 | $('#updraft-backupnow-button').on('click', function(e) { |
| 528 | if (!main_tour.canceled) { |
| 529 | main_tour.show('backup_options'); |
| 530 | } |
| 531 | }); |
| 532 | |
| 533 | // Click on status tab |
| 534 | $('#updraft-navtab-backups').on('click', function(e) { |
| 535 | if (!main_tour.canceled) { |
| 536 | main_tour.show('backup_now'); |
| 537 | } |
| 538 | }); |
| 539 | |
| 540 | $(document).on('click', 'label[for=updraft_servicecheckbox_updraftvault]', function(e) { |
| 541 | if (!main_tour.canceled && !$('#updraft_servicecheckbox_updraftvault').is(':checked')) { |
| 542 | setTimeout(function() { |
| 543 | main_tour.show('vault_selected'); |
| 544 | }, 200); |
| 545 | } |
| 546 | }); |
| 547 | |
| 548 | // close backup backupnow modal |
| 549 | $('#updraft-backupnow-modal').on("dialogclose", function(event, ui) { |
| 550 | if (!main_tour.canceled) { |
| 551 | main_tour.show('backup_now'); |
| 552 | } |
| 553 | }); |
| 554 | |
| 555 | // Backup now - manual backup is starting |
| 556 | $('.js-tour-backup-now-button').on('click', function(e) { |
| 557 | if (!main_tour.canceled) { |
| 558 | main_tour.show('backup_now_btn_success'); |
| 559 | } |
| 560 | }) |
| 561 | |
| 562 | // settings tab |
| 563 | $('#updraft-navtab-settings').on('click', function(e) { |
| 564 | if (!main_tour.canceled && !main_tour.going_somewhere) { |
| 565 | main_tour.show('settings_timing'); |
| 566 | } |
| 567 | }); |
| 568 | |
| 569 | // addons tab |
| 570 | $('#updraft-navtab-addons').on('click', function(e) { |
| 571 | if (!main_tour.canceled) { |
| 572 | main_tour.show('premium'); |
| 573 | } |
| 574 | }); |
| 575 | |
| 576 | // Tabs without guide |
| 577 | $('#updraft-navtab-migrate, #updraft-navtab-expert').on('click', function(e) { |
| 578 | if (!main_tour.canceled) { |
| 579 | main_tour.hide(); |
| 580 | } |
| 581 | }); |
| 582 | // start tour |
| 583 | main_tour.start(); |
| 584 | |
| 585 | // go back to first tab |
| 586 | if (updraftplus_tour_i18n.show_tab_on_load) { |
| 587 | $(updraftplus_tour_i18n.show_tab_on_load).trigger('click'); |
| 588 | } else { |
| 589 | $('#updraft-navtab-backups').trigger('click'); |
| 590 | } |
| 591 | |
| 592 | } |
| 593 | |
| 594 | // start plugins page tour |
| 595 | if ($('.js-updraftplus-settings').length) { |
| 596 | plugins_page_tour.start(); |
| 597 | } |
| 598 | |
| 599 | }); |
| 600 | |
| 601 | })(jQuery); |
| 602 |