jQuery(document).ready(function($) { const cats = []; var ccat; var ccat1; var scat; function Ashlar_CheckValue(value,arr){ var status = 'hasnot'; for(var i=0; i'); $(this).closest('.ashlar-repeater-field-control').find('.customizer-color-picker').wpColorPicker({ defaultColor: '#d0021b', change: function(event, ui){ setTimeout(function(){ ashlar_refresh_repeater_values(); }, 100); } }).parents('.customizer-type-colorpicker').find('.wp-color-result').first().remove(); $(this).closest('.ashlar-repeater-field-control').find('.old-one').remove(); } }); var cats2 = ''; $('.ashlar-custom-cat-color').each(function(){ cats2 = $(this).find('select option:selected').val(); if(cats2) { return false; // breaks } }); if( cats2 ){ // Category Color Code Start field.val(cats2).find("select option[value=" + cats2 +"]").remove(); } field.find('.ashlar-custom-cat-color select').change(function(){ optionSelected1 = $("option:selected", this); var ckey1 = optionSelected1.val(); $(this).val(ckey1).find("option[value=" + ckey1 +"]").attr('selected', true); Ashlar_Current_select(ckey1); }); // Category Color Code end } return false; }); $('.ashlar-repeater-field-control .title-rep-wrap').click(function(){ $(this).next('.ashlar-repeater-fields').slideToggle().toggleClass('extended'); }); //MultiCheck box Control JS $( 'body' ).on( 'change', '.ashlar-type-multicategory input[type="checkbox"]' , function() { var checkbox_values = $( this ).parents( '.ashlar-type-multicategory' ).find( 'input[type="checkbox"]:checked' ).map(function(){ return $( this ).val(); }).get().join( ',' ); $( this ).parents( '.ashlar-type-multicategory' ).find( 'input[type="hidden"]' ).val( checkbox_values ).trigger( 'change' ); ashlar_refresh_repeater_values(); }); $('body').on('change','.ashlar-type-radio input[type="radio"]', function(){ var $this = $(this); $this.parent('label').siblings('label').find('input[type="radio"]').prop('checked',false); var value = $this.closest('.radio-labels').find('input[type="radio"]:checked').val(); $this.closest('.radio-labels').next('input').val(value).trigger('change'); }); //Checkbox Multiple Control $( '.customize-control-checkbox-multiple input[type="checkbox"]' ).on( 'change', function() { checkbox_values = $( this ).parents( '.customize-control' ).find( 'input[type="checkbox"]:checked' ).map( function() { return this.value; } ).get().join( ',' ); $( this ).parents( '.customize-control' ).find( 'input[type="hidden"]' ).val( checkbox_values ).trigger( 'change' ); }); $('.customizer-color-picker').each(function(){ $(this).wpColorPicker({ defaultColor: '#d0021b', change: function(event, ui){ setTimeout(function(){ ashlar_refresh_repeater_values(); }, 100); } }).parents('.customizer-type-colorpicker').find('.wp-color-result').first().remove(); }); // ADD IMAGE LINK $('.customize-control-repeater').on( 'click', '.theme-custom-upload-button', function( event ){ event.preventDefault(); var imgContainer = $(this).closest('.theme-attachment-panel').find( '.thumbnail-image'), placeholder = $(this).closest('.theme-attachment-panel').find( '.placeholder'), imgIdInput = $(this).siblings('.upload-id'); // Create a new media frame frame = wp.media({ title: ashlar_repeater.upload_image, button: { text: ashlar_repeater.use_image }, multiple: false // Set to true to allow multiple files to be selected }); // When an image is selected in the media frame... frame.on( 'select', function() { // Get media attachment details from the frame state var attachment = frame.state().get('selection').first().toJSON(); // Send the attachment URL to our custom image input field. imgContainer.html( '' ); placeholder.addClass('hidden'); // Send the attachment id to our hidden input imgIdInput.val( attachment.url ).trigger('change'); }); // Finally, open the modal on click frame.open(); }); // DELETE IMAGE LINK $('.customize-control-repeater').on( 'click', '.theme-image-delete', function( event ){ event.preventDefault(); var imgContainer = $(this).closest('.theme-attachment-panel').find( '.thumbnail-image'), placeholder = $(this).closest('.theme-attachment-panel').find( '.placeholder'), imgIdInput = $(this).siblings('.upload-id'); // Clear out the preview image imgContainer.find('img').remove(); placeholder.removeClass('hidden'); // Delete the image id from the hidden input imgIdInput.val( '' ).trigger('change'); }); $("#customize-theme-controls").on("click", ".ashlar-repeater-field-remove",function(){ if( typeof $(this).parent() != 'undefined'){ $(this).closest('.ashlar-repeater-field-control').slideUp('normal', function(){ $(this).remove(); ashlar_refresh_repeater_values(); }); } return false; }); $('.wp-picker-clear').click(function(){ ashlar_refresh_repeater_values(); }); $('#customize-theme-controls').on('click', '.ashlar-repeater-field-close', function(){ $(this).closest('.ashlar-repeater-fields').slideUp(); $(this).closest('.ashlar-repeater-field-control').toggleClass('expanded'); }); /*Drag and drop to change order*/ $(".ashlar-repeater-field-control-wrap").sortable({ axis: 'y', orientation: "vertical", update: function( event, ui ) { ashlar_refresh_repeater_values(); } }); $("#customize-theme-controls").on('keyup change', '[data-name]',function(){ ashlar_refresh_repeater_values(); return false; }); $("#customize-theme-controls").on('change', 'input[type="checkbox"][data-name]',function(){ if($(this).is(":checked")){ $(this).val('yes'); }else{ $(this).val('no'); } ashlar_refresh_repeater_values(); return false; }); });