Sticky close button for foundation 6 reveal - zurb-foundation

Problem: when Reveal data is taller than window height, scrolling moves the close icon off the page. I want to make it sticky so that you always have the option of closing the page without scrolling back up to the top.
I have tried loading the foundation 6 .sticky example into the reveal, but none of my attempts have been successful.
This is what I think should work, which is loaded into the reveal container <div id="modal2" style="height: 100%"></div> via ajax. Unfortunately, the close button just scrolls with the content.
<script>
// this script cannot be located in the layouts.js,
// because the trigger doesn't exist at page load.
$('#close-modal2').click(function(){
// $('#modal2').foundation('close'); didn't work for some reason.
// 'open' closes all other modals, so it accomplishes what I need.
$('#modal').foundation('open');
});
</script>
<div>
<button id="close-modal2" class="close-button sticky"
aria-label="Close reveal" type="button" data-sticky>
<span aria-hidden="true">×</span>
</button>
</div>
<div id="paragraph-wrapper" data-sticky-container>
<div class="row">
<div class="small-11 small-centered columns">
<div> Lots of content here, enough to overflow window...</div>
<div> Losts of content here..... etc.</div>
</div>
</div>
</div>
Am I missing something? Has anyone else been able to get a sticky close button in a reveal?

The basic behaviour of the Reveal is to close if the user clicks outside of the reveal container, so a user does already have a quick way of exiting the reveal.
However, you could also use position: fixed; on the close element.
That would keep it in the same spot while the modal scrolled up and down.
CSS
#modal2 > .close-button {
position: fixed;
top: 1rem; //or whatever
right: 2rem; //or whatever
}
e.g. in a Fiddle
Using position: fixed; is a bit of a pain for styling and mobiles but that will be depending on your particular design.

Related

creating an if statement to look for specific button press

first time poster! I'm still fairly new to coding and Django...
I'm looking to create a django if statement to see if a certain button is pressed. I have a toast set up to show an error warning if a search returns no results, but it also pops up if the user clears the search.
Here's the button(s)
<div class="input-group-append">
<button class="form-control rounded-circle btn form-button ml-2" type="submit">
<span>
<i class="fas fa-search"></i>
</span>
</button>
<button class="form-control rounded-circle btn form-button ml-2 closebutton" type="clear" name="clear">
<span>
<i class="fas fa-times"></i>
</span>
</button>
</div>
I'd like it to spot if the button with the name/type "clear" is clicked, then it won't run the toast. Toast is below:
{% if button == 'clear' %}
<div class="toast custom-toast rounded-0 border-top-0" data-autohide="false">
<div class="arrow-up arrow-danger"></div>
<div class="w-100 toast-capper bg-danger"></div>
<div class="toast-header bg-white text-dark">
<strong class="mr-auto">Error!</strong>
<button type="button" class="ml-2 mb-1 close text-dark" data-dismiss="toast" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="toast-body bg-white">
{{ message }}
</div>
</div>
{% endif %}
I'd like it to spot if the button with the name/type "clear" is clicked, then it won't run the toast.
This if statement is only run on the server when it renders the HTML for the web page. It is checking if a variable named button has the string value "clear". This has nothing to do with any HTML elements in the page, let alone the name of a particular <button>. Instead, the value of the variable button comes from the "context" when your Python calls one of the render functions.
I'm looking to create a django if statement to see if a certain button is pressed.
There are two different ways to handle button clicks:
Submit a form to the server which then returns a response with a new page. This can be the same Django template rendered with different values in the context in order to get the behavior that you want.
Add an onclick handler to the button. This should be a JavaScript function that peforms the action you want. It can manipulate the elements in the page to add a toast or anything else.
The first option is very slow because it will require a new network request. The second option is probably preferred here since it will be very responsive to the user's actions.

"Bootstrap Modal Pop up" Youtube Video Autoplay, reopens the video when turned off

I've added a youtube video to my website that starts automatically at boot-up on the home page. The video opens as bootstrap modal pop up. However, when pop up closes, the video starts playing again in the background.
First, I want the video to start automatically.
Second, the video is automatically stopped when "pop up" is turned off.
Third, don't let the pop-up video start playing again in the background.
Version * Bootstrap v3.0.3
Thank you in advance for your help.
<!-- POPUP SCRIPT -->
<script>
$(document).ready(function(){
$("#myModal").on("hidden.bs.modal",function(){
$("#iframeYoutube").attr("src","#");
})
})
$(document).ready(function(){
$("#myModal").modal("show");
$("#myBtn").click(function(){
$("#myModal").modal();
});
});
</script>
<!-- HEADER -->
<header id="header" class="main__header"> </header>
<!-- POPUP BAŞLANGIÇ -->
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" style="background-color: #f9f9f900;">
<div class="modal-body" style="padding: 0px;">
<button type="button" class="close" style="padding:8px; background: white;" data-dismiss="modal">×</button>
<iframe id="iframeYoutube" width="100%" height="450px" alt="1" src="https://www.youtube.com/embed/example?&autoplay=1;rel=0&showinfo=0&controls=0&amp" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
</div>
</div>
</div>
</div>
<!-- POPUP BİTİŞ -->
Firstly, you should trigger a function when pop-up is closed.This function should stop video to be played in the background.
$("#modal-close-button").click(function () {
$("#video-stop-button").click();
});
$("#video-stop-button").click(function () {
alert("The video should stop as the modal closes because a click on the close button will trigger the stop button ");
});
You should call this function whenever your pop-up is closed to prevent video to be played in the background.

