mirror of
https://github.com/rstudio/shiny.git
synced 2026-04-07 03:00:20 -04:00
Add ability to reset brush with session$resetBrush/Shiny.resetBrush
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
Package: shiny
|
||||
Type: Package
|
||||
Title: Web Application Framework for R
|
||||
Version: 0.13.2.9003
|
||||
Version: 0.13.2.9004
|
||||
Date: 2016-02-17
|
||||
Authors@R: c(
|
||||
person("Winston", "Chang", role = c("aut", "cre"), email = "winston@rstudio.com"),
|
||||
|
||||
3
NEWS
3
NEWS
@@ -75,6 +75,9 @@ shiny 0.13.2.9001
|
||||
* Almost all code examples now have a runnable example with `shinyApp()`, so
|
||||
that users can run the examples and see them in action. (#1137, #1158)
|
||||
|
||||
* Added `session$resetBrush(brushId)` (R) and `Shiny.resetBrush(brushId)` (JS)
|
||||
to programatically clear brushes from `imageOutput`/`plotOutput`.
|
||||
|
||||
shiny 0.13.2
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
43
R/shiny.R
43
R/shiny.R
@@ -168,6 +168,18 @@ workerId <- local({
|
||||
#' example, \code{session$clientData$url_search}).
|
||||
#'
|
||||
#' @return
|
||||
#' \item{allowReconnect(value)}{
|
||||
#' If \code{value} is \code{TRUE} and run in a hosting environment (Shiny
|
||||
#' Server or Connect) with reconnections enabled, then when the session ends
|
||||
#' due to the network connection closing, the client will attempt to
|
||||
#' reconnect to the server. If a reconnection is successful, the browser will
|
||||
#' send all the current input values to the new session on the server, and
|
||||
#' the server will recalculate any outputs and send them back to the client.
|
||||
#' If \code{value} is \code{FALSE}, reconnections will be disabled (this is
|
||||
#' the default state). If \code{"force"}, then the client browser will always
|
||||
#' attempt to reconnect. The only reason to use \code{"force"} is for testing
|
||||
#' on a local connection (without Shiny Server or Connect).
|
||||
#' }
|
||||
#' \item{clientData}{
|
||||
#' A \code{\link{reactiveValues}} object that contains information about the client.
|
||||
#' \itemize{
|
||||
@@ -202,6 +214,11 @@ workerId <- local({
|
||||
#' \item{isClosed()}{A function that returns \code{TRUE} if the client has
|
||||
#' disconnected.
|
||||
#' }
|
||||
#' \item{ns(id)}{
|
||||
#' Server-side version of \code{ns <- \link{NS}(id)}. If bare IDs need to be
|
||||
#' explicitly namespaced for the current module, \code{session$ns("name")}
|
||||
#' will return the fully-qualified ID.
|
||||
#' }
|
||||
#' \item{onEnded(callback)}{
|
||||
#' Synonym for \code{onSessionEnded}.
|
||||
#' }
|
||||
@@ -249,17 +266,9 @@ workerId <- local({
|
||||
#' This is the request that was used to initiate the websocket connection
|
||||
#' (as opposed to the request that downloaded the web page for the app).
|
||||
#' }
|
||||
#' \item{allowReconnect(value)}{
|
||||
#' If \code{value} is \code{TRUE} and run in a hosting environment (Shiny
|
||||
#' Server or Connect) with reconnections enabled, then when the session ends
|
||||
#' due to the network connection closing, the client will attempt to
|
||||
#' reconnect to the server. If a reconnection is successful, the browser will
|
||||
#' send all the current input values to the new session on the server, and
|
||||
#' the server will recalculate any outputs and send them back to the client.
|
||||
#' If \code{value} is \code{FALSE}, reconnections will be disabled (this is
|
||||
#' the default state). If \code{"force"}, then the client browser will always
|
||||
#' attempt to reconnect. The only reason to use \code{"force"} is for testing
|
||||
#' on a local connection (without Shiny Server or Connect).
|
||||
#' \item{resetBrush(brushId)}{
|
||||
#' Resets/clears the brush with the given \code{brushId}, if it exists on
|
||||
#' any \code{imageOutput} or \code{plotOutput} in the app.
|
||||
#' }
|
||||
#' \item{sendCustomMessage(type, message)}{
|
||||
#' Sends a custom message to the web page. \code{type} must be a
|
||||
@@ -281,11 +290,6 @@ workerId <- local({
|
||||
#' from Shiny apps, but through friendlier wrapper functions like
|
||||
#' \code{\link{updateTextInput}}.
|
||||
#' }
|
||||
#' \item{ns(id)}{
|
||||
#' Server-side version of \code{ns <- \link{NS}(id)}. If bare IDs need to be
|
||||
#' explicitly namespaced for the current module, \code{session$ns("name")}
|
||||
#' will return the fully-qualified ID.
|
||||
#' }
|
||||
#'
|
||||
#' @name session
|
||||
NULL
|
||||
@@ -799,6 +803,13 @@ ShinySession <- R6Class(
|
||||
)
|
||||
)
|
||||
},
|
||||
resetBrush = function(brushId) {
|
||||
private$sendMessage(
|
||||
resetBrush = list(
|
||||
brushId = brushId
|
||||
)
|
||||
)
|
||||
},
|
||||
|
||||
# Public RPC methods
|
||||
`@uploadieFinish` = function() {
|
||||
|
||||
@@ -1162,6 +1162,10 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
||||
});
|
||||
});
|
||||
|
||||
addMessageHandler("resetBrush", function (message) {
|
||||
exports.resetBrush(message.brushId);
|
||||
});
|
||||
|
||||
// Progress reporting ====================================================
|
||||
|
||||
var progressHandlers = {
|
||||
@@ -2973,6 +2977,13 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
|
||||
};
|
||||
};
|
||||
|
||||
exports.resetBrush = function (brushId) {
|
||||
exports.onInputChange(brushId, null);
|
||||
imageOutputBinding.find(document).trigger("shiny-internal:brushed", {
|
||||
brushId: brushId, outputId: null
|
||||
});
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------
|
||||
// Source file: ../srcjs/output_binding_html.js
|
||||
|
||||
|
||||
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
@@ -4,6 +4,18 @@
|
||||
\alias{session}
|
||||
\title{Session object}
|
||||
\value{
|
||||
\item{allowReconnect(value)}{
|
||||
If \code{value} is \code{TRUE} and run in a hosting environment (Shiny
|
||||
Server or Connect) with reconnections enabled, then when the session ends
|
||||
due to the network connection closing, the client will attempt to
|
||||
reconnect to the server. If a reconnection is successful, the browser will
|
||||
send all the current input values to the new session on the server, and
|
||||
the server will recalculate any outputs and send them back to the client.
|
||||
If \code{value} is \code{FALSE}, reconnections will be disabled (this is
|
||||
the default state). If \code{"force"}, then the client browser will always
|
||||
attempt to reconnect. The only reason to use \code{"force"} is for testing
|
||||
on a local connection (without Shiny Server or Connect).
|
||||
}
|
||||
\item{clientData}{
|
||||
A \code{\link{reactiveValues}} object that contains information about the client.
|
||||
\itemize{
|
||||
@@ -38,6 +50,11 @@
|
||||
\item{isClosed()}{A function that returns \code{TRUE} if the client has
|
||||
disconnected.
|
||||
}
|
||||
\item{ns(id)}{
|
||||
Server-side version of \code{ns <- \link{NS}(id)}. If bare IDs need to be
|
||||
explicitly namespaced for the current module, \code{session$ns("name")}
|
||||
will return the fully-qualified ID.
|
||||
}
|
||||
\item{onEnded(callback)}{
|
||||
Synonym for \code{onSessionEnded}.
|
||||
}
|
||||
@@ -85,17 +102,9 @@
|
||||
This is the request that was used to initiate the websocket connection
|
||||
(as opposed to the request that downloaded the web page for the app).
|
||||
}
|
||||
\item{allowReconnect(value)}{
|
||||
If \code{value} is \code{TRUE} and run in a hosting environment (Shiny
|
||||
Server or Connect) with reconnections enabled, then when the session ends
|
||||
due to the network connection closing, the client will attempt to
|
||||
reconnect to the server. If a reconnection is successful, the browser will
|
||||
send all the current input values to the new session on the server, and
|
||||
the server will recalculate any outputs and send them back to the client.
|
||||
If \code{value} is \code{FALSE}, reconnections will be disabled (this is
|
||||
the default state). If \code{"force"}, then the client browser will always
|
||||
attempt to reconnect. The only reason to use \code{"force"} is for testing
|
||||
on a local connection (without Shiny Server or Connect).
|
||||
\item{resetBrush(brushId)}{
|
||||
Resets/clears the brush with the given \code{brushId}, if it exists on
|
||||
any \code{imageOutput} or \code{plotOutput} in the app.
|
||||
}
|
||||
\item{sendCustomMessage(type, message)}{
|
||||
Sends a custom message to the web page. \code{type} must be a
|
||||
@@ -117,11 +126,6 @@
|
||||
from Shiny apps, but through friendlier wrapper functions like
|
||||
\code{\link{updateTextInput}}.
|
||||
}
|
||||
\item{ns(id)}{
|
||||
Server-side version of \code{ns <- \link{NS}(id)}. If bare IDs need to be
|
||||
explicitly namespaced for the current module, \code{session$ns("name")}
|
||||
will return the fully-qualified ID.
|
||||
}
|
||||
}
|
||||
\description{
|
||||
Shiny server functions can optionally include \code{session} as a parameter
|
||||
|
||||
@@ -1368,3 +1368,10 @@ imageutils.createBrush = function($el, opts, coordmap, expandPixels) {
|
||||
stopResizing: stopResizing
|
||||
};
|
||||
};
|
||||
|
||||
exports.resetBrush = function(brushId) {
|
||||
exports.onInputChange(brushId, null);
|
||||
imageOutputBinding.find(document).trigger("shiny-internal:brushed", {
|
||||
brushId: brushId, outputId: null
|
||||
});
|
||||
};
|
||||
|
||||
@@ -641,19 +641,19 @@ var ShinyApp = function() {
|
||||
});
|
||||
|
||||
addMessageHandler('shiny-insert-ui', function (message) {
|
||||
var targets = $(message.selector);
|
||||
if (targets.length === 0) {
|
||||
// render the HTML and deps to a null target, so
|
||||
// the side-effect of rendering the deps, singletons,
|
||||
// and <head> still occur
|
||||
exports.renderHtml($([]), message.content.html, message.content.deps);
|
||||
} else {
|
||||
targets.each(function (i, target) {
|
||||
exports.renderContent(target, message.content, message.where);
|
||||
return message.multiple;
|
||||
});
|
||||
}
|
||||
});
|
||||
var targets = $(message.selector);
|
||||
if (targets.length === 0) {
|
||||
// render the HTML and deps to a null target, so
|
||||
// the side-effect of rendering the deps, singletons,
|
||||
// and <head> still occur
|
||||
exports.renderHtml($([]), message.content.html, message.content.deps);
|
||||
} else {
|
||||
targets.each(function (i, target) {
|
||||
exports.renderContent(target, message.content, message.where);
|
||||
return message.multiple;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
addMessageHandler('shiny-remove-ui', function (message) {
|
||||
var els = $(message.selector);
|
||||
@@ -667,6 +667,10 @@ var ShinyApp = function() {
|
||||
});
|
||||
});
|
||||
|
||||
addMessageHandler("resetBrush", function(message) {
|
||||
exports.resetBrush(message.brushId);
|
||||
});
|
||||
|
||||
// Progress reporting ====================================================
|
||||
|
||||
var progressHandlers = {
|
||||
|
||||
Reference in New Issue
Block a user