#The KISO Themes Kernel
KISO Themes ships with a super small internal API that you can also use. It's available globally on the
window
object as KISOThemes
. For example:KISOThemes.jsLibs('gmaps');
It provides some simple, but handy functions:
hookOnPageLoad
- A wrapper hook that will correctly initialize JS functions, automatically detecting whether you are using Turbolinks or standard jQuery.debounce
- A debounce functiongetRootCssVariable
- A function for returning a given CSS Variable from the document rootjsLibs
- A getter function which returns an array of strings defined on thebody
tag underdata-js-libs
jsLibIsActive
- A function that returns a boolean saying whether a particular string is defined indata-js-libs
#How the Kernel is used to enable JS plugins.
All external JS plugins shipped with KISO Themes are wrapped in a loader function:
//= require vendor/jasny/jasny_bootstrap (function() { function initJasny() { } KISOThemes.hookOnPageLoad( function() { KISOThemes.jsLibIsActive('jasny') && initJasny.call(this) }) })()
This allows for any particular JS plugin to be turned on or off on a given page simply by putting the string on the
body
tag's data-js-libs
attribute.