Problem/Motivation

When using the advanced option for timeoutFn the code is evaluated by eval and there is no return value. See #1424090: timeoutFn advanced option does not work - needs to return result value for the same issue in 7.x.
Reading through the issues related to this it seems very confusing to me on how the js in view ui has to be written and the only solution that worked for me is changing the code for the option like this to just write a function to the field with a return value.

var timeoutFnValue = advancedOptions[option];
timeoutFnValue = Drupal.viewsSlideshowCycle.advancedOptionCleanup(timeoutFnValue);
settings.opts[option] = function (currSlideElement, nextSlideElement, options, forwardFlag) {
  getTimeout = eval( '(' + timeoutFnValue + ')' );
  result = getTimeout();
  if (Number.isInteger(result)) {
    return result;
  }
  return settings.timeout;
}

Proposed resolution

Change the js code accordingly to allow the provided js to be a function with return value.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rogerpfaff created an issue. See original summary.

rogerpfaff’s picture

Status: Active » Needs review

Uhm. I messed up the issue fork I think, so I'm not opening a MR at this point as I don't know what happens then to the main branch I commited to in the fork. I'd be glad taking advice on how to fix this.

rogerpfaff’s picture

Title: Advanced option timeoutFn » Advanced option timeoutFn needs return values

Edit: Making the title clearer

rogerpfaff’s picture

Little OT: Cleaning up messed branches is not supported but maybe hidable in the future #3204376: How to remove branch from an issue fork