blocks
4 years ago
admin.js
2 months ago
asset_manager_core_js.js
1 month ago
iframeResizer.contentWindow.min.js
2 years ago
iframeResizer.min.js
2 years ago
marketplace_setup_wizard.js
2 months ago
optout.js
1 year ago
settings.js
1 year ago
marketplace_setup_wizard.js
69 lines
| 1 | /** |
| 2 | * Matomo - free/libre analytics platform |
| 3 | * |
| 4 | * @link https://matomo.org |
| 5 | * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later |
| 6 | * @package matomo |
| 7 | */ |
| 8 | |
| 9 | window.jQuery(document).ready(function ($) { |
| 10 | function pollForPluginActivation(setActiveClass) { |
| 11 | if (setActiveClass) { |
| 12 | $('.wizard-waiting-for').addClass('active').find('.waiting-for-install').show(); |
| 13 | } else { |
| 14 | $('.wizard-waiting-for').show(); |
| 15 | } |
| 16 | |
| 17 | var interval = setInterval(function () { |
| 18 | $.post(mtmMarketplaceWizardAjax.ajax_url, { |
| 19 | _ajax_nonce: mtmMarketplaceWizardAjax.is_active_nonce, |
| 20 | action: 'matomo_is_marketplace_active', |
| 21 | }, function (data) { |
| 22 | if (data.active) { |
| 23 | if (!setActiveClass) { |
| 24 | $('.wizard-waiting-for').hide(); |
| 25 | } else { |
| 26 | $('.wizard-waiting-for .waiting-for-activation').hide(); |
| 27 | } |
| 28 | |
| 29 | $('.wizard-reloading').show(); |
| 30 | |
| 31 | // reload after the dom has had a chance to update |
| 32 | setTimeout(function () { |
| 33 | window.location.reload(); |
| 34 | }); |
| 35 | |
| 36 | clearInterval(interval); |
| 37 | } else if (data.installed && setActiveClass) { |
| 38 | $('.wizard-waiting-for .waiting-for-install').hide(); |
| 39 | $('.wizard-waiting-for .waiting-for-activation').show(); |
| 40 | } |
| 41 | }); |
| 42 | }, 2000); |
| 43 | } |
| 44 | |
| 45 | function activateMarketplace(e) { |
| 46 | e.preventDefault(); |
| 47 | e.stopPropagation(); |
| 48 | |
| 49 | $('.wizard-waiting-for').show(); |
| 50 | |
| 51 | $.post(mtmMarketplaceWizardAjax.ajax_url, { |
| 52 | _ajax_nonce: mtmMarketplaceWizardAjax.activate_nonce, |
| 53 | action: 'matomo_activate_marketplace', |
| 54 | }, pollForPluginActivation.bind(null, false)); |
| 55 | } |
| 56 | |
| 57 | if (typeof mtmMarketplaceWizardAjax !== 'undefined' && mtmMarketplaceWizardAjax.ajax_url) { |
| 58 | var pollFn = pollForPluginActivation; |
| 59 | var activateFn = activateMarketplace; |
| 60 | if (mtmMarketplaceWizardAjax.is_welcome_page) { |
| 61 | pollFn = pollForPluginActivation.bind(null, true); |
| 62 | activateFn = activateMarketplace.bind(null, true); |
| 63 | } |
| 64 | |
| 65 | $('.matomo-marketplace-wizard-body .open-plugin-upload').on('click', pollFn); |
| 66 | $('.matomo-marketplace-wizard-body .activate-plugin').on('click', activateFn); |
| 67 | } |
| 68 | }); |
| 69 |