Skip to content

Commit

Permalink
add synonyms for functions that mask S4 functions (fixes #81)
Browse files Browse the repository at this point in the history
  • Loading branch information
daattali committed Dec 24, 2016
1 parent ba45981 commit accdfb4
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 1 deletion.
2 changes: 1 addition & 1 deletion 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: 0.8.0.9003
Version: 0.8.0.9004
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
6 changes: 6 additions & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Generated by roxygen2: do not edit by hand

export(addClass)
export(addCssClass)
export(alert)
export(colourInput)
export(colourPicker)
Expand All @@ -11,6 +12,7 @@ export(enable)
export(extendShinyjs)
export(hidden)
export(hide)
export(hideElement)
export(html)
export(info)
export(inlineCSS)
Expand All @@ -19,15 +21,19 @@ export(logjs)
export(onclick)
export(onevent)
export(removeClass)
export(removeCssClass)
export(reset)
export(runExample)
export(runcodeServer)
export(runcodeUI)
export(runjs)
export(show)
export(showElement)
export(showLog)
export(toggle)
export(toggleClass)
export(toggleCssClass)
export(toggleElement)
export(toggleState)
export(updateColourInput)
export(useShinyjs)
Expand Down
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- fixed bug where `showLog()` would only show the last message if multiple messages were printed in succession (#99)
- fixed bug where date inputs could not be reset to empty (#100)
- fixed textArea inputs not getting disabled when disabling a parent element
- add `showElement()`/`hideElement()`/`toggleElement()` and `addCssClass` etc functions as synonyms for functions that are masked by S4 (compromise for #81)
- fixed broken `runExample("sandbox")` example
- added a website for shinyjs: http://deanattali.com/shinyjs

Expand Down
24 changes: 24 additions & 0 deletions R/jsFunc-classFuncs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#' \strong{\code{addClass}} adds a CSS class, \strong{\code{removeClass}}
#' removes a CSS class, \strong{\code{toggleClass}} adds the class if it is
#' not set and removes the class if it is already set.\cr\cr
#' \strong{\code{addCssClass}}, \strong{\code{removeCssClass}}, and
#' \strong{\code{toggleCssClass}} are synonyms that may be safer to use if you're
#' working with S4 classes (since they don't mask any existing S4 functions).\cr\cr
#' If \code{condition} is given to \code{toggleClass}, that condition will be used
#' to determine if to add or remove the class. The class will be added if the
#' condition evaluates to \code{TRUE} and removed otherwise. If you find
Expand Down Expand Up @@ -82,15 +85,36 @@ addClass <- function(id, class, selector) {
}
#' @export
#' @rdname classFuncs
addCssClass <- function(id, class, selector) {
fxn <- "addClass"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
#' @export
#' @rdname classFuncs
removeClass <- function(id, class, selector) {
fxn <- "removeClass"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
#' @export
#' @rdname classFuncs
removeCssClass <- function(id, class, selector) {
fxn <- "removeClass"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
#' @export
#' @rdname classFuncs
toggleClass <- function(id, class, condition, selector) {
fxn <- "toggleClass"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
#' @export
#' @rdname classFuncs
toggleCssClass <- function(id, class, condition, selector) {
fxn <- "toggleClass"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
27 changes: 27 additions & 0 deletions R/jsFunc-visibilityFuncs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
#' \strong{\code{show}} makes an element visible, \strong{\code{hide}} makes
#' an element invisible, \strong{\code{toggle}} displays the element if it it
#' hidden and hides it if it is visible.\cr\cr
#' \strong{\code{showElement}}, \strong{\code{hideElement}}, and
#' \strong{\code{toggleElement}} are synonyms that may be safer to use if you're
#' working with S4 classes (since they don't mask any existing S4 functions).\cr\cr
#' If \code{condition} is given to \code{toggle}, that condition will be used
#' to determine if to show or hide the element. The element will be shown if the
#' condition evaluates to \code{TRUE} and hidden otherwise. If you find
Expand Down Expand Up @@ -87,6 +90,14 @@ show <- function(id, anim, animType, time, selector) {
jsFuncHelper(fxn, params)
}

#' @export
#' @rdname visibilityFuncs
showElement <- function(id, anim, animType, time, selector) {
fxn <- "show"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}

#' @export
#' @rdname visibilityFuncs
hide <- function(id, anim, animType, time, selector) {
Expand All @@ -95,10 +106,26 @@ hide <- function(id, anim, animType, time, selector) {
jsFuncHelper(fxn, params)
}

#' @export
#' @rdname visibilityFuncs
hideElement <- function(id, anim, animType, time, selector) {
fxn <- "hide"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}

#' @export
#' @rdname visibilityFuncs
toggle <- function(id, anim, animType, time, selector, condition) {
fxn <- "toggle"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}

#' @export
#' @rdname visibilityFuncs
toggleElement <- function(id, anim, animType, time, selector, condition) {
fxn <- "toggle"
params <- as.list(match.call())[-1]
jsFuncHelper(fxn, params)
}
12 changes: 12 additions & 0 deletions man/classFuncs.Rd

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

12 changes: 12 additions & 0 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 accdfb4

Please sign in to comment.