| 1 |
(function($){ |
| 2 |
let $imgFilter = $('#fieldhelperdiv .cf7sg_filter_taxonomy_images a.helper'); |
| 3 |
$imgFilter = $('#dynamic_checkbox-cf7sg-imagehdd, #dynamic_checkbox-cf7sg-imagegrid').siblings('.cf7sg-se-option').children('a').attr('data-cf7sghelp', $imgFilter.attr('data-cf72post')).addClass('helper'); |
| 4 |
//enable the filter helper code. |
| 5 |
$imgFilter.each(function(){ |
| 6 |
new Clipboard(this, { |
| 7 |
text: function(trigger) { |
| 8 |
let $target = $(trigger), |
| 9 |
text = $target.data('cf7sghelp'), |
| 10 |
key = $('#post_name').val(), //get post slug |
| 11 |
$form = $target.closest('.cf7sg-dynamic-list-tag-manager'), |
| 12 |
field = $('input.tg-name',$form).val(); |
| 13 |
text = text.replace(/\{\$form_key\}/gi, key); |
| 14 |
text = text.replace(/\{\$form_key_slug\}/gi, key.replace(/\-/g,'_')); |
| 15 |
text = text.replace(/\{\$field_name\}/gi, field); |
| 16 |
text = text.replace(/\{\$field_name_slug\}/gi, field.replace(/\-/g,'_')); |
| 17 |
text = text.replace(/\{\$field_type\}/gi, 'dynamic_checkbox'); |
| 18 |
text = text.replace(/\[dqt\]/gi, '"'); |
| 19 |
return text; |
| 20 |
} |
| 21 |
}) |
| 22 |
}) |
| 23 |
$('#dynamic-checkbox-tag-generator').change(':input',function(e){ |
| 24 |
let $target = $(e.target), |
| 25 |
$form = $(this), |
| 26 |
$l = $('#dynamic_checkbox-limit', $form).next('.max-selection'), //limit selection |
| 27 |
$t = $('#dynamic-checkbox-post-images', $form), //post thumbnails |
| 28 |
$style = $('input[name="dynamic_checkbox-style[]"]', $form),//styles. |
| 29 |
$source = $('input[name="sections"]', $form); //source of data |
| 30 |
|
| 31 |
switch(true){ |
| 32 |
case $target.is('.source-tab'): |
| 33 |
if($t.is(':checked')){ //post thumbnail option |
| 34 |
$t.prop('checked',false); |
| 35 |
$style.filter('#dynamic_checkbox-cf7sg-hybriddd, #dynamic_checkbox-cf7sg-treeview').attr('disabled',false); |
| 36 |
} |
| 37 |
$imgFilter.closest('.cf7sg-se-option').hide(); //hide all filters |
| 38 |
if($target.is('.taxonomy-tab') && ['cf7sg-imagehdd','cf7sg-imagegrid'].includes($style.filter(':checked').val())){ |
| 39 |
//shoe the image filter option. |
| 40 |
$style.filter(':checked').siblings('.cf7sg-se-option').show(); |
| 41 |
} |
| 42 |
break; |
| 43 |
case $target.is('#dynamic-checkbox-post-images'): |
| 44 |
if(e.target.checked){ |
| 45 |
switch($style.filter(':checked').val()){ |
| 46 |
case 'cf7sg-hybriddd': |
| 47 |
case 'cf7sg-treeview': |
| 48 |
$style.filter('#dynamic_checkbox-cf7sg-imagehdd').prop('checked',true); |
| 49 |
break; |
| 50 |
} |
| 51 |
} |
| 52 |
$style.filter('#dynamic_checkbox-cf7sg-hybriddd, #dynamic_checkbox-cf7sg-treeview').attr('disabled',e.target.checked); |
| 53 |
|
| 54 |
break; |
| 55 |
case $target.is('#dynamic_checkbox-limit'): //enable limit selection |
| 56 |
if(e.target.checked){ |
| 57 |
$l.prop('disabled',false); |
| 58 |
$l.next('input.data-attribute').val('maxcheck:'+$l.val()).trigger('change'); //hidden field |
| 59 |
} |
| 60 |
break; |
| 61 |
case $target.is('#dynamic_checkbox-nolimit'): //enable limit selection |
| 62 |
if(e.target.checked){ |
| 63 |
$l.next('input.data-attribute').val('').trigger('change'); //empty hidden field |
| 64 |
$l.prop('disabled',true); |
| 65 |
} |
| 66 |
break; |
| 67 |
case $target.is('.max-selection'): //update hidden value. |
| 68 |
$target.next('input.data-attribute').val('maxcheck:'+e.target.value).trigger('change'); |
| 69 |
break; |
| 70 |
case $target.is('.list-style'): |
| 71 |
if($source.filter(':checked').is('.taxonomy-tab')){ |
| 72 |
$target.siblings('.cf7sg-se-option').show(); //show the current one. |
| 73 |
} |
| 74 |
break; |
| 75 |
} |
| 76 |
}); |
| 77 |
})(jQuery); |
| 78 |
|