-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathglobal.R
More file actions
85 lines (77 loc) · 2.84 KB
/
global.R
File metadata and controls
85 lines (77 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
library(dplyr)
library(rCharts)
library(bigrquery)
library(lubridate)
library(knitr)
library(markdown)
##| Create a button link for referencing external urls.
##| - Its compactly and pretty and looks good in a table
createGravatarImage <- function(id) {
sprintf('
<img src="http://www.gravatar.com/avatar/%s?s=40" />
', id)
}
##|----------------
createButtonLink <- function(link, text) {
sprintf('<a href="%s" target="_blank" class="btn btn-primary">%s</a>', link, text)
}
##|----------------
##| create gravatar
# createButtonLink <- function(link, text) {
# sprintf('
# <a class="mcnButton"
# href="%s"
# target="_blank"
# style="font-weight: normal;
# background-color: #337EC6;
# border-radius: 5px;
# border: 6px solid #337EC6;
# cursor: pointer;
# letter-spacing: -0.5px;
# text-align: center;
# text-decoration: none;
# color: #FFFFFF;
# word-wrap: break-word !important;
# font-family:Arial;"
# >%s</button>
# ',link, text)
# }
# ##| Email button so I can get some feedback from users
# emailButton <- function(title, link) {
# html <- sprintf("<a href='%s' class='btn btn-success btn-lg'>%s</a>", link, title)
# Encoding(html) <- 'UTF-8'
# HTML(html)
# }
##|------------------------------------------
##| Helper Functions
##|------------------------------------------
##| converts markdown files to html using markdown package and returns result
inclMD <- function(file) return(markdownToHTML(file, options = c(""), stylesheet="shared/shiny.css"))
##| Email link that looks like a button
##| - This will open the default email client and populate fields
emailButton <- function(title, link) {
html <- sprintf("
<a href='%s' class='btn btn-success'>%s</a>
", link, title)
Encoding(html) <- 'UTF-8'
HTML(html)
}
##|-----------------------------------------
##| These are copied and modified from Radiant
##| https://github.com/mostly-harmless/radiant
##| http://vnijs.rady.ucsd.edu:3838/marketing/
##|-----------------------------------------
# Adding the figures path to avoid making a copy of all figures in www/figures
addResourcePath("figures", "help/figures/")
##| Binding to a bootstrap modal
helpModal <- function(title, link, content) {
html <- sprintf("<div id='%s' class='modal hide fade in' style='display: none; '>
<div class='modal-header'><a class='close' data-dismiss='modal' href='#'>×</a>
<h3>%s</h3>
</div>
<div class='modal-body'>%s</div>
</div>
<button type='button' data-toggle='modal' href='#%s' class='btn btn-primary btn-lg'>%s</button>", link, title, content, link, title)
Encoding(html) <- 'UTF-8'
HTML(html)
}