tf: Replace checkbox XML objects with JavaScript code

View source: R/tf.R

tfR Documentation

Replace checkbox XML objects with JavaScript code

Description

This function is a basically shortcut for ite with some assumptions. It's thought to be used when a checkbox should turn an option of an R function to a specified value, by default TRUE or FALSE (hence the name, abbreviated "true or false"). The same result can be obtained with ite, but for most common cases tf is much quicker.

Usage

tf(
  cbox,
  true = TRUE,
  not = FALSE,
  ifelse = FALSE,
  false = FALSE,
  opt = NULL,
  prefix = ",\n",
  level = 3,
  indent.by = rk.get.indent()
)

Arguments

cbox

An object of class XiMpLe.node containing a <checkbox> node, as generated by rk.XML.cbox.

true

Logical or character, the value the option should get. E.g., if true=TRUE then the option will be set to TRUE if the box is checked, or in case not=TRUE, if the box is not checked.

not

Logical, inverses the checked status of the checkbox. In other words, set this to TRUE if you want the option to be set if the box is not checked.

ifelse

Logical, whether the options should be set anyway. By default, the option will only be set in one condition. If ifelse=TRUE, it will get the inverse value in case of the alternative condition, e.g. it will be set to either not=TRUE or not=FALSE if the box is checked or unchecked.

false

Logical or character, the value the option should, only used get if ifelse=TRUE as well. E.g., if false=FALSE then the option will be set to FALSE if the box is not checked, or in case not=TRUE, if the box is checked.

opt

A character string, naming the R option to be set. If NULL, the XML ID of the checkbox node will be used.

prefix

A character string, what should be pasted before the actual option string. Default is a comma and a newline.

level

Integer, which indentation level to use, minimum is 1.

indent.by

A character string defining the indentation string to use. This refers to the genrated R code, not the JavaScript code. Indentation is added after the prefix and before the option string.

Value

An object of class rk.JS.ite.

See Also

ite, echo, id, and the Introduction to Writing Plugins for RKWard

Examples

# an example checkbox XML node
cbox1 <- rk.XML.cbox(label="foo", value="foo1", id.name="foo_option")
tf(cbox1)

rkward-community/rkwarddev documentation built on May 9, 2022, 3:02 p.m.