mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Fixed documentation problems and JS code logic
This commit is contained in:
@@ -36,12 +36,10 @@ getIcon <- function(tab) {
|
||||
#' \code{tabPanel}).
|
||||
#'
|
||||
#' @param target The \code{value} of an existing \code{tabPanel}, next to
|
||||
#' which \code{tab} will be added. If \code{NULL},the \code{tab} will be
|
||||
#' placed either as the first tab or the last tab, depending on the
|
||||
#' \code{position} argument.
|
||||
#' which \code{tab} will be added.
|
||||
#'
|
||||
#' @param position Should \code{tab} be added before or after the
|
||||
#' \code{target} tab?
|
||||
#' \code{target} tab?
|
||||
#'
|
||||
#' @param session The shiny session within which to call \code{insertTab}.
|
||||
#'
|
||||
@@ -104,6 +102,18 @@ insertTab <- function(inputId, tab, target,
|
||||
session$onFlushed(callback, once = TRUE)
|
||||
}
|
||||
|
||||
#' @param menuName This argument should only be used when you want to
|
||||
#' prepend (or append) \code{tab} to the beginning (or end) of an
|
||||
#' existing \code{\link{navbarMenu}} (which must itself be part of
|
||||
#' an existing \code{\link{navbarPage}}). In this case, this argument
|
||||
#' should be the \code{menuName} that you gave your \code{navbarMenu}
|
||||
#' when you first created it (by default, this is equal to the value
|
||||
#' of the \code{title} argument). Note that you still need to set the
|
||||
#' \code{inputId} argument to whatever the \code{id} of the parent
|
||||
#' \code{navbarPage} is. If \code{menuName} is left as \code{NULL},
|
||||
#' \code{tab} will be prepended (or appended) to whatever
|
||||
#' \code{inputId} is.
|
||||
#'
|
||||
#' @rdname insertTab
|
||||
#' @export
|
||||
prependTab <- function(inputId, tab, menuName = NULL,
|
||||
@@ -154,7 +164,7 @@ appendTab <- function(inputId, tab, menuName = NULL,
|
||||
|
||||
#' @rdname insertTab
|
||||
#' @export
|
||||
removeTab <- function(inputId, target, immediate = FALSE,
|
||||
removeTab <- function(inputId, target,
|
||||
session = getDefaultReactiveDomain()) {
|
||||
|
||||
force(inputId)
|
||||
@@ -167,8 +177,7 @@ removeTab <- function(inputId, target, immediate = FALSE,
|
||||
target = target)
|
||||
}
|
||||
|
||||
if (!immediate) session$onFlushed(callback, once = TRUE)
|
||||
else callback()
|
||||
session$onFlushed(callback, once = TRUE)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1371,31 +1371,29 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.definePrope
|
||||
|
||||
var $tabContent = $("div.tab-content[data-tabsetid='" + tabsetNumericId + "']");
|
||||
|
||||
if (message.prepend) {
|
||||
$tabsetPanel.prepend($liTag);
|
||||
$tabContent.prepend($divTag);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.append) {
|
||||
$tabsetPanel.append($liTag);
|
||||
$tabContent.append($divTag);
|
||||
return;
|
||||
}
|
||||
|
||||
var dataValue = "[data-value='" + message.target + "']";
|
||||
var $targetTabsetPanel = $tabsetPanel.find("a" + dataValue).parent();
|
||||
var $targetTabContent = $tabContent.find("div" + dataValue);
|
||||
|
||||
if ($targetTabsetPanel.length === 0) {
|
||||
throw 'There is no tabPanel with value ' + message.target + '. ' + 'Appending tab to the end...';
|
||||
if (message.prepend || message.append) {
|
||||
if (message.prepend) {
|
||||
$tabsetPanel.prepend($liTag);
|
||||
$tabContent.prepend($divTag);
|
||||
} else if (message.append) {
|
||||
$tabsetPanel.append($liTag);
|
||||
$tabContent.append($divTag);
|
||||
}
|
||||
} else {
|
||||
if (message.position === "before") {
|
||||
$targetTabsetPanel.before($liTag);
|
||||
$targetTabContent.before($divTag);
|
||||
} else if (message.position === "after") {
|
||||
$targetTabsetPanel.after($liTag);
|
||||
$targetTabContent.after($divTag);
|
||||
var dataValue = "[data-value='" + message.target + "']";
|
||||
var $targetTabsetPanel = $tabsetPanel.find("a" + dataValue).parent();
|
||||
var $targetTabContent = $tabContent.find("div" + dataValue);
|
||||
|
||||
if ($targetTabsetPanel.length === 0) {
|
||||
throw "There is no tabPanel with value " + message.target;
|
||||
} else {
|
||||
if (message.position === "before") {
|
||||
$targetTabsetPanel.before($liTag);
|
||||
$targetTabContent.before($divTag);
|
||||
} else if (message.position === "after") {
|
||||
$targetTabsetPanel.after($liTag);
|
||||
$targetTabContent.after($divTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
inst/www/shared/shiny.min.js
vendored
6
inst/www/shared/shiny.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -16,8 +16,7 @@ prependTab(inputId, tab, menuName = NULL,
|
||||
appendTab(inputId, tab, menuName = NULL,
|
||||
session = getDefaultReactiveDomain())
|
||||
|
||||
removeTab(inputId, target, immediate = FALSE,
|
||||
session = getDefaultReactiveDomain())
|
||||
removeTab(inputId, target, session = getDefaultReactiveDomain())
|
||||
}
|
||||
\arguments{
|
||||
\item{inputId}{The \code{id} of the \code{tabsetPanel} (or
|
||||
@@ -28,14 +27,24 @@ be inserted/removed.}
|
||||
\code{tabPanel}).}
|
||||
|
||||
\item{target}{The \code{value} of an existing \code{tabPanel}, next to
|
||||
which \code{tab} will be added. If \code{NULL},the \code{tab} will be
|
||||
placed either as the first tab or the last tab, depending on the
|
||||
\code{position} argument.}
|
||||
which \code{tab} will be added.}
|
||||
|
||||
\item{position}{Should \code{tab} be added before or after the
|
||||
\code{target} tab?}
|
||||
|
||||
\item{session}{The shiny session within which to call \code{insertTab}.}
|
||||
|
||||
\item{menuName}{This argument should only be used when you want to
|
||||
prepend (or append) \code{tab} to the beginning (or end) of an
|
||||
existing \code{\link{navbarMenu}} (which must itself be part of
|
||||
an existing \code{\link{navbarPage}}). In this case, this argument
|
||||
should be the \code{menuName} that you gave your \code{navbarMenu}
|
||||
when you first created it (by default, this is equal to the value
|
||||
of the \code{title} argument). Note that you still need to set the
|
||||
\code{inputId} argument to whatever the \code{id} of the parent
|
||||
\code{navbarPage} is. If \code{menuName} is left as \code{NULL},
|
||||
\code{tab} will be prepended (or appended) to whatever
|
||||
\code{inputId} is.}
|
||||
}
|
||||
\description{
|
||||
Dynamically insert or remove a \code{\link{tabPanel}} from an existing
|
||||
|
||||
@@ -753,31 +753,29 @@ var ShinyApp = function() {
|
||||
|
||||
var $tabContent = $("div.tab-content[data-tabsetid='" + tabsetNumericId + "']");
|
||||
|
||||
if (message.prepend) {
|
||||
$tabsetPanel.prepend($liTag);
|
||||
$tabContent.prepend($divTag);
|
||||
return;
|
||||
}
|
||||
|
||||
if (message.append) {
|
||||
$tabsetPanel.append($liTag);
|
||||
$tabContent.append($divTag);
|
||||
return;
|
||||
}
|
||||
|
||||
var dataValue = "[data-value='" + message.target + "']";
|
||||
var $targetTabsetPanel = $tabsetPanel.find("a" + dataValue).parent();
|
||||
var $targetTabContent = $tabContent.find("div" + dataValue);
|
||||
|
||||
if ($targetTabsetPanel.length === 0) {
|
||||
throw 'There is no tabPanel with value ' + message.target + '. ' + 'Appending tab to the end...';
|
||||
if (message.prepend || message.append) {
|
||||
if (message.prepend) {
|
||||
$tabsetPanel.prepend($liTag);
|
||||
$tabContent.prepend($divTag);
|
||||
} else if (message.append) {
|
||||
$tabsetPanel.append($liTag);
|
||||
$tabContent.append($divTag);
|
||||
}
|
||||
} else {
|
||||
if (message.position === "before") {
|
||||
$targetTabsetPanel.before($liTag);
|
||||
$targetTabContent.before($divTag);
|
||||
} else if (message.position === "after") {
|
||||
$targetTabsetPanel.after($liTag);
|
||||
$targetTabContent.after($divTag);
|
||||
var dataValue = "[data-value='" + message.target + "']";
|
||||
var $targetTabsetPanel = $tabsetPanel.find("a" + dataValue).parent();
|
||||
var $targetTabContent = $tabContent.find("div" + dataValue);
|
||||
|
||||
if ($targetTabsetPanel.length === 0) {
|
||||
throw "There is no tabPanel with value " + message.target;
|
||||
} else {
|
||||
if (message.position === "before") {
|
||||
$targetTabsetPanel.before($liTag);
|
||||
$targetTabContent.before($divTag);
|
||||
} else if (message.position === "after") {
|
||||
$targetTabsetPanel.after($liTag);
|
||||
$targetTabContent.after($divTag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user