Skip to content

Commit

Permalink
Added experimental width argument to bsModal (Issue #27)
Browse files Browse the repository at this point in the history
  • Loading branch information
ebailey78 committed Apr 15, 2015
1 parent 557b56a commit bf58f4e
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions R/bsModal.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
#'@template item_details
#'@template footer
#'@export
bsModal <- function(id, title, trigger, ..., size, footer = NULL, close.button = TRUE) {
bsModal <- function(id, title, trigger, ..., size, footer = NULL, close.button = TRUE, width = NULL) {
if(!missing(size)) {
if(size == "large") {
size = "modal-lg"
} else if(size == "small") {
size = "modal-sm"
}
size <- paste("modal-dialog", size)
width = NULL
} else {
size <- "modal-dialog"
}
Expand All @@ -32,19 +33,25 @@ bsModal <- function(id, title, trigger, ..., size, footer = NULL, close.button =
footer <- shiny::tagAppendChild(footer, tagList(shiny::tags$button(type = "button", class = "btn btn-default", "data-dismiss" = "modal", "Close")))
}

bsTag <- shiny::tags$div(class = size,
shiny::tags$div(class = "modal-content",
shiny::tags$div(class = "modal-header",
shiny::tags$button(type = "button", class = "close", "data-dismiss" = "modal", shiny::tags$span(shiny::HTML("&times;"))),
shiny::tags$h4(class = "modal-title", title)
),
shiny::tags$div(class = "modal-body", list(...)),
shiny::tags$div(class = "modal-footer",
footer
)
)
)

if(!is.null(width)) {
bsTag <- addAttribs(bsTag, style = paste0("width: ", width, " !important;"))
}

bsTag <- shiny::tags$div(class = "modal sbs-modal fade", id = id, tabindex = "-1", "data-sbs-trigger" = trigger,
shiny::tags$div(class = size,
shiny::tags$div(class = "modal-content",
shiny::tags$div(class = "modal-header",
shiny::tags$button(type = "button", class = "close", "data-dismiss" = "modal", shiny::tags$span(shiny::HTML("&times;"))),
shiny::tags$h4(class = "modal-title", title)
),
shiny::tags$div(class = "modal-body", list(...)),
shiny::tags$div(class = "modal-footer",
footer
)
)
)
bsTag
)

htmltools::attachDependencies(bsTag, shinyBSDep)
Expand Down

0 comments on commit bf58f4e

Please sign in to comment.