How to put glide-arrows outside of glide-track - html

I`m trying to build a carousel/rondell with glide.js.
I want the left and right arrows to be displayed outside of the glide-track.
The carousel/rondell should be fully responsive.
Here is a picture of how it should be.
Can somebody help me with that?
Thank you!

You have to write the logic for arrows by yourself as Glide only looks for controls inside its root element.
Use a Glide API and the .go() method on previously queried HTML elements.
var nextButton = document.querySelector('#next');
var prevButton = document.querySelector('#prev');
var glide = new Glide('#glide');
nextButton.addEventListener('click', function (event) {
event.preventDefault();
glide.go('>');
})
prevButton.addEventListener('click', function (event) {
event.preventDefault();
glide.go('<');
})
glide.mount();
Visit Glide API documentation for more informations

You can now customize the buttons by CSS
let glide =new Glider(document.querySelector('.glider'), {
slidesToShow: 1,
dots: '#dots',
draggable: true,
});
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/glider-js#1/glider.min.css">
<script src="https://cdn.jsdelivr.net/npm/glider-js#1/glider.min.js"></script>
<div class="glider-contain">
<div class="glider">
<div>your first content here</div>
<div>your second content here</div>
<div>your third content here</div>
<div>your content here</div>
</div>
<button aria-label="Previous" onclick="glide.scrollItem(glide.slide-1)" >«</button>
<button aria-label="Next" onclick="glide.scrollItem(glide.slide+1)">»</button>
<div role="tablist" class="dots"></div>
</div>

Related

Creating some sort of SPA using Jquery

I'm trying to build an SPA using jquery. I have some html (nothing special).
I just have a menu and some divs. Depending on which menu item you click, a specific div should be displayed.
I can use .show() and .hide() and make use of id's and data-attributes.
But I was wondering if there are better ways to perform this kind of functionality.
I have simplified your code to the bone to show it easier
Since your ID on the triggers kind of matches your sub-menu, I have used them to target the content. You would put the code in doc ready.
$( "#" + this.id.replace("-tab", "-menu") ) this line simply uses the clicked ID and replaces the -tab with -menu. This is done to work with your current html
var $menu = $('#menu');
var $subMenu = $('.sub-menu');
$('.menu-item').on("click", function() {
$menu.hide();
$( "#" + this.id.replace("-tab", "-menu") ).show();
});
$('.back-btn').on( "click", function() {
// hide all sub-menu, no need to be specific
$subMenu.hide();
$menu.show();
});
.sub-menu {
display: none
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="container-fluid" id="menu">
<div id="weed-tab" class="menu-item">
<p class="menu-name">Wiet</p>
</div>
<div id="indica-tab" class="menu-item">
<p class="menu-name">Indica</p>
</div>
</div>
<div class="container-fluid sub-menu" id="weed-menu">weed
<div class="back-btn">
back
</div>
</div>
<div class="container-fluid sub-menu" id="indica-menu">indica
<div class="back-btn">
back
</div>
</div>

Bootstrap v2.3.2 menu changes size after opening/closing it

The goal its to have a menu activated by a button.
This menu can have any type of content inside, so it must adapt according to its content.
In this example i have an accordion, but could be just a grid, or a form, since i'm making it as a bootstrap/jquery widget.
The problem is that the menu changes size after opening and closing it several times.
How can i improve it to make it adaptable to content and consistent, regarding that it will accept different contents.
Code
http://jsfiddle.net/fpmsusm5/
Javascript:
var button = $('#button');
var dialog = $('#modal');
button.on('click', function () {
dialog.toggleClass('hide');
dialog.position({
my: "right top",
at: "right-2 bottom",
of: button
});
})
$("#openpanel1").on("click", function () {
var curr_panel = $("#panel1")
curr_panel.toggleClass('show hide');
curr_panel.collapse(curr_panel.hasClass('show') ? 'show' : 'hide');
});
...
/* ensure any open panels are closed before showing selected */
$('#accordion').on('show.bs.collapse', function () {
$('#accordion .in').collapse('hide');
});
HTML:
<div class="pull-right">
<a id="button" class="btn">Settings</a>
</div>
<div id="modal" class="modal hide" style="overflow- y:hidden;width:auto;height:auto;max-height:100%; max-width:100% ">
<div class="modal-body" style="overflow-y:hidden; width:auto; height:auto; max-height:100%; max-width:100%">
<div id="accordion">
<button id="openpanel1" type="button" class="btn" style="width:100%;text-align:left"><i
class="icon-search"></i>Page Information
</button>
<div id="panel1" class="collapse">
<div class="panel-body">
Contents panel 1
</div>
</div>
....
</div>
</div>
</div>
Thanks for your insights.
Every time you position the dialog, it's changing the left property, and that's causing it to resize.
You don't have to reposition it every time you show/hide it, you can just do it once:
var dialog = $('#modal');
dialog.position({
my: "right top",
at: "right-2 bottom",
of: button
});
button.on('click', function () {
dialog.toggleClass('hide');
});
Then it stays the same size. Updated fiddle: http://jsfiddle.net/fpmsusm5/1/

How do I make div a clickable link?

So, I'm having trouble trying to figure out how to make the 2 left divs (volunteer sign-up and Request a volunteer) on my home page be clickable links. I currently have them change color when you hover over them but how do I make them link to there appropriate page. Any help w
http://partners.sbceo.org
Wrap the div in an anchor tag.
<a href="your-link-here">
<div></div>
</a>
<div class="mydiv" data-href="http://stackoverflow.com"></div>
<script>
$('.mydiv').on('click', function(){
window.location = $(this).data('href');
})
</script>
this way you could use more than one clickable div
Give the div a class or other identifier. Then using jQuery do something like:
$('identifier').click(function(){
window.location = "your url";
});
None jQuery:
<div id="hello"></div>
function linkTo(url){
window.location = url;
}
el = document.getElementById('hello');
el.onclick = linkTo('some website');
i can't see the link but you can do this using Javascript:
<div style="cursor: pointer;" onclick="window.location='http://google.com/'">
</div>

mootools self reference

how can i handle a self-reference in mootools?
After i made the next container visible, i would remove the clicked "remove" Button.
With Jquery i can do it throug the "this" operator.
window.addEvent('domready', function(){
$$('div.showButton').addEvent('click', function(){
// show next Container
$$('div.container').getNext().show('inline');
// remove this "showButton"
$(this).remove() // not working
});
});
<!-- container 1 -->
<div class="container">
<div class="showButton">Show next container</div>
<div class="hideButton">hide this container</div>
</div>
<!-- container 2 -->
<div class="container" style="display:none">
<div class="showButton">Show next container</div>
<div class="hideButton">hide this container</div>
</div>
You have to remember mootools is not jquery and they different in the implementation of stuff.
First the $$ function return array of elements and not element so you can't call show on an array - you have to take the element you want (usually it's the first).
Second - you can call the current element using $(this) but it's a bit unnecessary because you are already inside the element event so you just can use "this":
http://jsfiddle.net/kk4gz/2/
$$('div.showButton').addEvent('click', function(){
// show next Container
$$('div.container')[0].getNext().show('inline');
// remove this "showButton"
this.remove();
});

How to select and toggle hide on children divs of selected element in Jquery

I'm quite new to Jquery and have a problem when I try to select child divs in my program. The point is to have a button that fires a jquery function. This function is meant to get all children divs from where the button is and hide them. Here is my jquery code:
$(".button").click(function () {
$(this).children('div').fadeToggle("fast", function () {
});
});
My html is quite simple. A div within a div and within the second div are two more divs.
<div class="clients>
<input type="button" class="button" id="button" value="Hide Sites" autopostback="false"/>
<div class="websites>
<div class="urls"></div>
<div class="data"></div>
</div>
</div>
This is not working though. I've tried using jquery.next and siblings but couldn't get these to work either. Jquery.closest looked upwards and found the container div (clients) but this wasn't what I needed either. Guys help? Thanks
You have broken html, closing quote missing here class="clients and here class="websites
and you have to use next() instead of children()
Live Demo
<div class="clients">
<input type="button" class="button" id="button" value="Hide Sites" autopostback="false"/>
<div class="websites">
<div class="urls">1</div>
<div class="data">2</div>
</div>
</div>​
$(".button").click(function () {
$(this).next('div').fadeToggle("fast", function () {
});
});
try this format
$('.clients').on('click', $('.button'), function(){
});
Solved it by using jquery.siblings:
$(".button").click(function () {
$(this).siblings('div').fadeToggle("fast", function () {
});
});
I had previously tried siblings but I guess I had an error because now its working.
Thank you all!