pagerAnchorBuilder - trying to add classes - jquery-cycle

I'm using Cycle2 to build a carousel gallery and I've run into a little problem regarding styling the pager buttons. What I've gathered is that Cycle2 creates its own pager span tags for each slide which is a bummer becaus I've already styled my the sub-nav markup. This should be a minor issue as long as I can assign individual classes to the spans and change my css accordingly.
However, I can't get this to work.
TLDR: I was hoping that I could use pagerAnchorBuilder to create individual classes for each span. I can't. Help.
The original markup (pre Cycle2) looks like the following:
<div id ="sub-nav" class="sub-nav">
<ul>
<li><a id="available" class="available" href="#"></a></li>
<li><a id="reliable" class="reliable" href="#"></a></li>
<li><a id="use" class="use" href="#"></a></li>
<li><a id="reports" class="reports" href="#"></a></li>
<li class="last"><a id="software" class="software" href="#"></a></li>
</ul>
</div>
<div id="sliding-gallery" class="sliding-gallery home-content">
<ul>
<li>
<img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg">
<section>
<h2>Lorem ipsum dolor</h2>
<p>Sed augue lacus pretium vitae molestie eget rhoncus quis elit. Fusce orci wisi vel ipsum in p</p>
Read More
</section>
</li>
<li>
<img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg">
<section>
<h2>Lorem ipsum dolor</h2>
<p>Sed augue lacus pretium vitae molestie eget rhoncus quis elit. Fusce orci wisi vel ipsum in p</p>
Read More
</section>
</li>
</ul>
<span id="#prev" class="prev">Previous</span>
<span id="#next" class="next">Next</span>
</div>
With Cycle2 it looks like this (note the addition of the span tags)
<div id ="sub-nav" class="sub-nav">
<ul>
<li><a id="available" class="available" href="#"></a></li>
<li><a id="reliable" class="reliable" href="#"></a></li>
<li><a id="use" class="use" href="#"></a></li>
<li><a id="reports" class="reports" href="#"></a></li>
<li class="last"><a id="software" class="software" href="#"></a></li>
</ul>
<span class="cycle-pager-active">•</span><span>•</span><span>•</span><span>•</span><span>•</span></nav>
</div>
<div id="sliding-gallery" class="sliding-gallery home-content">
<ul>
<li>
<img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg">
<section>
<h2>Lorem ipsum dolor</h2>
<p>Sed augue lacus pretium vitae molestie eget rhoncus quis elit. Fusce orci wisi vel ipsum in p</p>
Read More
</section>
</li>
<li>
<img src="http://cloud.github.com/downloads/malsup/cycle/beach1.jpg">
<section>
<h2>Lorem ipsum dolor</h2>
<p>Sed augue lacus pretium vitae molestie eget rhoncus quis elit. Fusce orci wisi vel ipsum in p</p>
Read More
</section>
</li>
</ul>
<span id="#prev" class="prev">Previous</span>
<span id="#next" class="next">Next</span>
</div>
Cycle2
$('#sliding-gallery ul').cycle({
fx: 'carousel',
carouselVisible: 1,
speed: 'fast',
timeout: 10000,
slides: '>li',
next: '.next',
prev: '.prev',
pager: '.sub-nav',
pagerAnchorBuilder: function(idx, slide) {
return '.sub-nav span:eq(' + idx + ')';
}
});

I hope you are looking for something similar to this demo
jQuery(document).ready(function($){
var slideshows = $('.cycle-slideshow').on('cycle-next cycle-prev', function(e, opts) {
// advance the other slideshow
slideshows.not(this).cycle('goto', opts.currSlide);
});
$('#cycle-2 .cycle-slide').click(function(){
var index = $('#cycle-2').data('cycle.API').getSlideIndex(this);
slideshows.cycle('goto', index);
});
});
also you can find the above fiddle code on cycle2 website
can you provide your fiddle for this?

Related

How can I use two Auto Scaling Image Annotation in same page

