all files / src/ common.js

45% Statements 9/20
100% Branches 0/0
20% Functions 1/5
42.11% Lines 8/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                                                             
/* eslint-disable global-require */
import $ from 'jquery';
import { t } from './locales';
 
const utils = require('./modules/utils');
 
$(document).ready(function () {
  $(':checkbox[data-checkbox-api-prefix]').change(function () {
    const $this = $(this);
    const prefix = $this.data('checkbox-api-prefix');
    const id = $this.attr('id');
    utils.toggleCheckbox(prefix, '#' + id);
  });
 
  // for language picker dropdown
  $('#language-picker a').click(function (ev) {
    ev.preventDefault();
 
    const targetUrl = ev.currentTarget.href;
    $.ajax(targetUrl)
      .then(() => {
        location.reload();
      });
  });
});
 
export function appSetup() {
  // A set of hacks to allow apps to run within a FAB template
  // this allows for the server side generated menus to function
  window.$ = $;
  window.jQuery = $;
  require('bootstrap');
}
 
// Error messages used in many places across applications
export const COMMON_ERR_MESSAGES = {
  SESSION_TIMED_OUT: t('Your session timed out, please refresh your page and try again.'),
};