Advanced option timeoutFn needs return values

Created on 5 October 2023, about 1 year ago
Updated 6 October 2023, about 1 year ago

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.

Feature request
Status

Needs review

Version

5.0

Component

Code

Created by

🇩🇪Germany rogerpfaff Munich

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024