Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions R/introjs.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"))

}

Expand Down
9 changes: 7 additions & 2 deletions inst/javascript/rintro.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.

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]);
Expand Down Expand Up @@ -54,4 +59,4 @@ rintrojs = function() {
}
}
};
}();
}();