From 3577c10b5c3839a06f64cb19e72788401bd7406d Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 10 Mar 2018 19:04:29 +0100 Subject: Support for Bootswatch and other css themes. --- src/main/kotlin/pl/treksoft/kvision/KVManager.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/main/kotlin/pl/treksoft/kvision/KVManager.kt') diff --git a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt index 0030cf9d..e1c169c0 100644 --- a/src/main/kotlin/pl/treksoft/kvision/KVManager.kt +++ b/src/main/kotlin/pl/treksoft/kvision/KVManager.kt @@ -29,6 +29,7 @@ import com.github.snabbdom.datasetModule import com.github.snabbdom.eventListenersModule import com.github.snabbdom.propsModule import com.github.snabbdom.styleModule +import org.w3c.dom.asList import pl.treksoft.kvision.core.Component import pl.treksoft.kvision.utils.isIE11 import kotlin.browser.document @@ -48,8 +49,17 @@ internal object KVManager { internal const val AJAX_REQUEST_DELAY = 300 internal const val KVNULL = "#kvnull" + private val links = document.getElementsByTagName("link") private val bootstrapWebpack = try { - require("bootstrap-webpack") + val bootswatch = links.asList().find { it.getAttribute("href")?.contains("bootstrap.min.css") ?: false } + if (bootswatch != null) { + if (bootswatch.getAttribute("href")?.contains("/paper/") ?: false) { + require("./css/paper.css") + } + require("bootstrap-webpack!./js/bootstrap.config.js") + } else { + require("bootstrap-webpack") + } } catch (e: Throwable) { } private val fontAwesomeWebpack = try { -- cgit