// tslint:disable-next-line:no-var-requires
jQuery = require("jquery");

declare var global: any;
declare var window: any;
declare var jQuery: any;
declare var $: any;

global.jQuery = global.$ = jQuery;
window.jQuery = window.$ = $ = jQuery;

import "bootstrap-sass";

// tslint:disable-next-line:no-var-requires
require("jquery-validation");
// tslint:disable-next-line:no-var-requires
require("jquery-validation-unobtrusive");

import AsyncFormPostModule from "./modules/asyncFormPost";
import AsyncValueUpdateModule from "./modules/asyncValueUpdate";
import ClickableRowsModule from "./modules/clickableRows";
import ConfirmationModalModule from "./modules/confirmationModal";
import DropdownModule from "./modules/dropdown";
import InputStatusModule from "./modules/inputStatus";
import { NotificationModule, NotificationPositionEnum } from "./modules/notification";
import LeftMenuModule from "./modules/leftMenu";
import FileUploadModule from "./modules/fileUpload";
import TooltipModule from "./modules/tooltip";
import { TableModule } from "./modules/table";
import { CookieDisclaimerModule } from "./modules/cookieDisclaimer";
import NumericInputModule from "./modules/numericInput";
import {DatetimePickerModule, DatetimePickerTypeEnum} from "./modules/datetimepicker";

/**
 * Initialises embla, should be called in $(document).ready()
 */
const initEmbla = function() {
  $(document).on("focus", ".input-group > .form-control", function() {

    const $element = $(this);
    const $parent = $element.parent(".input-group");

    $parent.addClass("focus");

    $element.one("blur", function() {
      $parent.removeClass("focus");
    });
  });
};

export {
  initEmbla,
  AsyncFormPostModule,
  AsyncValueUpdateModule,
  ClickableRowsModule,
  ConfirmationModalModule,
  DropdownModule,
  InputStatusModule,
  NotificationModule,
  NotificationPositionEnum,
  LeftMenuModule,
  FileUploadModule,
  TooltipModule,
  CookieDisclaimerModule,
  TableModule,
  NumericInputModule,
  DatetimePickerModule,
  DatetimePickerTypeEnum
};
