Sha256: 4c33fa1aef6757694b573d3ab572b9735d78b61300bfa719c7faa774fc74e2e0
Contents?: true
Size: 1.39 KB
Versions: 161
Compression:
Stored size: 1.39 KB
Contents
//= require govuk/vendor/polyfills/Element/prototype/classList.js /* Toggle the class 'focus' on input boxes on element focus/blur Used by the search component but generic enough for reuse */ window.GOVUK = window.GOVUK || {} window.GOVUK.Modules = window.GOVUK.Modules || {}; (function (Modules) { function GemToggleInputClassOnFocus ($module) { this.$module = $module } GemToggleInputClassOnFocus.prototype.init = function () { this.toggleTarget = this.$module.querySelector('.js-class-toggle') this.$module.addFocusClass = this.addFocusClass.bind(this) this.$module.removeFocusClassFromEmptyInput = this.removeFocusClassFromEmptyInput.bind(this) if (!this.inputIsEmpty()) { this.addFocusClass() } this.toggleTarget.addEventListener('focus', this.$module.addFocusClass) this.toggleTarget.addEventListener('blur', this.$module.removeFocusClassFromEmptyInput) } GemToggleInputClassOnFocus.prototype.inputIsEmpty = function () { return this.toggleTarget.value === '' } GemToggleInputClassOnFocus.prototype.addFocusClass = function () { this.toggleTarget.classList.add('focus') } GemToggleInputClassOnFocus.prototype.removeFocusClassFromEmptyInput = function () { if (this.inputIsEmpty()) { this.toggleTarget.classList.remove('focus') } } Modules.GemToggleInputClassOnFocus = GemToggleInputClassOnFocus })(window.GOVUK.Modules)
Version data entries
161 entries across 161 versions & 1 rubygems