|
9 | 9 | BOOKMARK_ID = "._bookmark_" |
10 | 10 |
|
11 | 11 |
|
12 | | -#' Create a button for bookmarking/sharing |
13 | | -#' |
14 | | -#' A `bookmarkButton` is a [actionButton()] with a default label |
15 | | -#' that consists of a link icon and the text "Bookmark...". It is meant to be |
16 | | -#' used for bookmarking state. |
17 | | -#' |
18 | | -#' @inheritParams actionButton |
19 | | -#' @param title A tooltip that is shown when the mouse cursor hovers over the |
20 | | -#' button. |
21 | | -#' @param id An ID for the bookmark button. The only time it is necessary to set |
22 | | -#' the ID unless you have more than one bookmark button in your application. |
23 | | -#' If you specify an input ID, it should be excluded from bookmarking with |
24 | | -#' [setBookmarkExclude()], and you must create an observer that |
25 | | -#' does the bookmarking when the button is pressed. See the examples below. |
26 | | -#' |
27 | | -#' @seealso [enableBookmarking()] for more examples. |
28 | | -#' |
29 | | -#' @examples |
30 | | -#' ## Only run these examples in interactive sessions |
31 | | -#' if (interactive()) { |
32 | | -#' |
33 | | -#' # This example shows how to use multiple bookmark buttons. If you only need |
34 | | -#' # a single bookmark button, see examples in ?enableBookmarking. |
35 | | -#' ui <- function(request) { |
36 | | -#' fluidPage( |
37 | | -#' tabsetPanel(id = "tabs", |
38 | | -#' tabPanel("One", |
39 | | -#' checkboxInput("chk1", "Checkbox 1"), |
40 | | -#' bookmarkButton(id = "bookmark1") |
41 | | -#' ), |
42 | | -#' tabPanel("Two", |
43 | | -#' checkboxInput("chk2", "Checkbox 2"), |
44 | | -#' bookmarkButton(id = "bookmark2") |
45 | | -#' ) |
46 | | -#' ) |
47 | | -#' ) |
48 | | -#' } |
49 | | -#' server <- function(input, output, session) { |
50 | | -#' # Need to exclude the buttons from themselves being bookmarked |
51 | | -#' setBookmarkExclude(c("bookmark1", "bookmark2")) |
52 | | -#' |
53 | | -#' # Trigger bookmarking with either button |
54 | | -#' observeEvent(input$bookmark1, { |
55 | | -#' session$doBookmark() |
56 | | -#' }) |
57 | | -#' observeEvent(input$bookmark2, { |
58 | | -#' session$doBookmark() |
59 | | -#' }) |
60 | | -#' } |
61 | | -#' enableBookmarking(store = "url") |
62 | | -#' shinyApp(ui, server) |
63 | | -#' } |
64 | | -#' @export |
| 12 | +# ' Create a button for bookmarking/sharing |
| 13 | +# ' |
| 14 | +# ' A `bookmarkButton` is a [actionButton()] with a default label |
| 15 | +# ' that consists of a link icon and the text "Bookmark...". It is meant to be |
| 16 | +# ' used for bookmarking state. |
| 17 | +# ' |
| 18 | +# ' @inheritParams actionButton |
| 19 | +# ' @param title A tooltip that is shown when the mouse cursor hovers over the |
| 20 | +# ' button. |
| 21 | +# ' @param id An ID for the bookmark button. The only time it is necessary to set |
| 22 | +# ' the ID unless you have more than one bookmark button in your application. |
| 23 | +# ' If you specify an input ID, it should be excluded from bookmarking with |
| 24 | +# ' [setBookmarkExclude()], and you must create an observer that |
| 25 | +# ' does the bookmarking when the button is pressed. See the examples below. |
| 26 | +# ' |
| 27 | +# ' @seealso [enableBookmarking()] for more examples. |
| 28 | +# ' |
| 29 | +# ' @examples |
| 30 | +# ' ## Only run these examples in interactive sessions |
| 31 | +# ' if (interactive()) { |
| 32 | +# ' |
| 33 | +# ' # This example shows how to use multiple bookmark buttons. If you only need |
| 34 | +# ' # a single bookmark button, see examples in ?enableBookmarking. |
| 35 | +# ' ui <- function(request) { |
| 36 | +# ' fluidPage( |
| 37 | +# ' tabsetPanel(id = "tabs", |
| 38 | +# ' tabPanel("One", |
| 39 | +# ' checkboxInput("chk1", "Checkbox 1"), |
| 40 | +# ' bookmarkButton(id = "bookmark1") |
| 41 | +# ' ), |
| 42 | +# ' tabPanel("Two", |
| 43 | +# ' checkboxInput("chk2", "Checkbox 2"), |
| 44 | +# ' bookmarkButton(id = "bookmark2") |
| 45 | +# ' ) |
| 46 | +# ' ) |
| 47 | +# ' ) |
| 48 | +# ' } |
| 49 | +# ' server <- function(input, output, session) { |
| 50 | +# ' # Need to exclude the buttons from themselves being bookmarked |
| 51 | +# ' setBookmarkExclude(c("bookmark1", "bookmark2")) |
| 52 | +# ' |
| 53 | +# ' # Trigger bookmarking with either button |
| 54 | +# ' observeEvent(input$bookmark1, { |
| 55 | +# ' session$doBookmark() |
| 56 | +# ' }) |
| 57 | +# ' observeEvent(input$bookmark2, { |
| 58 | +# ' session$doBookmark() |
| 59 | +# ' }) |
| 60 | +# ' } |
| 61 | +# ' enableBookmarking(store = "url") |
| 62 | +# ' shinyApp(ui, server) |
| 63 | +# ' } |
| 64 | +# ' @export |
65 | 65 | def input_bookmark_button( |
66 | 66 | label: TagChild = "Bookmark...", |
67 | 67 | *, |
|
0 commit comments