I will try two scalize id however only one more worked. Every time second scalize function worked. How can I use one more scalize in one page. I want use scalize in repater.
I will try two scalize id however only one more worked. Every time second scalize function worked. How can I use one more scalize in one page. I want use scalize in repater.
`
<div class="scalize" id="scalize2">
<!-- Start Popover Template -->
<div id="content6" class="content center top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">4</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content4" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">5</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content5" class="content right bottom">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">6</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
</div>
</div>
<!-- End Popover Template -->
<img src="img/deneme.jpg" alt="" class="target">
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="121" data-left="922" data-popover="#content4">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="333" data-left="462" data-popover="#content5">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point2" data-top="444" data-left="546" data-popover="#content6">
<div></div>
</div>
<!-- End Item Point -->
</div>
<div class="scalize" id="scalize3">
<!-- Start Popover Template -->
<div id="content1" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">1</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content3" class="content right top">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">2</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
</div>
</div>
<div id="content2" class="content right bottom">
<div class="head">
<img src="img/close.png" alt="" />
<h6 class="title">3</h6>
</div>
<div class="body">
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
<p>Mel ad euismod adipiscing moderatius eos an decore quodsi animal.</p>
<p>Lorem ipsum dolor sit amet, ne est populo dictas, et pri ferri ubique labitur.</p>
</div>
</div>
<!-- End Popover Template -->
<img src="img/2.jpg" alt="" class="target">
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="320" data-left="922" data-popover="#content1">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="180" data-left="462" data-popover="#content3">
<div></div>
</div>
<!-- End Item Point -->
<!-- Start Item Point -->
<div class="item-point item-point3" data-top="192" data-left="546" data-popover="#content2">
<div></div>
</div>
<!-- End Item Point -->
</div>
<script type="text/javascript">
$(document).ready(function () {
$('#scalize2').scalize({
styleSelector: 'circle',
animationPopoverIn: 'fadeIn',
animationPopoverOut: 'fadeOut',
animationSelector: 'pulse2',
selector: '.item-point2',
getSelectorElement: function (el) {
$('.item-point2 .active').not($(el)[0]).find('.toggle2').click();
}
});
$('#scalize3').scalize({
styleSelector: 'circle',
animationPopoverIn: 'fadeIn',
animationPopoverOut: 'fadeOut',
animationSelector: 'pulse2',
selector: '.item-point3',
getSelectorElement: function (el) {
$('.item-point3 .active').not($(el)[0]).find('.toggle3').click();
}
});
});
</script>
`

Bootstrap Accordion button is not working properly

I am trying to make an accordion using bootstrap 5. Everything is okay but the expand button is not working. If Accordion1 is expanded then I can't expand other Accordion.
My code is given below:
<div className="accordion " id="accordionPanelsStayOpenExample">
<div className="accordion-item">
<h2 className="accordion-header" id="panelsStayOpen-headingOne">
<button className="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
Accordion Item #1
</button>
</h2>
<div id="panelsStayOpen-collapseOne" className="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
<div className="accordion-body">
<strong>Lorem ipsum dolor sit amet consectetur adipisicing elit. Cum voluptatum accusantium voluptates, quaerat voluptas tempore ut tempora, qui suscipit error veritatis. Voluptatem deserunt ipsa non optio! Ipsam deleniti maxime pariatur.</strong>
</div>
</div>
</div>
<div className="accordion-item">
<h2 className="accordion-header" id="panelsStayOpen-headingTwo">
<button className="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseTwo" aria-expanded="false" aria-controls="panelsStayOpen-collapseTwo">
Accordion Item #2
</button>
</h2>
<div id="panelsStayOpen-collapseTwo" className="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingTwo">
<div className="accordion-body">
<strong>This is the second item's accordion Lorem ipsum dolor sit amet consectetur adipisicing elit. Odit aliquid dolor beatae alias quas culpa reiciendis expedita deserunt sint quidem.</strong>
</div>
</div>
</div>
<div className="accordion-item">
<h2 className="accordion-header" id="panelsStayOpen-headingThree">
<button className="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseThree" aria-expanded="false" aria-controls="panelsStayOpen-collapseThree">
Accordion Item #3
</button>
</h2>
<div id="panelsStayOpen-collapseThree" className="accordion-collapse collapse" aria-labelledby="panelsStayOpen-headingThree">
<div className="accordion-body">
It is hidden by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the , though the transition does limit overflow.
</div>
</div>
</div>
</div>
I think I am making something wrong. If anyone show me the mistake, I will be very happy.

displaying posts in laravel

