<?php
/**
 * Theme functions and definitions
 *
 * @package HelloElementorChild
 */

/**
 * Load child theme css and optional scripts
 *
 * @return void
 */
function hello_elementor_child_enqueue_scripts() {
	wp_enqueue_style(
		'hello-elementor-child-style',
		get_stylesheet_directory_uri() . '/style.css',
		[
			'hello-elementor-theme-style',
		],
		'1.0.0'
	);
}
add_action( 'wp_enqueue_scripts', 'hello_elementor_child_enqueue_scripts', 20 );

wp_enqueue_script( 'jquery' );

// Create Shortcode job_title_get
// Shortcode: [job_title_get]
function create_jobtitleget_shortcode($atts) {

	ob_start();

	$atts = shortcode_atts(
		array(
		),
		$atts,
		'job_title_get'
	);
	if ( $_GET['opportunity'] ) {
		echo $_GET['opportunity'];
	} else {
		echo 'false';
	}

	return ob_get_clean();
}
add_shortcode( 'job_title_get', 'create_jobtitleget_shortcode' );

// Create Shortcode js-team-slide
// Shortcode: [js-team-slide]
function create_jsteamslide_shortcode($atts) {

	$atts = shortcode_atts(
		array(
		),
		$atts,
		'js-team-slide'
	);

	?>
	<script type="text/javascript">
		jQuery(function($){
			$(".photo-button").click(function(){
				var slide = $(this).attr("slide-to-show");
				$(".swiper-pagination-bullet")[slide-1].click();
				
				//get old current member
				$(".current-member").removeClass("current-member");
				
				// add class to this
				$(this).addClass("current-member");
			});
			
			$(".elementor-swiper-button").click(function(){
			    var slide = $(".current-member").attr("slide-to-show");

			    // check orientation 
			    if ( $(this).attr("aria-label") == "Next slide" ) {
			        
			        var new_slide = parseInt(slide) + 1;
			        $("[slide-to-show=" + ( new_slide )  + "]").addClass("current-member");
			    } else if ( $(this).attr("aria-label") == "Previous slide" ) {
			        var new_slide = parseInt(slide) - 1;
			        $("[slide-to-show=" + ( new_slide )  + "]").addClass("current-member");
			    }
			    
			    $("[slide-to-show=" + ( slide )  + "]").removeClass("current-member");
			    
			});
		});

	</script>
	<?php

}
add_shortcode( 'js-team-slide', 'create_jsteamslide_shortcode' );

function custom_script() {
	?>
		<script type="text/javascript">
			jQuery(function($) {
				jQuery(document).ready(function( $ ){
				    $(".menu-item").click(function() {  //use a class, since your ID gets mangled
					    $(".hfe-nav-menu__layout-vertical").toggleClass("menu-is-active");      //add the class to the clicked element
					    $(".hfe-nav-menu-icon i").removeClass("fa-minus").addClass("fa-bars");
					    $(".hfe-nav-menu__toggle").toggleClass("hfe-active-menu hfe-active-menu-full-width"); 
					    $(".hfe-nav-menu__toggle").attr("aria-expanded","false");
					});
				});
			});
		</script>
	<?php
}
add_action( 'wp_footer', 'custom_script' );