Foundation Sticky plugin suddenly not working

For the longest time, the Foundation Sticky plugin was working as expected, sticking as the page scroll met the top of the sidebar. Now, suddenly, it's broken:
https://www.arcresources.com/about-arc/board-of-directors/member-bios
It jumps once, and the classes are changed, indicating the plugin is firing and adding the top margin, but after that, nothing.
I've tried commenting out all other JS, and relevant CSS to see if something was interfering, but the same problem persists.
Adding width: 100% and position: fixed to the data-sticky div produces the right results, but this is the code the Sticky plugin should be adding and removing based on my top and bottom anchors.
Sidebar code:
<div class="grid-container sidebar-nav-wrapper {{ firstSegment }}">
<div class="grid-x grid-margin-x">
<nav data-sticky-container class="show-for-large large-3 large-offset-9 cell sidebar-nav">
<div data-sticky data-top-anchor="main" data-btm-anchor="main:bottom" data-sticky-on="large" data-margin-top="6">
<!-- Sidebar content -->
</div>
</nav>
</div>
</div>

Off-canvas menu with sticky close button

I've made use of an off-canvas menu that comes in from the left without any trouble. At the bottom of the off-canvas menu there's a close button. Is there anyway to make the close button on an off canvas menu sticky?
For users, it is awkward (and not obvious) to have to scroll to the bottom to find the bottom, especially on long menus.
EDIT: Added some sample code: On the live site there might be 80 links (rather than 3), and I want the div with the close button to always be visible at the bottom of the current screen when the off-canvas menu is visible.
<div class="row">
<button type="button" class="button hide-for-large" data-toggle="filterCanvas">Filters</button>
</div>
<div class="row">
<div class="off-canvas-wrapper">
<div class="off-canvas off-canvas in-canvas-for-large position-left float-left" id="filterCanvas" data-off-canvas>
<div class="sidebar">
<p><strong>List of options</strong></p>
<div class="clearfix">
Link1
Link2
Link3
</div>
<div class="buttons hide-for-large text-center">
<button class="button expanded" data-toggle="filterCanvas">Close</button>
</div>
</div>
</div><!-- /filterCanvas -->
<div class="off-canvas-content float-left" style="min-height: 300px;margin-left:15px;" data-off-canvas-content>
<div class="view-content" style="margin-bottom: 20px;">
Page content here
</div>
</div><!-- /off-canvas-content -->
</div><!-- /off-canvas-wrapper -->
</div><!-- /row -->
Would be easier if you posted some code...
But, saying that, you could position the open/close button relative to the viewport, that way you could just have it fixed to the bottom left, and just adjust it when open.
As said, we would need some code though for this to be useful.
Edit: Based upon code sample provided
So given your example, you could do something as simple as the below, and just toggle the 'activated' class when opening/closing the menu.
<!-- The below button doesnt need to be in a row, as will be fixed,
the activated class will only be present when the sidebar is
open and not by default -->
<button type="button"
class="button hide-for-large off-canvas-button activated"
data-toggle="filterCanvas">Filters</button>
<div class="row">
<-- example code removed for brevity -->
</div><!-- /off-canvas-content -->
.off-canvas-button {
position: fixed;
left: 2em; // change to desired space from edge
bottom: 2em; // change to desired space from edge
}
.off-canvas-button.activated {
left: 6em; // adjust to suit with of sidebar (example is 4em)
}

pass my php variables to a bootstrap modal not working

in my page
foreach ($json->items as $sam) {
$link= $sam->id->videoId;
echo''.$link.'';
//its showing last 5 youtube video id ok.. i set every video id witha button for modal
echo'<button type="button" data-toggle="modal" data-target="#PlayModal" class="btn btn-outline btn-danger">Play</button>';
}
but when im trying to open a model by box in new winddow pop up there only show 1st video ID. modal not getting '.$link.' valu in popup window. modal code puting same page blew finish {}
echo'<div class="modal inmodal" id="PlayModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content animated bounceInRight">
<div class="modal-body">
<p>'.$name.'</p>
<div class="modal-footer">
<button type="button" class="btn btn-outline btn-danger" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>';
According to the code given, even the first video should not play.
it is not printing the value of LINK inside the button, so it will not work.
Unless you have a JAVASCRIPT code observing the click and playing the video on click.
You can create the HTML code first manually containing the 5 video ID, and each video should have a button (according to your description), when clicked it will open the modal.
once that is done, you will be able to use php for each to properly echo the html code.
alternatively, the videos are in HTML list, and javascript will handle the event click, reading the video ID and passing to the player in the modal.
in either case, you need to understand the HTML structure first.