Flexslider change code - javascript

I use WordPress. Theme name Wp-tuts. My site: http://www.memuralimi.com.
I use the slider; Flexslider. When I click with the mouse, the images are changing.
I want that when the mouse comes over the thumbnail, the images change.
flexslider-home.js
jQuery(function($){
$(window).load(function() {
$('.featured-slider-preloader').hide();
$('#featured-slider').flexslider({
slideshow : true,
controlsContainer: "#featured-slider-wrap",
animation : 'fade',
pauseOnHover: true,
animationSpeed : 400,
smoothHeight : true,
directionNav: false,
prevText : '<span class="fa fa-angle-left"></span>',
nextText : '<span class="fa fa-angle-right"></span>',
controlNav : "thumbnails"
});
});
});
Content-featured-slider.php
<?php
$wpex_featured_cat = get_theme_mod( 'wpex_homepage_slider_cat' );
// Show homepage featured slider if theme panel category isn't blank
if( $wpex_featured_cat !== '' && $wpex_featured_cat !== '-1' ) {
// Get posts based on featured category
$wpex_query = new WP_Query( array(
'post_type' =>'post',
'posts_per_page' => get_theme_mod( 'wpex_homepage_slider_count', '6' ),
'no_found_rows' => true,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' => 'ID',
'terms' => $wpex_featured_cat
)
),
'meta_query' => array(
array(
'key' => '_thumbnail_id',
)
)
) );
if( $wpex_query->have_posts() ) {
// Get Scripts
wp_enqueue_script( 'flexslider', WPEX_JS_DIR_URI .'/flexslider.js', array( 'jquery' ), '', true );
wp_enqueue_script( 'wpex-flexslider-home', WPEX_JS_DIR_URI .'/flexslider-home.js', array( 'flexslider' ), '', true); ?>
<div id="featured-slider-wrap" class="boxed clr">
<div id="featured-slider" class="flexslider-container">
<div class="flexslider">
<ul class="slides">
<?php
// Loop through each post
while( $wpex_query->have_posts() ) : $wpex_query->the_post(); ?>
<li class="featured-slider-slide" data-thumb="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ), 490, 340, true ); ?>">
<div class="featured-slider-img">
<a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( the_title_attribute( 'echo=0' ) ); ?>">
<img src="<?php echo aq_resize( wp_get_attachment_url( get_post_thumbnail_id() ), '400', '225', true ); ?>" alt="<?php echo the_title(); ?>" />
</a>
</div><!-- .featured-slider-img -->
<div class="featured-slider-caption-excerpt clr">
</div><!-- .featured-slider-caption-excerpt -->
</article><!--.featured-slider-caption -->
</li><!-- .featured-slider-->
<?php endwhile; ?>
</ul><!--.slides -->
</div><!-- .flexslider -->
<span class="featured-slider-preloader"><i class="fa fa-spinner fa-spin"></i></span>
</div><!-- #featured-flexslider -->
</div><!-- #featured-slider-wrap -->
<?php } ?>
<?php wp_reset_postdata(); ?>
<?php } ?>

Related

how can I visualize the lightbox directly magnific popup

