/* Js for Upload Page Header Images by Media uploader.*/ jQuery(document).ready(function($){ /* Js for Slider Addon */ var val = $("#fst_slider_type").val(); if(val == "image") { $("#postimagediv").show(); } if(val == "undefined") { $("#postimagediv").show(); } if(val == "") { $("#postimagediv").hide(); } /* JS for Customizer Font Icon Box */ $('.ap-customize-icons li').click(function(){ $(this).parents('.ap-customize-icons').find('li').removeClass(); $(this).addClass('selected'); var iconVal = $(this).parents('.icons-list-wrapper').find('li.selected').children('i').attr('class'); $(this).parents( '.ap-customize-icons' ).find('.ap-icon-value').val(iconVal); $(this).parents( '.ap-customize-icons' ).find('.selected-icon-preview').html(''); $('.fa-times').show(); $('.ap-icon-value').trigger('change'); }); $('.fa-times').click(function() { $(this).parents('.ap-customize-icons').find('li').removeClass(); $(this).removeClass('selected'); var iconVal = $(this).parents('.icons-list-wrapper').find('li.selected').children('i').attr('class'); $(this).parents( '.ap-customize-icons' ).find('.ap-icon-value').val(iconVal); $(this).parents( '.ap-customize-icons' ).find('.selected-icon-preview').html(''); $('.ap-icon-value').trigger('change'); }); /* Code for Search Customizer Font Icons */ $('.search_icon').keyup(function() { var search_keyword = $(this).val(); $( '.uk-iconnav li i.active' ).removeClass("active"); $( '.uk-iconnav li i' ).filter('[class^="fas fa-'+search_keyword+'"],[class^="far fa-'+search_keyword+'"],[class^="fab fa-'+search_keyword+'"]' ).addClass('active'); $( '.uk-iconnav li i' ).parent('li').hide(); $( '.uk-iconnav li i.active' ).parent('li').show(); }) /* End Font icons code */ /* For about us widget */ $(document).on("click", ".upload_image_button", function() { jQuery.data(document.body, 'prevElement', $(this).prev()); window.send_to_editor = function(html) { var imgurl = jQuery('img',html).attr('src'); var inputText = jQuery.data(document.body, 'prevElement'); if (inputText != undefined && inputText != '') { inputText.val(imgurl); } tb_remove(); }; tb_show('', 'media-upload.php?type=image&TB_iframe=true'); return false; }); /* For Hide/Show page header settings */ jQuery(document).on("change","#fst_page_header", function() { if ($(this).val() == 'no') { $(".header-cls").hide(); } else { $(".header-cls").show(); } }); var page_header = $("#fst_page_header").val(); if (page_header == 'no') { $(".header-cls").hide(); } else { $(".header-cls").show(); } }); /* Js for Slider Addon */ function fstSliderType(type) { if (type == 'image') { jQuery(".fst-img-div").show(); jQuery("#postimagediv").show(); jQuery(".fst-video-div").hide(); } else { jQuery(".fst-video-div").show(); jQuery(".fst-img-div").hide(); jQuery("#postimagediv").hide(); } } /* Js for Slider Addon */ function fstGetSource(source) { if (source == 'youtube') { jQuery(".source-url-cls").html("YouTube Id"); jQuery(".source-url-eg-cls").html("Please enter the YouTube Id eg : 30300114, Click here to see how to get code."); jQuery(".source-url-eg-cls").css("color","#ccc"); jQuery("#fst_video_id").val(""); } else if(source == 'vimeo') { jQuery(".source-url-cls").html("Vimeo Id"); jQuery(".source-url-eg-cls").html("Please enter the Vimeo Id eg : 30300114, Click here to see how to get code."); jQuery(".source-url-eg-cls").css("color","#ccc"); jQuery("#fst_video_id").val(""); } else { jQuery(".source-url-cls").html("Url"); jQuery(".source-url-eg-cls").html("Enter the Url e.g : https://quirksmode.org/html5/videos/big_buck_bunny.mp4"); jQuery("#fst_video_id").val(""); } } function mediaUploade(id) { var mediaUploader; // If the uploader object has already been created, reopen the dialog if (mediaUploader) { mediaUploader.open(); return; } // Extend the wp.media object mediaUploader = wp.media.frames.file_frame = wp.media({ title: 'Choose Image', button: { text: 'Choose Image' }, multiple: true }); // When a file is selected, grab the URL and set it as the text field's value mediaUploader.on('select', function() { var attachment = mediaUploader.state().get('selection').first().toJSON(); jQuery('#'+id).val(attachment.url); jQuery('#src_'+id).attr("src",attachment.url); }); // Open the uploader dialog mediaUploader.open(); } function RemoveMediaUploade(id) { jQuery('#'+id).val(''); jQuery('#src_'+id).attr("src",''); } /* * Select/Upload image(s) event */ /** Gallery Images JS **/ jQuery( document ).on( 'click', '#manage_gallery', upload_gallery_button ) .on( 'click', '#empty_gallery', empty_gallery_button ) .on( 'click', '.fst-gallery-item .remove', empty_single_image ); function upload_gallery_button(e) { var $this = jQuery( e.currentTarget ); e.preventDefault(); if ( ! $this.data( 'lockedAt' ) || + new Date() - $this.data( 'lockedAt' ) > 300) { // Doubleclick prevent. var $input_field = jQuery( '#mytheme_gallery_input' ); var ids = $input_field.val(); var gallerysc = '[gallery ids="' + ids + '"]'; wp.media.gallery.edit( gallerysc ).on('update', function(g) { var id_array = []; var url_array = []; jQuery.each(g.models, function(id, img){ url_array.push( img.attributes.url ); id_array.push( img.id ); }); var ids = id_array.join( "," ); ids = ids.replace( /,\s*$/, "" ); var urls = url_array.join( "," ); urls = urls.replace( /,\s*$/, "" ); $input_field.val( ids ); var html = ''; for (var i = 0 ; i < url_array.length; i++) { html += '