From 0964004fc091a6cd5e1566373ba5590ec4f35e51 Mon Sep 17 00:00:00 2001 From: Lukas Klass Date: Tue, 5 Nov 2019 13:47:37 +0100 Subject: [PATCH 1/2] allow to start intro on specific element --- R/introjs.R | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/R/introjs.R b/R/introjs.R index ca8000a..178f16d 100644 --- a/R/introjs.R +++ b/R/introjs.R @@ -23,6 +23,7 @@ #' @param session the Shiny session object (from the server function of the Shiny app) #' @param options List of options to be passed to intro.js #' @param events List of text that are the body of a Javascript function. Must wrap in [I()] +#' @param element Element to start the intro on #' @note For documentation on intro.js options and events, see \url{https://github.com/usablica/intro.js/wiki/Documentation}. #' @seealso [introjsUI()] [introBox()] #' @examples @@ -62,11 +63,12 @@ introjs <- function(session, options = list(), - events = list()) { - options <- list(options = options, events = events) + events = list(), + element = NULL) { + options <- list(options = options, events = events, element = element) session$sendCustomMessage(type = "introjs", message = jsonlite::toJSON(options, - auto_unbox = TRUE)) + auto_unbox = TRUE, null = "null")) } From 6f7ecb6a5f639176789821bb73327e359eaacaf6 Mon Sep 17 00:00:00 2001 From: Lukas Klass Date: Tue, 5 Nov 2019 13:49:03 +0100 Subject: [PATCH 2/2] Allow to start intro on specific element --- inst/javascript/rintro.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/inst/javascript/rintro.js b/inst/javascript/rintro.js index b39bfd8..f4325fd 100644 --- a/inst/javascript/rintro.js +++ b/inst/javascript/rintro.js @@ -14,7 +14,12 @@ // along with this program. If not, see . Shiny.addCustomMessageHandler('introjs',function(options) { - introJs().setOptions(options.options).oncomplete(function() { + if (options.element == null) { + var intro = introJs(); + } else { + var intro = introJs(options.element); + } + intro.setOptions(options.options).oncomplete(function() { options.events.hasOwnProperty("oncomplete") && eval(options.events.oncomplete[0]); }).onexit(function() { options.events.hasOwnProperty("onexit") && eval(options.events.onexit[0]); @@ -54,4 +59,4 @@ rintrojs = function() { } } }; -}(); \ No newline at end of file +}();