aboutsummaryrefslogtreecommitdiff
path: root/kvision-modules/kvision-pace
diff options
context:
space:
mode:
authorRobbie Cronin <robert.cronin@uqconnect.edu.au>2019-06-26 12:42:55 +0800
committerGitHub <noreply@github.com>2019-06-26 12:42:55 +0800
commitd20bc8739b1ad58c1222d63258f01ef9e9d34064 (patch)
tree078b87746de4a305452224de39272529def43679 /kvision-modules/kvision-pace
parent97d136f14f086cf457453f1c94da1ecdae835234 (diff)
parent1f5742bebbafbe20a9d7527794798db7ebe5ab98 (diff)
downloadkvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.tar.gz
kvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.tar.bz2
kvision-d20bc8739b1ad58c1222d63258f01ef9e9d34064.zip
Merge pull request #2 from rjaros/master
pull version 0.0.37
Diffstat (limited to 'kvision-modules/kvision-pace')
-rw-r--r--kvision-modules/kvision-pace/build.gradle4
-rw-r--r--kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/KVManagerPace.kt8
-rw-r--r--kvision-modules/kvision-pace/src/main/kotlin/pl/treksoft/kvision/pace/Pace.kt174
-rw-r--r--kvision-modules/kvision-pace/webpack.config.d/css.js2
4 files changed, 108 insertions, 80 deletions
diff --git a/kvision-modules/kvision-pace/build.gradle b/kvision-modules/kvision-pace/build.gradle
index d577df20..238f9efa 100644
--- a/kvision-modules/kvision-pace/build.gradle
+++ b/kvision-modules/kvision-pace/build.gradle
@@ -4,6 +4,10 @@ kotlinFrontend {
npm {
dependency("pace-progressbar", "1.0.8")
+ devDependency("karma", "3.1.4")
+ devDependency("karma-chrome-launcher", "2.2.0")
+ devDependency("karma-webpack", "3.0.5")
+ devDependency("qunit", "2.8.0")
}
} \ No newline at end of file
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..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
@@ -26,10 +27,13 @@ internal val kVManagerPaceInit = KVManagerPace.init()
/**
* Internal singleton object which initializes and configures KVision Moment module.
*/
+@Suppress("EmptyCatchBlock", "TooGenericExceptionCaught")
internal object KVManagerPace {
- fun init() {}
+ 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..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
@@ -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
@@ -22,108 +23,125 @@
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<dynamic>? = null,
- trackWebSockets:Boolean? = null,
- ignoreURLs:Array<dynamic>? = null) {
+class PaceAjaxOptions(
+ trackMethods: Array<dynamic>? = null,
+ trackWebSockets: Boolean? = null,
+ ignoreURLs: Array<dynamic>? = 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<dynamic>? = null) {
+class PaceElementsOptions(
+ minSamples: Int? = null,
+ selectors: Array<dynamic>? = 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
+ }
}
}
-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 setNewTheme(color: PaceColor, theme: PaceTheme) {
- require("pace-progressbar/themes/${color.paceColorString}/pace-theme-${theme.paceThemeString}.css")
+ fun init(req: dynamic = require("pace-progressbar/themes/blue/pace-theme-flash.css")) {
}
+
fun setOptions(options: PaceOptions) {
window["Pace"].options = options.paceOptionsJs
}
@@ -140,4 +158,4 @@ class Pace {
window["Pace"].stop()
}
}
-} \ No newline at end of file
+}
diff --git a/kvision-modules/kvision-pace/webpack.config.d/css.js b/kvision-modules/kvision-pace/webpack.config.d/css.js
new file mode 100644
index 00000000..5d710d35
--- /dev/null
+++ b/kvision-modules/kvision-pace/webpack.config.d/css.js
@@ -0,0 +1,2 @@
+config.module.rules.push({ test: /\.css$/, loader: "style-loader!css-loader" });
+