Fancybox issues with mutiple popups and timeouts - javascript

I have fancybox 2.1.5 and have built a page with 4 different links to open a fancybox popup. I have also added a setTimeout for these popups so that after a set amount of time, the popup will automatically go away.
The issue is that when I open a popup, manually close it, and then click on a popup, randomly between 1 to a few seconds, it will close itself (I have it set to 15 second timeout). I don't know if this is caused by having multiple popup links, or what. Below is the code I used:
$(document).ready(function() {
$('.fancybox').fancybox({
beforeShow: function(){
this.title = $(this.element).next('.newTitle').html();
},
width : '700',
height : '380',
closeBtn : false,
helpers : {
overlay : {
css : {
'overflow' : 'hidden',
'background' : 'rgba(0,0,0,0.85)'
}
}
}/*,
afterLoad: function(){
setTimeout( function() {$.fancybox.close(); },15000);
}*/
});
});
And the HTML:
<a class="fancybox fancybox.iframe" href="includes/elevator.html"><img src="images/elevator.gif" class="round" width="324" height="183"/></a>

Related

buttons persist when launching dialog

I am using jQueryUI and I have a web page with a few links that when clicked will display a modal window. The issue i am having is that when i click one of the links that has a button then close it and click another link that doesnt have buttons the modal launches but the buttons are still there. Despite the fact that no buttons are being specified. I have tried to use the close property when creating the dialog calling $(this).dialog("close") doesnt solve the issue. Calling $(this).dialog("destroy") solves the issue except that the contents of the modal are then shown on the webpage.
This is the function I call to launch the modal.
General.modal = function(options)
{
if(!options.hasOwnProperty(modal))
{
options.modal = true;
}
$('#modal').dialog(options);
};
This is the call without buttons.
myApp.General.modal({
title : groupTitle + " Documentation",
height : 500,
width : 600,
});
This is the call to that function with buttons:
myApp.General.modal({
title : "Upload Documentation (" + groupTitle + ")",
height : 500,
close: function(){$(this).dialog("close");},
width : 600,
buttons : {
"Upload" : jQuery.proxy(directoryView.uploadClicked, directoryView, model.get("gid"))
}
});
I presume that the dialog is not being destroyed so the last button definition is staying around. You probably need to ensure the buttons attribute is null on subsequent calls:
myApp.General.modal({
title : groupTitle + " Documentation",
height : 500,
width : 600,
buttons : null,
});

How to call fancybox resize function when fancybox-wrap height changes

