From d675222435a12bc4dced19a171bdcbc057e81e05 Mon Sep 17 00:00:00 2001 From: John Coene Date: Fri, 22 Nov 2019 11:03:31 +0100 Subject: [PATCH] remove initilize to avoid clash with {methods} --- NAMESPACE | 1 - R/highlight.R | 46 ++++++++++++++++++++++++--------------- README.md | 1 - inst/cicerone/cicerone.js | 2 +- man/highlight.Rd | 42 +++++++++++++++++------------------ 5 files changed, 50 insertions(+), 42 deletions(-) diff --git a/NAMESPACE b/NAMESPACE index d4a7b7c6..d4402b82 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -3,6 +3,5 @@ export(Cicerone) export(highlight) export(initialise) -export(initialize) export(use_cicerone) import(assertthat) diff --git a/R/highlight.R b/R/highlight.R index 32da7653..4e6a1fd4 100644 --- a/R/highlight.R +++ b/R/highlight.R @@ -35,37 +35,51 @@ #' the function attempts to get the session with #' \link[shiny]{getDefaultReactiveDomain}. #' +#' @section Position: +#' * left +#' * right +#' * left-center +#' * left-bottom +#' * top +#' * top-center +#' * top-right +#' * right +#' * right-center +#' * right-bottom +#' * bottom +#' * bottom-center +#' * mid-center +#' #' @name highlight #' @export -highlight <- function(el, title, description, position = "right", - class = "popover-class", show_btns = NULL, close_btn_text = NULL, +highlight <- function(el, title = NULL, description = NULL, position = NULL, + class = NULL, show_btns = NULL, close_btn_text = NULL, next_btn_text = NULL, prev_btn_text = NULL, session = NULL) { if(is.null(session)) session <- shiny::getDefaultReactiveDomain() - assertthat::assert_that(!missing(el), !missing(title), !missing(description)) + assertthat::assert_that(!missing(el)) el <- paste0("#", el) - popover <- list( - className = class, - title = title, - description = description, - position = position - ) + popover <- list() + if(!is.null(class)) popover$className <- class + if(!is.null(title)) popover$title <- title + if(!is.null(description)) popover$description <- description + if(!is.null(position)) popover$position <- position if(!is.null(show_btns)) popover$showButtons <- show_btns if(!is.null(close_btn_text)) popover$closeBtnText <- close_btn_text if(!is.null(next_btn_text)) popover$nextBtnText <- next_btn_text if(!is.null(prev_btn_text)) popover$prevBtnText <- prev_btn_text - step = list( - element = el, - popover = popover - ) + step = list(element = el) + + if(length(popover)) + step$popover <- popover - session$sendCustomMessage("cicerone-highlight-man", list(obj = step)) + session$sendCustomMessage("cicerone-highlight-man", step) invisible() } @@ -101,7 +115,3 @@ initialise <- function(animate = TRUE, opacity = .75, padding = 10, session$sendCustomMessage("cicerone-init", list(globals = globals)) invisible() } - -#' @rdname highlight -#' @export -initialize <- initialise \ No newline at end of file diff --git a/README.md b/README.md index 72428a91..d9a668e0 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,6 @@ ui <- fluidPage( server <- function(input, output) { - # American English also available initialise() observeEvent(input$highlight, { diff --git a/inst/cicerone/cicerone.js b/inst/cicerone/cicerone.js index 60815cf7..c5b212fc 100644 --- a/inst/cicerone/cicerone.js +++ b/inst/cicerone/cicerone.js @@ -86,7 +86,7 @@ Shiny.addCustomMessageHandler('cicerone-previous', function(opts) { }); Shiny.addCustomMessageHandler('cicerone-highlight-man', function(opts) { - driver.highlight(opts.obj); + driver.highlight(opts); }); Shiny.addCustomMessageHandler('cicerone-get-highlighted', function(opts) { diff --git a/man/highlight.Rd b/man/highlight.Rd index b5f55bb3..147c39ac 100644 --- a/man/highlight.Rd +++ b/man/highlight.Rd @@ -3,15 +3,14 @@ \name{highlight} \alias{highlight} \alias{initialise} -\alias{initialize} \title{Highlight & Initialise} \usage{ highlight( el, - title, - description, - position = "right", - class = "popover-class", + title = NULL, + description = NULL, + position = NULL, + class = NULL, show_btns = NULL, close_btn_text = NULL, next_btn_text = NULL, @@ -34,22 +33,6 @@ initialise( keyboard_control = TRUE, session = NULL ) - -initialize( - animate = TRUE, - opacity = 0.75, - padding = 10, - allow_close = TRUE, - overlay_click_next = FALSE, - done_btn_text = "Done", - close_btn_text = "Close", - stage_background = "#ffffff", - next_btn_text = "Next", - prev_btn_text = "Previous", - show_btns = TRUE, - keyboard_control = TRUE, - session = NULL -) } \arguments{ \item{el}{Id of element to be highlighted.} @@ -101,3 +84,20 @@ to close, arrow keys to move).} \description{ Initialise and highlight an element. } +\section{Position}{ + +* left +* right +* left-center +* left-bottom +* top +* top-center +* top-right +* right +* right-center +* right-bottom +* bottom +* bottom-center +* mid-center +} +