Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
remove initilize to avoid clash with {methods}
  • Loading branch information
JohnCoene committed Nov 22, 2019
1 parent b76bc06 commit d675222
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 42 deletions.
1 change: 0 additions & 1 deletion NAMESPACE
Expand Up @@ -3,6 +3,5 @@
export(Cicerone)
export(highlight)
export(initialise)
export(initialize)
export(use_cicerone)
import(assertthat)
46 changes: 28 additions & 18 deletions R/highlight.R
Expand Up @@ -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()
}
Expand Down Expand Up @@ -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
1 change: 0 additions & 1 deletion README.md
Expand Up @@ -101,7 +101,6 @@ ui <- fluidPage(

server <- function(input, output) {

# American English also available
initialise()

observeEvent(input$highlight, {
Expand Down
2 changes: 1 addition & 1 deletion inst/cicerone/cicerone.js
Expand Up @@ -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) {
Expand Down
42 changes: 21 additions & 21 deletions man/highlight.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d675222

Please sign in to comment.