Skip to content

Commit

Permalink
add a refresh function; fixes #205
Browse files Browse the repository at this point in the history
  • Loading branch information
daattali committed Apr 5, 2020
1 parent 5254259 commit cfc5aaf
Show file tree
Hide file tree
Showing 16 changed files with 121 additions and 33 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: shinyjs
Title: Easily Improve the User Experience of Your Shiny Apps in Seconds
Version: 1.1.0.9000
Version: 1.1.0.9001
Authors@R: person("Dean", "Attali", email = "[email protected]",
role = c("aut", "cre"))
Description: Perform common useful JavaScript operations in Shiny apps that will
Expand Down Expand Up @@ -28,4 +28,4 @@ License: AGPL-3
SystemRequirements: pandoc with https support
LazyData: true
VignetteBuilder: knitr
RoxygenNote: 6.1.1
RoxygenNote: 7.1.0
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export(js)
export(logjs)
export(onclick)
export(onevent)
export(refresh)
export(removeClass)
export(removeCssClass)
export(reset)
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# shinyjs 1.1.0.*

TODO date

- New feature: add a `refresh()` function (#205)

# shinyjs 1.1

2020-01-12
Expand Down
10 changes: 10 additions & 0 deletions R/refresh.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#' Refresh the page
#'
#' @export
refresh <- function() {
fxn <- "refresh"
params <- list()
jsFuncHelper(fxn, params)
}


2 changes: 1 addition & 1 deletion R/useShinyjs.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ useShinyjs <- function(rmd = FALSE, debug = FALSE, html = FALSE,
# all the default shinyjs methods that should be forwarded to javascript
jsFuncs <- c("show", "hide", "toggle", "enable", "disable", "toggleState",
"addClass", "removeClass", "toggleClass", "html", "onevent",
"alert", "logjs", "runjs", "reset", "delay", "click")
"alert", "logjs", "runjs", "reset", "delay", "click", "refresh")

# grab the file with all the default shinyjs javascript functions
shiny::addResourcePath("shinyjs", system.file("srcjs", package = "shinyjs"))
Expand Down
10 changes: 10 additions & 0 deletions inst/srcjs/shinyjs-default-funcs.js
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,16 @@ shinyjs = function() {
var $el = _getElements(params);
if ($el === null) return;
$el[0].click();
},

// refresh the page
refresh : function(params) {
var defaultParams = {
id : null
};
params = shinyjs.getParams(params, defaultParams);

window.location.reload(false);
}
};
}();
Expand Down
21 changes: 15 additions & 6 deletions man/classFuncs.Rd

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

3 changes: 1 addition & 2 deletions man/html.Rd

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

4 changes: 3 additions & 1 deletion man/js.Rd

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

3 changes: 1 addition & 2 deletions man/onevent.Rd

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

11 changes: 11 additions & 0 deletions man/refresh.Rd

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

10 changes: 8 additions & 2 deletions man/runcode.Rd

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

1 change: 0 additions & 1 deletion man/shinyjs.Rd

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

3 changes: 1 addition & 2 deletions man/stateFuncs.Rd

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

3 changes: 1 addition & 2 deletions man/useShinyjs.Rd

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

62 changes: 50 additions & 12 deletions man/visibilityFuncs.Rd

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

0 comments on commit cfc5aaf

Please sign in to comment.