From 824c3578d063fb265e8a3b642c17d7569841da07 Mon Sep 17 00:00:00 2001 From: Francisco Hodge Date: Wed, 31 Oct 2018 19:48:17 -0400 Subject: [PATCH] Add class per plugin --- src/lib/components/Keyboard.js | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lib/components/Keyboard.js b/src/lib/components/Keyboard.js index a5ac28a6..ac0d9544 100644 --- a/src/lib/components/Keyboard.js +++ b/src/lib/components/Keyboard.js @@ -63,6 +63,11 @@ class SimpleKeyboard { this.options.theme = this.options.theme || "hg-theme-default"; this.options.inputName = this.options.inputName || "default"; + /** + * @type {object} Classes identifying loaded plugins + */ + this.keyboardPluginClasses = ''; + /** * Bindings */ @@ -557,11 +562,11 @@ class SimpleKeyboard { /* istanbul ignore next */ if(module.constructor.name && module.constructor.name !== "Function"){ - this.keyboardDOM.classList.add( - `module-${this.utilities.camelCase(module.constructor.name)}` - ); + let classStr = `module-${this.utilities.camelCase(module.constructor.name)}`; + this.keyboardPluginClasses = this.keyboardPluginClasses + ` ${classStr}`; } + this.render(); module.init(this); }); } @@ -633,7 +638,7 @@ class SimpleKeyboard { /** * Adding themeClass, layoutClass to keyboardDOM */ - this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass}`; + this.keyboardDOM.className += ` ${this.options.theme} ${layoutClass} ${this.keyboardPluginClasses}`; /** * Iterating through each row