import { InobyModule } from "@lib/inoby-module";
import * as $ from "jquery";

class MBVikAddons extends InobyModule {
  public run() {
    ConditionableTextarea();
    $("input[name='checkindate'], input[name='checkoutdate']").attr("placeholder", "Zadať dátum");
    $(".vbrdetboxtop .vbo-room-carat > img").each(function () {
      var title = $(this).prop("title");
      $(this)
        .parent(".vbo-room-carat")
        .append("<span>" + title + "</span>");
    });
    $(".vbo-showprc-room-block .room_carats img").each(function () {
      var title = $(this).prop("title");
      $(this)
        .parent(".vbo-room-carat")
        .append("<span>" + title + "</span>");
    });
    $(".vbcurrency").each(function () {
      $(this).next(".vbprice").addBack().wrapAll('<div class="price-fix"/>');
    });
  }
}

function ConditionableTextarea() {
  $('label:contains("Žiadam o vystavenie ubytovacieho poukazu")').closest(".vbo-oconfirm-cfield-entry").addClass("conditionable-checkbox");
  $('label:contains("Žiadam o vystavenie ubytovacieho poukazu")').closest(".vbo-oconfirm-cfield-entry").children().children("input").addClass("conditionable-checkbox-input");
  $('label:contains("Žiadam o vystavenie ubytovacieho poukazu")').closest(".vbo-oconfirm-cfield-entry").next(".vbo-oconfirm-cfield-entry-textarea").addClass("conditionable-names");
  $(".conditionable-names").hide();
  $(".conditionable-checkbox-input").change(function () {
    if ($(".conditionable-checkbox-input").is(":checked")) {
      $(".conditionable-names").show();
    } else {
      $(".conditionable-names").hide();
    }
  });
}

new MBVikAddons().runOnReady();