I have a carousel slider to display posts. I want to display latest 3 posts and then on next slide other 3 posts which are in row. So for example 9,8,7 -> 6,5,4 -> 3,2,1 But i dont know how to take latest 3 on active and then display other 3 posts in row.
Controller:
$posts = Post::all();
Carousel:
<section class="news">
<h1 class="section-heading text-highlight"><span class="line">Novinky</span></h1>
<div class="carousel-controls">
<a class="prev" href="#news-carousel" data-slide="prev"><i class="fas fa-caret-left"></i></a>
<a class="next" href="#news-carousel" data-slide="next"><i class="fas fa-caret-right"></i></a>
</div><!--//carousel-controls-->
<div class="section-content clearfix">
<div id="news-carousel" class="news-carousel carousel slide">
<div class="carousel-inner">
<div class="item carousel-item active">
<div class="row">
#foreach($posts->take(3) as $post) // Taking 3 posts but not latest
<div class="col-lg-4 col-12 news-item">
<h2 class="title">{{ $post->title }}</h2>
<img class="thumb" src="{{ Storage::disk('public')->url('post/'.$post->image) }}" alt="{{ $post->title }}" />
<p>Suspendisse purus felis, porttitor quis sollicitudin sit amet, elementum et tortor. Praesent lacinia magna in malesuada vestibulum. Pellentesque urna libero.</p>
<a class="read-more" href="news-single.html">Číst více<i class="fas fa-chevron-right"></i></a>
asd
</div><!--//news-item-->
#endforeach
</div><!--//row-->
</div><!--//item-->
<div class="item carousel-item">
<div class="row">
#foreach($posts->take(3) as $post) // Taking the same 3 posts :/
<div class="col-lg-4 col-12 news-item">
<h2 class="title">{{ $post->title }}</h2>
<img class="thumb" src="{{ Storage::disk('public')->url('post/'.$post->image) }}" alt="{{ $post->title }}" />
<p>Suspendisse purus felis, porttitor quis sollicitudin sit amet, elementum et tortor. Praesent lacinia magna in malesuada vestibulum. Pellentesque urna libero.</p>
<a class="read-more" href="news-single.html">Číst více<i class="fas fa-chevron-right"></i></a>
</div><!--//news-item-->
#endforeach
</div><!--//row-->
</div><!--//item-->
</div><!--//carousel-inner-->
</div><!--//news-carousel-->
</div><!--//section-content-->
</section><!--//news-->
Image:
Active slide:
Next slide
first order them by created at like this:
$posts = Post::orderByDesc('created_at')->get();
then use chunk method in laravel collections to do that like this:
#foreach ($posts->chunk(3) as $key => $chunk)
<div class="item carousel-item {{ $key == 0 ? 'active' : ''}}">
<div class="row">
#foreach($chunk as $post)
<div class="col-lg-4 col-12 news-item">
<h2 class="title">{{ $post->title }}</h2>
<img class="thumb" src="{{ Storage::disk('public')->url('post/'.$post->image) }}" alt="{{ $post->title }}" />
<p>Suspendisse purus felis, porttitor quis sollicitudin sit amet, elementum et tortor. Praesent lacinia magna in malesuada vestibulum. Pellentesque urna libero.</p>
<a class="read-more" href="news-single.html">Číst více<i class="fas fa-chevron-right"></i></a>
asd
</div><!--//news-item-->
#endforeach
</div><!--//row-->
</div><!--//item-->
#endforeach
this method separates collections to parts that you want like this:
$collection = collect([1, 2, 3, 4, 5, 6, 7]);
$chunks = $collection->chunk(4);
$chunks->toArray();
// [[1, 2, 3, 4], [5, 6, 7]]
$posts = Post::orderBy('created_at', 'desc')->get();

How can I add a click handler in Vue used in Laravel?

