import loader from "../../../elements/loader.hbs";

const defaultLoader = '.loader-wrapper';
const HIDDEN_CLASS_NAME = 'd-none';

function defineLoaderWrapper(loader) {
  return loader ? loader : defaultLoader;
}

export function appendLoader(payload) {
  $(payload.wrapper).append(loader(payload));
}

export function showLoader(loaderSelector) {
  $(defineLoaderWrapper(loaderSelector)).removeClass(HIDDEN_CLASS_NAME);
}

export function hideLoader(loaderSelector) {
  $(defineLoaderWrapper(loaderSelector)).addClass(HIDDEN_CLASS_NAME);
}
