diff -r 861cae17abda -r 6cb4d10f0b8b web/res/metadataplayer/test/interface 1.2/source/islideshow.js
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/web/res/metadataplayer/test/interface 1.2/source/islideshow.js Wed Apr 06 16:26:16 2011 +0200
@@ -0,0 +1,422 @@
+/**
+ * Interface Elements for jQuery
+ * Slideshow
+ *
+ * http://interface.eyecon.ro
+ *
+ * Copyright (c) 2006 Stefan Petre
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ */
+
+
+/**
+ * Creates an image slideshow. The slideshow can autoplay slides, each image can have caption, navigation links: next, prev, each slide. A page may have more then one slideshow, eachone working independently. Each slide can be bookmarked. The source images can be defined by JavaScript in slideshow options or by HTML placing images inside container.
+ *
+ *
+ *
+ * @name Slideshow
+ * @description Creates an image slideshow. The slideshow can autoplay slides, each image can have caption, navigation links: next, prev, each slide. A page may have more then one slideshow, eachone working independently. Each slide can be bookmarked. The source images can be defined by JavaScript in slideshow options or by HTML placing images inside container.
+ * @param Hash hash A hash of parameters
+ * @option String container container ID
+ * @option String loader path to loading indicator image
+ * @option String linksPosition (optional) images links position ['top'|'bottom'|null]
+ * @option String linksClass (optional) images links cssClass
+ * @option String linksSeparator (optional) images links separator
+ * @option Integer fadeDuration fade animation duration in miliseconds
+ * @option String activeLinkClass (optional) active image link CSS class
+ * @option String nextslideClass (optional) next image CSS class
+ * @option String prevslideClass (optional) previous image CSS class
+ * @option String captionPosition (optional) image caption position ['top'|'bottom'|null]
+ * @option String captionClass (optional) image caption CSS class
+ * @option String autoplay (optional) seconds to wait untill next images is displayed. This option will make the slideshow to autoplay.
+ * @option String random (optional) if slideshow autoplayes the images can be randomized
+ * @option Array images (optional) array of hash with keys 'src' (path to image) and 'cation' (image caption) for images
+ *
+ * @type jQuery
+ * @cat Plugins/Interface
+ * @author Stefan Petre
+ */
+jQuery.islideshow = {
+ slideshows: [],
+ gonext : function()
+ {
+ this.blur();
+ slideshow = this.parentNode;
+ id = jQuery.attr(slideshow, 'id');
+ if (jQuery.islideshow.slideshows[id] != null) {
+ window.clearInterval(jQuery.islideshow.slideshows[id]);
+ }
+ slide = slideshow.ss.currentslide + 1;
+ if (slideshow.ss.images.length < slide) {
+ slide = 1;
+ }
+ images = jQuery('img', slideshow.ss.holder);
+ slideshow.ss.currentslide = slide;
+ if (images.size() > 0) {
+ images.fadeOut(
+ slideshow.ss.fadeDuration,
+ jQuery.islideshow.showImage
+ );
+ }
+ },
+ goprev : function()
+ {
+ this.blur();
+ slideshow = this.parentNode;
+ id = jQuery.attr(slideshow, 'id');
+ if (jQuery.islideshow.slideshows[id] != null) {
+ window.clearInterval(jQuery.islideshow.slideshows[id]);
+ }
+ slide = slideshow.ss.currentslide - 1;
+ images = jQuery('img', slideshow.ss.holder);
+ if (slide < 1) {
+ slide = slideshow.ss.images.length ;
+ }
+ slideshow.ss.currentslide = slide;
+ if (images.size() > 0) {
+ images.fadeOut(
+ slideshow.ss.fadeDuration,
+ jQuery.islideshow.showImage
+ );
+ }
+ },
+ timer : function (c)
+ {
+ slideshow = document.getElementById(c);
+ if (slideshow.ss.random) {
+ slide = slideshow.ss.currentslide;
+ while(slide == slideshow.ss.currentslide) {
+ slide = 1 + parseInt(Math.random() * slideshow.ss.images.length);
+ }
+ } else {
+ slide = slideshow.ss.currentslide + 1;
+ if (slideshow.ss.images.length < slide) {
+ slide = 1;
+ }
+ }
+ images = jQuery('img', slideshow.ss.holder);
+ slideshow.ss.currentslide = slide;
+ if (images.size() > 0) {
+ images.fadeOut(
+ slideshow.ss.fadeDuration,
+ jQuery.islideshow.showImage
+ );
+ }
+ },
+ go : function(o)
+ {
+ var slideshow;
+ if (o && o.constructor == Object) {
+ if (o.loader) {
+ slideshow = document.getElementById(o.loader.slideshow);
+ url = window.location.href.split("#");
+ o.loader.onload = null;
+ if (url.length == 2) {
+ slide = parseInt(url[1]);
+ show = url[1].replace(slide,'');
+ if (jQuery.attr(slideshow,'id') != show) {
+ slide = 1;
+ }
+ } else {
+ slide = 1;
+ }
+ }
+ if(o.link) {
+ o.link.blur();
+ slideshow = o.link.parentNode.parentNode;
+ id = jQuery.attr(slideshow, 'id');
+ if (jQuery.islideshow.slideshows[id] != null) {
+ window.clearInterval(jQuery.islideshow.slideshows[id]);
+ }
+ url = o.link.href.split("#");
+ slide = parseInt(url[1]);
+ show = url[1].replace(slide,'');
+ if (jQuery.attr(slideshow,'id') != show) {
+ slide = 1;
+ }
+ }
+ if (slideshow.ss.images.length < slide || slide < 1) {
+ slide = 1;
+ }
+ slideshow.ss.currentslide = slide;
+ slidePos = jQuery.iUtil.getSize(slideshow);
+ slidePad = jQuery.iUtil.getPadding(slideshow);
+ slideBor = jQuery.iUtil.getBorder(slideshow);
+ if (slideshow.ss.prevslide) {
+ slideshow.ss.prevslide.o.css('display', 'none');
+ }
+ if (slideshow.ss.nextslide) {
+ slideshow.ss.nextslide.o.css('display', 'none');
+ }
+
+ //center loader
+ if (slideshow.ss.loader) {
+ y = parseInt(slidePad.t) + parseInt(slideBor.t);
+ if (slideshow.ss.slideslinks) {
+ if (slideshow.ss.slideslinks.linksPosition == 'top') {
+ y += slideshow.ss.slideslinks.dimm.hb;
+ } else {
+ slidePos.h -= slideshow.ss.slideslinks.dimm.hb;
+ }
+ }
+ if (slideshow.ss.slideCaption) {
+ if (slideshow.ss.slideCaption && slideshow.ss.slideCaption.captionPosition == 'top') {
+ y += slideshow.ss.slideCaption.dimm.hb;
+ } else {
+ slidePos.h -= slideshow.ss.slideCaption.dimm.hb;
+ }
+ }
+ if (!slideshow.ss.loaderWidth) {
+ slideshow.ss.loaderHeight = o.loader ? o.loader.height : (parseInt(slideshow.ss.loader.css('height'))||0);
+ slideshow.ss.loaderWidth = o.loader ? o.loader.width : (parseInt(slideshow.ss.loader.css('width'))||0);
+ }
+
+ slideshow.ss.loader.css('top', y + (slidePos.h - slideshow.ss.loaderHeight)/2 + 'px');
+ slideshow.ss.loader.css('left', (slidePos.wb - slideshow.ss.loaderWidth)/2 + 'px');
+ slideshow.ss.loader.css('display', 'block');
+ }
+
+ //getimage
+ images = jQuery('img', slideshow.ss.holder);
+ if (images.size() > 0) {
+ images.fadeOut(
+ slideshow.ss.fadeDuration,
+ jQuery.islideshow.showImage
+ );
+ } else {
+ lnk = jQuery('a', slideshow.ss.slideslinks.o).get(slide-1);
+ jQuery(lnk).addClass(slideshow.ss.slideslinks.activeLinkClass);
+ var img = new Image();
+ img.slideshow = jQuery.attr(slideshow,'id');
+ img.slide = slide-1;
+ img.src = slideshow.ss.images[slideshow.ss.currentslide-1].src ;
+ if (img.complete) {
+ img.onload = null;
+ jQuery.islideshow.display.apply(img);
+ } else {
+ img.onload = jQuery.islideshow.display;
+ }
+ //slideshow.ss.holder.html('');
+ if (slideshow.ss.slideCaption) {
+ slideshow.ss.slideCaption.o.html(slideshow.ss.images[slide-1].caption);
+ }
+ //jQuery('img', slideshow.ss.holder).bind('load',jQuery.slideshowDisplay);
+ }
+ }
+ },
+ showImage : function()
+ {
+ slideshow = this.parentNode.parentNode;
+ slideshow.ss.holder.css('display','none');
+ if (slideshow.ss.slideslinks.activeLinkClass) {
+ lnk = jQuery('a', slideshow.ss.slideslinks.o).removeClass(slideshow.ss.slideslinks.activeLinkClass).get(slideshow.ss.currentslide - 1);
+ jQuery(lnk).addClass(slideshow.ss.slideslinks.activeLinkClass);
+ }
+ //slideshow.ss.holder.html('
');
+
+ var img = new Image();
+ img.slideshow = jQuery.attr(slideshow,'id');
+ img.slide = slideshow.ss.currentslide - 1;
+ img.src = slideshow.ss.images[slideshow.ss.currentslide - 1].src ;
+ if (img.complete) {
+ img.onload = null;
+ jQuery.islideshow.display.apply(img);
+ } else {
+ img.onload = jQuery.islideshow.display;
+ }
+ if (slideshow.ss.slideCaption) {
+ slideshow.ss.slideCaption.o.html(slideshow.ss.images[slideshow.ss.currentslide-1].caption);
+ }
+ //jQuery('img', slideshow.ss.holder).bind('load',jQuery.slideshowDisplay);
+ },
+ display : function ()
+ {
+ slideshow = document.getElementById(this.slideshow);
+ if (slideshow.ss.prevslide) {
+ slideshow.ss.prevslide.o.css('display', 'none');
+ }
+ if (slideshow.ss.nextslide) {
+ slideshow.ss.nextslide.o.css('display', 'none');
+ }
+ slidePos = jQuery.iUtil.getSize(slideshow);
+ y = 0;
+ if (slideshow.ss.slideslinks) {
+ if (slideshow.ss.slideslinks.linksPosition == 'top') {
+ y += slideshow.ss.slideslinks.dimm.hb;
+ } else {
+ slidePos.h -= slideshow.ss.slideslinks.dimm.hb;
+ }
+ }
+ if (slideshow.ss.slideCaption) {
+ if (slideshow.ss.slideCaption && slideshow.ss.slideCaption.captionPosition == 'top') {
+ y += slideshow.ss.slideCaption.dimm.hb;
+ } else {
+ slidePos.h -= slideshow.ss.slideCaption.dimm.hb;
+ }
+ }
+ par = jQuery('.slideshowHolder', slideshow);
+ y = y + (slidePos.h - this.height)/2 ;
+ x = (slidePos.wb - this.width)/2;
+ slideshow.ss.holder.css('top', y + 'px').css('left', x + 'px').html('
');
+ slideshow.ss.holder.fadeIn(slideshow.ss.fadeDuration);
+ nextslide = slideshow.ss.currentslide + 1;
+ if (nextslide > slideshow.ss.images.length) {
+ nextslide = 1;
+ }
+ prevslide = slideshow.ss.currentslide - 1;
+ if (prevslide < 1) {
+ prevslide = slideshow.ss.images.length;
+ }
+ slideshow.ss.nextslide.o
+ .css('display','block')
+ .css('top', y + 'px')
+ .css('left', x + 2 * this.width/3 + 'px')
+ .css('width', this.width/3 + 'px')
+ .css('height', this.height + 'px')
+ .attr('title', slideshow.ss.images[nextslide-1].caption);
+ slideshow.ss.nextslide.o.get(0).href = '#' + nextslide + jQuery.attr(slideshow, 'id');
+ slideshow.ss.prevslide.o
+ .css('display','block')
+ .css('top', y + 'px')
+ .css('left', x + 'px')
+ .css('width', this.width/3 + 'px')
+ .css('height', this.height + 'px')
+ .attr('title', slideshow.ss.images[prevslide-1].caption);
+ slideshow.ss.prevslide.o.get(0).href = '#' + prevslide + jQuery.attr(slideshow, 'id');
+ },
+ build : function(o)
+ {
+ if (!o || !o.container || jQuery.islideshow.slideshows[o.container])
+ return;
+ var container = jQuery('#' + o.container);
+ var el = container.get(0);
+
+ if (el.style.position != 'absolute' && el.style.position != 'relative') {
+ el.style.position = 'relative';
+ }
+ el.style.overflow = 'hidden';
+ if (container.size() == 0)
+ return;
+ el.ss = {};
+
+ el.ss.images = o.images ? o.images : [];
+ el.ss.random = o.random && o.random == true || false;
+ imgs = el.getElementsByTagName('IMG');
+ for(i = 0; i< imgs.length; i++) {
+ indic = el.ss.images.length;
+ el.ss.images[indic] = {src:imgs[i].src, caption:imgs[i].title||imgs[i].alt||''};
+ }
+
+ if (el.ss.images.length == 0) {
+ return;
+ }
+
+ el.ss.oP = jQuery.extend(
+ jQuery.iUtil.getPosition(el),
+ jQuery.iUtil.getSize(el)
+ );
+ el.ss.oPad = jQuery.iUtil.getPadding(el);
+ el.ss.oBor = jQuery.iUtil.getBorder(el);
+ t = parseInt(el.ss.oPad.t) + parseInt(el.ss.oBor.t);
+ b = parseInt(el.ss.oPad.b) + parseInt(el.ss.oBor.b);
+ jQuery('img', el).remove();
+ el.ss.fadeDuration = o.fadeDuration ? o.fadeDuration : 500;
+ if (o.linksPosition || o.linksClass || o.activeLinkClass) {
+ el.ss.slideslinks = {};
+ container.append('