In my Laravel application, I have made a component in Vue. The component itself is rendering properly, but the click handler is not firing. I have read many articles on the issue, but can't find the solution.(https://prnt.sc/tyiwmh + https://prnt.sc/tyiwwb + https://prnt.sc/tyix8l)
<template>
<div class="item border rounded-lg p-3">
<header>
<h2 class="mb-3">John Doe</h2>
<div class="arrows" v-on:click="showContent">
<img src="storage/img/chevron-down-light.svg" alt="" class="arrow-down">
<img src="storage/img/chevron-up-light.svg" alt="" class="arrow-up">
</div>
</header>
<div class="item-content" v-if="visible">
<div class="content-1">
<ul>
<li><b>Email:</b> john.doe#hotmail.com</li>
<li><b>Tel:</b> 0497 99 88 77</li>
</ul>
</div>
<hr>
<div class="content-2">
<ul>
<li><b>Vertrekplaats:</b> Ark van Noë</li>
<li><b>Aankomstplaats:</b> Watermolen Grobbendonk</li>
</ul>
</div>
<hr>
<div class="content-3">
<ul>
<li>2 enkelzitkajaks</li>
<li>3 dubbelzitkajaks</li>
<li>0 canadese kano's</li>
<li>2 zwemvesten</li>
<li>3 tonnetjes</li>
</ul>
</div>
<hr>
<div class="content-4">
<h3>Extra info:</h3>
<p>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Incidunt fuga dignissimos hic? Velit, ea aliquam! Consequuntur provident vitae, hic repudiandae, animi, ipsa ullam quidem accusamus vero ipsum aut porro nostrum.
</p>
</div>
</div>
</div>
</template>
<script>
export default {
data: function() {
return {
visible: false
}
},
methods: {
showContent: function() {
console.log('the button is clicked');
}
}
}
</script>
This might help no method necessary:
<div class="arrows" #click="visisble = !visible">
<img #click="visisble = !visible"
:src="'storage/img/chevron-' + (visible ? 'down-light.svg':'up-light.svg')"
alt=""
:class="'arrow-' + (visible ? 'down' : 'up' )">
</div>

asp.net mvc 4 tabs

I'm working on a project with Visual Studio 2010 ASP.Net MVC4 (engine view Razor) and need to make a tabs.
I define this scrips and css:
<link href="#Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.7.1.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-ui-1.8.20.min.js")" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$("#tabs").tabs();
});
</script>
It also defines the format html for the tabs:
<div id="tabs"> .....
but when excecute don't showme the tabs, how I can solve this problem. only showme format html, this:
Index
Tab Header 1
Tab Header 2
Tab Header 3
Content for Tab 1 goes here.
Content for Tab 2 goes here.
Content for Tab 3 goes here.
Here is a jsfiddle for Jquery Tabs.
Step 1: Import
<link href="#Url.Content("~/Content/themes/base/jquery-ui.css")" rel="stylesheet" type="text/css" />
<script src="#Url.Content("~/Scripts/jquery-1.4.4.min.js")" type="text/javascript"></script>
<script src="#Url.Content("~/Scripts/jquery-ui-1.8.24.min.js")" type="text/javascript"></script>
Step 2: Html Code
In the ‘li’ tags you need to define the tab header and for each tab header a tab content div exists, the code below is pretty self explanatory.
<div id="tabs">
<ul>
<li>Tab Header 1</li>
<li>Tab Header 2</li>
<li>Tab Header 3</li>
</ul>
<div id="tabs-1">
Content for Tab 1 goes here.<br/>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
<div id="tabs-2">
Content for Tab 2 goes here.<br/>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
<div id="tabs-3">
Content for Tab 3 goes here.<br/>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
</div>
Step 3: Final Touch – Jquery call to tabs()
<script type="text/javascript">
$(function () {
$("#tabs").tabs();
});
</script>
Output:
Source
If you work with ASP.net MVC4 then config _Layout.cshtml
add this lines into Head html
#Styles.Render("~/Content/css")
#Styles.Render("~/Content/themes/base/css")
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/jqueryui")
#Scripts.Render("~/bundles/modernizr")
and delete from body (html) this line
#Scripts.Render("~/bundles/jquery")
and execute the program and show the tabs
Bootstrap 3.x solution:
<ul class="nav nav-tabs">
<li class="active">
Tab Header 1
</li>
<li>
Tab Header 2
</li>
<li>
Tab Header 3
</li>
</ul>
<div class="tab-content">
<div class="tab-pane fade active" id="tab_1">
<p>Content for Tab 1 goes here.</p>
</div>
<div class="tab-pane fade" id="tab_2">
<p>Content for Tab 2 goes here.</p>
</div>
<div class="tab-pane fade" id="tab_3">
<p>Content for Tab 3 goes here.</p>
</div>
</div>
Just to add Bootstrap 3.x solution.
I encountered a problem using
class="tab-pane fade active" id="tab_1", the entries in tab_1 will not display upon page load.
Instead, I removed fade in the tab_1 (see below)
<div class="tab-pane active" id="tab_1">
<p>Content for Tab 1 goes here.</p>
</div>
or replace it with class="tab-pane fade active in"
It worked for me.

Resources