PDA

View Full Version : Script Conflicts



Tartanneil
07-05-2011, 04:17 PM
I'm running this script for a tooltip slideshow:


var tooltipshow = {
init: function(id, category, effects){
this.id = $("#" + id);
this.category = category;
this.effects = effects;
this.speed = effects.speed || 500;

var me = this;
$("#" + id + " a").each(function(){
$(this).hover(
function(){
me.createToolTip(me.category[$(this).data("category")]);
},
function(){
me.tooltip.remove();
me.currimg = 0;
clearTimeout(me.counter);
});
});

return this; //pass this to the init caller variable;
},
createToolTip: function(category){
this.tooltip = $("<div></div>")
.addClass("tip");
this.images = new Array();
var me = this;
$.each(category, function(key, value){
me.images[key] = $("<img></img>")
.attr({
src: value,
width: 50,
height: 50
});
me.tooltip.append(me.images[key]);
});

$(document).mousemove(function(e){
var x = (e.pageX || e.clientX + document.body.scrollLeft) + 10;
var y = (e.pageY || e.clientY + document.body.scrollTop) + 10;

me.tooltip.css({
top: y + "px",
left: x + "px"
});
});

$("body").append(this.tooltip);
this.currimg = 0; // the current image
this.counter = setTimeout(function(){ me.slideshow(); }, this.speed);
},
slideshow: function(){
this.images[this.currimg].animate({'opacity': 0}, 500);
this.images[(this.currimg+1 > this.images.length-1) ? 0 : this.currimg+1].animate({'opacity': 1}, 500);
this.currimg++;
if(this.currimg > this.images.length-1){
this.currimg = 0;
}

var me = this;
this.counter = setTimeout(function(){ me.slideshow(); }, this.speed+500);
}
}

The tooltip slideshow also requires a second script that is stored here (http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.js).


Somewhere in the tooltip scripts there is a conflict with the Lightbox Image Viewer 2.03a (http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm) causing the viewer to stop working when the tooltip scripts are installed. Can anyone help me solve the issue?

Thanks in advance

jscheuer1
07-05-2011, 07:49 PM
Using jQuery for the tip and Prototype for the Lightbox doesn't make much sense. Prototype and jQuery are script libraries - sets of routines for automating common javascript tasks and effects. The two can coexist sometimes, depending upon versions used and upon the scripts that are using them. But I think that it might not work out in this case. In any case it's usually at least a little complicated to work out even when it can be.

You could use Slimbox 2:

http://www.digitalia.be/software/slimbox2

for the lightbox, it already uses jQuery. So there would be no conflict of that sort (between libraries). In fact you could and probably should only need to use one copy of jQuery for the page.

Tartanneil
07-06-2011, 07:36 AM
Tried it. It worked. You rock!