PDA

View Full Version : Simple Controls Gallery - Status outside of simplegallery div



ArrobaJay
05-08-2010, 03:45 PM
1) Script Title: Simple Controls Gallery

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex4/simplegallery.htm

3) Describe problem: Hi,

What I want is a really straightforward jQuery gallery, and yours fits the bill perfectly. So as to make it 100% friendly with browsers and mobile devices alike, I'd like to use an external status and links etc "< image 3 of 6 >" that kind of idea. I've sorted the links to next and previous images no problem, however I'm struggling to see how I can get the current and total number of images without using the default panel.

Thanks in advance,

Jay

jscheuer1
05-08-2010, 09:40 PM
You can use the onslide property which already is passed the current image number (from the demo page):


<script type="text/javascript">

var mygallery=new simpleGallery({
wrapperid: "simplegallery1", //ID of main gallery container,
dimensions: [250, 180], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
imagearray: [
["http://i26.tinypic.com/11l7ls0.jpg", "http://en.wikipedia.org/wiki/Swimming_pool", "_new", "There's nothing like a nice swim in the Summer."],
["http://i29.tinypic.com/xp3hns.jpg", "http://en.wikipedia.org/wiki/Cave", "", ""],
["http://i30.tinypic.com/531q3n.jpg", "", "", "Eat your fruits, it's good for you!"],
["http://i31.tinypic.com/119w28m.jpg", "", "", ""]
],
autoplay: [true, 2500, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
oninit:function(){ //event that fires when gallery has initialized/ ready to run
//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
},
onslide:function(curslide, i){ //event that fires after each slide is shown
//Keyword "this": references current gallery instance
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
}
})

</script>

The total number of images can be got within that function as:


this.setting.imagearray.length

One way to take advantage of that:


onslide:function(curslide, i){ //event that fires after each slide is shown
//Keyword "this": references current gallery instance
//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
document.getElementById('status_display').innerHTML = 'image ' + (i + 1) + ' of ' + this.setting.imagearray.length;
}

All you need is a span or a div with the id of 'status_display'.