mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-06 04:35:13 -05:00
Add slider2Input
This commit is contained in:
40
R/input-slider2.R
Normal file
40
R/input-slider2.R
Normal file
@@ -0,0 +1,40 @@
|
||||
#' @export
|
||||
slider2Input <- function(inputId, label, min, max, value, step = NULL,
|
||||
round = FALSE, format = '#,##0.#####', locale = 'us',
|
||||
ticks = TRUE, animate = FALSE, width = NULL) {
|
||||
|
||||
sliderProps <- dropNulls(list(
|
||||
class = "js-range-slider",
|
||||
id = inputId,
|
||||
`data-type` = if (length(value) > 1) "double",
|
||||
`data-min` = min,
|
||||
`data-max` = max,
|
||||
`data-from` = value[1],
|
||||
`data-to` = if (length(value) > 1) value[2],
|
||||
`data-step` = step,
|
||||
`data-grid` = if(ticks) TRUE,
|
||||
`data-grid-snap` = if (!is.null(step)) TRUE
|
||||
))
|
||||
|
||||
sliderTag <- do.call(tags$input, sliderProps)
|
||||
|
||||
|
||||
if (is.null(label)) {
|
||||
sliderTag <- div(class = "form-group",
|
||||
sliderTag
|
||||
)
|
||||
} else {
|
||||
sliderTag <- div(class = "form-group",
|
||||
controlLabel(inputId, label),
|
||||
sliderTag
|
||||
)
|
||||
}
|
||||
|
||||
dep <- htmlDependency("ionrangeslider", "2.0.1", c(href="shared/ionrangeslider"),
|
||||
script = "js/ion.rangeSlider.min.js",
|
||||
stylesheet = c("css/normalize.css", "css/ion.rangeSlider.css",
|
||||
"css/ion.rangeSlider.skinModern.css")
|
||||
)
|
||||
|
||||
attachDependencies(sliderTag, dep)
|
||||
}
|
||||
Reference in New Issue
Block a user