1

I have zero experience in Javascript and JQuery but I have used both in this document.

The first one is to give support to IE for CSS3 transitions and is taken from CSS3 Hover Transition. The code used is

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.js"></script>
<script type="text/javascript" src="scripts/jquery.hoverTransition.js"></script>

The seond one is for a slideshow gallery and is taken from slideshow gallery and the code is

<script type="text/javascript" src="scripts/jquery-1.3.2.js"></script>
<script type="text/javascript" src="scripts/jquery.galleriffic.js"></script>
<script type="text/javascript" src="scripts/jquery.opacityrollover.js"></script>

As can be seen the former CSS3 Transitions links to jquery 1.6.1 while the later slideshow gallery links to jquery 1.3.2. Do I have to refer to both these files?

I tried removing one link and the other as well but if either of the link is removed, neither the CSS3 Hover Transitions work nor the Slideshow Glaeery work. Alos if I place the above in my head element, they dont work. They only work If I have them at the bottom after the footer and before the body element.

The following is in my head tag. (for the Slideshow Gallery)

<!-- We only want the thunbnails to display when javascript is disabled -->
<script type="text/javascript">
document.write('<style>.noscript { display: none; }</style>');
</script>

And the following is at the bottom. (for the Slideshow Gallery)

    <script type="text/javascript">
        jQuery(document).ready(function($) {
            // We only want these styles applied when javascript is enabled
            $('div.navigation').css({'width' : '300px', 'float' : 'left'});
            $('div.content').css('display', 'block');

            // Initially set opacity on thumbs and add
            // additional styling for hover effect on thumbs
            var onMouseOutOpacity = 0.67;
            $('#thumbs ul.thumbs li').opacityrollover({
                mouseOutOpacity:   onMouseOutOpacity,
                mouseOverOpacity:  1.0,
                fadeSpeed:         'fast',
                exemptionSelector: '.selected'
            });

            // Initialize Advanced Galleriffic Gallery
            var gallery = $('#thumbs').galleriffic({
                delay:                     5500,
                numThumbs:                 15,
                preloadAhead:              10,
                enableTopPager:            true,
                enableBottomPager:         true,
                maxPagesToShow:            7,
                imageContainerSel:         '#slideshow',
                controlsContainerSel:      '#controls',
                captionContainerSel:       '#caption',
                loadingContainerSel:       '#loading',
                renderSSControls:          true,
                renderNavControls:         true,
                playLinkText:              'Play',
                pauseLinkText:             'Pause',
                prevLinkText:              'Previous',
                nextLinkText:              'Next',
                nextPageLinkText:          'Next &rsaquo;',
                prevPageLinkText:          '&lsaquo; Prev',
                enableHistory:             false,
                autoStart:                 true,
                syncTransitions:           true,
                defaultTransitionDuration: 900,
                onSlideChange:             function(prevIndex, nextIndex) {
                    // 'this' refers to the gallery, which is an extension of $('#thumbs')
                    this.find('ul.thumbs').children()
                        .eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
                        .eq(nextIndex).fadeTo('fast', 1.0);
                },
                onPageTransitionOut:       function(callback) {
                    this.fadeTo('fast', 0.0, callback);
                },
                onPageTransitionIn:        function() {
                    this.fadeTo('fast', 1.0);
                }
            });
        });
    </script>
Jawad
  • 8,352
  • 10
  • 40
  • 45
  • 1
    What exactly is your question? – jfriend00 Aug 26 '12 at 23:41
  • @jfriend00: Do I have to refer to both these files?. Why do I need to refer/link to different versions of jquery (1.6.1 & 1.3.2) and why they dont work when placed at the top? – Jawad Aug 26 '12 at 23:44
  • @Jawad try to refer only to 1.6.1 or better try to use latest version 1.8.0. If you do as in your code you'll really get only 1.3, cause it is included later. And I'm almost sure that `hoverTransition.js` won't work cause it requires at least 1.6 – d.k Aug 26 '12 at 23:49
  • @caligula: I tried the latest version as well. Using 1.8.0 causes the CSS3 hover Transitions to not work but gallery works. Tried 1.6.1 but CSS3 hover Transitions work and slideshow gallery don't work. Tried 1.3.2 and gallery works but transitions dont work. Tried to place them in head tag, dont work. ONLY way both of them works is if I have both 1.3.2 and 1.6.1 and placed at the bottom. – Jawad Aug 26 '12 at 23:56

1 Answers1

2

It is complicated and undesirable to put two different versions of jQuery in the same page. Your first goal is to avoid this entirely - you'd rather only have the newer version of jQuery in the page.

So, your first order of business is to do some research on the jQuery plug-ins you're using and see if they will all work with a common version of jQuery.

If you determine that they will all work with a common version of jQuery, then just include jQuery in your page before the plugins and include the plugins before your code that uses them. The jQuery code can go in the HEAD section or in the BODY section as long as it's before anything that tries to use it. The plug-in code can probably go anywhere after the jQuery code, but you'd have to consult the plug-in doc to make sure.

If you determine that you have to have two different versions of jQuery, then you need to work out how you go about doing that. Here's a related question on how that is done: Can I use multiple versions of jQuery on the same page?.

When using two versions of jQuery, you end up having to define a unique symbol that represents a particular version of jQuery using jQuery.noConflict() (not jQuery and not $) and then ALL code that uses that plug-in has to use that unique symbol.

Community
  • 1
  • 1
jfriend00
  • 683,504
  • 96
  • 985
  • 979
  • An excellant answer but given my no "exp" not praticall. The Hover Transition plugin is think not supported and one can not even find the plugin file. I had to veiwsource and copy the code from the demopage to make my own file. Guess I have to ditch one or another as can't surely dig in the code to "update" it to work with latest jquery version. – Jawad Aug 27 '12 at 00:07
  • @Jawad - You may not want to hear this, but it sounds to me like you'll need to use plug-ins that work within the limits of what you know how to do. That probably means they come with straightforward instructions for how to install and use them and the ones you select all work with a common version of jQuery. – jfriend00 Aug 27 '12 at 00:13
  • Yeah that about captures the esseance of the problem. I guess I have to dig for alternative jquery plugins for slidshow gallery and CSS3 Hover Transitions for IE that both work on 1.8.0 version. – Jawad Aug 27 '12 at 00:15