From bf58f4e48ab066033a78d9b3d595032fc85d392c Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 15 Apr 2015 07:38:04 -0400 Subject: [PATCH] Added experimental width argument to bsModal (Issue #27) --- R/bsModal.R | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/R/bsModal.R b/R/bsModal.R index f073422..e409ea3 100644 --- a/R/bsModal.R +++ b/R/bsModal.R @@ -12,7 +12,7 @@ #'@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" @@ -20,6 +20,7 @@ bsModal <- function(id, title, trigger, ..., size, footer = NULL, close.button = size = "modal-sm" } size <- paste("modal-dialog", size) + width = NULL } else { size <- "modal-dialog" } @@ -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("×"))), + 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("×"))), - 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)