Jquery shadow box Conflict - php

<script type="text/javascript">
function Start(){
Shadowbox.init({skipSetup: true});
Shadowbox.open({
content: '/luckycement/flashxml/LuckyCement.swf',
player: 'swf',
title: "",
width: 800,
height: 600
})
}
//window.onload=Start;
</script>
<script src="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/SpryAssets/SpryCollapsiblePanel.js" type="text/javascript"></script>
<script src="<?php echo $this->baseurl ?>/templates/rhuk_milkyway/SpryAssets/jquery-1.3.1.min.js" type="text/javascript"></script>
<script type="text/javascript" src="/luckycement/plugins/content/arisexylightboxlite/js/jquery.min.js"></script>
<script type="text/javascript" src="/luckycement/plugins/content/arisexylightboxlite/js/jquery.noconflict.js"></script>
<script type="text/javascript" src="/luckycement/plugins/content/arisexylightboxlite/js/jquery.easing.js"></script>
<script type="text/javascript" src="/luckycement/plugins/content/arisexylightboxlite/js/jquery.sexylightbox.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function(){ SexyLightbox.initialize({"dir":"\/luckycement\/plugins\/content\/arisexylightboxlite\/js\/sexyimages"}); });
</script>
<!--script type="text/javascript" src="js/jquery-1.3.1.min.js"></script-->
<script type="text/javascript">
$(document).ready(function() {
//alert('nida');
//Execute the slideShow
slideShow();
slideshowimg();
$("#accordion").accordion();
//alert($("#tabarea_r").attr('id'));
});
function slideShow() {
//alert($('#gallery').attr('id'));
//Set the opacity of all images to 0
$('#gallery a').css({opacity: 0.0});
//Get the first image and display it (set it to full opacity)
$('#gallery a:first').css({opacity: 1.0});
//Call the gallery function to run the slideshow, 6000 = change to next image after 6 seconds
setInterval('gallery()',5000);
}
function gallery() {
//if no IMGs have the show class, grab the first image
var current = ($('#gallery a.show')? $('#gallery a.show') : $('#gallery a:first'));
//Get next image, if it reached the end of the slideshow, rotate it back to the first image
var next = ((current.next().length) ? ((current.next().hasClass('caption'))? $('#gallery a:first') :current.next()) : $('#gallery a:first'));
//Get next image caption
var caption = next.find('img').attr('rel');
//Set the fade in effect for the next image, show class has higher z-index
next.css({opacity: 0.0})
.addClass('show')
.animate({opacity: 1.0}, 1000);
//Hide the current image
current.animate({opacity: 0.0}, 1000)
.removeClass('show');
//Set the opacity to 0 and height to 1px
$('#gallery .caption').animate({opacity: 0.0}, { queue:false, duration:0 }).animate({height: '1px'}, { queue:true, duration:300 });
//Animate the caption, opacity to 0.7 and heigth to 100px, a slide up effect
$('#gallery .caption').animate({opacity: 0.7},100 ).animate({height: '100px'},500 );
//Display the content
$('#gallery .content').html(caption);
}
</script>
can anyone help me in sorting the issue? I'm using shadowbox.js for showing gallery images in shadowbox but it conflicts with my gallery. I'm using the function start() that call on index page load and run the flash file in shadowbox. But for displaying images it doesnot show shadowbox conflicts my javascript files.

They are conflicting because you are using two different jQuery versions. Use the latest jQuery Version only for both sexylightbox and shadowbox.

Related

How to load Jquery when using multiple php files

