Skip to content

Commit b16a3cf

Browse files
committed
Updates
1 parent 91395c0 commit b16a3cf

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

R/widgets.R

+9-9
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ examples.form.widgets = function() {
1010

1111
myText = textInput("myText","Text:","Hello World"),
1212
radioButtons("myRadio",label="Make your choice",choices = list("Choice A"="A","Choice B"= "B"), selected=NA),
13-
13+
smallButton("btn",label="", icon=icon("trash-o")),
1414
smallButton("btn","Click me", form.ids=c("check", "myRadio","myText"))
1515
)
1616
buttonHandler("btn", function(formValues,...) {
@@ -45,30 +45,30 @@ examples.widgets = function() {
4545
viewApp(app)
4646
}
4747

48-
smallButton = function(id, label,class.add="",class="btn btn-default action-button btn-xs",style="",form.ids=NULL,form.sel=NULL,...) {
48+
smallButton = function(id, label,class.add="",class="btn btn-default action-button btn-xs",style="",icon=NULL, form.ids=NULL,form.sel=NULL,...) {
4949
args = list(...)
5050
if ("data-form-selector" %in% names(args) | (is.null(form.ids) & is.null(form.sel))) {
51-
tags$button(id=id, style=style, type="button", class=paste(class,class.add),...,label)
51+
tags$button(id=id, style=style, type="button", class=paste(class,class.add),...,list(icon, label))
5252
} else {
5353
if (is.null(form.sel)) {
5454
form.sel = paste0("#", form.ids,collapse=", ")
5555
}
56-
tags$button(id=id, style=style, type="button", class=paste(class,class.add),`data-form-selector`=form.sel,...,label)
56+
tags$button(id=id, style=style, type="button", class=paste(class,class.add),`data-form-selector`=form.sel,...,list(icon, label))
5757

5858
}
5959
}
6060

61-
simpleButton = function(id, label,class.add="",class="btn btn-default action-button",style="",form.ids=NULL,form.sel=NULL,as.tag=TRUE,...) {
61+
simpleButton = function(id, label,class.add="",class="btn btn-default action-button",style="",icon=NULL, form.ids=NULL,form.sel=NULL,as.tag=TRUE,...) {
6262
args = list(...)
6363
class=paste(class,class.add)
6464
if (as.tag) {
6565
if ("data-form-selector" %in% names(args) | (is.null(form.ids) & is.null(form.sel))) {
66-
tags$button(id=id, style=style, type="button", class=class,...,label)
66+
tags$button(id=id, style=style, type="button", class=class,...,list(icon, label))
6767
} else {
6868
if (is.null(form.sel)) {
6969
form.sel = paste0("#", form.ids,collapse=", ")
7070
}
71-
tags$button(id=id, style=style, type="button",class=class ,`data-form-selector`=form.sel,...,label)
71+
tags$button(id=id, style=style, type="button",class=class ,`data-form-selector`=form.sel,...,list(icon, label))
7272

7373
}
7474
} else {
@@ -141,9 +141,9 @@ makeEventsId = function(prefix, id=NULL, class=NULL) {
141141

142142
random.string = function(n=1, nchar=12) {
143143
if (n == 1) {
144-
paste0(sample(c(LETTERS,letters,0:9), nchar, TRUE), collapse="")
144+
paste0(sample(c(LETTERS,letters), nchar, TRUE), collapse="")
145145
} else {
146-
unlist(replicate(n,paste0(sample(c(LETTERS,letters,0:9), nchar, TRUE),collapse="")))
146+
unlist(replicate(n,paste0(sample(c(LETTERS,letters), nchar, TRUE),collapse="")))
147147
}
148148
}
149149

inst/www/shinyEvents.js

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ shinyEventsExtractFormValues = function(id) {
1111
return vals;
1212
};
1313

14+
shinyEventsWidgetsValues = function(widgets) {
15+
var vals = {};
16+
if (typeof widgets === "undefined") return(null);
17+
$(widgets).each(function( index ) {
18+
var valId = $(this).attr("id");
19+
var value = shinyEventsWidgetValue($(this));
20+
vals[valId] = value;
21+
});
22+
return vals;
23+
};
24+
1425
// Tries to extract the value of different shiny widgets
1526
// x is a jquery object e.g. $("#myInput")
1627
// for normal inputs we just return x.val()

0 commit comments

Comments
 (0)