fix wpcfto select and repeater related visibility and validation
This commit is contained in:
@@ -596,11 +596,6 @@ jQuery(function($){
|
||||
}
|
||||
}
|
||||
|
||||
$(document).on('change', '#customer_data select', function() {
|
||||
var value = $(this).val();
|
||||
$(this).attr('data-current-value', value);
|
||||
});
|
||||
|
||||
$(document).on('click', '.delete-preview-field', function(e){
|
||||
e.preventDefault();
|
||||
$(this).parents('.preview-field').remove();
|
||||
@@ -760,40 +755,40 @@ jQuery(function($){
|
||||
$(this).closest('.child-field-title').toggleClass('option-detail-opened');
|
||||
});
|
||||
|
||||
var all_checkbox = $('[type="checkbox"]');
|
||||
if(all_checkbox.length > 0){
|
||||
$.each(all_checkbox, function(a,b){
|
||||
if($(b).val() == 'yes'){
|
||||
$(b).val('no').trigger('click');
|
||||
}
|
||||
});
|
||||
}
|
||||
// var all_checkbox = $('[type="checkbox"]');
|
||||
// if(all_checkbox.length > 0){
|
||||
// $.each(all_checkbox, function(a,b){
|
||||
// if($(b).val() == 'yes'){
|
||||
// $(b).val('no').trigger('click');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
function modify_payment_box_behavior() {
|
||||
// function modify_payment_box_behavior() {
|
||||
|
||||
var allbox = $('#payments multi_checkbox');
|
||||
var checkbox_input = $('.payments-payment input[type=checkbox]');
|
||||
var checked_value = [];
|
||||
if(checkbox_input.length > 0){
|
||||
$.each(checkbox_input, function(x, y){
|
||||
if($(y).is(':checked')){
|
||||
checked_value.push($(y).val());
|
||||
$('[data-field=wpcfto_addon_option_payment_'+$(y).val()+']').show();
|
||||
}else{
|
||||
$('[data-field=wpcfto_addon_option_payment_'+$(y).val()+']').hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
// var allbox = $('#payments multi_checkbox');
|
||||
// var checkbox_input = $('.payments-payment input[type=checkbox]');
|
||||
// var checked_value = [];
|
||||
// if(checkbox_input.length > 0){
|
||||
// $.each(checkbox_input, function(x, y){
|
||||
// if($(y).is(':checked')){
|
||||
// checked_value.push($(y).val());
|
||||
// $('[data-field=wpcfto_addon_option_payment_'+$(y).val()+']').show();
|
||||
// }else{
|
||||
// $('[data-field=wpcfto_addon_option_payment_'+$(y).val()+']').hide();
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
setTimeout(() => {
|
||||
modify_payment_box_behavior();
|
||||
}, 500);
|
||||
// setTimeout(() => {
|
||||
// modify_payment_box_behavior();
|
||||
// }, 500);
|
||||
|
||||
$(document).on('click', '.payments-payment input[type=checkbox]', function(){
|
||||
modify_payment_box_behavior();
|
||||
});
|
||||
// $(document).on('click', '.payments-payment input[type=checkbox]', function(){
|
||||
// modify_payment_box_behavior();
|
||||
// });
|
||||
|
||||
$(document).on('mouseover', 'span.grab', function(){
|
||||
$(this).css('pointer', 'grab');
|
||||
@@ -807,9 +802,14 @@ jQuery(function($){
|
||||
$(this).closest('.child-fields-wrapper').find('.the_title').text($(this).val());
|
||||
});
|
||||
|
||||
$(document).on('change', '#customer_data select', function() {
|
||||
var value = $(this).val();
|
||||
$(this).attr('data-current-value', value);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
jQuery(function($){
|
||||
// jQuery(function($){
|
||||
|
||||
// setTimeout(() => {
|
||||
// var autocomplete_fields = $('.wpcfto-box .autocomplete');
|
||||
@@ -831,116 +831,116 @@ jQuery(function($){
|
||||
// }, 500);
|
||||
// });
|
||||
|
||||
$( document ).on( 'click', '.add-thumbnail', function( event ) {
|
||||
// $( document ).on( 'click', '.add-thumbnail', function( event ) {
|
||||
|
||||
var gallery_items_frame;
|
||||
const $el = $( this );
|
||||
var target_field = $el.attr('data-field');
|
||||
var target_id = $el.siblings('.'+target_field+'-id');
|
||||
var target_url = $el.siblings('.'+target_field+'-url');
|
||||
var selected = target_id.val();
|
||||
var able_multiple = $el.attr('data-able-multiple');
|
||||
// var gallery_items_frame;
|
||||
// const $el = $( this );
|
||||
// var target_field = $el.attr('data-field');
|
||||
// var target_id = $el.siblings('.'+target_field+'-id');
|
||||
// var target_url = $el.siblings('.'+target_field+'-url');
|
||||
// var selected = target_id.val();
|
||||
// var able_multiple = $el.attr('data-able-multiple');
|
||||
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
|
||||
if ( gallery_items_frame ) {
|
||||
// if ( gallery_items_frame ) {
|
||||
|
||||
// Select the attachment when the frame opens
|
||||
gallery_items_frame.on( 'open', function() {
|
||||
var selection = gallery_items_frame.state().get( 'selection' );
|
||||
selection.reset( selected ? [ wp.media.attachment( selected ) ] : [] );
|
||||
});
|
||||
// // Select the attachment when the frame opens
|
||||
// gallery_items_frame.on( 'open', function() {
|
||||
// var selection = gallery_items_frame.state().get( 'selection' );
|
||||
// selection.reset( selected ? [ wp.media.attachment( selected ) ] : [] );
|
||||
// });
|
||||
|
||||
// Open the modal.
|
||||
gallery_items_frame.open();
|
||||
// // Open the modal.
|
||||
// gallery_items_frame.open();
|
||||
|
||||
return;
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
|
||||
// Create the media frame.
|
||||
gallery_items_frame = wp.media.frames.gallery_items = wp.media({
|
||||
// Set the title of the modal.
|
||||
title: 'Choose or upload media',
|
||||
button: {
|
||||
text: 'Select'
|
||||
},
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: 'Choose or upload media',
|
||||
filterable: 'all',
|
||||
multiple: able_multiple
|
||||
})
|
||||
]
|
||||
});
|
||||
// // Create the media frame.
|
||||
// gallery_items_frame = wp.media.frames.gallery_items = wp.media({
|
||||
// // Set the title of the modal.
|
||||
// title: 'Choose or upload media',
|
||||
// button: {
|
||||
// text: 'Select'
|
||||
// },
|
||||
// states: [
|
||||
// new wp.media.controller.Library({
|
||||
// title: 'Choose or upload media',
|
||||
// filterable: 'all',
|
||||
// multiple: able_multiple
|
||||
// })
|
||||
// ]
|
||||
// });
|
||||
|
||||
// Select the attachment when the frame opens
|
||||
gallery_items_frame.on( 'open', function() {
|
||||
var selection = gallery_items_frame.state().get( 'selection' );
|
||||
selection.reset( selected ? [ wp.media.attachment( selected ) ] : [] );
|
||||
});
|
||||
// // Select the attachment when the frame opens
|
||||
// gallery_items_frame.on( 'open', function() {
|
||||
// var selection = gallery_items_frame.state().get( 'selection' );
|
||||
// selection.reset( selected ? [ wp.media.attachment( selected ) ] : [] );
|
||||
// });
|
||||
|
||||
gallery_items_frame.on( 'select', function() {
|
||||
attachment = gallery_items_frame.state().get('selection').first().toJSON();
|
||||
target_id.val( attachment.id );
|
||||
target_url.val( attachment.url );
|
||||
if(target_id.val() !== ''){
|
||||
// $el.removeClass('text-white').addClass('text-info d-none');
|
||||
if($el.hasClass('btn')){
|
||||
$el.siblings('i').hide();
|
||||
}else{
|
||||
$el.hide();
|
||||
}
|
||||
$el.siblings('img').removeClass('d-none').attr('src', attachment.url).show();
|
||||
}else{
|
||||
// $el.removeClass('text-info d-none').addClass('text-white');
|
||||
if($el.hasClass('btn')){
|
||||
$el.siblings('i').show();
|
||||
}else{
|
||||
$el.show();
|
||||
}
|
||||
$el.siblings('img').addClass('d-none').hide();
|
||||
}
|
||||
});
|
||||
// gallery_items_frame.on( 'select', function() {
|
||||
// attachment = gallery_items_frame.state().get('selection').first().toJSON();
|
||||
// target_id.val( attachment.id );
|
||||
// target_url.val( attachment.url );
|
||||
// if(target_id.val() !== ''){
|
||||
// // $el.removeClass('text-white').addClass('text-info d-none');
|
||||
// if($el.hasClass('btn')){
|
||||
// $el.siblings('i').hide();
|
||||
// }else{
|
||||
// $el.hide();
|
||||
// }
|
||||
// $el.siblings('img').removeClass('d-none').attr('src', attachment.url).show();
|
||||
// }else{
|
||||
// // $el.removeClass('text-info d-none').addClass('text-white');
|
||||
// if($el.hasClass('btn')){
|
||||
// $el.siblings('i').show();
|
||||
// }else{
|
||||
// $el.show();
|
||||
// }
|
||||
// $el.siblings('img').addClass('d-none').hide();
|
||||
// }
|
||||
// });
|
||||
|
||||
// Open the modal.
|
||||
gallery_items_frame.open();
|
||||
// // Open the modal.
|
||||
// gallery_items_frame.open();
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
$( document ).on( 'click', '.trumbowyg-button-group:has(.trumbowyg-insertImage-button)', function( event ) {
|
||||
// $( document ).on( 'click', '.trumbowyg-button-group:has(.trumbowyg-insertImage-button)', function( event ) {
|
||||
|
||||
var gallery_items_frame;
|
||||
// var gallery_items_frame;
|
||||
|
||||
event.preventDefault();
|
||||
// event.preventDefault();
|
||||
|
||||
// Create the media frame.
|
||||
gallery_items_frame = wp.media.frames.gallery_items = wp.media({
|
||||
// Set the title of the modal.
|
||||
title: 'Choose or upload media',
|
||||
button: {
|
||||
text: 'Select'
|
||||
},
|
||||
states: [
|
||||
new wp.media.controller.Library({
|
||||
title: 'Choose or upload media',
|
||||
filterable: 'all',
|
||||
multiple: false
|
||||
})
|
||||
]
|
||||
});
|
||||
// // Create the media frame.
|
||||
// gallery_items_frame = wp.media.frames.gallery_items = wp.media({
|
||||
// // Set the title of the modal.
|
||||
// title: 'Choose or upload media',
|
||||
// button: {
|
||||
// text: 'Select'
|
||||
// },
|
||||
// states: [
|
||||
// new wp.media.controller.Library({
|
||||
// title: 'Choose or upload media',
|
||||
// filterable: 'all',
|
||||
// multiple: false
|
||||
// })
|
||||
// ]
|
||||
// });
|
||||
|
||||
gallery_items_frame.on( 'select', function() {
|
||||
attachment = gallery_items_frame.state().get('selection').first().toJSON();
|
||||
var target_input_url = $('.trumbowyg-modal.trumbowyg-fixed-top .trumbowyg-input-html input');
|
||||
var target_confirm = $('.trumbowyg-modal.trumbowyg-fixed-top .trumbowyg-modal-submit');
|
||||
target_input_url.val( attachment.url );
|
||||
target_confirm.trigger('click');
|
||||
// gallery_items_frame.on( 'select', function() {
|
||||
// attachment = gallery_items_frame.state().get('selection').first().toJSON();
|
||||
// var target_input_url = $('.trumbowyg-modal.trumbowyg-fixed-top .trumbowyg-input-html input');
|
||||
// var target_confirm = $('.trumbowyg-modal.trumbowyg-fixed-top .trumbowyg-modal-submit');
|
||||
// target_input_url.val( attachment.url );
|
||||
// target_confirm.trigger('click');
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
// Open the modal.
|
||||
gallery_items_frame.open();
|
||||
// // Open the modal.
|
||||
// gallery_items_frame.open();
|
||||
|
||||
});
|
||||
// });
|
||||
|
||||
});
|
||||
// });
|
||||
@@ -1,13 +1,13 @@
|
||||
function numberFormat(nStr) {
|
||||
nStr = parseFloat(nStr).toFixed(2);
|
||||
var x = nStr.split('.');
|
||||
var x1 = x[0];
|
||||
var x2 = x.length > 1 ? '.' + x[1] : '';
|
||||
var rgx = /(\d+)(\d{3})/;
|
||||
while (rgx.test(x1)) {
|
||||
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
||||
}
|
||||
return x1 + x2;
|
||||
nStr = parseFloat(nStr).toFixed(2);
|
||||
var x = nStr.split('.');
|
||||
var x1 = x[0];
|
||||
var x2 = x.length > 1 ? '.' + x[1] : '';
|
||||
var rgx = /(\d+)(\d{3})/;
|
||||
while (rgx.test(x1)) {
|
||||
x1 = x1.replace(rgx, '$1' + ',' + '$2');
|
||||
}
|
||||
return x1 + x2;
|
||||
}
|
||||
|
||||
function processPostsReport(data) {
|
||||
@@ -38,32 +38,32 @@ jQuery(function($){
|
||||
});
|
||||
|
||||
(function() {
|
||||
var supportsPassive = false;
|
||||
try {
|
||||
var opts = Object.defineProperty({}, 'passive', {
|
||||
get: function() {
|
||||
supportsPassive = true;
|
||||
}
|
||||
});
|
||||
window.addEventListener("testPassive", null, opts);
|
||||
window.removeEventListener("testPassive", null, opts);
|
||||
} catch (e) {}
|
||||
|
||||
if (!supportsPassive) return;
|
||||
|
||||
var origAddEventListener = EventTarget.prototype.addEventListener;
|
||||
EventTarget.prototype.addEventListener = function(type, listener, options) {
|
||||
// Only patch touchstart and touchmove if options is not explicitly passive
|
||||
if (
|
||||
(type === 'touchstart' || type === 'touchmove') &&
|
||||
(options === undefined || options === false || (typeof options === 'object' && !options.passive))
|
||||
) {
|
||||
options = options || {};
|
||||
if (typeof options === 'object') {
|
||||
options.passive = true;
|
||||
}
|
||||
var supportsPassive = false;
|
||||
try {
|
||||
var opts = Object.defineProperty({}, 'passive', {
|
||||
get: function() {
|
||||
supportsPassive = true;
|
||||
}
|
||||
return origAddEventListener.call(this, type, listener, options);
|
||||
};
|
||||
})();
|
||||
});
|
||||
window.addEventListener("testPassive", null, opts);
|
||||
window.removeEventListener("testPassive", null, opts);
|
||||
} catch (e) {}
|
||||
|
||||
if (!supportsPassive) return;
|
||||
|
||||
var origAddEventListener = EventTarget.prototype.addEventListener;
|
||||
EventTarget.prototype.addEventListener = function(type, listener, options) {
|
||||
// Only patch touchstart and touchmove if options is not explicitly passive
|
||||
if (
|
||||
(type === 'touchstart' || type === 'touchmove') &&
|
||||
(options === undefined || options === false || (typeof options === 'object' && !options.passive))
|
||||
) {
|
||||
options = options || {};
|
||||
if (typeof options === 'object') {
|
||||
options.passive = true;
|
||||
}
|
||||
}
|
||||
return origAddEventListener.call(this, type, listener, options);
|
||||
};
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user