|
Server : Apache/2.2.22 (Unix) mod_ssl/2.2.22 OpenSSL/1.0.0-fips mod_auth_passthrough/2.1 mod_bwlimited/1.4 System : Linux server.jackjohnson.com 2.6.32-279.5.2.el6.x86_64 #1 SMP Fri Aug 24 01:07:11 UTC 2012 x86_64 User : jackjohn ( 502) PHP Version : 5.3.17 Disable Function : NONE Directory : /home/jackjohn/public_html/shopsite-images/en-IE/javascript/ |
Upload File : |
"use_strict";
var CBP_text_idx = 0;
var grid_size = 10;
var paypal_condition, g_paypal_condition, initial;
function startDraggable (initial_q, paypal_condition_q, ppcredit_condition_q) {
g_paypal_condition = paypal_condition_q;
paypal_condition = paypal_condition_q;
initial = initial_q;
ppcredit_condition = ppcredit_condition_q;
}
function start_cbp() {
CBP_text_idx = $('#CBP_text_idx').val();
if($('.CBP_button').data('ui-draggable'))
$('.CBP_button').draggable('destroy');
$('.CBP_text').draggable({
containment: '#CBP_container',
scroll:false,
stop: function(event, ui) {
$('#' + $(this).attr('id') + '_left').val(ui.position.left);
$('#' + $(this).attr('id') + '_top').val(ui.position.top);
}
});
if ($('#CBP_snap_text').is(':checked')) {
snap_to_grid('.CBP_text');
}
//auto-resize input text field. http://stackoverflow.com/questions/1288297/jquery-auto-size-text-input-not-textarea/1288372#1288372
$(document).off('keyup', '.CBP_text > input');
$(document).on('keyup', '.CBP_text > input',function () {
var oneLetterWidth = 8;
var len = $(this).val().length;
$(this).width(len * oneLetterWidth);
});
$(document).off('click','.CBP_remove_text');
$(document).on('click', '.CBP_remove_text', function () {
$(this).parent().remove();
var idx = $(this).attr('id').substr(16);
var text_indexes = $('#CBP_text_indexes').val();
$('#CBP_text_indexes').val(text_indexes.replace('|' + idx + '|', '|'));
});
$(document).off('click','#CBP_add_text');
$(document).on('click', '#CBP_add_text', function () {
let html = '<div class="CBP_text CBP_text_added" id="CBP_text_'+CBP_text_idx+'">'+
'<input type="text" size="3" name="CBP_text_input_'+CBP_text_idx+'" id="CBP_text_input_'+CBP_text_idx+'" value="or">'+
'<a class="CBP_remove_text" id="CBP_remove_text_'+CBP_text_idx+'">x</a>'+
'<input type="hidden" name="CBP_text_'+CBP_text_idx+'_left" id="CBP_text_'+CBP_text_idx+'_left" value="0">'+
'<input type="hidden" name="CBP_text_'+CBP_text_idx+'_top" id="CBP_text_'+CBP_text_idx+'_top" value="0">'+
'</div>';
$('#CBP_container').append($(html));
setTimeout(function(){$('.CBP_text_added').removeClass('CBP_text_added')}, 1000);
$('#CBP_text_'+CBP_text_idx).draggable({
containment: '#CBP_container',
scroll:false,
stop: function(event, ui) {
$('#' + $(this).attr('id') + '_left').val(ui.position.left);
$('#' + $(this).attr('id') + '_top').val(ui.position.top);
}
});
if ($('#CBP_snap_text').is(':checked')) {
snap_to_grid('#CBP_text_'+CBP_text_idx);
}
//auto-resize input text field. http://stackoverflow.com/questions/1288297/jquery-auto-size-text-input-not-textarea/1288372#1288372
$('#CBP_text_input_'+CBP_text_idx).on('keyup',function () {
var len = $(this).val().length;
$(this).attr('size', len);
});
$('#CBP_remove_text_'+CBP_text_idx).on('click',function () {
$(this).parent().remove();
var idx = $(this).attr('id').substr(16);
var text_indexes = $('#CBP_text_indexes').val();
$('#CBP_text_indexes').val(text_indexes.replace('|' + idx + '|', '|'));
});
var text_indexes = $('#CBP_text_indexes').val();
$('#CBP_text_indexes').val(text_indexes + CBP_text_idx + '|');
CBP_text_idx++;
});
}
function start_cbp2() {
if($('.CBP_button').data('ui-draggable'))
$('.CBP_button').draggable('destroy');
$('.CBP_button').draggable({
containment: '#CBP_container',
scroll:false,
stop: function(event, ui) {
$('#' + $(this).attr('id') + '_left').val(ui.position.left);
$('#' + $(this).attr('id') + '_top').val(ui.position.top);
}
});
if ($('#CBP_snap_buttons').is(':checked')) {
snap_to_grid('.CBP_button');
}
}
$(function() {
if($('#paypal_checkbox').is(':checked') && $('#paypal_standard').is(':checked')) {
$('#paypal_checkbox').addClass('payment_shopsite');
}
start_cbp();
$('#button_save_changes').on('click',function () {
if (overlaps_detected())
return confirm('Your checkout buttons overlap. Are you sure that is how you want them?');
else return 1;
});
$('#CBP_snap_buttons').on('change',function() {
if ($('#CBP_snap_buttons').is(':checked')) {
snap_to_grid('.CBP_button');
} else {
$('.CBP_button').draggable( 'option' , 'grid' , [ 1,1 ] );
}
});
$('#CBP_snap_text').on('change',function() {
if ($('#CBP_snap_text').is(':checked'))
snap_to_grid('.CBP_text');
else
$('.CBP_text').draggable( 'option' , 'grid' , [ 1,1 ] );
});
$('#paypal_standard').on('click',function() {
var st = payment_processors['paypal'] + 'use';
$('#paypal_checkbox').prop('checked',true);
$('#paypal_checkbox').attr('name',st);
$('#paypal_checkbox').addClass('payment_shopsite');
$('#CBP_paypal').addClass('CBP_hide');
$('#CBP_ppcredit').addClass('CBP_hide');
$('#CBP_ppcp').addClass('CBP_hide');
$('.ppcp-info').hide();
$(this).parent().nextAll('.payconfig_button').attr('id', 'configure_paypal');
paypal_entangle($(this));
hide_show_ss_checkout(paypal_condition);
hide_show_all();
});
$('#paypal_express').on('click',function() {
var st = payment_processors['paypalexp'] + 'use';
$('#paypal_checkbox').prop('checked',true);
$('#paypal_checkbox').attr('name',st);
$('#paypal_checkbox').removeClass('payment_shopsite');
if (paypal_condition)
$('#CBP_paypal').removeClass('CBP_hide');
if (ppcredit_condition)
$('#CBP_ppcredit').removeClass('CBP_hide');
$('#CBP_ppcp').addClass('CBP_hide');
$('.ppcp-info').hide();
$(this).parent().nextAll('.payconfig_button').attr('id', 'configure_paypalexp');
paypal_entangle($(this));
hide_show_ss_checkout(paypal_condition);
hide_show_all();
});
$('#paypal_commerce').on('click',function() {
var st = payment_processors['paypalcommbtns'] + 'use';
$('#paypal_checkbox').prop('checked',true);
$('#paypal_checkbox').attr('name',st);
$('#paypal_checkbox').removeClass('payment_shopsite');
$('#CBP_paypal').addClass('CBP_hide');
$('#CBP_ppcredit').addClass('CBP_hide');
$('#CBP_ppcp').removeClass('CBP_hide');
$('.ppcp-info').show();
$(this).parent().nextAll('.payconfig_button').attr('id', 'configure_paypalcommbtns');
paypal_entangle($(this));
hide_show_ss_checkout(paypal_condition);
hide_show_all();
});
$('#paypal_checkbox').on('click',function() {
if ($('#paypal_checkbox').is(':checked')) {
let sl = $('[name=paypal_selection]:checked');
if(sl.length == 1)
sl.click();
else
$('[name=paypal_selection]:first').click();
} else {
$('#CBP_paypal').addClass('CBP_hide');
$('#CBP_ppcredit').addClass('CBP_hide');
$('#CBP_ppcp').addClass('CBP_hide');
}
paypal_entangle($(this));
});
$('#amazon_checkbox').on('click',function() {
if ($('#amazon_checkbox').is(':checked')) {
$('#CBP_amazon_pwa').removeClass('CBP_hide');
} else {
$('#CBP_amazon_pwa').addClass('CBP_hide');
}
});
$('#applepay_checkbox').on('click',function() {
if ($('#applepay_checkbox').is(':checked')) {
$('#CBP_applepay').removeClass('CBP_hide');
} else {
$('#CBP_applepay').addClass('CBP_hide');
}
});
$('#googlepay_checkbox').on('click',function() {
if ($('#googlepay_checkbox').is(':checked')) {
$('#CBP_googlepay').removeClass('CBP_hide');
} else {
$('#CBP_googlepay').addClass('CBP_hide');
}
});
$('#process').on('change',function() {
paypal_entangle();
});
$('.payment_method_checkbox').each(function() {
show_hide_config_block(this);
});
$('.payment_method_checkbox').on('change',function () {
show_hide_config_block(this);
hide_show_ss_checkout(paypal_condition);
hide_show_all();
});
if($('#paypal_checkbox').is(':checked')){$('[name=paypal_selection]:checked').click()}
get_processor();
hide_show_ss_checkout(paypal_condition);
hide_show_all();
if (initial) {
if ($('#CBP_paypal').length) {
$('#CBP_paypal_left').val($('#CBP_paypal').offset().left - $('#CBP_container').offset().left);
$('#CBP_paypal_top').val($('#CBP_paypal').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_amazon_pwa').length) {
$('#CBP_amazon_pwa_left').val($('#CBP_amazon_pwa').offset().left - $('#CBP_container').offset().left);
$('#CBP_amazon_pwa_top').val($('#CBP_amazon_pwa').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_ppcredit').length) {
$('#CBP_ppcredit_left').val($('#CBP_ppcredit').offset().left - $('#CBP_container').offset().left);
$('#CBP_ppcredit_top').val($('#CBP_ppcredit').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_checkout').length) {
$('#CBP_checkout_left').val($('#CBP_checkout').offset().left - $('#CBP_container').offset().left);
$('#CBP_checkout_top').val($('#CBP_checkout').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_applepay').length) {
$('#CBP_applepay_left').val($('#CBP_applepay').offset().left - $('#CBP_container').offset().left);
$('#CBP_applepay_top').val($('#CBP_applepay').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_googlepay').length) {
$('#CBP_googlepay_left').val($('#CBP_googlepay').offset().left - $('#CBP_container').offset().left);
$('#CBP_googlepay_top').val($('#CBP_googlepay').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_checkout').length) {
$('#CBP_checkout_left').val($('#CBP_checkout').offset().left - $('#CBP_container').offset().left);
$('#CBP_checkout_top').val($('#CBP_checkout').offset().top - $('#CBP_container').offset().top);
}
if ($('#CBP_text_0').length) {
$('#CBP_text_0_left').val($('#CBP_text_0').offset().left - $('#CBP_container').offset().left-8);
$('#CBP_text_0_top').val($('#CBP_text_0').offset().top - $('#CBP_container').offset().top-8);
}
if ($('#CBP_text_1').length) {
$('#CBP_text_1_left').val($('#CBP_text_1').offset().left - $('#CBP_container').offset().left-8);
$('#CBP_text_1_top').val($('#CBP_text_1').offset().top - $('#CBP_container').offset().top-8);
}
calculate_dimensions();
$('#CBP_wrapper').wrap('<form id="ser_form"/>');
//force switch to new CBP
jQuery.ajax({
url:'payconfig.cgi?ajax=init_cbp&' + $('#ser_form').serialize(),
success: function(result) {
if(result.isOk == false)
alert(result.message);
else {
$('#CBP_wrapper').html(result);
$('#CBP_wrapper').unwrap();
}
},
async:false
});
}
start_cbp2();
$(document).on( 'change','.payment_shopsite', function() {
hide_show_ss_checkout(paypal_condition);
hide_show_all();
});
});
function show_hide_config_block(b) {
if ($(b).is(':checked'))
$(b).parent().next().show().closest('.config_item').addClass('pm-selected');
else
$(b).parent().next().hide().closest('.config_item').removeClass('pm-selected');
}
/* validations */
$(function() {
$('.payment_method_hidden').addClass('paypal_entangle_check');
$('#applepay_checkbox').addClass('applepay_entangle_check');
$('#googlepay_checkbox').addClass('googlepay_entangle_check');
$('.payment_method_checkbox:first').addClass('payconfig_save');
$.validator.addMethod('payment_method_checkbox',check_configuration,vmess.payment_method_check);
$.validator.addMethod('paypal_entangle_check',paypal_entangle,vmess.paypal_check);
$.validator.addMethod('applepay_entangle_check',applepay_entangle,vmess.applepay_check);
$.validator.addMethod('googlepay_entangle_check',googlepay_entangle,vmess.googlepay_check);
$.validator.addMethod('payconfig_save',check_one_enabled,vmess.check_one_enabled);
$('form').validate({
rules:{},
ignore:'',
errorPlacement:function(e,l) {
e.css({'display':'block','clear':'both'});
if ($(l).attr('name') == 'process') {
var process = $(l).val();
if ($('#configure_'+process).length) {
$('#configure_' + process).before(e);
}
else {
$('#all_processors').before(e);
}
} else if ($(l).hasClass('payconfig_save')) {
$('div.config_item.payment_method').addClass('error_hl').parent().append(e.css({'margin-top':'10px'}).attr('id','special_error'));
} else if($(l).hasClass('payment_method_checkbox')) {
e.css({'margin-top':'10px'});
l.parent().parent().append(e);
$(l).closest('.payment_method').addClass('error_hl');
} else {
l.parent().append(e);
$(l).closest('.payment_method').addClass('error_hl');
}
},
errorClass: 'validation_error'
});
});
function check_configuration(v,e) {
var res = true;
var code = '';
if ($(e).is(':checked')) {
code = $(e).attr('name');
if (code == 'cc')
code = $('#process').val();
} else
return true;
jQuery.ajax({url:'payconfig.cgi?ajax=check_configuration&processor='+code+'&selectedprocess='+$('#all_processors').find(':selected').val(),
success: function(result) {
if (result != '1')
res = false;
},
async:false
});
return res;
}
function applepay_entangle(v,e){let p=$('#process').val();return !$('#applepay_checkbox').is(':checked')||(p=='anetaccept')||(p=='braintree_v0');}
function googlepay_entangle(v,e){let p=$('#process').val();return !$('#googlepay_checkbox').is(':checked')||(p=='braintree_v0');}
function paypal_entangle(v,e){return!($('#process').val()=='paypalpro'&&!(($('#paypal_checkbox').attr('name')==payment_processors['paypalexp']+'use')&&$('#paypal_checkbox').is(':checked')))}
function check_one_enabled(v,e){return($('.payment_shopsite').is(':checked'))||($('.payment_method_checkbox').is(':checked'));}
function snap_to_grid(selector) {
$(selector).draggable( 'option' , 'grid' , [ grid_size,grid_size ] );
$(selector).each(function(index) {
var left = Math.floor(parseInt($(this).css('left')) / grid_size) * grid_size;
var top = Math.floor(parseInt($(this).css('top')) / grid_size) * grid_size;
if (!isNaN(left)) {
$(this).css('left', left);
$('#' + $(this).attr('id') + '_left').val(left);
}
if (!isNaN(top)){
$(this).css('top', top);
$('#' + $(this).attr('id') + '_top').val(top);
}
});
}
function calculate_dimensions() {
var CBP_width = 0;
var CBP_height = 0;
$('.CBP_button, .CBP_text').each(function(index) {
if (!$(this).hasClass('CBP_hide')) {
var right = $(this).offset().left + $(this).width();
if (right > CBP_width)
CBP_width = right;
var bottom = $(this).offset().top + $(this).height();
if (bottom > CBP_height)
CBP_height = bottom;
}
});
$('#CBP_width').val(CBP_width - $('#CBP_container').offset().left);
$('#CBP_height').val(CBP_height - $('#CBP_container').offset().top);
}
function hide_show_ss_checkout(paypal_condition) {
if (($('#process').val() != 'None' && $('#cc').is(':checked')) || $('.payment_shopsite').is(':checked') || ($('input[name="'+payment_processors['paypalexp'] + 'use"]').is(':checked')) && !paypal_condition) {
$('#CBP_checkout').removeClass('CBP_hide');
} else {
$('#CBP_checkout').addClass('CBP_hide');
}
}
function hide_show_all() {
if ($('.CBP_button').length - $('.CBP_hide').length < 2) {
$('#CBP_wrapper').css({display:'none'});
$('#CBP_options').css({display:'none'});
$('#CBP_few').css({display:'block'});
}
else {
$('#CBP_wrapper').css({display:'block'});
$('#CBP_options').css({display:'block'});
$('#CBP_few').css({display:'none'});
}
}
//http://stackoverflow.com/questions/1560926/efficiently-detect-when-sibling-elements-overlap
function findIntersectors(targetSelector, intersectorsSelector) {
let res = false, $target = $(targetSelector), tAxis = $target.offset(), t_x = [tAxis.left, tAxis.left + $target.outerWidth()], t_y = [tAxis.top, tAxis.top + $target.outerHeight()];
$(intersectorsSelector||'.CBP_button:not(.CBP_hide)').each(function() {
if (!res) {
let $this = $(this);
if ($this.attr('id') != $target.attr('id')) {
let thisPos = $this.offset(), i_x = [thisPos.left, thisPos.left + $this.outerWidth()], i_y = [thisPos.top, thisPos.top + $this.outerHeight()];
if ( t_x[0] < i_x[1] && t_x[1] > i_x[0] &&
t_y[0] < i_y[1] && t_y[1] > i_y[0]) {
res = true;
}
}
}
});
return res;
}
$(document).on('click','.conf_link, .payconfig_button', function() {
if (tryb4) {
alert(tryb4);
return;
}
var id = $(this).attr('id').substring(10), process = $('#all_processors').find(':selected').val(),src = 'payconfig.cgi?Configure Processor.x=1&modal=1&selectedprocess='+process;
if (id != 'any')
process = id;
src += '&process='+process;
$('.payment_method_checkbox').each(function(){
if($(this).is(':checked')){src+='&'+this.name+'='+this.value;}
});
$.modal('<iframe src="' + src + '" id="modal">', {
closeHTML: '',
autoResize: true,
minWidth: 1000,
overlayClose:false,
onClose: function() { $.modal.close(); $('body').css({'overflow':''});}
});
var height=$('iframe#modal').height(),wh=$(window).height();
if(height > wh){$('iframe#modal').height(wh)}
$(this).closest('.value').find('input:checkbox').attr('checked', 'checked');
$('body').css({'overflow':'hidden'});
});
$(document).on('change','#all_processors', function () {
if($(this).val()=='paypalcommerce'){$('#ppcp-cc-connect').show()}else{$('#ppcp-cc-connect').hide()}
$('#process').val(get_processor()).change();
hide_show_ss_checkout(g_paypal_condition);
hide_show_all();
});
$(document).on('click','#all_processors, .payment_method', function () {
remove_errors();
});
$(document).on('change','.payment_shopsite', function () {
$('.button_block').find('label.validation_error').remove();
$('li.error_hl').removeClass('error_hl');
});
function remove_errors() {
$('.payment_method, .currently_active, .button_block').find('label.validation_error').remove();
$('.error_hl').removeClass('error_hl');
$('.validation_error').removeClass('validation_error');
$('label#special_error').remove();
}
//1 -- overlaps detected
function overlaps_detected() {
calculate_dimensions();
return (
(!$('#CBP_paypal').hasClass('CBP_hide') && findIntersectors('#CBP_paypal'))
|| (!$('#CBP_ppcredit').hasClass('CBP_hide') && findIntersectors('#CBP_ppcredit'))
|| (!$('#CBP_ppcp').hasClass('CBP_hide') && findIntersectors('#CBP_ppcp'))
|| (!$('#CBP_amazon_pwa').hasClass('CBP_hide') && findIntersectors('#CBP_amazon_pwa'))
|| (!$('#CBP_applepay').hasClass('CBP_hide') && findIntersectors('#CBP_applepay'))
|| (!$('#CBP_googlepay').hasClass('CBP_hide') && findIntersectors('#CBP_googlepay'))
|| (!$('#CBP_checkout').hasClass('CBP_hide') && findIntersectors('#CBP_checkout')));
}
function get_processor() {
var process = $('#all_processors').find('option:selected').val();
if(process == 'None'){$('#configure_any').hide()}else{$('#configure_any').show()}
return process;
}
function process_modal(paytype_enabled, cc_processor_flag, code, name, passed_from_child) {
$.modal.close(); $('body').css({'overflow':''});
if(cc_processor_flag) {
$('.currently_active').html('<a id="configure_'+code+'" class="conf_link">'+name+'</a>');
}
if (paytype_enabled && overlaps_detected()) {
alert('You just enabled a payment method that uses a checkout button. Make sure to arrange checkout buttons and click "Save Changes" on this page before leaving');
$('#CBP_wrapper').css({'border':'3px solid red'});
$('body').mouseup(function() {$('#CBP_wrapper').css({'border':'1px solid #DFDFDF'});});
}
}
function finishCaptcha(enabled){$('#captcha_config').val(enabled&&'true'||'false');}
$(document).on('change','#country_select_box', function () {
$('body').css({'cursor':'wait'})
$('<input type="hidden" name="update_country" value="1">').appendTo('#country_chooser');
$('form').submit();
});
$(function($){
var b=$('#button_config_captcha'),t=$('#button_test_captcha');
if($('#all_processors').val()=='paypalcommerce'){$('#ppcp-cc-connect').show()}else{$('#ppcp-cc-connect').hide()}
b.on('click',function(e){
e.preventDefault();
$.modal('<iframe src="?ConfigCaptcha.x=1&type='+$('input[name=sec_captcha_type]:checked').val()+'&modal=1" id=modal>',{closeHTML:'',autoResize:true,minWidth:1000,overlayClose:false});
});
$('input[name=sec_captcha_type]').on('change',function(){
var c=$('input[name=sec_captcha_type]:checked').val();
if(c=='5'||c=='6')b.show();else{b.hide()}if(c>2)t.show();else{t.hide()}
}).change();
t.on('click',function(e){
e.preventDefault();
$.modal('<iframe src="?TestCaptcha.x=1&type='+$('input[name=sec_captcha_type]:checked').val()+'" style="height:300px;width:100%">',{closeHTML:'',autoResize:true,minWidth:460,overlayClose:false});
});
});