I have need to show this gallery as http://tympanus.net/Tutorials/ResponsiveImageGallery/ in fancy box. It works fine except one design problem that is fancybox doesn't come in the center for first time as it has to download few image for first time if one open the same album second time it then show correctly in the center as all image are cached. I tried to resolve this issue with following code but it is not work
I cant give fancybox fixed width and height as images are of different dimensions
$(".fancybox-frame").fancybox({
maxWidth: 740,
maxHeight: 600,
fitToView: false,
width: '70%',
height: '70%',
autoSize: true,
closeClick: true,
hideOnOverlayClick: true,
openEffect: 'none',
closeEffect: 'none',
onComplete: function () {
$.fancybox.resize();
$.fancybox.center();
}
});
Other solution i can think of is to call fancybox.center() and $.fancybox.center(); function when fancybox wrapper with changes fancybox-wrap.
This i can help me correctly repositioning the fancybox in center.
But i am not sure how to track height change for fancybox-wrap and call the reposition the fancy box.
Fancybox V 1.3.4
Help in this regarding is appreciated.
UPDATE:
Just to give you an idea i face similar problem that is happend on this link.
http://www.picssel.com/playground/jquery/getImageAjax.html
When you click for the first time it small fancy-box and doesn't re-size when image is downloaded. In my case i have to download multiple image and it take time to display the first image in between takes default value but doent resize when first image is download.
set autoSize to false in order to set width and height for fancybox. i.e.
$(".fancybox-frame").fancybox({
maxWidth: 740,
maxHeight: 600,
fitToView: false,
autoSize: false,
width: '70%',
height: '70%',
closeClick: true,
hideOnOverlayClick: true,
openEffect: 'none',
closeEffect: 'none',
onComplete: function () {
$.fancybox.resize();
$.fancybox.center();
}
});
Hope this helps you.
Dynamic Inline Content Loading
function loadAnswer(id){
jQuery.fancybox({
'content' : jQuery("#outerFAQ"+id).html(),
/*For Auto height and width*/
'onComplete' : function(){
jQuery('#fancybox-wrap').css({height:'auto',width:'auto'});
jQuery.fancybox.resize();
jQuery.fancybox.center();
}
});
}
/*Dynamically Set the id and passing it to function*/
<a class="fancybox" href="#" onClick="loadAnswer(<?php echo $data->getId()/*Dynamic id*/ ?>);"> Demo </a>
<div id="outerFAQ<?php echo $data->getId(); ?>" style="display:none;">
<div id="ans<?php echo $data->getId();?>">
demo
</div>
<div>
Single inline content loading
jQuery( "#demo" ).click(function() {
jQuery.fancybox({
'content' : jQuery("#demoContent").html(),
onComplete: function () {
/*Static height width*/
jQuery("#fancybox-content").css({
height:'500px',
overflow:'scroll',
});
jQuery("#fancybox-wrap").css("top","10");
jQuery(".fancybox-wrap").css("position", "absolute");
}
});
<a id="demo" href="#">Click me</a>
<div style="display: none">
<div id="demoContent">
demo
</div>
</div>
if you fancybox is already open and want to resize then below code will helps you.
$.ajax({
url: 'YOUR URL',
data:'DATA WANT TO TRANSFER',
type: 'post'
dataType: "text",
success:function(result){
//PLAY WITH RESULT SET
$.fancybox.toggle();
},
error:function(request,error){
alert("Error occured : "+error);
}
});
Reference from : Resize Fancybox
Solution, I managed to make it work by resizing after delay of 3 seconds by that time first image is downloaded completely
$(".fancybox-iframe").fancybox({
width: '70%',
height: '70%',
hideOnOverlayClick: true,
centerOnScroll:true,
onComplete : function(){
// $.fancybox.resize();
// $.fancybox.center();
var resize = setTimeout(function () {
$.fancybox.center();
}, 3000)
}
});
I believe more professional approach will be check using jquery when image is downloaded completely and then call $.fancybox.center(); function
Please if this is fine or we can do it some otherway.
Did you try to use <center></center> include of your fancybox? I think so it'll work on your page. and no need to use java, cause you are just trying to use it as center.

Fancybox2 modification to iframe with navigation buttons

i have a list of iframe pop ups for which i am using the data-fancybox-group="gallery" so that the user can browser left and right through the content. The page this list sits in is also inside an iframe. the reason for this is so that the main header does not reload as it needs to play continuous music via soundcloud. I had to amend $('.fancybox').fancybox(); to make the iframe content automatically resize to fit the content and to appear outside it parent frame. However this amended script prevents the button function from working. this is my code, basically i need to get the iframe buttons function working like a gallery...
<script type="text/javascript">
$(document).ready(function() {
/*
* Simple image gallery. Uses default settings
*/
$('.fancybox').click(function(e){
e.preventDefault();
parent.$.fancybox({'href' : this.href,
'type':'iframe',
autoSize : false});
//fancybox
return false;
}); //click
/*$('.fancybox').fancybox();*/
/*
* Button helper. Disable animations, hide close button, change title type and content
*/
parent.$('.fancybox-buttons').fancybox({
openEffect : 'none',
closeEffect : 'none',
prevEffect : 'none',
nextEffect : 'none',
closeBtn : false,
helpers : {
title : {
type : 'inside'
},
buttons : {}
},
afterLoad : function() {
this.title = 'Image ' + (this.index + 1) + ' of ' + this.group.length + (this.title ? ' - ' + this.title : '');
}
});
});
</script>

Refreshing the content of BootStrap Popover

I am trying to refresh the content of the popover. I know the content gets updated when i click the button, however, its not showing on the already opened popover..
$('#popOverPr')
.popover(
{
animate : false,
html : true,
offset : 10,
placement : 'bottom',
template : '<div class="popover popOverProgress" "><div class="arrow" style="left:80%";></div><div class="popover-inner"><h3 class="popover-title" style="display:none;"></h3><div class="popover-content"><p></p></div></div></div>',
content : function() {
return $('#popOverPr-content').html();
}
$('#popOverPr').popover('show');
$('.popoverButton').on('click', function() {
//if(........)
$('#popOverPauseText').text("Resume");
// else
$('#popOverPauseText').text("Start");
}
});
You can destroy the popover, recreate a new one with different content

qTip tooltip does not appear, jQuery

I have a site that displays items, 12 items per page and I can paginate through the pages using jquery. On the same page I implemented a the tooltip feature with qTip.
Hovering over the items some information appear. That works until I use the paginator to go to the next page.
The pagination reloads the content. But it has the same structure as when I refresh the page.
Here's my code:
$(document).ready(function() {
$(".cornerize").corner("5px");
$('a#verd').live('click', exSite);
$("a.tp").live('click', thumpsUp);
$("a#next").click(getProgramms);
$("a#previous").click(getProgramms);
$("a#page").each(function() {
$(this).click(getProgramms);
});
$('a.ppname[rel]').each(function(){
$(this).qtip( {
content : {url :$(this).attr('rel')},
position : {
corner : {
tooltip : 'leftBottom',
target : 'rightBottom'
}
},
style : {
border : {
width : 5,
radius : 10
},
padding : 10,
textAlign : 'center',
tip : true,
name : 'cream'
}
});
});
});
The html/dom does not change:
<a class="ppname" rel="link" href="#">...</a>
qTip takes from every a.ppname the rel value end loads the content.
This is happening because new elements are not automatically "qTiped" when they are loaded after page load. For regular events, you would have to use .live() instead of .bind().
This has been solved before (judging from the comment): Problem with qTip - Tips not showing because elements load after the script.
The correct way to do it is (from that answer):
$('a.ppname[rel]').live('mouseover', function() {
var target = $(this);
if (target.data('qtip')) { return false; }
target.qtip({
overwrite: false, // Make sure another tooltip can't overwrite this one without it being explicitly destroyed
show: {
ready: true // Needed to make it show on first mouseover event
},
content : {url :$(this).attr('rel')},
position : {
corner : {
tooltip : 'leftBottom',
target : 'rightBottom'
}
},
style : {
border : {
width : 5,
radius : 10
},
padding : 10,
textAlign : 'center',
tip : true,
name : 'cream'
});
target.trigger('mouseover');
});

Categories

Resources