For the View Slideshow Xtra Overlay module, in the Widget theming (theme_views_slideshow_xtra_overlay_widget_render) function I save a setting:

$js_vars = array(
      'viewsSlideshowXtraOverlay' => array(
          $vars['vss_id'] => array(
              'pauseAfterMouseMove' => $vars['settings']['pause_after_mouse_move'],
          ),
      ),
  );
  drupal_add_js($js_vars, 'setting');

Thus the setting is indexed by $vars['vss_id']. I found it difficult to get to this data, because the value of the vss_id is: views_slideshow_xtra_example-page, and there is no element with either a class or id equal to that, except for ones that begin with 'views_slideshow_cycle'. But I don't want to reference the string 'cycle' in the js string manipulation code, as the code needs to be generic for all rotation plug-ins. So I had to go up to the main View div, and get the View ID and Display ID from the main div, which was cumbersome, but worked:

      $('.views_slideshow_main').each(function() {
        var view = $(this).parent().parent().parent();
        var viewClasses = classList(view);
        $.each( viewClasses, function(index, item) {
 
          // We need the following code because the id of the element selected will be something like:
          // "views_slideshow_cycle_main_views_slideshow_xtra_example-page"
          // We don't want to reference the string "cycle" in our code, and there is not a way to 
          // get the "View ID - Display ID" substring from the id string, unless the string "cycle"
          // is referenced in a string manipulation function.
          
          // Get the View ID
          if((/^view-id-/).test(item)) {
            viewId = item.substring('view-id-'.length);
          }

          // Get the Display ID
          if((/^view-display-id-/).test(item)) {
            viewDisplayId = item.substring('view-display-id-'.length);
          }
          
        });
        
        var settings = Drupal.settings.viewsSlideshowXtraOverlay[viewId + '-' + viewDisplayId];
        if (settings.hasOwnProperty('pauseAfterMouseMove')) {
          //  ...
        }

For Drupal 8, it would be preferable if there was an easier way to do this. For example, if the id of the main div had two dashes to separate the rotation plugin from the View ID, that would have made it easier:

views_slideshow_cycle_main--views_slideshow_xtra_example-page

instead of:

views_slideshow_cycle_main_views_slideshow_xtra_example-page

Or, add a class that indicates the vss_id:

vss_id--views_slideshow_xtra_example-page

Or, preface the vss_id string saved by the Widget to have the full slideshow id:

views_slideshow_cycle_main_views_slideshow_xtra_example-page

Thanks,

captaindav

Comments

redndahead’s picture

Boy are we getting ahead of ourselves. I'll have to look at this when a new version comes. Perhaps when I get to doing a slideshow_api module.

captaindav’s picture

I think that having the class names generated by drupal_clean_css_identifier, and placing two dashes between each component of the class name, is the preferred method of generating class names in Drupal. This is the method used by Views to generate its class names.

redndahead’s picture

I certainly agree. I'm not in a hurry to make this change in this version since it'll be fairly disruptive.

tomogden’s picture

Now that we're approaching a D8 release, will there be any movement on this issue?

NickDickinsonWilde’s picture

Version: 7.x-3.x-dev » 8.x-4.x-dev
Assigned: Unassigned » NickDickinsonWilde

Will look into this shortly (ie within a few weeks most likely).

NickDickinsonWilde’s picture

Looked at this a bit further and postponed a bit futher. There are stable releases of 8.x-4.x and changing this would either be messy or potentially break theming so that's a no go. But I have some plans for 8.x-5.x that will fix this as well.

Neslee Canil Pinto’s picture

Status: Postponed » Closed (outdated)