R/load_jstools.R

Defines functions load_jstools jstools_dep

Documented in load_jstools

#' @importFrom htmltools htmlDependency
#' @title load shinytools JavaScript functions
#' @description load shinytools JavaScript functions in a shiny application.
#' Operation has to be made in the UI part.
#' @examples
#' \dontrun{
#' library(shinytools)
#'
#' if (interactive()) {
#'   options(device.ask.default = FALSE)
#'
#'   # Define UI
#'   ui <- fluidPage(
#'     titlePanel("Hello dghiesse!"),
#'     load_jstools(),
#'     sidebarLayout(
#'       sidebarPanel(
#'         sliderInput( "obs",
#'           "Number of observations:",
#'           min = 0, max = 1000, value = 500)
#'       ),
#'       mainPanel(plotOutput("distPlot"))
#'     )
#'   )
#'
#'   server <- function(input, output) {
#'     output$distPlot <- renderPlot({
#'       hist(rnorm(input$obs))
#'     })
#'   }
#'
#'   print(shinyApp(ui, server))
#' }
#' }
#'
#' @export
load_jstools <- function() {
  tagList(
    jstools_dep(),
    load_tingle()
  )
}

jstools_dep <- function(){
  htmlDependency("shinytools",
                 "1.0.0",
                 src = system.file(package="shinytools", "static"),
                 script = "js/shinytools.js")
}
ardata-fr/dgihesse documentation built on Nov. 14, 2019, 7:25 a.m.