mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Make tab prepend/append just edge cases of insert
This commit is contained in:
committed by
Barbara Borges Ribeiro
parent
48b8923b67
commit
f1873a014c
@@ -135,8 +135,6 @@ insertTab <- function(inputId, tab, target,
|
||||
divTag = processDeps(item$divTag, session),
|
||||
menuName = NULL,
|
||||
target = target,
|
||||
prepend = FALSE,
|
||||
append = FALSE,
|
||||
position = position)
|
||||
}
|
||||
session$onFlushed(callback, once = TRUE)
|
||||
@@ -173,9 +171,7 @@ prependTab <- function(inputId, tab, menuName = NULL,
|
||||
divTag = processDeps(item$divTag, session),
|
||||
menuName = menuName,
|
||||
target = NULL,
|
||||
prepend = TRUE,
|
||||
append = FALSE,
|
||||
position = NULL)
|
||||
position = "after")
|
||||
}
|
||||
session$onFlushed(callback, once = TRUE)
|
||||
}
|
||||
@@ -199,9 +195,7 @@ appendTab <- function(inputId, tab, menuName = NULL,
|
||||
divTag = processDeps(item$divTag, session),
|
||||
menuName = menuName,
|
||||
target = NULL,
|
||||
prepend = FALSE,
|
||||
append = TRUE,
|
||||
position = NULL)
|
||||
position = "before")
|
||||
}
|
||||
session$onFlushed(callback, once = TRUE)
|
||||
}
|
||||
|
||||
@@ -1493,11 +1493,7 @@ ShinySession <- R6Class(
|
||||
)
|
||||
},
|
||||
sendInsertTab = function(inputId, liTag, divTag, menuName,
|
||||
target, prepend, append, position) {
|
||||
if (is.null(target) && prepend == append) {
|
||||
stop("If target is NULL, either `prepend` or `append` ",
|
||||
"must be TRUE. Both cannot be TRUE, however.")
|
||||
}
|
||||
target, position) {
|
||||
private$sendMessage(
|
||||
`shiny-insert-tab` = list(
|
||||
inputId = inputId,
|
||||
@@ -1505,8 +1501,6 @@ ShinySession <- R6Class(
|
||||
divTag = divTag,
|
||||
menuName = menuName,
|
||||
target = target,
|
||||
prepend = prepend,
|
||||
append = append,
|
||||
position = position
|
||||
)
|
||||
)
|
||||
|
||||
@@ -767,9 +767,11 @@ var ShinyApp = function() {
|
||||
|
||||
// Unless the item is being prepended/appended, the target tab
|
||||
// must be provided
|
||||
var target = null;
|
||||
var $targetLiTag = null;
|
||||
if (message.target !== null) {
|
||||
var target = getTargetTabs($tabset, $tabContent, message.target);
|
||||
var $targetLiTag = target.$liTag;
|
||||
target = getTargetTabs($tabset, $tabContent, message.target);
|
||||
$targetLiTag = target.$liTag;
|
||||
}
|
||||
|
||||
// If the item is to be placed inside a navbarMenu (dropdown),
|
||||
@@ -797,10 +799,19 @@ var ShinyApp = function() {
|
||||
}
|
||||
|
||||
// actually insert the item into the right place
|
||||
if (message.prepend) $tabset.prepend($liTag);
|
||||
else if (message.append) $tabset.append($liTag);
|
||||
else if (message.position === "before") $targetLiTag.before($liTag);
|
||||
else if (message.position === "after") $targetLiTag.after($liTag);
|
||||
if (message.position === "before") {
|
||||
if ($targetLiTag) {
|
||||
$targetLiTag.before($liTag);
|
||||
} else {
|
||||
$tabset.append($liTag);
|
||||
}
|
||||
} else if (message.position === "after") {
|
||||
if ($targetLiTag) {
|
||||
$targetLiTag.after($liTag);
|
||||
} else {
|
||||
$tabset.prepend($liTag);
|
||||
}
|
||||
}
|
||||
$tabContent.append($divTag);
|
||||
|
||||
exports.renderContent($liTag[0], $liTag.html());
|
||||
|
||||
Reference in New Issue
Block a user