digitalmarketplace-frontend
Version:
Digital Marketplace Frontend contains assets and components used in Digital Marketplace projects
39 lines (35 loc) • 1.34 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.DigitalMarketplaceFrontend = {}));
})(this, (function (exports) { 'use strict';
class SearchBox {
static moduleName = 'dm-search-box';
$module;
$toggleTarget;
constructor($module) {
this.$module = $module;
this.$toggleTarget = this.$module.find('.js-class-toggle');
}
init() {
if (!this.inputIsEmpty()) {
this.addFocusClass();
}
this.$toggleTarget.on('focus', this.addFocusClass.bind(this));
this.$toggleTarget.on('blur', this.removeFocusClassFromEmptyInput.bind(this));
}
inputIsEmpty() {
return this.$toggleTarget.val() === '';
}
addFocusClass() {
this.$toggleTarget.addClass('focus');
}
removeFocusClassFromEmptyInput() {
if (this.inputIsEmpty()) {
this.$toggleTarget.removeClass('focus');
}
}
}
exports.SearchBox = SearchBox;
}));
//# sourceMappingURL=search-box.bundle.js.map