| 1 |
jQuery(document).ready(function ($) { |
| 2 |
$('#wpwrap').on('click', '.open-upsell', function (e) { |
| 3 |
e.preventDefault(); |
| 4 |
feature = $(this).data('feature'); |
| 5 |
$(this).blur(); |
| 6 |
open_upsell(feature); |
| 7 |
|
| 8 |
return false; |
| 9 |
}); |
| 10 |
|
| 11 |
$('#wpwrap').on('click', '.open-pro-dialog', function (e) { |
| 12 |
e.preventDefault(); |
| 13 |
$(this).blur(); |
| 14 |
|
| 15 |
pro_feature = $(this).data('pro-feature'); |
| 16 |
if (!pro_feature) { |
| 17 |
pro_feature = $(this).parent('label').attr('for'); |
| 18 |
} |
| 19 |
open_upsell(pro_feature); |
| 20 |
|
| 21 |
return false; |
| 22 |
}); |
| 23 |
|
| 24 |
$('#wp-captcha-code-pro-dialog').dialog({ |
| 25 |
dialogClass: 'wp-dialog wp-captcha-code-pro-dialog', |
| 26 |
modal: true, |
| 27 |
resizable: false, |
| 28 |
width: 850, |
| 29 |
height: 'auto', |
| 30 |
show: 'fade', |
| 31 |
hide: 'fade', |
| 32 |
close: function (event, ui) {}, |
| 33 |
open: function (event, ui) { |
| 34 |
$(this).siblings().find('span.ui-dialog-title').html('WP Captcha PRO is here!'); |
| 35 |
wp_captcha_code_fix_dialog_close(event, ui); |
| 36 |
}, |
| 37 |
autoOpen: false, |
| 38 |
closeOnEscape: true, |
| 39 |
}); |
| 40 |
|
| 41 |
function clean_feature(feature) { |
| 42 |
feature = feature || 'captcha-code-unknown'; |
| 43 |
feature = feature.toLowerCase(); |
| 44 |
feature = feature.replace(' ', '-'); |
| 45 |
|
| 46 |
return feature; |
| 47 |
} |
| 48 |
|
| 49 |
function open_upsell(feature) { |
| 50 |
feature = clean_feature(feature); |
| 51 |
|
| 52 |
$('#wp-captcha-code-pro-dialog').dialog('open'); |
| 53 |
|
| 54 |
$('#wp-captcha-code-pro-table .button-buy').each(function (ind, el) { |
| 55 |
tmp = $(el).data('href-org'); |
| 56 |
tmp = tmp.replace('pricing-table', feature); |
| 57 |
$(el).attr('href', tmp); |
| 58 |
}); |
| 59 |
} // open_upsell |
| 60 |
|
| 61 |
if (window.localStorage.getItem('wp_captcha_code_upsell_shown') != 'true') { |
| 62 |
open_upsell('cc-welcome'); |
| 63 |
|
| 64 |
window.localStorage.setItem('wp_captcha_code_upsell_shown', 'true'); |
| 65 |
window.localStorage.setItem('wp_captcha_code_upsell_shown_timestamp', new Date().getTime()); |
| 66 |
} |
| 67 |
|
| 68 |
if (window.location.hash == '#get-pro') { |
| 69 |
open_upsell('cc-url-hash'); |
| 70 |
window.location.hash = ''; |
| 71 |
} |
| 72 |
|
| 73 |
$('.install-wp301').on('click', function (e) { |
| 74 |
e.preventDefault(); |
| 75 |
|
| 76 |
if ( |
| 77 |
!confirm( |
| 78 |
'The free WP 301 Redirects plugin will be installed & activated from the official WordPress repository. Click OK to proceed.' |
| 79 |
) |
| 80 |
) { |
| 81 |
return false; |
| 82 |
} |
| 83 |
|
| 84 |
jQuery('body').append( |
| 85 |
'<div style="width:550px;height:450px; position:fixed;top:10%;left:50%;margin-left:-275px; color:#444; background-color: #fbfbfb;border:1px solid #DDD; border-radius:4px;box-shadow: 0px 0px 0px 4000px rgba(0, 0, 0, 0.85);z-index: 9999999;"><iframe src="' + |
| 86 |
wp_captcha_code_vars.wp301_install_url + |
| 87 |
'" style="width:100%;height:100%;border:none;" /></div>' |
| 88 |
); |
| 89 |
jQuery('#wpwrap').css('pointer-events', 'none'); |
| 90 |
|
| 91 |
e.preventDefault(); |
| 92 |
return false; |
| 93 |
}); |
| 94 |
|
| 95 |
function wp_captcha_code_fix_dialog_close(event, ui) { |
| 96 |
jQuery('.ui-widget-overlay').bind('click', function () { |
| 97 |
jQuery('#' + event.target.id).dialog('close'); |
| 98 |
}); |
| 99 |
} // wp_captcha_code_fix_dialog_close |
| 100 |
|
| 101 |
$('#wpwrap').on('change', 'select', function (e) { |
| 102 |
option_class = $('#' + $(this).attr('id') + ' :selected').attr('class'); |
| 103 |
if (option_class == 'pro-option') { |
| 104 |
option_text = $('#' + $(this).attr('id') + ' :selected').text(); |
| 105 |
value = $('#' + $(this).attr('id') + ' :selected').attr('value'); |
| 106 |
$(this).val('builtin'); |
| 107 |
$(this).trigger('change'); |
| 108 |
open_upsell($(this).attr('id') + '-' + value); |
| 109 |
$('.show_if_' + $(this).attr('id')).hide(); |
| 110 |
} |
| 111 |
}); |
| 112 |
}); |
| 113 |
|
| 114 |
|