Fancybox / How to scroll in opened div and have the background fixed? - facebook

I'm currently working on a project with some fancybox (inline content).
I'd like to have the same kind of behavior that exists on facebook: when I click, the content is displayed in the fancybox, and if I scroll, I do scroll in the fancybox, but the background has to remain fixed.
I tried to mix a couple of ideas I've found here and there, mainly:
$(".jqShowArticle, .jqShowPortfolio").fancybox({
'onStart' : function(){
$("body").css({"overflow": "hidden", "position": "fixed"});
$("#fancybox-overlay").css({"overflow": "scroll"});
},
'onClosed' : function(){
$("body").css({"overflow": "auto", "position": ""});
}
});
But it doesn't work... Here is the page: http://espresso.double-espresso.com/
You can click on every portfolio item (pictures with text appearing on hover...) or blog entry to see what it does...
Thanks a lot for your help!

There seems to be an answer on https://github.com/fancyapps/fancyBox/issues/24. I'm not sure how they do it exactly though.

Related

How to fix Blocking screen with content On my quick app pages?

On my quick app pages, some
content may be blocked by the app menu. For example, the sign-in entry is blocked by the app menu in the following figure.
Although the menu is configured to be movable, users do not know that they can move it.
How can I solve this problem?
The following solutions are provided to solve your problem:
Separating the menu from any content displayed
Hiding the menu
Adding a message indicating that the menu is movable
For Detail,pls kindly refer this link : What if some content is blocked by the app menu?
You can separate the menu from any content displayed by changing the value of titleBar to true in the manifest.json file.
e.g.
"display": {
"fullScreen": false,
"titleBar": "true",
"menu": false,
"menuBarData": {
"draggable": true
},
There is a good example with other solutions. Please check link

fancybox disable image preloading

Started to try out this fancybox3 plugin to zoom thumbnail images in our app that works perfectly on desktop and mobile browsers.
In the app where the cart has thumbnail images of the products added to it that can be purchased. If I remove a product(image of it)from the cart, it gets removed from the cart, however, if I zoom one of the remaining product images of the cart and navigate through it, still showing the removed product there. I am expecting to see only the product images present in cart.
I tried using the preload: 0 option but that does not work for me. Fancybox is initiated in following way
$('[data-fancybox="images"]').fancybox({
idleTime : false,
loop: true,
transitionEffect : "fade",
animationDuration: 333,
buttons: [
'close'
],
protect: true,
infobar: false,
preload: 0
});
Any help to make this work is really appreciated.
Thank you
Looks like you have misunderstood the concept of "preloading". The script preloads images before displaying, but what that means is that it is showing loading icon before displaying full image. If you disable preloading and provide dimensions (width/height) of full image, then the script will display thumbnail image while full image is loading. This is a great feature if you want to make your app/webpage look more interactive (e.g., user would not stare at black overlay with loading icon but will see something useful instead).
But what you have described sounds like "caching" and fancyBox is not caching dom elements. So, if you see something in the gallery, that means that corresponding element exists in your page.
So, make sure that your product is actually removed from the dom or try to tweak the selector to match only "actual" products using "selector" option, e.g., something like:
$().fancybox({
selector : '.fancybox:not(.removed)'
});
Obviously, you should tweak this to suit your needs. Since you have not provided any details, I can not create a full example.
#Janis, Thank you so much for the clarification on 'preloading' concept.
You were right about dom still holding the removed item. Upon removal, the div is simple being set as display none.
First, I added code to remove the div form the dom but that resulted in page getting refresh which we don't want.
Next tried, the selector option and it worked perfectly.
function hideCartItem(id) {
var divItem = document.getElementById("divCartItem" + id);
var elem = "#divCartItem" + id
if (divItem != null) {
$(elem).hide();
$(elem).remove();
// added code
$('[data-fancybox="images"]').fancybox({
divItem: '.fancybox:not(.removed)'
});
}
}
Thank you so mcuh for your help. Much appreciated!!

Toggle Entire Accordion Functionality with Link or Button

I have an accordion that works great. I'm trying to figure out a way to search all the flaps of the accordion:
Find String on Page (Ctrl+F) when jQuery Accordion in Use
I have used the destroy method on a link and then reinitializing on another link, but it would be great to toggle this with one button. ((I originally asked this question without this solution here, so the answer below is just this. I won't accept it until I see if any better solutions come up))
$(document).ready(function() {
$("#hide").click(function() {
$(".accordion").accordion("destroy");
});
$("#show").click(function() {
$(".accordion").accordion({
navigation : true,
collapsible : true,
heightStyle : "fill",
active :
});
});
});
I was also able to toggle the entire accordion with jQuery toggle() but this just makes the entire thing disappear. What I want is to toggle the accordion functionality, while leaving the div structure behind so it's visible, just as if someone disabled JavaScript in the browser.
So the above kind of does what I want, except in reality, the better solution is to actually remove the class .accordion because that makes the page truly look like it should. Destroying the accordion actually breaks some stuff and this is undesirable.
I thought it would be as easy as this but it's not working:
$(document).ready(function() {
$("#hide").click(function() {
$("#accordion").removeClass(".accordion");
});
$("#show").click(function() {
$("#accordion").addClass(".accordion");
});
});
This does seem to be adding and removing the class I'm telling it to, but the initial remove is not removing the accordion class to remove the accordion itself.
I have used the destroy method on a link and then reinitializing on another link (although one button toggle would be better):
$(document).ready(function() {
$("#hide").click(function() {
$(".accordion").accordion("destroy");
});
$("#show").click(function() {
$(".accordion").accordion({
navigation : true,
collapsible : true,
heightStyle : "fill",
active :
});
});
});
I had to edit some CSS to make this work out, but it's the best I could find.
NOTE
I should note that I ended up finding even a simpler approach to this. Simply adding a reload restores the page back to its original state:
$("#show").click(function() {
location.reload();
});
The destroy and reload is a very simple solution. The one button aspect is solved with this event which goes in the document ready function:
// event to destroy accordion and make it's content searchable
$("#open-1").on("click",function() {
// if the button says Enable reload to bring the accordion back
if ($(this).html() == "Enable") {
location.reload();
}
// otherwise destroy the accordion and change the button to Enable
else {
$("#accord-1").accordion('destroy');
$(this).html("Enable");
}
});
The button can say anything you want initially. The key is that it's set to "Enable" and tested for "Enable" to reload the page. You can make that any string you want as well. Here's a complete example.

IE 8 autocomplete with jQuery UI modal dialog

I have a modal jQuery dialog with a number of text fields. The text fields are affected by the standard IE 8 autocomplete (which is desired). However, when the host page is scrolled to any position but the top (either before or after the dialog has been opened), the auotocomplete div is offset by the distance of the scroll (e.g. it appears well below the associated textbox). Effectively, the dialog follows the scroll of the host page, but the autocomplete does not follow. This effect is seen even when the host page has been scrolled before opening the dialog.
$("#InterestsDetailModalContainer").dialog({autoOpen: false});
$("#InterestsDetailModalContainer").dialog("option", "title", "Additional Interests Detail");
$("#InterestsDetailModalContainer").dialog("option", "height", 600);
$("#InterestsDetailModalContainer").dialog("option", "width", 1000);
$("#InterestsDetailModalContainer").dialog("option", "modal", true);
I'm having a hard time finding anything out there that isn't talking about the jQuery autocomplete feature, which I am NOT using here.
Thanks!
You can mention the options in a single line of selector like the following:
$("#InterestsDetailModalContainer").dialog({
autoOpen: false,
title: "Additional Interests Detail",
height: 600,
width: 1000,
modal: true,
});
Try this, It's not a solution, but try this and let know weather solved.

target="_parent" in Fancybox is loading a new window

Ok here's a messy one.
I've got an iframe on a page, and in that iframe I've loaded up a Fancybox iframe with a link in it that has target="_parent". My only problem is it's loading the link in a new window for some bizzare reason, not out of the fancybox and into the iframe.
My link is Continue Checkout
You can view an example of the code at https://www.dpdesignz.net/homefresh/dps/success.html. My biggest thing though is that even though this page is on my https://www.dpdesignz.net domain, the link in the button cannot be changed from the http://www.dpdesignz.co.nz to https://www.dpdesignz.net
Can anyone see what may be going wrong here?
Your link has the class="button" but there isn't in any part of your code anything that binds that selector to fancybox
something like:
$(".button").fancybox({
width : 650,
height: 400,
type : "iframe"
});
otherwise it will always open in anew window