From 03b0a40a8a25c2979b91bc3a5c5d2e9f7014192f Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Fri, 21 Jun 2019 23:23:22 +0200 Subject: Style fixes. --- .../kotlin/pl/treksoft/kvision/KVManagerPace.kt | 4 +- .../main/kotlin/pl/treksoft/kvision/pace/Pace.kt | 139 ++++++++++++++------- 2 files changed, 97 insertions(+), 46 deletions(-) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt index 38a83fb5..76eeb749 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt @@ -26,10 +26,12 @@ internal val kVManagerPaceInit = KVManagerPace.init() /** * Internal singleton object which initializes and configures KVision Moment module. */ +@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught") internal object KVManagerPace { fun init() {} private val pace = try { require("pace-progressbar").default - } catch (e: Throwable) {} + } catch (e: Throwable) { + } } diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index a5d80908..aacde82b 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -22,69 +22,117 @@ package pl.treksoft.kvision.pace -import pl.treksoft.kvision.require -import pl.treksoft.kvision.utils.obj import org.w3c.dom.events.Event import org.w3c.dom.get +import pl.treksoft.kvision.require +import pl.treksoft.kvision.utils.obj import kotlin.browser.window -class PaceAjaxOptions(trackMethods:Array? = null, - trackWebSockets:Boolean? = null, - ignoreURLs:Array? = null) { +class PaceAjaxOptions( + trackMethods: Array? = null, + trackWebSockets: Boolean? = null, + ignoreURLs: Array? = null +) { internal var paceAjaxOptionsJs: dynamic = obj { - if (trackMethods != null) { this.trackMethods = trackMethods } - if (trackWebSockets != null) { this.trackWebSockets = trackWebSockets } - if (ignoreURLs != null) { this.ignoreURLs = ignoreURLs } + if (trackMethods != null) { + this.trackMethods = trackMethods + } + if (trackWebSockets != null) { + this.trackWebSockets = trackWebSockets + } + if (ignoreURLs != null) { + this.ignoreURLs = ignoreURLs + } } } -class PaceElementsOptions(minSamples:Int? = null, - selectors:Array? = null) { +class PaceElementsOptions( + minSamples: Int? = null, + selectors: Array? = null +) { internal var paceElementsOptionsJs: dynamic = obj { - if (minSamples != null) { this.minSamples = minSamples } - if (selectors != null) { this.selectors = selectors } + if (minSamples != null) { + this.minSamples = minSamples + } + if (selectors != null) { + this.selectors = selectors + } } } -class PaceEventLagOptions(minSamples:Int? = null, - sampleCount:Int? = null, - lagThreshold:Int? = null) { +class PaceEventLagOptions( + minSamples: Int? = null, + sampleCount: Int? = null, + lagThreshold: Int? = null +) { internal var paceEventLagOptionsJs: dynamic = obj { - if (minSamples != null) { this.minSamples = minSamples } - if (sampleCount != null) { this.sampleCount = sampleCount } - if (lagThreshold != null) { this.lagThreshold = lagThreshold } + if (minSamples != null) { + this.minSamples = minSamples + } + if (sampleCount != null) { + this.sampleCount = sampleCount + } + if (lagThreshold != null) { + this.lagThreshold = lagThreshold + } } } class PaceOptions( - ajax:PaceAjaxOptions? = null, - catchupTime:Int? = null, - easeFactor:Double? = null, - elements:PaceElementsOptions? = null, - eventLag:PaceEventLagOptions? = null, - ghostTime:Int? = null, - initialRate:Double? = null, - maxProgressPerFrame:Int? = null, - minTime:Int? = null, - restartOnPushState:Boolean? = null, - restartOnRequestAfter:Double? = null, - startOnPageLoad:Boolean? = null, - target:String? = null + ajax: PaceAjaxOptions? = null, + catchupTime: Int? = null, + easeFactor: Double? = null, + elements: PaceElementsOptions? = null, + eventLag: PaceEventLagOptions? = null, + ghostTime: Int? = null, + initialRate: Double? = null, + maxProgressPerFrame: Int? = null, + minTime: Int? = null, + restartOnPushState: Boolean? = null, + restartOnRequestAfter: Double? = null, + startOnPageLoad: Boolean? = null, + target: String? = null ) { internal var paceOptionsJs: dynamic = obj { - if (ajax != null) { this.ajax = ajax.paceAjaxOptionsJs } - if (catchupTime != null) { this.catchupTime = catchupTime } - if (easeFactor != null) { this.easeFactor = easeFactor } - if (elements != null) { this.elements = elements.paceElementsOptionsJs } - if (eventLag != null) { this.eventLag = eventLag.paceEventLagOptionsJs } - if (ghostTime != null) { this.ghostTime = ghostTime } - if (initialRate != null) { this.initialRate = initialRate } - if (maxProgressPerFrame != null) { this.maxProgressPerFrame = maxProgressPerFrame } - if (minTime != null) { this.minTime = minTime } - if (restartOnPushState != null) { this.restartOnPushState = restartOnPushState } - if (restartOnRequestAfter != null) { this.restartOnRequestAfter = restartOnRequestAfter } - if (startOnPageLoad != null) { this.startOnPageLoad = startOnPageLoad } - if (target != null) { this.target = target } + if (ajax != null) { + this.ajax = ajax.paceAjaxOptionsJs + } + if (catchupTime != null) { + this.catchupTime = catchupTime + } + if (easeFactor != null) { + this.easeFactor = easeFactor + } + if (elements != null) { + this.elements = elements.paceElementsOptionsJs + } + if (eventLag != null) { + this.eventLag = eventLag.paceEventLagOptionsJs + } + if (ghostTime != null) { + this.ghostTime = ghostTime + } + if (initialRate != null) { + this.initialRate = initialRate + } + if (maxProgressPerFrame != null) { + this.maxProgressPerFrame = maxProgressPerFrame + } + if (minTime != null) { + this.minTime = minTime + } + if (restartOnPushState != null) { + this.restartOnPushState = restartOnPushState + } + if (restartOnRequestAfter != null) { + this.restartOnRequestAfter = restartOnRequestAfter + } + if (startOnPageLoad != null) { + this.startOnPageLoad = startOnPageLoad + } + if (target != null) { + this.target = target + } } } @@ -124,6 +172,7 @@ class Pace { fun setNewTheme(color: PaceColor, theme: PaceTheme) { require("pace-progressbar/themes/${color.paceColorString}/pace-theme-${theme.paceThemeString}.css") } + fun setOptions(options: PaceOptions) { window["Pace"].options = options.paceOptionsJs } @@ -140,4 +189,4 @@ class Pace { window["Pace"].stop() } } -} \ No newline at end of file +} -- cgit From 6b4b19c45f81dcedb664daaaec2c154bdb56719f Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 22 Jun 2019 00:33:36 +0200 Subject: Simple initialization for Pace module. --- .../kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index aacde82b..e429ff77 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-present Robert Jaros + * Copyright (c) 2019-present Robert Cronin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -169,6 +170,10 @@ enum class PaceTheme(var paceThemeString: String) { class Pace { companion object { + fun init() { + setNewTheme(PaceColor.Blue, PaceTheme.Flash) + } + fun setNewTheme(color: PaceColor, theme: PaceTheme) { require("pace-progressbar/themes/${color.paceColorString}/pace-theme-${theme.paceThemeString}.css") } -- cgit From 848a7470864eb245158700c3bb83c06fb56f9a6a Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sat, 22 Jun 2019 00:33:57 +0200 Subject: Correct copyright notice. --- .../src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt | 1 + .../src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt | 1 + .../kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt index 0000db83..330d818d 100644 --- a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt +++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/KVManagerMoment.kt @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-present Robert Jaros + * Copyright (c) 2019-present Robert Cronin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt index 39e7c2dc..5f21bfe2 100644 --- a/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt +++ b/kvision-modules/kvision-moment/src/main/kotlin/pl/treksoft/kvision/moment/Moment.kt @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-present Robert Jaros + * Copyright (c) 2019-present Robert Cronin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt index 76eeb749..9678d1fa 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt @@ -1,5 +1,6 @@ /* * Copyright (c) 2017-present Robert Jaros + * Copyright (c) 2019-present Robert Cronin * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -28,7 +29,8 @@ internal val kVManagerPaceInit = KVManagerPace.init() */ @Suppress("EmptyCatchBlock", "TooGenericExceptionCaught") internal object KVManagerPace { - fun init() {} + fun init() { + } private val pace = try { require("pace-progressbar").default -- cgit From 72ef5f4fde6945e53a60cd5ac49437034ebcbd15 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 23 Jun 2019 04:32:28 +0200 Subject: Hardcode blue flash theme. --- .../kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index e429ff77..ceb4cc10 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -171,11 +171,7 @@ enum class PaceTheme(var paceThemeString: String) { class Pace { companion object { fun init() { - setNewTheme(PaceColor.Blue, PaceTheme.Flash) - } - - fun setNewTheme(color: PaceColor, theme: PaceTheme) { - require("pace-progressbar/themes/${color.paceColorString}/pace-theme-${theme.paceThemeString}.css") + require("pace-progressbar/themes/blue/pace-theme-flash.css") } fun setOptions(options: PaceOptions) { -- cgit From a382413a95e2b056e818c2acb4b524e9a87597e4 Mon Sep 17 00:00:00 2001 From: Robert Jaros Date: Sun, 23 Jun 2019 12:33:55 +0200 Subject: Working solution for pace theme selection. --- .../main/kotlin/pl/treksoft/kvision/pace/Pace.kt | 34 +--------------------- 1 file changed, 1 insertion(+), 33 deletions(-) (limited to 'kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft') diff --git a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt index ceb4cc10..d5c77534 100644 --- a/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt +++ b/kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt @@ -137,41 +137,9 @@ class PaceOptions( } } -enum class PaceColor(var paceColorString: String) { - Black("black"), - Blue("blue"), - Green("green"), - Orange("orange"), - Pink("pink"), - Purple("purple"), - Red("red"), - Silver("silver"), - White("white"), - Yellow("yellow") -} - -enum class PaceTheme(var paceThemeString: String) { - BarberShop("barber-shop"), - BigCounter("big-counter"), - Bounce("bounce"), - CenterAtom("center-atom"), - CenterCircle("center-circle"), - CenterRadar("center-radar"), - CenterSimple("center-simple"), - CornerIndicator("corner-indicator"), - FillLeft("fill-left"), - Flash("flash"), - FlatTop("flat-top"), - LoadingBar("loading-bar"), - MacOSX("mac-osx"), - Material("material"), - Minimal("minimal") -} - class Pace { companion object { - fun init() { - require("pace-progressbar/themes/blue/pace-theme-flash.css") + fun init(req: dynamic = require("pace-progressbar/themes/blue/pace-theme-flash.css")) { } fun setOptions(options: PaceOptions) { -- cgit