mirror of
https://github.com/rstudio/shiny.git
synced 2026-02-06 20:55:24 -05:00
Add bookmarkOutput
This commit is contained in:
20
srcjs/output_binding_bookmark.js
Normal file
20
srcjs/output_binding_bookmark.js
Normal file
@@ -0,0 +1,20 @@
|
||||
var bookmarkOutputBinding = new OutputBinding();
|
||||
$.extend(bookmarkOutputBinding, {
|
||||
find: function(scope) {
|
||||
return $(scope).find('.shiny-bookmark-output');
|
||||
},
|
||||
renderValue: function(el, data) {
|
||||
const $el = $(el);
|
||||
const $button = $el.find('button');
|
||||
|
||||
// Initialize clipboardjs for this element, one time only
|
||||
if (!$button.data('clipboard-initialized')) {
|
||||
new Clipboard($button[0]);
|
||||
$button.data('clipboard-initialized', true);
|
||||
}
|
||||
|
||||
$el.find('input')[0].value = location.protocol + '//' + location.host +
|
||||
location.pathname + '?' + data;
|
||||
}
|
||||
});
|
||||
outputBindings.register(bookmarkOutputBinding, 'shiny.bookmarkOutput');
|
||||
Reference in New Issue
Block a user