Create a branch to support jCarousel 0.3 - using https://github.com/jsor/jcarousel

jCarousel 0.3 is very different to previous versions as it uses separate .js files for certain functions e.g. autoscroll.

Proposed resolution - Create a branch to use jCarousel 0.3
The branch will update jcarousel_add() to create settings appropriate to jCarousel0.3, and jcarousel.js will be updated to handle the new settings.

I'll attach a patch to this issue which should progress this.

Comments

damianrobinson’s picture

I have attached a patch to enable usage of jCarousel 0.3

quicksketch’s picture

Status: Active » Needs review

Thanks, this looks like a good start! Considering 0.3 isn't even released yet, it might be a bit early to try and use it on production sites, but I agree it would be a good idea to get rolling on a branch that supported it.

A few thoughts:

-    if (!options.hasOwnProperty('buttonNextHTML') && !options.hasOwnProperty('buttonPrevHTML')) {
-      options.buttonNextHTML = Drupal.theme('jCarouselButton', 'next');
-      options.buttonPrevHTML = Drupal.theme('jCarouselButton', 'previous');
-    }
-
-    // Initialize the jcarousel.
     $carousel.addClass('jcarousel-processed').jcarousel(options);

I find it odd that you specifically removed theming functions here, yet output the same markup in a non-configurable location later:

+        case 'control':
+          // Add the control buttons
+          $('<div class="prev-wrapper"><a class="jcarousel-prev" href="javascript:void(0);"></a></div>').appendTo($carousel);
+          $('<div class="next-wrapper"><a class="jcarousel-next" href="javascript:void(0);"></a></div>').appendTo($carousel);

Also, what's the need for "prev-wrapper" and "next-wrapper"? And aren't those awfully generic class names to be including in a module?

As stated in the patch, there are also a lot of TODOs that should be addressed, things like pagers being broken or options being hard-coded instead of using the available configuration options. What's you're thinking on moving that forward? I'd like to have something that works before branching. Leaving things mixed up to the bare-minimum of being functional leads to confusion.

Regarding the use of sub-libraries, how signficant is the advantage versus just using a compressed version of the whole library? I imagine 3-4 uncompressed src files are going to be larger than just all the libraries compressed together into a single file. Is the primary reason for this because the final version of jCarousel isn't released (and so there isn't a compressed package available)?

damianrobinson’s picture

The prev / next wrapper functions were really for a specific usecase, and I think would be redundant.

Regarding the theme options for options.buttonNextHTML etc - these options do not exist in 0.3 - which is why they are added as part of the control options. Thinking about this though navigational control elements should still be configurable.

I think moving forward I'd like to see all the options used correctly, as at present there is a combination of 0.2 and 0.3 options, and I'd like these to be explicitly switched so we don't have any redundant options.

I suggest I develop this further using a vanilla install. This will enable me to fully evaluate all the plugins and ensure the settings are applied correctly. This will help with views integration at a later date.

As you suggested the use of sub libraries is because 0.3 is not officially released. I'm not sure why there are separate files for different functions, seems odd to me too as they are small even in an uncompressed state. IMO there will be no harm in compressing them all in one file, this will reduce the need to have logic to determine which ones to include depending on what options are set.

quicksketch’s picture

Regarding the theme options for options.buttonNextHTML etc - these options do not exist in 0.3 - which is why they are added as part of the control options. Thinking about this though navigational control elements should still be configurable.

I'm saying that instead of this:

+        case 'control':
+          // Add the control buttons
+          $('<div class="prev-wrapper"><a class="jcarousel-prev" href="javascript:void(0);"></a></div>').appendTo($carousel);
+          $('<div class="next-wrapper"><a class="jcarousel-next" href="javascript:void(0);"></a></div>').appendTo($carousel);

You should keep the theming code in tact like this:

+        case 'control':
+          // Add the control buttons
+          $(Drupal.theme('jCarouselButton', 'previous')).appendTo($carousel);
+          $(Drupal.theme('jCarouselButton', 'next')).appendTo($carousel);

It produces the same output and allows users to override Drupal.theme.prototype.jCarouselButton in their theme.

Thanks for your work on this, it's definitely going to save me work in the long-run as we'll need to support the 0.3 version eventually.

damianrobinson’s picture

Yes I totally agree with what you are suggesting.

damianrobinson’s picture

I've created a new patch which includes an updated help function to demonstrate how vertical and horizontal carousels can work. This includes better use of js theme functions as suggested.

I've used plugins i.e. control, pagination & swipe to demonstrate these. There is one issue where the vertical pagination controls the horizontal carousel which needs fixing. The autoscroll does work but I have set to disabled.

Still not quite sure about how to add the jcarousel package using libraries, as you only know what plugin to use after jcarousel_add has been called.

You would need to download https://github.com/jsor/jcarousel and have it in /js for this to work. It's worth having a look at the tests that ship with it.

Hopefully this may be enough to start a new branch to develop this further.

iLLin’s picture

0.3 is out now, is there a branch out we can start helping with?

damianrobinson’s picture

HI I'm not sure what the current state of this is. As far as I'm aware there isn't one yet. I'm not a contributor for this module, if you contact quicksketch he may be able to create one for development. I haven't reviewed the latest version of jcarousel but it will be worth reviewing as it will no doubt influence how a new version of this module is developed.

I guess we'd also need to think about how people upgrade from the current version of jcarousel to the one which uses version 0.3, so an upgrade path may also be required as part of this work.

cknoebel’s picture

Issue summary: View changes

+1 on this and I hope the issue (or module) isn't dead. I ran into a problem with Safari 6 not playing nice with the navigation. The fix was simple (http://theweblab.com.bd/blog/jcarousel-safari-navigation-issue/). Before I made the change in the module's version of the script, I tried using it with the current jcarousel version (0.3) and it blew chunks. Would be nice to use the latest.

markpavlitski’s picture

@knoebel the module definitely isn't dead.

We're working on a rewrite of the module including v0.3 support, and to hopefully fix a lot of the issues that user's are experiencing.

I'm torn as to whether to continue maintaining the current 7.x-2.x branch with jCarousel v0.2, so thoughts would be welcome.

sardbaba’s picture

Hi,
are there updates about the v0.3 support?

guardiola86’s picture

Is there any update on this? Any plan to support 0.3 version?

guardiola86’s picture

Priority: Normal » Major
markpavlitski’s picture

Assigned: damianrobinson » Unassigned
Priority: Major » Normal

jCarousel 0.3 is a big improvement, but is architecturally very different.

We are working on a 7.x-3.x-dev branch for this module in git, which contains very early stages of a rewrite of the module to support jCarousel 0.3 and to resolve some long standing issues such as block caching.

markpavlitski’s picture

Version: 7.x-2.6 » 7.x-3.x-dev
deggertsen’s picture

Status: Needs review » Fixed

This is fixed. Further discussion should probably happen on this issue: #2349751: [META] Support jCarousel v0.3

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.