// first preload all the images, while getting their actual width and height (function(proceed) {
var n_loaded = 0; function loop(i, img) { // for (i = 0; i < plan.length; i++) but with independent var i, img (for the closures) img.onload = function(e) { n_loaded++; plan[i].width = img.width; plan[i].height = img.height; if (n_loaded == plan.length) proceed(); } img.src = plan[i].src; if (i + 1 < plan.length) loop(i + 1, new Image()); } loop(0, new Image());
// utility to compute the css for a given phase between p.from and p.to // phase = 1: begin fade-in, 2: end fade-in, 3: begin fade-out, 4: end fade-out function position_to_css(p, phase) { switch (phase) { case 1: var pos = 0; break; case 2: var pos = fade_ms / (p.time_ms + 2 * fade_ms); break; case 3: var pos = 1 - fade_ms / (p.time_ms + 2 * fade_ms); break; case 4: var pos = 1; break; } return { left: Math.round(p.from.left + pos * (p.to.left - p.from.left )), top: Math.round(p.from.top + pos * (p.to.top - p.from.top )), width: Math.round(p.from.width + pos * (p.to.width - p.from.width )), height: Math.round(p.from.height + pos * (p.to.height - p.from.height)) }; }
// check global params if (! opts.fade) abort('missing fade parameter.'); if (opts.speed && opts.sleep) abort('you cannot set both speed and sleep at the same time.'); // conversion from sec to ms; from px/sec to px/ms var fade_ms = Math.round(opts.fade * 1000); if (opts.sleep) var sleep = Math.round(opts.sleep * 1000); if (opts.speed) var speed = opts.speed / 1000, fade_px = Math.round(fade_ms * speed);
// set container css self.empty().css({ overflow: 'hidden', padding: 0 }); if (! self.css('position').match(/absolute|relative|fixed/)) self.css({ position: 'relative' }); if (! self.width() || ! self.height()) abort('container element does not have its own width and height');
// prepare each image for (var i = 0; i < plan.length; ++i) {
var p = plan[i]; if (! p.src) abort('missing src parameter in picture {0}.', i + 1);
if (speed) { // speed/dir mode
// check parameters and translate speed/dir mode into full mode (from/to/time) switch (p.dir) { case 'up': p.from = { xrel: .5, yrel: 0, zoom: 1 }; p.to = { xrel: .5, yrel: 1, zoom: 1 }; var slide_px = p.height - self_height - 2 * fade_px; break; case 'down': p.from = { xrel: .5, yrel: 1, zoom: 1 }; p.to = { xrel: .5, yrel: 0, zoom: 1 }; var slide_px = p.height - self_height - 2 * fade_px; break; case 'left': p.from = { xrel: 0, yrel: .5, zoom: 1 }; p.to = { xrel: 1, yrel: .5, zoom: 1 }; var slide_px = p.width - self_width - 2 * fade_px; break; case 'right': p.from = { xrel: 1, yrel: .5, zoom: 1 }; p.to = { xrel: 0, yrel: .5, zoom: 1 }; var slide_px = p.width - self_width - 2 * fade_px; break; default: abort('missing or malformed \"dir\" parameter in picture {0}.', i + 1); } if (slide_px <= 0) abort('picture number {0} is too short for the desired fade duration.', i + 1); p.time_ms = Math.round(slide_px / speed);
} else if (! sleep) { // full mode
// check and parse parameters if (! p.from || ! p.to || ! p.time) abort('missing either speed/sleep option, or from/to/time params in picture {0}.', i + 1); try { p.from = parse_position_param(p.from) } catch (e) { abort('malformed \"from\" parameter in picture {0}.', i + 1); } try { p.to = parse_position_param(p.to) } catch (e) { abort('malformed \"to\" parameter in picture {0}.', i + 1); } if (! p.time) abort('missing \"time\" parameter in picture {0}.', i + 1); p.time_ms = Math.round(p.time * 1000) }
// append the image element to the container var elm; if (p.href) elm = jQuery(format('<a href=\"{0}\"><img src=\"{1}\"/></a>', p.href, p.src)); else elm = jQuery(format('<img src=\"{0}\"/>', p.src)); if (p.onclick) elm.click(p.onclick); elm.css({ position: 'absolute', visibility: 'hidden', top: 0, left: 0 }).find('img').css({ border: 0 }); elm.appendTo(self); } speed = undefined; // speed mode has now been translated to full mode
var imgs = self.children();
// show first image imgs.eq(0).css({ visibility: 'visible' }); if (! sleep) imgs.eq(0).css(position_to_css(plan[0], 2));
// create animation chain var countdown = opts.loop; function create_chain(i, chainf) { // building the chain backwards, or inside out
// if the loop option was requested, push a countdown check if (opts.loop && i == plan.length * 2 - 2) { var newf_orig = newf; newf = function() { if (--countdown) newf_orig(); } }
if (i > 0) return create_chain(i - 1, newf); else return newf; } var animation = create_chain(plan.length * 2 - 1, function() { return animation(); });
// start animation animation();
});
return self; };
?php
class Slide extends Module
{
function __construct()
{
$this->name = 'slide';
$this->tab = 'Tools';
$this->version = 0.2;
parent::__construct(); // The parent construct is required for translations
$this->page = basename(__FILE__, '.php');
$this->displayName = $this->l('Slide');
$this->description = $this->l('Shows a slideshow in your home page');
}
function install()
{
if (!parent::install() OR !$this->registerHook('home') OR !$this->registerHook('header'))
Well I'm not familiar with this slider and my Spanish isn't what it was, but I'd say it's a pretty fair bet that it should come after the 2 existing images in the document head:
/*ruta de imagenes y vinculo (si se usa)*/ [ { src: '/modules/slide/images/slide_01.jpg', href: '/low-priced-retractable-pens/89-s-ft.html' }, { src: '/modules/slide/images/slide_02.jpg', href: '/low-priced-retractable-pens/56-ingeo-pen-color.html' } ****NEW IMAGE GOES HERE**** ]); /*ruta de imagenes y vinculo (si se usa)*/ });
Can anyone let me know where in the coding i'd need to add the info to do so.
Thank you so much if anyone could help. I'm pretty sure its easy if someone knows coding.
{literal}
<link rel=\"stylesheet\" href=\"{/literal}{$base_dir}{literal}modules/slide/css/carrusel.css\" type=\"text/css\" media=\"screen\" charset=\"utf-8\" />
<script src=\"{/literal}{$base_dir}{literal}modules/slide/js/jquery.cross-slide.js\" type=\"text/javascript\"></script>
<!-- Configura el Slide -->
<script type='text/javascript' id='source-slide'>
$(function() {
$('#slide').crossSlide({
/*Configuracion de la velocidad de cambio y fundido*/
sleep: 4, //in sec
fade: 2 //in sec
/*Configuracion de la velocidad de cambio y fundido*/
},
/*ruta de imagenes y vinculo (si se usa)*/
[
{ src: '{/literal}{$base_dir}{literal}modules/slide/images/slide_01.jpg', href: '/low-priced-retractable-pens/89-s-ft.html' },
{ src: '{/literal}{$base_dir}{literal}modules/slide/images/slide_02.jpg', href: '/low-priced-retractable-pens/56-ingeo-pen-color.html' }
]);
/*ruta de imagenes y vinculo (si se usa)*/
});
</script>
<!-- Configura el Slide -->
{/literal}
Just the load icon keeps loading when I add it here.
I'll try again, hopefully it was a typo or something.
Edit: No luck the load icon stays loading when add the line here. Sure its needed there just something else needs to allow the range etc