views:

26

answers:

4

hi fellows, i just bought a joomla template from template monster. there is photo gallery on home page which skips to photos by clicking onto them.

what i need is a self sliding photo gallery you know what i mean automatically skipping photos in preset interval. http://www.mirelmuhendislik.com/home-tr/index.php this is the homepage.

i tried to do it by

function clicker() {
document.getElementById('photo2').click();
}
setInterval("clicker()",5000);

but it didnt work. i dunno why it didnt work is it because of javascript embedding options of joomla or is it because my javascript code?? and how can i solve this problem? i'd be glad to see some suggestions please help :/

+1  A: 

In this scenario you can use .bind() and .trigger()

$(function() {
   setInterval(function() {
      $('#slider').trigger('slide');  //triggers 'slide'
   },2000);  //Performs sliding every 2 seconds
});

$('#slider').bind('slide', function() {
   //write your slide methods
});

Edit : Code & Demo Page : http://jsbin.com/efoje4

HTML :

<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"&gt;&lt;/script&gt;
<meta charset=utf-8 />
<title>Hello world !!</title>
  <style type="text/css">
    div {margin:0px auto;padding:0px; width:300px;height:200px; overflow:hidden; }
    ul { margin :0px; padding:0px; list-style:none; width:1200px;height:200px;}
    li{float : left;margin:0px padding:0px; width:300px;height:200px; }
    img { margin:0px padding:0px; width:300px;height:200px; }    
  </style>

</head>
<body>
  <div>
    <ul id="slider">
      <li>
          <img src="http://mystuffspace.com/graphic/adorable-puppies.jpg"/&gt;
      </li>
      <li>
          <img src="http://2.bp.blogspot.com/_TP5pGCYHvfg/SyMRSFukqJI/AAAAAAAAA0Y/yIP62DYXOP8/s400/Puppies.jpg"/&gt;
      </li>
      <li>
          <img src="http://temunot.files.wordpress.com/2008/11/4-cute-puppies-wallpaper-640x480.jpg" />
      </li>
      <li>
          <img src="http://mystuffspace.com/graphic/puppies-2.jpg" />
      </li>
    </ul>
  </div>
</body>
</html>

JavaScript :

var margin  = 0, slider = $('#slider'), width = 300;

$(document).ready(function() {
  setInterval(function() {
      slider.trigger('slide');
  },2000);
});

 slider.bind('slide',function() {
  if(margin <= slider.width() *(-1) + width) {
      margin = 0;
  }else if(margin <= slider.width()) {
    margin -= width;  
  }
   slider.animate({marginLeft : margin},500);
});
Ninja Dude
thanks for great code but :/ my problem is pretty different
Ahmet Yıldırım
A: 
<div class="extra_wrapper">
<div id="gallery" class="content">
<div class="slideshow-container">
<div id="loading" class="loader"></div>
<div id="slideshow" class="slideshow"></div>
</div>
</div>
<div id="thumbs" class="navigation">
<ul id="slider" class="thumbs noscript">
<li> <a class="thumb" name="leaf" href="images/stories/big_pic1.png"> <img src="images/stories/gallery_pic1.jpg" /></a></li>
<li> <a class="thumb" name="leaf" href="images/stories/big_pic2.png"> <img src="images/stories/gallery_pic2.jpg" /></a></li>
<li> <a class="thumb" name="leaf" href="images/stories/big_pic3.png"> <img src="images/stories/gallery_pic3.jpg" /></a></li>
<li> <a class="thumb" name="leaf" href="images/stories/big_pic4.png"> <img src="images/stories/gallery_pic4.jpg" /></a></li>
<li class="last"> <a class="thumb" name="leaf" href="images/stories/big_pic5.png"> <img src="images/stories/gallery_pic5.jpg" /></a></li>
</ul>
</div>
</div>

this is the module script that runs photo gallery on my site http://mirelmuhendislik.com/home-tr/ here when i add your script it moved whole photogallery not only the big photos which suppose to be skipping. i want small photos below to stay still

Ahmet Yıldırım
btw that id="slider" wasnt in the script at default i just forgot to remove sorry
Ahmet Yıldırım
@Ahmet At the time I visited your site, I can't access the page, seems like you're still installing joomla, thought that automatic slideShow is enough =). I'll Modify the code :)
Ninja Dude
A: 

it seems in this template they used jquery galleriffic library maybe we can set it to slide automatically in the settings below.

var defaults = {
    delay:                     3000,
    numThumbs:                 20,
    preloadAhead:              40, // Set to -1 to preload all images
    enableTopPager:            false,
    enableBottomPager:         true,
    maxPagesToShow:            7,
    imageContainerSel:         '',
    captionContainerSel:       '',
    controlsContainerSel:      '',
    loadingContainerSel:       '',
    renderSSControls:          true,
    renderNavControls:         true,
    playLinkText:              'Play',
    pauseLinkText:             'Pause',
    prevLinkText:              'Previous',
    nextLinkText:              'Next',
    nextPageLinkText:          'Next &rsaquo;',
    prevPageLinkText:          '&lsaquo; Prev',
    enableHistory:             false,
    enableKeyboardNavigation:  true,
    autoStart:                 false,
    syncTransitions:           false,
    defaultTransitionDuration: 1000,
    onSlideChange:             undefined, // accepts a delegate like such: function(prevIndex, nextIndex) { ... }
    onTransitionOut:           undefined, // accepts a delegate like such: function(slide, caption, isSync, callback) { ... }
    onTransitionIn:            undefined, // accepts a delegate like such: function(slide, caption, isSync) { ... }
    onPageTransitionOut:       undefined, // accepts a delegate like such: function(callback) { ... }
    onPageTransitionIn:        undefined, // accepts a delegate like such: function() { ... }
    onImageAdded:              undefined, // accepts a delegate like such: function(imageData, $li) { ... }
    onImageRemoved:            undefined  // accepts a delegate like such: function(imageData, $li) { ... }
};
Ahmet Yıldırım
A: 

yea there is a problem about accessing site with www. prefix ok problem solved i just edited jquery galleriffic code and replaced

if(this.autoStart) {
this.play();
}

with

this.play();

you may ask why i didnt just set autoStart=1 well i tried it but it didnt work i dunno why

Ahmet Yıldırım