( function( $, api ) { /* === Repeater Text Control === */ api.controlConstructor['webnotick-repeater-text'] = api.Control.extend({ ready: function() { 'use strict'; var control = this; control.initCustomControl(); }, initCustomControl: function() { 'use strict'; var control = this; control.populate(control); control.container.on( 'click', '.btn-add-field', control, function(event) { control.add(event); } ); control.container.on( 'change', '.repeater-text-single-field', control, function() { control.updateValue(); } ); control.container.on( 'click', '.btn-remove-field', control, function(event) { control.remove(event); control.updateValue(); } ); }, populate: function() { 'use strict'; var wrapper = this.selector; var multi_saved_value = jQuery(wrapper).find( '.repeater-text-value' ).val(); if ( multi_saved_value.length > 0 ) { var multi_saved_values = multi_saved_value.split( '|' ); jQuery(wrapper).find( '.repeater-text-fields' ).empty(); jQuery.each(multi_saved_values, function( i, value ) { jQuery(wrapper).find( '.repeater-text-fields' ).append( '
' ); }); } }, add: function(event) { 'use strict'; event.preventDefault(); jQuery(event.target).parent('.repeater-text-input').find('.repeater-text-fields').append( '
' ); }, remove: function(event) { 'use strict'; event.preventDefault(); jQuery(event.target).parent().parent().remove(); }, updateValue: function() { 'use strict'; var values = ''; var wrapper = this.selector; jQuery(wrapper).find( '.repeater-text-fields .repeater-text-single-field' ).each(function() { values += jQuery(this).val() + '|'; }); jQuery(wrapper).find( '.repeater-text-value' ).val( values.slice( 0, -1 ) ).change(); } }); // upsell api.sectionConstructor['webnotick-upsell'] = api.Section.extend( { // No events for this type of section. attachEvents: function () {}, // Always make the section active. isContextuallyActive: function () { return true; } } ); } )( jQuery, wp.customize ); /** * Custom Js for image select in customizer * * @package webnotick */ jQuery(document).ready(function($) { // Function to handle icon selection $('#webnotick-img-container img').click(function() { var item_id = $(this).parent().parent().parent().parent().attr('id'); $('#' + item_id).find('li').each(function() { $('#' + item_id).find('img').removeClass('webnotick-radio-img-selected') ; }); $(this).addClass('webnotick-radio-img-selected') ; }); // Adding icons list to the body $('body').prepend('
'); var icon_class; // Open icons list on click $('li[id^="customize-control-theme_options-featured_icon"]').click(function() { $('li[id^="customize-control-theme_options-featured_icon"]').removeClass('active'); $(this).addClass('active'); $('#icons-list-wrapper').addClass('active'); }); // Handle icon selection $('#icons-list-wrapper li').click(function() { icon_class = $(this).find('i').attr('class'); $('#icons-list-wrapper li').removeClass('active'); $(this).addClass('active'); }); // Save selected icon $('#icons-list-wrapper .save-icon').click(function() { $('#icons-list-wrapper').removeClass('active'); $('li[id^="customize-control-theme_options-featured_icon"].active input').val(icon_class).change(); }); // Close the icons list $('#icons-list-wrapper .close-button').click(function() { $('#icons-list-wrapper').removeClass('active'); $('#icons-list-wrapper li').removeClass('active'); $('li[id^="customize-control-theme_options-featured_icon"]').removeClass('active'); }); // Close the icons list when clicking outside of it $(document).click(function (e) { var container = $('.icons-list, li[id^="customize-control-theme_options-featured_icon"] input'); if (!container.is(e.target) && container.has(e.target).length === 0) { $('#icons-list-wrapper').removeClass('active'); $('#icons-list-wrapper li').removeClass('active'); $('li[id^="customize-control-theme_options-featured_icon"]').removeClass('active'); } }); // Close the icons list when pressing the Escape key $(document).keyup(function(e) { if (e.keyCode === 27) { $('#icons-list-wrapper').removeClass('active'); $('#icons-list-wrapper li').removeClass('active'); $('li[id^="customize-control-theme_options-featured_icon"]').removeClass('active'); } }); // Add the search functionality $('#myInput').on('keyup', function() { var value = $(this).val().toLowerCase(); $('#myUL li').filter(function() { var iconClass = $(this).find('i').attr('class').toLowerCase(); $(this).toggle(iconClass.indexOf(value) > -1); }); }); // IconPicker $('.icp-auto').iconpicker(); }); // /////////////////////