Skip to content

Commit 2dda874

Browse files
authored
Merge pull request #362 from sdcTools/feature-remove-shinybs
remove shinyBS dependency in `sdcApp`
2 parents dd4b958 + 10c8ace commit 2dda874

5 files changed

Lines changed: 35 additions & 4 deletions

File tree

DESCRIPTION

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ Imports:
5050
haven,
5151
rhandsontable,
5252
DT,
53-
shinyBS,
5453
prettydoc,
5554
VIM (>= 4.7.0),
5655
httr,

NAMESPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ import(methods)
9494
import(rhandsontable)
9595
import(robustbase)
9696
import(shiny)
97-
import(shinyBS)
9897
import(tools)
9998
import(xtable)
10099
importFrom(DT,datatable)

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# 5.7.10
22
- fix inconsistency in `rankSwap()` Output [Issue #361]
3+
- remove shinyBS dependency in `sdcApp`
34

45
# 5.7.9
56
- Improvements for `recordSwap()`:

R/0classes.r

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#' @import xtable
1212
#' @import data.table
1313
#' @import ggplot2
14-
#' @import shinyBS
1514
#' @import shiny
1615
#' @import rhandsontable
1716
#' @importFrom DT datatable

inst/shiny/sdcApp/global.R

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ library(grid)
33
library(sdcMicro)
44
library(rhandsontable)
55
library(haven)
6-
library(shinyBS)
76
library(data.table)
87

98
if (!getShinyOption("sdcAppInvoked", FALSE)) {### Beginning required code for deployment
@@ -233,6 +232,40 @@ summaryfn <- function(x) {
233232
vv
234233
}
235234

235+
# to get rid of the shinyBS dependency
236+
tipify <- function(el, title, placement = "bottom", trigger = "hover", options = NULL) {
237+
# generate a unique ID for the wrapper element and wrap element in span-tag
238+
wrapper_id <- paste0("tip-", round(runif(1, 1e9, 9e9)), "-", as.integer(Sys.time()))
239+
wrapped_el <- tags$span(id = wrapper_id, el)
240+
241+
# define the JS options, forcing html: true allows to render inline-html code
242+
js_options <- list(
243+
html = TRUE
244+
)
245+
if (!is.null(options)) {
246+
js_options <- c(js_options, options)
247+
}
248+
249+
# add req. attributes
250+
wrapped_el <- htmltools::tagAppendAttributes(
251+
wrapped_el,
252+
"data-toggle" = "tooltip",
253+
"data-placement" = placement,
254+
"data-trigger" = trigger
255+
)
256+
257+
# the attribute should be treated as html-content
258+
wrapped_el$attribs$title <- htmltools::HTML(title)
259+
260+
# the js-script to initialize the tooltip using the generated id
261+
init_script <- tags$script(HTML(paste0(
262+
"$(document).ready(function() { $('#", wrapper_id, "').tooltip(",
263+
jsonlite::toJSON(js_options, auto_unbox = TRUE),
264+
");});"
265+
)))
266+
return(tagList(wrapped_el, init_script))
267+
}
268+
236269
# global, reactive data-structure
237270
data(testdata, envir = .GlobalEnv)
238271
data(testdata2, envir = .GlobalEnv)

0 commit comments

Comments
 (0)