13
13
Dependencies (please load these first):
14
link-core/prototype.js
15
link-core/effects.js, link-core/fastinit.js, link-core/crossfade.js
15
link-core/jquery.cycle.all.js
16
16
directory.js (note that this file does not exist yet, but will when the build script runs)
19
/* Accepts the following parameters using global variables set ahead of time:
20
* SLIDESHOW_SLIDE_INTERVAL (default is 45)
21
* SLIDESHOW_TRANSITION_DURATION (default is 0.5)
22
* SLIDESHOW_LOOP (default is false)
23
* SLIDESHOW_TRANSITION_TYPE (default is Crossfade.Transition.Cover)
19
/* Pass parameters by creating a global SLIDESHOW_OPTIONS object, containing
20
any options described at <http://jquery.malsup.com/cycle/options.html>
22
The default callback for cycle.next also checks an extra autopause parameter,
23
which will pause the slideshow when it reaches the end (but doesn't stop it)
26
window.onDomReady = DomReady;
29
document.addEventListener("DOMContentLoaded", fn, false);
34
window.onDomReady(function(){
36
slide_interval : window.SLIDESHOW_SLIDE_INTERVAL || 45,
37
slide_transition_duration : window.SLIDESHOW_TRANSITION_DURATION || 0.5,
38
loop : window.SLIDESHOW_LOOP || false,
39
transition_type : window.SLIDESHOW_TRANSITION_TYPE || Crossfade.Transition.Cover
28
$(document).ready(function() {
29
slideshow = $('#slideshow');
31
var slideshow_options = {
42
var instance_options = []; /* this will hold parameters passed to the slideshow */
42
var instance_options = [];
43
43
parameters = window.location.hash.slice(window.location.hash.indexOf('#') + 1).split('?');
44
44
for(var i = 0; i < parameters.length; i++)
52
52
setLocale(instance_options['locale']);
54
54
if ( instance_options.indexOf('rtl') > -1 )
61
interval:settings.slide_interval,
62
duration:settings.slide_transition_duration,
64
transition:settings.transition_type
66
slideshow = new Crossfade('slideshow');
55
$(document.body).addClass('rtl');
69
61
var debug_controls;
70
62
if ( instance_options.indexOf('controls') > -1 )
71
debug_controls = $('debug-controls');
72
var controls = $('controls') || debug_controls;
63
debug_controls = $('#debug-controls');
64
var controls = $('#controls') || debug_controls;
74
66
if (debug_controls) {
75
debug_controls.style.display = "block";
67
debug_controls.show();
79
71
/* we assume #controls contains
80
72
#current-slide, #prev-slide and #next-slide */
82
/* TODO: only loop when the user is interacting with the controls; we
83
should still stop the timer if it reaches the end on its own */
84
slideshow.options.loop = true;
86
$('current-slide').value = slideshow.filenames[0];
87
$('prev-slide').onclick = prevSlide;
88
$('next-slide').onclick = nextSlide;
73
/*slideshow.options.loop = true;*/ /* TODO: USE CYCLE.NOWRAP */
75
slideshow_options.prev = $('#prev-slide');
76
slideshow_options.next = $('#next-slide');
81
slideshow_options.after = function(curr, next, opts) {
82
var index = opts.currSlide;
83
/* pause at last slide if requested in options */
84
if ( index == opts.slideCount - 1 && opts.autopause ) {
85
slideshow.cycle('pause'); /* slides can still be advanced manually */
89
$.extend(slideshow_options, window.SLIDESHOW_OPTIONS);
90
slideshow.cycle(slideshow_options);
93
94
function setLocale(locale) {
94
var slideanchors = $$("div#slideshow div a");
96
slideanchors.each(function(anchor) {
97
var slide_name = anchor.readAttribute("href");
98
var new_url = _get_translated_url(slide_name, locale);
95
slideshow.find('div>a').each(function() {
96
var new_url = get_translated_url($(this).attr('href'), locale);
100
98
if ( new_url != null ) {
101
anchor.href = new_url;
102
/*console.log("Using translation at: "+ new_url);*/
99
$(this).attr('href', new_url);
106
function _get_translated_url(slide_name, locale) {
103
function get_translated_url(slide_name, locale) {
107
104
var translated_url = null
109
if ( _translation_exists(slide_name, locale) ) {
106
if ( translation_exists(slide_name, locale) ) {
110
107
translated_url = "./loc."+locale+"/"+slide_name;
112
109
var before_dot = locale.split(".",1)[0];
113
110
var before_underscore = before_dot.split("_",1)[0];
114
if ( before_underscore != null && _translation_exists(slide_name, before_underscore) )
111
if ( before_underscore != null && translation_exists(slide_name, before_underscore) )
115
112
translated_url = "./loc."+before_underscore+"/"+slide_name;
116
else if ( before_dot != null && _translation_exists(slide_name, before_dot) )
113
else if ( before_dot != null && translation_exists(slide_name, before_dot) )
117
114
translated_url = "./loc."+before_dot+"/"+slide_name;
120
117
return translated_url;
123
function _translation_exists(slide_name, locale) {
120
function translation_exists(slide_name, locale) {
126
123
result = ( directory[locale][slide_name] == true );