PDA

View Full Version : Mootools lightbox conflict?



Paul123
08-18-2008, 07:02 PM
Hi all.
I have the mootools javascript working on a menu on a site i'm building. Works as should.
I am also trying to use lightbox to expand images. both work fine independantly, but lightbox fails when together.

if I remove this section from the head lightbox works,


<script type="text/javascript">
var Kwix = {

start: function(){
Kwix.parseKwicks();
},

parseKwicks: function(){

var squeeze_to = 100;
var max_width = 217;

//get original widths
var start_widths = new Array();
var kwicks = $$('#kwick .kwick');
var fx = new Fx.Elements(kwicks, {wait: false, duration: 250, transition:Fx.Transitions.Cubic.easeOut});
kwicks.each(function(kwick, i){

start_widths[i] = kwick.getStyle('width').toInt();

//mouse is in, squeeze and expand
kwick.addEvent('mouseenter', function(e){

var obj = {};
obj[i] = {
'width': [kwick.getStyle('width').toInt(), max_width]
};

var counter = 0;

kwicks.each(function(other, j){
if (other != kwick){
var w = other.getStyle('width').toInt();
if (w != squeeze_to) obj[j] = {'width': [w,squeeze_to] };
}
});
fx.start(obj);
}
);
});

//mouse is out, squeeze back
$('kwick').addEvent('mouseleave', function(e){
var obj = {};
kwicks.each(function(other, j){
obj[j] = {'width': [other.getStyle('width').toInt(), start_widths[j]]};
});
fx.start(obj);
});
}
};
//lock and load!
window.addEvent('domready',Kwix.start);
</script>


I have tried to amend the code following example on development page lightbox.

;initLightbox()">
Tried this in various locations in the above code.
I have also tried

<body onload="initLightbox();">
To be honest it's guesswork my understanding of javascript is poor.
I considered using this similar solution (http://www.dynamicdrive.com/forums/showthread.php?t=27432), but thought i'd be digging bigger holes.
The link to page is here (http://freshfreelance.org.uk/home/wright-ideas/)
Any ideas,
Thanks in advance.
Paul