key => values switching in jcarousel.js
Qwaygon - November 1, 2009 - 08:30
| Project: | jCarousel |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | critical |
| Assigned: | Qwaygon |
| Status: | closed |
Description
original code from jcarousel-6.x-1.1 (jcarousel.js)
else if (typeof(options[callbackname]) == 'object' && (options[callbackname] instanceof Array)) {
// Arrays are evaluated as a list of callback registrations. This is because callbacks
// like itemVisibleInCallback can either be a function call back, or an array of callbacks
// consisting of both onBeforeAnimation and onAfterAnimation.
for (subcallback in options[callbackname]) {
var name = options[callbackname][subcallback];
options[callbackname][name] = eval(options[callbackname][name]);
}
}this part
for (subcallback in options[callbackname]) {
var name = options[callbackname][subcallback];
options[callbackname][name] = eval(options[callbackname][name]);
}basicly in php analog will do this (this is more cleary)
<?php
foreach ($options[$callbackname] as $subcallback => $name){
options[$callbackname][$name] = eval($options[$callbackname][$name]);
}
?>so as you can see you swith $key=>$values in place and if i have lets say this (i DO actualy have this as part of my code in module)
<?php
jcarousel_add('#mycarousel'.$node->nid,
array(
'itemLoadCallback' => 'mycarousel_itemLoadCallback',
'itemVisibleOutCallback' => array(
'onAfterAnimation' => 'mycarousel_onAfterAnimation',
),
),
);
?>the result will be (in your case)
options['itemVisibleOutCallback'][ 'mycarousel_onAfterAnimation'] = eval(options[ 'itemVisibleOutCallback'][ 'mycarousel_onAfterAnimation']);where you evaluting non existed array item, and save it to unknown for jcarousel module callback.. and of course it will not work.
i changed that part to
// Arrays are evaluated as a list of callback registrations. This is because callbacks
// like itemVisibleInCallback can either be a function call back, or an array of callbacks
// consisting of both onBeforeAnimation and onAfterAnimation.
for (subcallback in options[callbackname]) {
options[callbackname][subcallback] = eval(options[callbackname][subcallback]);
}and wooho! all callbacks starts to be callbacked... almost :)
here another thing (original code)
else if (typeof(options[callbackname]) == 'object' && (options[callbackname] instanceof Array)) {i have to change to
else if (typeof(options[callbackname]) == 'object' || (options[callbackname] instanceof Array)) {after that all is done - all subcallbacks were in places and were callbacked when they suposed to be called, in other words all start working as expected.

#1
Hmmm, interesting!..... Maybe a patch would help ;-) .
#2
Like this?
#3
have not test it (im satisfying with my changes) but as it seems for me this bug is a big functionality lost so its better be fixed inside a new version of a module by author, however having a patch is always good to :)
#4
Well, if you test it, and say it's good, I'll commit it and make a new version :-) .
#5
sorry for haven't posted long time but was a bit bisy, downloaded applyed tested - all works fine, well done :)
#6
Thanks a lot for the help :) . I'll commit this tomorrow.
#7
Thanks a lot! http://drupal.org/cvs?commit=287078
#8
tty for good module
#9
Automatically closed -- issue fixed for 2 weeks with no activity.