(function ($) { $(function () { $( '.apct-tabs-trigger' ).click(function(){ $( '.apct-tabs-trigger' ).removeClass( 'nav-tab-active' ); $(this).addClass( 'nav-tab-active' ); var board_id = 'tab-'+$(this).attr('id'); $('.apct-tab-contents').hide(); $('#'+board_id).show(); var board_class = $(this).attr('id'); if((board_class=="apct-about")||(board_class=="apct-shorcode")||(board_class=="apct-custom-settings")){$('.apct-setting-form').hide();} else{$('.apct-setting-form').show();} }); //Js For Media Uploader $('#apct_upload_image_button').click(function(e) { e.preventDefault(); var image = wp.media({ title: 'Upload Image', multiple: false }).open() .on('select', function(e){ var uploaded_image = image.state().get('selection').first(); console.log(uploaded_image); var image_url = uploaded_image.toJSON().url; $('#apct_upload_image_url').val(image_url); tb_remove(); }); }); //Show hide custom input field on radio button on setting option $('input[name="testim_display_num"]').bind('change',function(){ var showOrHide = ($(this).val() == 'custom') ? true : false; $('.custom-display-testim-num').toggle(showOrHide); }); //Generate color field $('.apct-color-field').wpColorPicker(); //Generate preview for typography $(".apct-font-select").change(function(){ var font_family = $( "#testimonial-google-font option:selected" ).val(); var replaced_font = font_family.replace(' ', '+'); if( font_family != 'default'){ $('#apct-font-family').append(""); $('#apct-font-family').css("font-family",font_family); }else{ $('#apct-font-family').css("font-family",''); } }); $("#testim_font_size").change(function() { font_size = $('#testim_font_size').val(); $('#apct-font-family').css("font-size",font_size); }); //display dynamic shorcode on jquery on generate shortcode button clicked $(".apct-shortcode-button").click(function(){ testim_type = $( "#testimonial-type option:selected" ).val(); testim_number = ($("input[name=testim_display_num]:checked").attr('id') == 'testim-all')?$("input[name=testim_display_num]:checked").val():$('#custom-display-testim-num').val(); show_title = ($("input[name=show_testim_title]").attr('checked'))?'show':'hide'; show_comp_detail = ($("input[name=show_testim_comp_name]").attr('checked'))?'show':'hide'; testim_rating_pos = $("input[name=testim_rating_pos]:checked").val(); rating_type = ($("input[name=testim_rating_type]").attr('checked'))?'star':'num'; testim_orderby = $("#testim_order_by_iand option:selected" ).val(); testim_ordertype = $("#testim_order_by_ascdsc option:selected" ).val(); show_date = ($("input[name=testim_publication_date]").attr('checked'))?'show':'hide'; show_image = ($("input[name=testim_featured_image]").attr('checked'))?'show':'hide'; $( "#apct-generated-shortcode" ).html( "[ap_custom_testimonial  " + "type='" + testim_type + "' " +"display_num='" + testim_number + "' " +"title='" + show_title + "' " +"comp_detail='" + show_comp_detail + "' " +"rating='" + testim_rating_pos + "' " +"rating_type='" + rating_type + "' " +"order_by='" + testim_orderby + "' " +"order_type='" + testim_ordertype + "' " +"date='" + show_date + "' " +"image='" + show_image + "']" ); }); /** Backend Js for Popup to display full detail about Testimonial */ $('.testinomial-view-entry > a').click(function(e) { var entry_id = $(this).data('entry-id'); $.ajax({ url: apct_backend_js_params.ajax_url, data: { entry_id: entry_id, _wpnonce: apct_backend_js_params.ajax_nonce, action: 'apct_testimonial_view_actions' }, type: 'post', beforeSend: function () { $('#boxes').fadeIn(300, function () { $('.apct-view-wrap').show(); $('.apct-overlay').show(); }); }, success: function (res) { $('.apct-view-wrap').hide(); $('#boxes').html(res); } }); /** Entry Popup Close */ $(document).mouseup(function (e) { var popup = $(".boxes"); if (!$('.boxes').is(e.target) && !popup.is(e.target) && popup.has(e.target).length == 0) { popup.fadeOut(100); $('.boxes').html(''); $('.apct-overlay').fadeOut(100); } }); $('body').on('click','.apct-popup-close', function () { $('.boxes').fadeOut(100, function () { $('.loading').html(''); $('.boxes').html(''); }); $('.boxes').fadeOut(100); $('.apct-overlay').fadeOut(100); }); }); /** restrict alphabetical input for input field */ $('.apct_restrict').keydown(function(event) { // Allow special chars + arrows if (event.keyCode == 46 || event.keyCode == 8 || event.keyCode == 9 || event.keyCode == 27 || event.keyCode == 13 || (event.keyCode == 65 && event.ctrlKey === true) || (event.keyCode >= 35 && event.keyCode <= 39)){ return; }else { // If it's not a number stop the keypress if (event.shiftKey || (event.keyCode < 48 || event.keyCode > 57) && (event.keyCode < 96 || event.keyCode > 105 )) { event.preventDefault(); } } }); /** Add Scroll to Top */ $(window).scroll(function(){ if ($(this).scrollTop() > 100) { $('.apct-scrollToTop').fadeIn(); } else { $('.apct-scrollToTop').fadeOut(); } }); $('.apct-scrollToTop').click(function(){ $('html, body').animate({scrollTop : 0},400); return false; }); }); }(jQuery));