with wordpress i installed magnific popup, how can I view the popup directly, without the preview of the images? in the work I am doing I need that when I click on an image, the popup opens immediately! I have tried in a thousand ways but I cannot find the most suitable solution
I apologize for the delay, I have tried two methods, one is tied directly to the plugin so the code I have to make it work is the following:
(function ($) {
$('.gallery').each(function() {
$(this).magnificPopup({
delegate: 'a',
type: 'image',
gallery: {
enabled:true
}
});
});
}(jQuery));
it works but as previously said I would like you to be able to view the popup without the preview of the gallery!
the second option i used genesis custom block, the system works but can't find the images here is the code:
(function ($) {
$('a.btn-gallery').on('click', function(event) {
event.preventDefault();
var gallery = $(this).attr('href');
$(gallery).magnificPopup({
delegate: 'a',
type:'image',
gallery: {
enabled: true
}
}).magnificPopup('open');
});
}(jQuery));
.btn-gallery img{max-width: 100%;height: auto;padding: 30px;}
.hidden{overflow: hidden;display: none;visibility: hidden;}
<div class=" block-gallery <?php block_field('className'); ?>">
<div class="col-100 grid grid--center">
<div class="col-30">
<a href="#gallery-1" class="btn-gallery">
<?php $attachment_id = block_value( 'image-preview-1'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
</a>
</div>
</div>
<div id="gallery-1" class="hidden">
<a href="
<?php $attachment_id = block_value( 'image-1'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
<a href="
<?php $attachment_id = block_value( 'image-2'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
<a href="
<?php $attachment_id = block_value( 'image-3'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
<a href="
<?php $attachment_id = block_value( 'image-4'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
<a href="
<?php $attachment_id = block_value( 'image-5'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
<a href="
<?php $attachment_id = block_value( 'image-6'); ?>
<?php echo wp_get_attachment_image( $attachment_id, 'New_quad' );?>
"></a>
</div>
</div>
this is the function that calls the block on wordpress:
<?php
use function Genesis\CustomBlocks\add_block;
use function Genesis\CustomBlocks\add_field;
/* gallery */
function register_gallery_block() {
add_block( 'gallery', array( 'icon' => 'waves' ) );
add_field( 'gallery', 'image-preview-1', array(
'control' => 'image'
) );
//gallery-1
add_field( 'gallery', 'image-1', array(
'control' => 'image'
) );
add_field( 'gallery', 'image-2', array(
'control' => 'image'
) );
add_field( 'gallery', 'image-3', array(
'control' => 'image'
) );
add_field( 'gallery', 'image-4', array(
'control' => 'image'
) );
add_field( 'gallery', 'image-5', array(
'control' => 'image'
) );
add_field( 'gallery', 'image-6', array(
'control' => 'image'
) );
add_action( 'genesis_custom_blocks_add_blocks', 'register_gallery_block' );

how to properly replace a hover with off-canvas menu

I have a theme with two toggle menu options (standard and mobile with hover effect).I'm trying to replace the hover with an off-canvas menu solution taking in consideraion this described procedure.
After I've updated the css style code using the custom css field option, I've uploaded to the server and registered in script-calls.php(instead of calling in footer.php) classie.js and sidebarEffects.js files :
...
// Main Scripts
function register_js() {
if (!is_admin()) {
$url_prefix = is_ssl() ? 'https:' : 'http:';
// Register
wp_register_script('classie', THB_THEME_ROOT . '/assets/js/plugins/classie.js', 'jquery', null, TRUE);
wp_register_script('sidebarEffects', THB_THEME_ROOT . '/assets/js/plugins/sidebarEffects.js', 'jquery', null, TRUE);
// Enqueue
wp_enqueue_script('classie');
wp_enqueue_script('sidebarEffects');
wp_localize_script( 'app', 'themeajax', array( 'url' => admin_url( 'admin-ajax.php' ) ) );
}
}
...
The original theme mobile menu section in header.php looks like this:
...
<body <?php body_class($class); ?> data-url="<?php echo esc_url(home_url()); ?>" data-cart-count="<?php if($woocommerce) { echo $woocommerce->cart->cart_contents_count; } ?>" data-sharrreurl="<?php echo THB_THEME_ROOT; ?>/inc/sharrre.php">
<div id="wrapper" class="open">
<!-- Start Mobile Menu -->
<nav id="mobile-menu">
<div class="menu-container custom_scroll">
<div class="menu-holder">
<?php if ($page_menu) { ?>
<?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'mobile-menu sf-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else if(has_nav_menu('nav-menu')) { ?>
<?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'mobile-menu sf-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else { ?>
<ul class="mobile-menu">
<li>Please assign a menu from Appearance -> Menus</li>
</ul>
<?php } ?>
</div>
<div class="menu-footer">
<?php echo do_shortcode($menu_footer); ?>
<?php if (ot_get_option('menu_ls') == 'on') { do_action( 'thb_language_switcher' ); } ?>
</div>
</div>
<div class="spacer"></div>
</nav>
<!-- End Mobile Menu -->
<!-- Start Quick Cart -->
<?php do_action( 'thb_side_cart' ); ?>
<!-- End Quick Cart -->
<!-- Start Loader -->
<div class="preloader"></div>
<!-- End Loader -->
<!-- Start Header -->
<header class="header row no-padding <?php echo $header_style; ?>" data-equal=">.columns" role="banner">
<div class="small-7 medium-4 columns logo<?php if ($header_style == 'style1') { ?> show-for-large-up<?php } ?>">
<?php if ($header_style == 'style2') { ?>
<a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"
rel="home"><?php bloginfo( 'name' ); ?>
</a>
<?php } ?>
</div>
<?php if ($header_style != 'style2') { ?>
<div class="small-7 medium-4 columns logo">
<?php if ($header_style == 'style1') { ?>
<a class="logotext" href="<?php echo esc_url( home_url( '/' ) ); ?>"
title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>"
rel="home"><?php bloginfo( 'name' ); ?>
</a>
<?php } ?>
</div>
<?php } ?>
<div class="small-5 <?php if ($header_style == 'style2') { echo 'medium-8'; } else { echo 'medium-4';} ?> columns menu-holder">
<?php $full_menu_true = ($menu_mobile_toggle_view == 'style2' && $header_style == 'style2');?>
<?php if ($full_menu_true) { ?>
<nav id="full-menu" role="navigation">
<?php if ($page_menu) { ?>
<?php wp_nav_menu( array( 'menu' => $page_menu, 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else if(has_nav_menu('nav-menu')) { ?>
<?php wp_nav_menu( array( 'theme_location' => 'nav-menu', 'depth' => 2, 'container' => false, 'menu_class' => 'full-menu', 'walker' => new thb_mobileDropdown ) ); ?>
<?php } else { ?>
<ul class="full-menu">
<li>Please assign a menu from Appearance -> Menus</li>
</ul>
<?php } ?>
</nav>
<?php } ?>
<?php if ($header_search != 'off') { do_action( 'thb_quick_search' ); } ?>
<?php if ($header_cart != 'off') { do_action( 'thb_quick_cart' ); } ?>
<a href="#" data-target="open-menu" class="mobile-toggle<?php if (!$full_menu_true) { ?> always<?php } ?>">
<div>
<span></span><span></span><span></span>
</div>
</a>
</div>
</header>
<!-- End Header -->
...
(not so sure if it's ok), I've modified/replaced the above section with:
...
<body <?php body_class($class); ?> data-url="<?php echo esc_url(home_url()); ?>" data-cart-count="<?php if($woocommerce) { echo $woocommerce->cart->cart_contents_count; } ?>" data-sharrreurl="<?php echo THB_THEME_ROOT; ?>/inc/sharrre.php">
<div id="st-container" class="st-container">
<!-- content push wrapper -->
<div class="st-pusher">
<nav class="st-menu st-effect-1" id="menu-1">
<!-- sidebar content -->
</nav>
<div id="st-trigger-effects"><button data-effect="st-effect-3">Menu</button></div>
<div class="st-content"><!-- this is the wrapper for the content -->
<div class="st-content-inner"><!-- extra div for emulating position:fixed of the menu -->
<!-- Start Mobile Menu -->
<nav id="primary-navigation" class="st-menu st-effect-3" id="menu-3" role="navigation">
<h1 class="menu-toggle"><?php _e( 'Primary Menu', 'notio-wp' ); ?></h1>
<a class="screen-reader-text skip-link" href="#content"><?php _e( 'Skip to content', 'notio-wp' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary', 'menu_class' => 'nav-menu' ) ); ?>
</nav>
<!-- End Mobile Menu -->
...
Also in footer.php I've closed these divs:
...
</div><!-- /st-content-inner -->
</div><!-- /st-content -->
</div><!-- /st-pusher -->
</div><!-- /st-container -->
</body>
</html>
Unfortunately, my result is not functional.The final goal is to obtain the off-canvas menu effect on the right side as alternative to the hover menu, using the existing toggle menu option (between off-side and standard menu), also using the existing burger menu button (when off-canvas is activated). Any thoughts or any other solution with the same effect will be much appreciated.Thanks

I want to apply an external js file that will autohide my navigation bar

I want to apply a js I found here on stackoverflow to my navigation bar. This is aimed to autohide it after a moment of inactivity. But I dont know how to include and apply the code to my navigation bar.
This is how my html goes
<div class="basic-wrapper">
<a class="btn responsive-menu pull-right" data-toggle="collapse" data-target=".navbar-collapse">
<i class='icon-menu-1'></i>
</a>
<a class="navbar-brand" href="<?php echo home_url(); ?>">
<?php
if( get_option('custom_logo') ){
echo '<img src="'. get_option('custom_logo') .'" alt="" data-src="'. get_option('custom_logo') .'" data-ret="'. get_option('custom_logo_retina') .'" class="retina" />';
} else {
echo bloginfo('title');
echo '<br /><small>';
echo bloginfo('description');
echo '</small>';
}
?>
</a>
</div>
<div class="collapse navbar-collapse pull-right">
<?php
if ( has_nav_menu( 'primary' ) ){
wp_nav_menu(
array(
'theme_location' => 'primary',
'depth' => 3,
'container' => false,
'container_class' => false,
'menu_class' => 'nav navbar-nav',
'fallback_cb' => 'wp_bootstrap_navwalker::fallback',
'menu_id' => 'ebor-main-menu',
'walker' => new ebor_bootstrap_navwalker()
)
);
} else {
echo 'Set up a navigation menu now';
}
if( get_option("header_social_link_1") )
get_template_part('loop/loop','socialheader');
?>
</div>
</div><!--/.container-->
</div><!--/.nav-collapse -->
This is the code I found-
$("div").hide();
$("html").mousemove(function( event ) {
$("div").show();
myStopFunction();
myFunction();
});
function myFunction() {
myVar = setTimeout(function(){
$("div").hide();
}, 1000);
}
function myStopFunction() {
if(typeof myVar != 'undefined'){
clearTimeout(myVar);
}
}
If you are asign how to include an external javascript file, you need to do the following:
<script src="//path/to/external/js/file.js"></script>
As for the actual JS code, i dont think that will give you what you are looking for, as it will hide ALL DIVs on the page.
You'd want to replace that with something like. $("div#IDofMenuContatiner")...

Bootstrap off canvas to WordPress

I am trying to add bootstrap off canvas to wordpress page to be visible on xs devices, like this example
http://getbootstrap.com/examples/offcanvas/
My theme.js folder doesn't seems to be loaded in my wordpress page.
this is page.php code
<?php get_header(); ?>
<div class="container">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-md-9">
<p class="pull-right visible-xs">
<button type="button" class="btn btn-primary btn-xs offcanvas-control" data-toggle="offcanvas">Sidebar <span class="glyphicon glyphicon-resize-horizontal"></span></button>
</p>
<?php if( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="page-header">
<h1><?php the_title(); ?></h1>
</div>
<?php the_content(); ?>
<?php endwhile; else: ?>
<div class="page-header">
<h1>Oh no!</h1>
</div>
<p>No content is appearing for this page!</p>
<?php endif; ?>
</div>
<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>
this is sidebar.php
<div class="col-md-3 sidebar sidebar-offcanvas">
<?php if ( ! dynamic_sidebar( 'page' ) ): ?>
<h3>Widget Setup</h3>
<p>Please add widgets to the page widget to have them display here</p>
<?php endif; ?>
</div>
this is theme.js
jQuery(document).ready(function ( $ ) {
$('[data-toggle=offcanvas]').click(function () {
$('.row-offcanvas').toggleClass('active');
});
});
this is functions.php
// Load the Theme JS
function theme_js() {
global $wp_scripts;
wp_register_script( 'html5shiv', 'https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js', '', '', false );
wp_register_script( 'respond', 'https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js', '', '', false );
$wp_scripts->add_data( 'html5shiv', 'conditional', 'lt IE 9' );
$wp_scripts->add_data( 'respond', 'conditional', 'lt IE 9' );
wp_enqueue_script( 'bootstrap_js', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'), '', true );
wp_enqueue_script( 'theme_js', get_template_directory_uri() . '/js/theme.js', array('jquery','bootstrap_js'), '', true );
}
add_action( 'wp_enqueue_scripts', 'theme_js' );
Browser only loads this scripts
<script type='text/javascript' src='http://localhost:8888/wordpress/wp-includes/js/jquery/jquery.js?ver=1.11.0'></script>

Twitter Bootstrap Carousel doesn't auto-start

Bootstrap carousel used to work before but it's no longer working. I can't figure it out what I have done wrong now. I' am loading jQuery on my head and Javascript external files and bootstrap JS in the footer.
I want when the document is loaded / page is loaded the Carousel should auto start. I have tried few options but no luck.
$(function(){
$('.carousel').carousel({
interval: 2000
});
});
$(function(){
$('.carousel').carousel({
interval: 2000
});
$('.carousel-control.right').trigger('click');
});
This is the JavaScript which is loaded in the footer.
$("#homeCarousel .item:first").addClass("active");
$("#homeCarousel .carousel").carousel({interval: 100});
This the HTML
<div id="homeCarousel" class="carousel slide visible-lg">
<div id="CurrentDemandMeter">
<div class="graph"><?php require_once("snippets/home_current_deman_graph.php"); ?></div>
<div class="graphDeails">
<div class="our_current_demand_label">Our current demand</div>
<div class="what_is_this_label"><a class="what_is_this_link" href="#"></a></div>
</div>
</div>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php
$i=0;
$args = array('category_name' => 'homepage-carousel',);
$loop = new WP_Query($args);
while($loop->have_posts()): $loop->the_post();
$link = get_field("learn_more_link", $post->ID);
//$link = $meta_values[0];
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts( $args );
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
$attachment = wp_get_attachment_url( $attachment->ID, 'full' );
?>
<div class="item">
<div class="fill"><img src="<?php echo $attachment; ?>" class="img-responsive"/></div>
<div class="carousel-caption">
<h1><?php echo substr(the_title($before = '', $after = '...', FALSE), 0, 30); ?></h1>
<div class="excerpt"><?php echo the_excerpt(); ?></div>
</div>
</div>
<?php
}
}
endwhile;
wp_reset_query();
?>
</div>
</div>
I' ve managed to find the Answer for my Question. For some reason "data-ride="carousel" was missing from
<div id="homeCarousel" class="carousel slide visible-lg" data-ride="carousel">
Just a simple mistake...Cheers!

Categories