I have divided my html-file into a header.php, content.php and footer.php
I would like to load the js files and the document.getready function either in the hader or in the footer file. But I got an error saying: Uncaught ReferenceError: $ is not defined.
In my header.php I load the following scripts in the head section:
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js" async></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.js" async></script>`
And in my Footer after the closing </body>-Tag I call:
<script>
$(document).ready(function() {
if( !window.isCMS) {
// Group images by gallery using data-fancybox-group attributes
var galleryId = 1;
$('.editable-gallery').each( function() {
$(this).find('a').attr('data-fancybox', 'gallery-' + galleryId++);
});
$('.editable-gallery').each( function() {
$(this).find('img').attr('width', '200');
});
// Initialize Fancybox
$("[data-fancybox]").fancybox({
// Use the alt attribute for captions per http://fancyapps.com/fancybox/#useful
//beforeShow: function() {
// var alt = this.element.find('img').attr('alt');
//this.inner.find('img').attr('alt', alt);
//this.title = alt;
//}
});
}
});
</script>
In my content.php file I include my header.php and footer.php like this:
<?php include ("header.php"); ?>
<?php include ("footer.php"); ?>
How and where do I have to implement the script files and the document.getready function?
This is my Gallery Code in my content.php:
<div id="my-gallery" class="editable-gallery">
<img src="fotos/2018/rl/02022018/3.jpg" alt="">
<img src="fotos/2018/rl/02022018/1.jpg" alt="">
<img src="fotos/2018/rl/02022018/3.jpg" alt="">
</div>
I have to add the attr "data-fancybox" and "width" to work with fancybox.
1st:- The error comes from src="http://code.jquery.com/jquery-latest.min.js" it should be https instead of http >> src="https://code.jquery.com/jquery-latest.min.js"
2nd:- you can include js files or js code in <head> OR BEFORE </body>
3rd:- you can use <script></script> anywhere from <head> to </body> even before the line you including your jquery BUT use $(document).ready(function(){ //code here })
Note: if you have any plugins you must include the plugins after including jquery
your js code works fine
$(document).ready(function() {
//if( !window.isCMS) {
// Group images by gallery using data-fancybox-group attributes
var galleryId = 1;
$('.editable-gallery').each( function() {
$(this).find('a')
.attr('data-fancybox', 'gallery-' + galleryId++).find('img').attr('width' , '200');
});
// Initialize Fancybox
$("[data-fancybox]").fancybox({
// Use the alt attribute for captions per http://fancyapps.com/fancybox/#useful
//beforeShow: function() {
// var alt = this.element.find('img').attr('alt');
//this.inner.find('img').attr('alt', alt);
//this.title = alt;
//}
});
//}
});
<!-- 1. Add latest jQuery and fancyBox files -->
<script src="//code.jquery.com/jquery-3.3.1.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js"></script>
<!-- 2. Create links -->
<div id="my-gallery" class="editable-gallery">
<img src="http://via.placeholder.com/350x150" alt="">
<img src="http://via.placeholder.com/350x150" alt="">
<img src="http://via.placeholder.com/350x150" alt="">
</div>
<!-- 3. Have fun! -->

Adding intro image fadeIn wordpress

I would like to add an image that fades in and then fades out after a certain amount of time. I have tried to add the code below into index.php and it works but it throws everything off like alignments and spacings. Where would I put this so that it only loads when the homepage is first loaded?
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<img style="display: none; z-index: 9999;" id="book" src="images/test.jpg" alt="" width="100%" height="100%">
<script>
$( "#book" ).fadeIn ( 2500, function() {});
$( "#book" ).fadeOut( 1000, function() {});
</script>
use document on ready, it will fire a function when the document is loaded:
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
<img style="display: none; z-index: 9999;" id="book" src="images/test.jpg" alt="" width="100%" height="100%">
<script>
$(document).ready(function(){
$( "#book" ).fadeIn ( 2500, function() {});
$( "#book" ).fadeOut( 1000, function() {});
});
</script>
let me know if it works
run your functions after everything ready
$( document ).ready(function() {
//your code
});
it may work.
and have a look at
http://codex.wordpress.org/Function_Reference/wp_enqueue_script

Enable/Disable button when image has been uploaded

Hi im uploading images to the server. My upload button are active always and i use simple ajax code to upload the image without page referesh.How to enable the a select button after the image has been uploaded.the java script code i have posted here...
<!--AJAX UPLOADING SCRIPT -->
<script type="text/javascript" src="lib/scripts/jquery.min.js"></script
<script type="text/javascript" src="lib/scripts/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#photoimg').live('change', function(){
$("#preview").html('');
$("#preview").html('<br /><img src="loader.gif" alt="Uploading...."/>');
$("#imageform").ajaxForm({target: '#preview'}).submit();
});
});
});
});
///To enable/disable the language button depending on the image upload.
$(document).ready(function(){
$("#language").attr('disabled',true);
$("#language").change(
function(){
if ($("#PerformOcrForm").ajaxForm({target: '#previewText'}).submit()) {
$("#language").removeAttr('disabled',false);
}
else {
$('#language').attr('disabled',true);
}
});
});
</script>
Pls try firebug for the see the error of brackets.

Making Div tag resize according to browser size when using jquery.flashgallery to display the image gallery

<div id="banner">
<script type="text/javascript" src="gallery/js/jquery.js"></script>
<script type="text/javascript" src="gallery/js/swfobject.js"></script>
<script type="text/javascript" src="gallery/js/flashgallery.js"></script>
<script type="text/javascript">
jQuery.flashgallery('gallery/gallery.swf', 'gallery/config.xml',{ width:'100%', height:'100%', allowFullScreen: 'true', background: 'transparent'});
</script>
</div>
Here i want to make banner div to resize when i resize the browser window
can some body help on this Thanks..
My last post was by accident, try something like this. I have not tried it though.
$(window).resize(function() {
var divRatio = .7;
var divHeight = $(window).height()) * divRatio;
var divWidth = $(window).width()) * divRatio;
$('.yourDivYouWantHere').css({
height : divHeight;
width : divWidth;
});
}
Kevin

PHP Customizing Module to show if DIV exists

I'm very new to PHP, so customizing ready-made scripts is no forte of mine quite yet.
I have an animated popup modal script, which currently triggers when a certain is clicked. I'd also like to trigger this same script automatically when a particular div exists on the page.
The #mask, as you can see from the code, is a translucent layer of black over the page.
Here's the script that I need to adjust:
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
});
});
Currently it opens automatically when this link is clicked:
<a href="#" name="modal">
And I'm trying to get it to run automatically when this DIV exists on the page:
<div name="showintrovideo"></div>
Thanks so much guys, you're always such great help!
- - Andrew
EDIT
Here's the full code I'm working with:
HTML
<div id="boxes">
<div id="qrcodemarketing" class="window">
<!-- close button is defined as close class -->
<div style="float:right;">
<img src="images/close_window.png" width="22"height="22" alt="Close Window" />
</div>
<iframe width="640" height="480" src="http://www.youtube.com/embed/MYVIDEO" frameborder="0" allowfullscreen></iframe><br /><b>Pause the video before closing this window</b>
</div>
</div>
<!-- Do not remove div#mask, because you'll need it to fill the whole screen -->
<div id="mask"></div>
CSS
#mask {
position:absolute;
width:100%;
height:100%;
left:0;
top:0;
z-index:9000;
background-color:#000;
display:none;
}
#boxes .window {
position:absolute;
background:none;
display:none;
z-index:9999;
padding:20px;
color:#fff;
}
.js file
$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=modal]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Get the screen height and width
var maskHeight = $(document).height();
var maskWidth = $(window).width();
//Set height and width to mask to fill up the whole screen
$('#mask').css({'width':maskWidth,'height':maskHeight});
//transition effect
$('#mask').fadeIn(1000);
$('#mask').fadeTo("slow",0.8);
//Get the window height and width
var winH = $(window).height();
var winW = $(window).width();
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
//transition effect
$(id).fadeIn(2000);
});
//if close button is clicked
$('.window .close').click(function (e) {
//Cancel the link behavior
e.preventDefault();
$('#mask, .window').hide();
});
//if mask is clicked
$('#mask').click(function () {
$(this).hide();
$('.window').hide();
});
});
It it possible to just tweak the .js file so that it can also open automatically as well as by click?
Thanks!
You're probably best using a session or cookie to determine whether to show the intro video. I'd also wrap your popup in a method you can call on a jQuery element. Something like:
$('a').myPopupMethod();
That way, you can also call it programmatically:
$.myPopupMethod();
In your HTML page, you can then use PHP to determine whether to show your popup or not:
<?php
session_start();
$video_watched = $_SESSION['video_watched'];
?>
<!DOCTYPE html>
<html>
<body>
<script src="jquery.js"></script>
<?php if ($video_watched != true): ?>
<script>
$(document).ready(function() {
$.myPopupMethod();
});
</script>
<?php endif; ?>
</body>
</html>

Categories