check_width

by mtenschert

JavaScript

function getCurrentPromoWidth() {
  try {
    var CurrentPromoWidth = 0;
    var CurrentPromoWidth = document.getElementById('booking_parameters_promotionCode').clientWidth;
  } catch (e) {
    console.log("initial_product_development.js: catch - no promocode field");
  }
}

var getNewPromoWidthFunction = function() {
  var NewWidth = 0;
  try {
    var NewWidth = document.getElementById('booking_parameters_promotionCode').clientWidth;
  } catch (e) {
    console.log("initial_product_development.js: catch - no promocode field");
  }
  getNewPromoWidthFunction = NewWidth;
  alert(getNewPromoWidthFunction);
}

function promoCodeChangeClass(getInitialPromoWidth) {
  // statement for more or less than 272 pixels. 272 pixel (275 is needed) because of less width after click in input field (padding)
  if (getInitialPromoWidth >= 272) {
    console.log("initial_product_development.js: bigger or simmilar than 272");
    console.log(getPromoWidth);
    $("li.overlay__input-promotion-code.small").removeClass("small"); //remove class
    $("li.overlay__input-promotion-code").addClass("big"); //add class
  } else {
    console.log("initial_product_development.js: smaller than 272, or no promocode-field found");
    console.log(getPromoWidth);
    $("li.overlay__input-promotion-code.big").removeClass("big"); //remove class
    $("li.overlay__input-promotion-code").addClass("small"); //add class
  }
}

function checkPromoSize(getInitialPromoWidth) {
  // try because of page they do not have the Id "booking_parameters_promotionCode"
  try {
    var getNewPromoWidth = 0;
    var getNewPromoWidth = document.getElementById('booking_parameters_promotionCode').clientWidth;
  } catch (e) {
    console.log("initial_product_development.js: catch - no promocode field");
  }

  if (getInitialPromoWidth != getNewPromoWidth) {
    promoCodeChangeClass();
  }
}

function checkPromoSizeTimout() {
  // timeout because of the search-button-clicks need more time between
  setTimeout(function()...