Remove opening hours and make map view defauls on mobile

Is there any way to remove opening times in the store locator? This could be global, for all locations or specific to individual locations within a widget.

Also, it looks great on a desktop, but on a mobile, I would like the store locator to default to showing the map rather than the list. Is this possible?

1 Like

Re the times, or open 24/7 as an option

1 Like

Hi there, @Andy_Lamb :waving_hand:

You can remove the opening/closing hours in the Edit Texts section on the Settings tab. After deleting a phrase, don’t forget to press “Space” on your keyboard to save changes:


To make the map view default on mobile, please add this code to the Custom JS field on the Settings tab of your widget’s settings:

const openMapsButtonSelector = "[class*='mobile-layout__Container-sc'] [class*='FloatingButton__FloatingButtonContainer-sc'] button";

const LISTEN_TYPES = {
  one: {
    select: (selector, root) => root.querySelector(selector),
    validate: (node) => !!node
  },
  all: {
    select: (selector, root) => root.querySelectorAll(selector),
    validate: (node) => node?.length > 0
  }
};

function listenStep(args) {
  args.node = args.select(args.selector, args.root);

  if (!args.validate(args.node)) {
    args.step++;
    if (args.step < args.limit)
      setTimeout(() => {
        listenStep(args);
      }, args.delay);
    else
      args.reject();
  }
  else {
    args.resolve(args.node);
  }
}

async function asyncListenFor(selector, type = 'one', customArgs = {}) {
  const args = {
    root: document,
    node: undefined,
    selector,
    delay: 100,
    limit: 50,
    step: 0,
    select: LISTEN_TYPES[type].select,
    validate: LISTEN_TYPES[type].validate,
    reject: () => {},
    ...customArgs
  };

  if (type === 'one' || type === 'all') {
    return new Promise((resolve) => {
      listenStep({ ...args, resolve });
    });
  }
}

asyncListenFor(openMapsButtonSelector).then((openMapsButton) => {
  openMapsButton.click();
});

Give it a try and let me know if it helped :wink:

1 Like

Amazing service as is usual Max and the code and removing the opening times info have made me a very happy man :slight_smile: All works perfectly.

Once again I am blown away by Elfsight and your level of engagement with users and have a few social posts planned in saying just that.

2 Likes

So glad everything’s working perfectly for you! Thanks for trusting Elfsight and for all your kind words – your feedback has totally made our day :heart:

Don’t hesitate to ask any questions here if you face any difficulties. We’ll be happy to help you :wink: