var TF_Dimension_Control=function(){function e(){this.initEvents()}var t=e.prototype;return t.initEvents=function(){document.querySelectorAll(".tf-dimension-controls--item--value").forEach(function(e){tfAutosizeInput(e)}),document.addEventListener("click",function(e){this.onToggleLocks(e),this.onFocus(e)}.bind(this)),document.addEventListener("dblclick",function(e){this.onSelectValue(e)}.bind(this)),document.addEventListener("change",function(e){this.onValueChange(e)}.bind(this)),document.addEventListener("input",function(e){this.onValueChange(e)}.bind(this)),document.addEventListener("focusout",function(e){this.onStoppedTyping(e)}.bind(this))},t.onSelectValue=function(e){var e=e.target.closest(".tf-dimension-controls--item");e&&((e=e.querySelector(".tf-dimension-controls--item--value")).focus(),e.select())},t.onFocus=function(e){var t=e.target.closest(".tf-dimension-controls--item"),e=e.target.closest(".tf-unit-control-dropdown");t&&!e&&(t.querySelector("input.tf-dimension-controls--item--value").focus(),t.classList.add("has-focus"))},t.onStoppedTyping=function(e){e=e.target.closest(".tf-dimension-controls--item--value");e&&(e.blur(),e.closest(".tf-dimension-controls--item").classList.remove("has-focus"))},t.onToggleLocks=function(e){var t,n,o=e.target.closest(".tf-dimension-control--locks--item");o&&(n=e.target.closest(".tf-dimension-control")?e.target.closest(".tf-dimension-control"):e.target.closest(".nr-responsive-control--item"),t=o.dataset.type,o.classList.remove("active"),n.querySelector('.tf-dimension-control--locks--item[data-type="'+(n="lock"===t?"unlock":"lock")+'"]').classList.add("active"),this.setLinkedValue(o,"unlock"==n?"0":"1"),e.preventDefault())},t.getLinkedValue=function(e){var t=responsiveControlLinked=!1;return this.getWrapper(e)&&this.getWrapper(e).querySelector(".tf-dimension-control-link-value")&&(t="1"==this.getWrapper(e).querySelector(".tf-dimension-control-link-value").value),e.closest(".nr-responsive-control--item")&&e.closest(".nr-responsive-control--item").querySelector(".tf-dimension-control-link-value")&&(responsiveControlLinked="1"==e.closest(".nr-responsive-control--item").querySelector(".tf-dimension-control-link-value").value),t||responsiveControlLinked?"1":"0"},t.setLinkedValue=function(e,t){this.getWrapper(e)&&this.getWrapper(e).querySelector(".tf-dimension-control-link-value")?this.getWrapper(e).querySelector(".tf-dimension-control-link-value").value=t:e.closest(".nr-responsive-control--item")&&e.closest(".nr-responsive-control--item").querySelector(".tf-dimension-control-link-value")&&(e.closest(".nr-responsive-control--item").querySelector(".tf-dimension-control-link-value").value=t)},t.onValueChange=function(e){var n,o,i,t,e=e.target.closest(".tf-dimension-controls--item--value");e&&(n=parseInt(e.value),o=!!e.getAttribute("max")&&parseInt(e.max),i=e.value,t=this.getWrapper(e),this.isLinked(e)?t.querySelectorAll('input[type="number"]').forEach(function(e){e.value=o&&o<n?o:i;var t=e.closest(".tf-dimension-controls--item");""===i?t.classList.remove("has-value"):t.classList.add("has-value"),e.dispatchEvent(new CustomEvent("input"))}):(o&&o<n&&(e.value=o,e.dispatchEvent(new CustomEvent("input"))),t=e.closest(".tf-dimension-controls--item"),""===i?t.classList.remove("has-value"):t.classList.add("has-value")))},t.getWrapper=function(e){return e.closest(".tf-dimension-control")},t.isLinked=function(e){return"1"===this.getLinkedValue(e)},e}();document.addEventListener("DOMContentLoaded",function(){new TF_Dimension_Control});

