PluginProbe
Tiered Pricing Table for WooCommerce / 2.3.2
Tiered Pricing Table for WooCommerce v2.3.2
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / freemius / templates / forms / license-activation.php

license-activation.php in Tiered Pricing Table for WooCommerce 2.3.2, at freemius/templates/forms/license-activation.php

701 lines 26.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2015, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.1.9
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var Freemius $fs
15 */
16 $fs = freemius( $VARS['id'] );
17 $slug = $fs->get_slug();
18 $unique_affix = $fs->get_unique_affix();
19
20 $cant_find_license_key_text = fs_text_inline( "Can't find your license key?", 'cant-find-license-key', $slug );
21 $message_above_input_field = fs_text_inline( 'Please enter the license key that you received in the email right after the purchase:', 'activate-license-message', $slug );
22 $message_below_input_field = '';
23
24 $header_title = $fs->is_free_plan() ?
25 fs_text_inline( 'Activate License', 'activate-license', $slug ) :
26 fs_text_inline( 'Update License', 'update-license', $slug );
27
28 if ( $fs->is_registered() ) {
29 $activate_button_text = $header_title;
30 } else {
31 $freemius_site_url = $fs->has_paid_plan() ?
32 'https://freemius.com/wordpress/' :
33 // Insights platform information.
34 'https://freemius.com/wordpress/usage-tracking/';
35
36 $freemius_link = '<a href="' . $freemius_site_url . '" target="_blank" tabindex="0">freemius.com</a>';
37
38 $message_below_input_field = sprintf(
39 fs_text_inline( 'The %1$s will be periodically sending data to %2$s to check for security and feature updates, and verify the validity of your license.', 'license-sync-disclaimer', $slug ),
40 $fs->get_module_label( true ),
41 $freemius_link
42 );
43
44 $activate_button_text = fs_text_inline( 'Agree & Activate License', 'agree-activate-license', $slug );
45 }
46
47 $license_key_text = fs_text_inline( 'License key', 'license-key' , $slug );
48
49 $is_network_activation = (
50 $fs->is_network_active() &&
51 fs_is_network_admin() &&
52 ! $fs->is_delegated_connection()
53 );
54 $network_activation_html = '';
55
56 $sites_details = array();
57 if ( $is_network_activation ) {
58 $all_sites = Freemius::get_sites();
59
60 foreach ( $all_sites as $site ) {
61 $site_details = $fs->get_site_info( $site );
62
63 $blog_id = Freemius::get_site_blog_id( $site );
64 $install = $fs->get_install_by_blog_id($blog_id);
65
66 if ( is_object( $install ) && FS_Plugin_License::is_valid_id( $install->license_id ) ) {
67 $site_details['license_id'] = $install->license_id;
68 }
69
70 $sites_details[] = $site_details;
71 }
72
73 if ( $is_network_activation ) {
74 $vars = array(
75 'id' => $fs->get_id(),
76 'sites' => $sites_details,
77 'require_license_key' => true
78 );
79
80 $network_activation_html = fs_get_template( 'partials/network-activation.php', $vars );
81 }
82 }
83
84 $premium_licenses = $fs->get_available_premium_licenses();
85 $available_licenses = array();
86 foreach ( $premium_licenses as $premium_license ) {
87 $activations_left = $premium_license->left();
88 if ( ! ( $activations_left > 0 ) ) {
89 continue;
90 }
91
92 $available_licenses[ $activations_left . '_' . $premium_license->id ] = $premium_license;
93 }
94
95 $total_available_licenses = count( $available_licenses );
96 if ( $total_available_licenses > 0 ) {
97 $license_input_html = <<< HTML
98 <div class="fs-license-options-container">
99 <table>
100 <tbody>
101 <tr class="fs-available-license-key-container">
102 <td><input type="radio" name="license_type" value="available"></td>
103 <td>
104 HTML;
105
106 if ( $total_available_licenses > 1 ) {
107 // Sort the licenses by number of activations left in descending order.
108 krsort( $available_licenses );
109
110 $license_input_html .= '<select class="fs-licenses">';
111
112 /**
113 * @var FS_Plugin_License $license
114 */
115 foreach ( $available_licenses as $license ) {
116 $label = sprintf(
117 "%s-Site %s License - %s",
118 ( 1 == $license->quota ?
119 'Single' :
120 ( $license->is_unlimited() ? 'Unlimited' : $license->quota )
121 ),
122 $fs->_get_plan_by_id( $license->plan_id )->title,
123 ( htmlspecialchars( substr( $license->secret_key, 0, 6 ) ) .
124 str_pad( '', 23 * 6, '&bull;' ) .
125 htmlspecialchars( substr( $license->secret_key, - 3 ) ) )
126 );
127
128 $license_input_html .= "<option data-id='{$license->id}' value='{$license->secret_key}' data-left='{$license->left()}'>{$label}</option>";
129 }
130
131 $license_input_html .= '</select>';
132 } else {
133 $available_licenses = array_values( $available_licenses );
134
135 /**
136 * @var FS_Plugin_License $available_license
137 */
138 $available_license = $available_licenses[0];
139 $value = sprintf(
140 "%s-Site %s License - %s",
141 ( 1 == $available_license->quota ?
142 'Single' :
143 $available_license->quota
144 ),
145 $fs->_get_plan_by_id( $available_license->plan_id )->title,
146 ( htmlspecialchars( substr( $available_license->secret_key, 0, 6 ) ) .
147 str_pad( '', 23 * 6, '&bull;' ) .
148 htmlspecialchars( substr( $available_license->secret_key, - 3 ) ) )
149 );
150
151 $license_input_html .= <<< HTML
152 <input
153 class="fs-available-license-key"
154 type="text"
155 value="{$value}"
156 data-id="{$available_license->id}"
157 data-license-key="{$available_license->secret_key}"
158 data-left="{$available_license->left()}"
159 readonly />
160 HTML;
161 }
162
163 $license_input_html .= <<< HTML
164 </td>
165 </tr>
166 <tr>
167 <td><input type="radio" name="license_type" value="other"></td>
168 <td class="fs-other-license-key-container">
169 <label for="other_license_key_{$unique_affix}">Other: </label>
170 <div>
171 <input id="other_license_key_{$unique_affix}" class="fs-license-key" type="text" placeholder="Enter license key" tabindex="1">
172 </div>
173 </td>
174 </tr>
175 </tbody>
176 </table>
177 </div>
178 HTML;
179 } else {
180 $license_input_html = "<input class='fs-license-key' type='text' placeholder='{$license_key_text}' tabindex='1' />";
181 }
182
183 /**
184 * IMPORTANT:
185 * DO NOT ADD MAXLENGTH OR LIMIT THE LICENSE KEY LENGTH SINCE
186 * WE DO WANT TO ALLOW INPUT OF LONGER KEYS (E.G. WooCommerce Keys)
187 * FOR MIGRATED MODULES.
188 */
189 $modal_content_html = <<< HTML
190 <div class="notice notice-error inline license-activation-message"><p></p></div>
191 <p>{$message_above_input_field}</p>
192 {$license_input_html}
193 <a class="show-license-resend-modal show-license-resend-modal-{$fs->get_unique_affix()}" href="!#" tabindex="2">{$cant_find_license_key_text}</a>
194 {$network_activation_html}
195 <p>{$message_below_input_field}</p>
196 HTML;
197
198 fs_enqueue_local_style( 'fs_dialog_boxes', '/admin/dialog-boxes.css' );
199 ?>
200 <script type="text/javascript">
201 (function( $ ) {
202 $( document ).ready(function() {
203 var modalContentHtml = <?php echo json_encode($modal_content_html); ?>,
204 modalHtml =
205 '<div class="fs-modal fs-modal-license-activation fs-modal-license-activation-<?php echo $unique_affix ?>">'
206 + ' <div class="fs-modal-dialog">'
207 + ' <div class="fs-modal-header">'
208 + ' <h4><?php echo esc_js($header_title) ?></h4>'
209 + ' <a href="!#" class="fs-close"><i class="dashicons dashicons-no" title="<?php echo esc_js( fs_text_x_inline( 'Dismiss', 'as close a window', 'dismiss', $slug ) ) ?>"></i></a>'
210 + ' </div>'
211 + ' <div class="fs-modal-body">'
212 + ' <div class="fs-modal-panel active">' + modalContentHtml + '</div>'
213 + ' </div>'
214 + ' <div class="fs-modal-footer">'
215 + ' <button class="button button-secondary button-close" tabindex="4"><?php fs_esc_js_echo_inline( 'Cancel', 'cancel', $slug ) ?></button>'
216 + ' <button class="button button-primary button-activate-license" tabindex="3"><?php echo esc_js( $activate_button_text ) ?></button>'
217 + ' </div>'
218 + ' </div>'
219 + '</div>',
220 $modal = $(modalHtml),
221 $activateLicenseLink = $('span.activate-license.<?php echo $unique_affix ?> a, .activate-license-trigger.<?php echo $unique_affix ?>'),
222 $activateLicenseButton = $modal.find('.button-activate-license'),
223 $licenseKeyInput = $modal.find( 'input.fs-license-key' ),
224 $licenseActivationMessage = $modal.find( '.license-activation-message' ),
225 isNetworkActivation = <?php echo $is_network_activation ? 'true' : 'false' ?>;
226
227 $modal.appendTo($('body'));
228
229 var
230 $licensesDropdown = $modal.find( '.fs-licenses' ),
231 $licenseTypes = $modal.find( 'input[type="radio"][name="license_type"]' ),
232 $applyOnAllSites = $modal.find( '.fs-apply-on-all-sites-checkbox' ),
233 $sitesListContainer = $modal.find( '.fs-sites-list-container' ),
234 $availableLicenseKey = $modal.find( '.fs-available-license-key' ),
235 $otherLicenseKey = $modal.find( '#other_license_key_<?php echo $unique_affix ?>' ),
236 $multisiteOptionsContainer = $modal.find( '.fs-multisite-options-container' ),
237 $activationsLeft = null,
238 hasLicensesDropdown = ( $licensesDropdown.length > 0 ),
239 hasLicenseTypes = ( $licenseTypes.length > 0 ),
240 maxSitesListHeight = null,
241 totalSites = <?php echo count( $sites_details ) ?>,
242 singleBlogID = null;
243
244 function registerEventHandlers() {
245 var
246 $otherLicenseKeyContainer = $modal.find( '.fs-other-license-key-container' );
247
248 if ( isNetworkActivation ) {
249 $applyOnAllSites.click(function() {
250 var applyOnAllSites = $( this ).is( ':checked' );
251
252 $multisiteOptionsContainer.toggleClass( 'fs-apply-on-all-sites', applyOnAllSites );
253
254 showSites( ! applyOnAllSites );
255
256 if ( hasValidLicenseKey() && ( applyOnAllSites || hasSelectedSite() ) ) {
257 enableActivateLicenseButton();
258 } else {
259 disableActivateLicenseButton();
260 }
261 });
262
263 $sitesListContainer.delegate( 'td:not(:first-child)', 'click', function() {
264 // If a site row is clicked, trigger a click on the checkbox.
265 $( this ).parent().find( 'td:first-child input' ).click();
266 });
267
268 $sitesListContainer.delegate( 'input[type="checkbox"]', 'click', function() {
269 enableDisableSitesSelection();
270
271 if ( hasValidLicenseKey() && hasSelectedSite() ) {
272 enableActivateLicenseButton();
273 } else {
274 disableActivateLicenseButton();
275 }
276 });
277 }
278
279 if ( hasLicensesDropdown ) {
280 $licensesDropdown.change(function() {
281 // When a license is selected, select the associated radio button.
282 $licenseTypes.filter( '[value="available"]' ).attr( 'checked', true );
283
284 if ( ! isNetworkActivation || $modal.hasClass( 'is-single-site-activation' ) ) {
285 enableActivateLicenseButton();
286 return true;
287 }
288
289 toggleActivationOnAllSites();
290 })
291 }
292
293 if ( hasLicenseTypes ) {
294 $licenseTypes.change(function() {
295 var
296 licenseKey = $modal.find( 'input.fs-license-key' ).val().trim(),
297 otherLicenseKeySelected = isOtherLicenseKeySelected();
298
299 if ( ( licenseKey.length > 0 || ( hasLicenseTypes && ! otherLicenseKeySelected ) ) &&
300 ( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() )
301 ) {
302 /**
303 * If the "other" license is not empty or an available license is selected, enable the activate
304 * button.
305 *
306 * @author Leo Fajardo (@leorw)
307 */
308 enableActivateLicenseButton();
309 } else {
310 disableActivateLicenseButton();
311 }
312
313 if ( ! isNetworkActivation ) {
314 return;
315 }
316
317 if ( otherLicenseKeySelected ) {
318 $applyOnAllSites.attr( 'disabled', false );
319 enableDisableSitesSelection();
320 resetActivateLicenseCheckboxLabel();
321 } else if ( ! $modal.hasClass( 'is-single-site-activation' ) ) {
322 toggleActivationOnAllSites();
323 }
324 });
325
326 if ( ! hasLicensesDropdown ) {
327 $availableLicenseKey.click(function() {
328 $licenseTypes.filter( '[value="available"]' ).click();
329 });
330 }
331
332 $otherLicenseKeyContainer.click(function() {
333 $licenseTypes.filter( '[value="other"]' ).click();
334 });
335 }
336
337 $activateLicenseLink.click(function (evt) {
338 evt.preventDefault();
339
340 showModal( evt );
341 });
342
343 $modal.on('input propertychange', 'input.fs-license-key', function () {
344
345 var licenseKey = $(this).val().trim();
346
347 /**
348 * If license key is not empty, enable the license activation button.
349 */
350 if ( licenseKey.length > 0 && ( $modal.hasClass( 'is-single-site-activation' ) || ! isNetworkActivation || hasSelectedSite() ) ) {
351 enableActivateLicenseButton();
352 }
353 });
354
355 $modal.on( 'blur', 'input.fs-license-key', function( evt ) {
356 var
357 licenseKey = $(this).val().trim(),
358 $focusedElement = $( evt.relatedTarget ),
359 hasSelectedAvailableLicense = ( hasLicenseTypes && $focusedElement.parents( '.fs-available-license-key-container' ).length > 0 );
360
361 /**
362 * If license key is empty, disable the license activation button.
363 */
364 if ( ( 0 === licenseKey.length && ( ! hasLicenseTypes || ! hasSelectedAvailableLicense ) ) ||
365 ( isNetworkActivation && ! hasSelectedSite() )
366 ) {
367 disableActivateLicenseButton();
368 }
369 });
370
371 $modal.on('click', '.button-activate-license', function (evt) {
372 evt.preventDefault();
373
374 if ($(this).hasClass('disabled')) {
375 return;
376 }
377
378 var
379 licenseKey = '';
380
381 if ( hasLicenseTypes ) {
382 if ( isOtherLicenseKeySelected() ) {
383 licenseKey = $otherLicenseKey.val();
384 } else {
385 if ( ! hasLicensesDropdown ) {
386 licenseKey = $availableLicenseKey.data( 'license-key' );
387 } else {
388 licenseKey = $licensesDropdown.val();
389 }
390 }
391 } else {
392 licenseKey = $licenseKeyInput.val().trim();
393 }
394
395 disableActivateLicenseButton();
396
397 if (0 === licenseKey.length) {
398 return;
399 }
400
401 var data = {
402 action : '<?php echo $fs->get_ajax_action( 'activate_license' ) ?>',
403 security : '<?php echo $fs->get_ajax_security( 'activate_license' ) ?>',
404 license_key: licenseKey,
405 module_id : '<?php echo $fs->get_id() ?>'
406 };
407
408 if ( isNetworkActivation ) {
409 var
410 sites = [];
411
412 if ( null === singleBlogID ) {
413 var
414 applyOnAllSites = $applyOnAllSites.is( ':checked' );
415
416 $sitesListContainer.find( 'tr' ).each(function() {
417 var
418 $this = $( this ),
419 includeSite = ( applyOnAllSites || $this.find( 'input' ).is( ':checked' ) );
420
421 if ( ! includeSite )
422 return;
423
424 var site = {
425 uid : $this.find( '.uid' ).val(),
426 url : $this.find( '.url' ).val(),
427 title : $this.find( '.title' ).val(),
428 language: $this.find( '.language' ).val(),
429 charset : $this.find( '.charset' ).val(),
430 blog_id : $this.find( '.blog-id' ).find( 'span' ).text()
431 };
432
433 sites.push( site );
434 });
435 } else {
436 data.blog_id = singleBlogID;
437 }
438
439 data.sites = sites;
440 }
441
442 $.ajax({
443 url: ajaxurl,
444 method: 'POST',
445 data: data,
446 beforeSend: function () {
447 $activateLicenseButton.text( '<?php fs_esc_js_echo_inline( 'Activating license', 'activating-license', $slug ) ?>...' );
448 },
449 success: function( result ) {
450 var resultObj = $.parseJSON( result );
451 if ( resultObj.success ) {
452 closeModal();
453
454 // Redirect to the "Account" page and sync the license.
455 window.location.href = resultObj.next_page;
456 } else {
457 showError( resultObj.error.message ? resultObj.error.message : resultObj.error );
458 resetActivateLicenseButton();
459 }
460 }
461 });
462 });
463
464 // If the user has clicked outside the window, close the modal.
465 $modal.on('click', '.fs-close, .button-secondary', function () {
466 closeModal();
467 return false;
468 });
469 }
470
471 registerEventHandlers();
472
473 $('body').trigger('licenseActivationLoaded');
474
475 /**
476 * @author Leo Fajardo (@leorw)
477 * @since 2.0.0
478 */
479 function enableDisableSitesSelection() {
480 var
481 canApplyOnAllSites = $applyOnAllSites.is( ':enabled' ),
482 disableSitesSelection = null;
483
484 if ( ! canApplyOnAllSites ) {
485 var
486 selectedSites = $sitesListContainer.find( 'input[type="checkbox"]:checked' ).length,
487 activationsLeft = Math.max( 0, $activationsLeft.data( 'left' ) - selectedSites );
488
489 disableSitesSelection = ( 0 === activationsLeft );
490
491 $activationsLeft.text( activationsLeft );
492 } else {
493 disableSitesSelection = false;
494 }
495
496 $sitesListContainer
497 .find( 'input[type="checkbox"]:not(:checked)' )
498 .attr( 'disabled', disableSitesSelection );
499 }
500
501 /**
502 * @author Leo Fajardo (@leorw)
503 * @since 2.0.0
504 *
505 * @returns {Boolean}
506 */
507 function isOtherLicenseKeySelected() {
508 return ( hasLicenseTypes && 'other' === $licenseTypes.filter( ':checked' ).val() );
509 }
510
511 /**
512 * @author Leo Fajardo (@leorw)
513 * @since 2.0.0
514 *
515 * @returns {Boolean}
516 */
517 function hasValidLicenseKey() {
518 var licenseKey = '';
519 if ( hasLicenseTypes ) {
520 if ( 'available' === $licenseTypes.filter( ':checked' ).val() ) {
521 return true;
522 } else {
523 licenseKey = $otherLicenseKey.val();
524 }
525 } else {
526 licenseKey = $modal.find( 'input.fs-license-key' ).val();
527 }
528
529 return ( licenseKey.trim().length > 0 );
530 }
531
532 /**
533 * @author Leo Fajardo (@leorw)
534 * @since 2.0.0
535 *
536 * @returns {Boolean}
537 */
538 function hasSelectedSite() {
539 return ( $applyOnAllSites.is( ':checked' ) ||
540 $sitesListContainer.find( 'input[type="checkbox"]:checked:not(:disabled)' ).length > 0 );
541 }
542
543 /**
544 * @author Leo Fajardo (@leorw)
545 * @since 2.0.0
546 */
547 function toggleActivationOnAllSites() {
548 var activationsLeft,
549 licenseID;
550
551 if (hasLicensesDropdown) {
552 var $selectedOption = $licensesDropdown.find( ':selected' );
553 activationsLeft = $selectedOption.data('left');
554 licenseID = $selectedOption.data('id');
555 } else {
556 activationsLeft = $availableLicenseKey.data('left');
557 licenseID = $availableLicenseKey.data('id');
558 }
559
560 // Cleanup previously auto-selected site.
561 $modal.find( '.fs-sites-list-container input[type=checkbox]:disabled' )
562 .attr('disabled', false)
563 .attr('checked', false);
564
565 var $blogsWithActiveLicense = $modal.find( '.fs-sites-list-container tr[data-license-id=' + licenseID + '] input[type=checkbox]' );
566
567 if ($blogsWithActiveLicense.length > 0) {
568 $blogsWithActiveLicense.attr('checked', true)
569 .attr('disabled', true);
570
571 activationsLeft += $blogsWithActiveLicense.length;
572 }
573
574 if ( activationsLeft >= totalSites ) {
575 $applyOnAllSites.attr( 'disabled', false );
576 enableDisableSitesSelection();
577
578 resetActivateLicenseCheckboxLabel();
579
580 return;
581 }
582
583 $applyOnAllSites.attr( 'checked', false );
584 $applyOnAllSites.attr( 'disabled', true );
585
586 showSites( true );
587
588 var
589 activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Choose up to %s site(s) to activate the license on.', 'choose-up-to-n-sites-to-activate-the-license-on', $slug ) ?>';
590
591 activateLicenseCheckboxLabel = activateLicenseCheckboxLabel.replace( '%s', '<span data-left="' + activationsLeft + '" class="activations-left">' + activationsLeft + '</span>' );
592
593 // Update the label of the "Activate license on all sites" checkbox.
594 $applyOnAllSites.parent().find( 'span' ).html( activateLicenseCheckboxLabel );
595 $activationsLeft = $modal.find( '.activations-left' );
596
597 if ( hasSelectedSite() ) {
598 enableActivateLicenseButton();
599 enableDisableSitesSelection();
600 } else {
601 disableActivateLicenseButton();
602 }
603 }
604
605 /**
606 * @author Leo Fajardo (@leorw)
607 * @since 2.0.0
608 */
609 function resetActivateLicenseCheckboxLabel() {
610 var activateLicenseCheckboxLabel = '<?php fs_esc_js_echo_inline( 'Activate license on all sites in the network.', 'activate-license-on-all-sites-in-the-network', $slug ) ?>';
611 $applyOnAllSites.parent().find( 'span' ).text( activateLicenseCheckboxLabel );
612 }
613
614 /**
615 * @author Leo Fajardo (@leorw)
616 * @since 2.0.0
617 *
618 * @param {Boolean} show
619 */
620 function showSites( show ) {
621 $sitesListContainer.toggle( show );
622 if ( show && null === maxSitesListHeight ) {
623 /**
624 * Set the visible number of rows to 5 (5 * height of the first row).
625 *
626 * @author Leo Fajardo (@leorw)
627 */
628 maxSitesListHeight = ( 5 * $sitesListContainer.find( 'tr:first' ).height() );
629 $sitesListContainer.css( 'max-height', maxSitesListHeight );
630 }
631 }
632
633 function showModal( evt ) {
634 resetModal();
635
636 // Display the dialog box.
637 $modal.addClass('active');
638 $('body').addClass('has-fs-modal');
639
640 var
641 $singleInstallDetails = $( evt.target ).parents( 'tr.fs-install-details' ),
642 isSingleSiteActivation = ( $singleInstallDetails.length > 0 );
643
644 $modal.toggleClass( 'is-single-site-activation', isSingleSiteActivation );
645
646 singleBlogID = isSingleSiteActivation ?
647 $singleInstallDetails.prev().data( 'blog-id' ) :
648 null;
649
650 $multisiteOptionsContainer.toggle( isNetworkActivation && ! isSingleSiteActivation );
651
652 if ( hasLicenseTypes ) {
653 $licenseTypes.attr( 'checked', false );
654
655 if ( hasLicensesDropdown ) {
656 $licensesDropdown.find( 'option:first' ).attr( 'selected', true ).trigger( 'change' );
657 } else {
658 $licenseTypes.filter( '[value="available"]' ).click();
659 }
660
661 $otherLicenseKey.val( '' );
662 } else {
663 $licenseKeyInput.val( '' );
664 $licenseKeyInput.focus();
665 }
666 }
667
668 function closeModal() {
669 $modal.removeClass('active');
670 $('body').removeClass('has-fs-modal');
671 }
672
673 function resetActivateLicenseButton() {
674 enableActivateLicenseButton();
675 $activateLicenseButton.text( <?php echo json_encode( $activate_button_text ) ?> );
676 }
677
678 function resetModal() {
679 hideError();
680 resetActivateLicenseButton();
681 }
682
683 function enableActivateLicenseButton() {
684 $activateLicenseButton.removeClass( 'disabled' );
685 }
686
687 function disableActivateLicenseButton() {
688 $activateLicenseButton.addClass( 'disabled' );
689 }
690
691 function hideError() {
692 $licenseActivationMessage.hide();
693 }
694
695 function showError( msg ) {
696 $licenseActivationMessage.find( ' > p' ).html( msg );
697 $licenseActivationMessage.show();
698 }
699 });
700 })( jQuery );
701 </script>