Selaa lähdekoodia

Add gumshoe.js and vanillajs-scrollspy.js to side nav menu when enabled

master
Garrick Aden-Buie 7 vuotta sitten
vanhempi
commit
bb5f080229
9 muutettua tiedostoa jossa 75 lisäystä ja 12 poistoa
  1. +16
    -4
      DESCRIPTION
  2. +21
    -4
      R/bulma_document.R
  3. +12
    -1
      inst/bulma/bulma.html
  4. +0
    -0
      inst/bulma/bulma.min.css
  5. +12
    -0
      inst/bulma/deps.yaml
  6. +2
    -0
      inst/bulma/gumshoe.min.js
  7. +2
    -0
      inst/bulma/vanillajs-scrollspy.min.js
  8. +7
    -0
      man/bulma-package.Rd
  9. +3
    -3
      man/bulma_document.Rd

+ 16
- 4
DESCRIPTION Näytä tiedosto

@@ -2,10 +2,22 @@ Package: bulma
Title: What the Package Does (One Line, Title Case)
Version: 0.0.0.9000
Authors@R:
person(given = "Garrick",
family = "Aden-Buie",
role = c("aut", "cre"),
email = "g.adenbuie@gmail.com")
c(person(given = "Garrick",
family = "Aden-Buie",
role = c("aut", "cre"),
email = "g.adenbuie@gmail.com"),
person(given = "Jeremy",
family = "Thomas",
role = "ctb",
comment = "Author of bulma.css"),
person(given = "Chris",
family = "Ferdinandi",
role = "ctb",
comment = "Author of gumshoe.js"),
person(given = "Eder",
family = "Sampaio",
role = "ctb",
comment = "Author of vanillajs-scrollspy.js"))
Description: What the package does (one paragraph).
License: MIT + file LICENSE
Imports:

+ 21
- 4
R/bulma_document.R Näytä tiedosto

@@ -45,7 +45,7 @@ bulma_document <- function(
extra_dependencies = NULL
) {
css_files <- c(
"--css", bulma_file("bulma", "bulma.0.7.2.min.css"))
"--css", bulma_file("bulma", "bulma.min.css"))

if (!is.null(css)) {
for (css_file in css) {
@@ -61,13 +61,30 @@ bulma_document <- function(
# ),
# ...
# )
deps <- htmltools::htmlDependency(
deps <- list(
htmltools::htmlDependency(
name = "bulma",
version = "0.7.2",
src = bulma_file("bulma"),
stylesheet = "bulma.0.7.2.min.css"
stylesheet = "bulma.min.css"
),
rmarkdown::html_dependency_font_awesome(),
if (toc) htmltools::htmlDependency(
name = "gumshoe",
version = "3.5.1",
src = bulma_file("bulma"),
script = "gumshoe.min.js"
),
if (toc) htmltools::htmlDependency(
name = "vanillajs-scrollspy",
version = "2.0.3",
src = bulma_file("bulma"),
script = "vanillajs-scrollspy.min.js"
)
extra_dependencies <- append(extra_dependencies, list(deps, rmarkdown::html_dependency_font_awesome()))
)

deps <- deps[!vapply(deps, is.null, logical(1))]
extra_dependencies <- append(extra_dependencies, deps)

# preprocessor ----
pre_processor <- function(metadata, input_file, runtime, knit_meta, files_dir, output_dir) {

+ 12
- 1
inst/bulma/bulma.html Näytä tiedosto

@@ -130,7 +130,7 @@ $endif$ <!-- bulma.hero_links -->
</div>
</div>
<div class="column">
<aside class="menu" id="toc-aside">
<aside class="menu" id="toc-aside" data-gumshoe>
$if(toc)$$table-of-contents$$endif$
</aside>
</div>
@@ -150,7 +150,16 @@ document.addEventListener("DOMContentLoaded", function(event) {
tables[i].classList.add(...tableClasses);
}
})
</script>

$if(toc)$
<script src="gumshoe.js"></script>
<script src="vanillajs-scrollspy.min.js"></script>
<script>
gumshoe.init({activeClass: "has-text-weight-semibold"});
const toc = document.querySelector('#toc-aside');
const scrollspy = new VanillaScrollspy(toc, 1000, 'easeInOutQuint');
scrollspy.init();
// Add appropriate TOC classes
document.addEventListener("DOMContentLoaded", function(event) {
var toc = document.getElementById('toc-aside').getElementsByTagName("ul");
@@ -159,6 +168,8 @@ document.addEventListener("DOMContentLoaded", function(event) {
}
})
</script>
$endif$

$if(mathjax-url)$
<!-- dynamically load mathjax for compatibility with self-contained -->
<script>

inst/bulma/bulma.0.7.2.min.css → inst/bulma/bulma.min.css Näytä tiedosto


+ 12
- 0
inst/bulma/deps.yaml Näytä tiedosto

@@ -0,0 +1,12 @@
bulma:
version: 0.7.2
url: https://raw.githubusercontent.com/jgthms/bulma/master/css/bulma.min.css
license: MIT 2018 Jeremy Thomas
gumshoe:
version: 3.5.1
url: https://raw.githubusercontent.com/cferdinandi/gumshoe/master/dist/js/gumshoe.min.js
license: MIT 2018 Chris Ferdinandi
vanillajs-scrollspy:
version: 2.0.3
url: https://raw.githubusercontent.com/ederssouza/vanillajs-scrollspy/master/dist/vanillajs-scrollspy.min.js
license: MIT 2018 Eder Sampaio

+ 2
- 0
inst/bulma/gumshoe.min.js Näytä tiedosto

@@ -0,0 +1,2 @@
/*! gumshoejs v3.5.1 | (c) 2018 Chris Ferdinandi | MIT License | http://github.com/cferdinandi/gumshoe */
!(function(e,t){"function"==typeof define&&define.amd?define([],t(e)):"object"==typeof exports?module.exports=t(e):e.gumshoe=t(e)})("undefined"!=typeof global?global:this.window||this.global,(function(e){"use strict";var t,n,o,r,a,c,i,l={},s=[],u={selector:"[data-gumshoe] a",selectorHeader:"[data-gumshoe-header]",container:e,offset:0,activeClass:"active",scrollDelay:!1,callback:function(){}},f=function(){return"querySelector"in document&&"addEventListener"in e&&"classList"in document.createElement("_")},d=function(e,t,n){if("[object Object]"===Object.prototype.toString.call(e))for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.call(n,e[o],o,e);else for(var r=0,a=e.length;r<a;r++)t.call(n,e[r],r,e)},v=function(){var e={},t=!1,n=0,o=arguments.length;"[object Boolean]"===Object.prototype.toString.call(arguments[0])&&(t=arguments[0],n++);for(;n<o;n++){var r=arguments[n];!(function(n){for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t&&"[object Object]"===Object.prototype.toString.call(n[o])?e[o]=v(!0,e[o],n[o]):e[o]=n[o])})(r)}return e},m=function(e){return Math.max(e.scrollHeight,e.offsetHeight,e.clientHeight)},g=function(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)},h=function(e){var n=0;if(e.offsetParent)do{n+=e.offsetTop,e=e.offsetParent}while(e);else n=e.offsetTop;return n=n-a-t.offset,n>=0?n:0},p=function(t){var n=t.getBoundingClientRect();return n.top>=0&&n.left>=0&&n.bottom<=(e.innerHeight||document.documentElement.clientHeight)&&n.right<=(e.innerWidth||document.documentElement.clientWidth)},y=function(){s.sort((function(e,t){return e.distance>t.distance?-1:e.distance<t.distance?1:0}))};l.setDistances=function(){o=g(),a=r?m(r)+h(r):0,d(s,(function(e){e.distance=h(e.target)})),y()};var b=function(){var e=document.querySelectorAll(t.selector);d(e,(function(e){if(e.hash){var t=document.querySelector(e.hash);t&&s.push({nav:e,target:t,parent:"li"===e.parentNode.tagName.toLowerCase()?e.parentNode:null,distance:0})}}))},H=function(){c&&(c.nav.classList.remove(t.activeClass),c.parent&&c.parent.classList.remove(t.activeClass))},C=function(e){H(),e.nav.classList.add(t.activeClass),e.parent&&e.parent.classList.add(t.activeClass),t.callback(e),c={nav:e.nav,parent:e.parent}};l.getCurrentNav=function(){var n=e.pageYOffset;if(e.innerHeight+n>=o&&p(s[0].target))return C(s[0]),s[0];for(var r=0,a=s.length;r<a;r++){var c=s[r];if(c.distance<=n)return C(c),c}H(),t.callback()};var L=function(){d(s,(function(e){e.nav.classList.contains(t.activeClass)&&(c={nav:e.nav,parent:e.parent})}))};l.destroy=function(){t&&(t.container.removeEventListener("resize",j,!1),t.container.removeEventListener("scroll",j,!1),s=[],t=null,n=null,o=null,r=null,a=null,c=null,i=null)};var E=function(e){window.clearTimeout(n),n=setTimeout((function(){l.setDistances(),l.getCurrentNav()}),66)},j=function(e){n||(n=setTimeout((function(){n=null,"scroll"===e.type&&l.getCurrentNav(),"resize"===e.type&&(l.setDistances(),l.getCurrentNav())}),66))};return l.init=function(e){f()&&(l.destroy(),t=v(u,e||{}),r=document.querySelector(t.selectorHeader),b(),0!==s.length&&(L(),l.setDistances(),l.getCurrentNav(),t.container.addEventListener("resize",j,!1),t.scrollDelay?t.container.addEventListener("scroll",E,!1):t.container.addEventListener("scroll",j,!1)))},l}));

+ 2
- 0
inst/bulma/vanillajs-scrollspy.min.js Näytä tiedosto

@@ -0,0 +1,2 @@
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.VanillaScrollspy=t():e.VanillaScrollspy=t()}(window,function(){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:o})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=1)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var o=function(){function e(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}return function(t,n,o){return n&&e(t.prototype,n),o&&e(t,o),t}}();var r=function(e){return window.setTimeout(e,1e3/60),e};window.requestAnimFrame=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||r;var i=function(){function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2e3,o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"easeOutSine";!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.menu=t,this.speed=n,this.easing=o}return o(e,[{key:"scrollToY",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0,n=window.scrollY||document.documentElement.scrollTop,o=0,r=Math.max(.1,Math.min(Math.abs(n-t)/this.speed,.8)),i={easeOutSine:function(e){return Math.sin(e*(Math.PI/2))},easeInOutSine:function(e){return-.5*(Math.cos(Math.PI*e)-1)},easeInOutQuint:function(e){return(e/=.5)<1?.5*Math.pow(e,5):.5*(Math.pow(e-2,5)+2)}};!function u(){var a=(o+=1/60)/r,c=i[e.easing](a);a<1?(window.requestAnimFrame(u),window.scrollTo(0,n+(t-n)*c)):window.scrollTo(0,t)}()}},{key:"menuControl",value:function(){var e=void 0,t=void 0,n=void 0,o=this.menu.querySelectorAll('a[href^="#"]'),r=window.scrollY||document.documentElement.scrollTop;for(e=0;e<o.length;e+=1)t=o[e],(n=document.querySelector(t.getAttribute("href"))).offsetTop<=r&&n.offsetTop+n.clientHeight>r?t.classList.add("active"):t.classList.remove("active")}},{key:"animated",value:function(){var e=this;function t(t){t.preventDefault();var n=document.querySelector(this.hash);e.scrollToY(n.offsetTop)}var n=void 0,o=this.menu.querySelectorAll('a[href^="#"]');for(n=0;n<o.length;n+=1)o[n].addEventListener("click",t)}},{key:"init",value:function(){var e=this;this.animated(),document.addEventListener("scroll",function(){e.menuControl()})}}]),e}();t.default=i},function(e,t,n){"use strict";e.exports=n(0).default}])});
//# sourceMappingURL=vanillajs-scrollspy.min.js.map

+ 7
- 0
man/bulma-package.Rd Näytä tiedosto

@@ -11,5 +11,12 @@ What the package does (one paragraph).
\author{
\strong{Maintainer}: Garrick Aden-Buie \email{g.adenbuie@gmail.com}

Other contributors:
\itemize{
\item Jeremy Thomas (Author of bulma.css) [contributor]
\item Chris Ferdinandi (Author of gumshoe.js) [contributor]
\item Eder Sampaio (Author of vanillajs-scrollspy.js) [contributor]
}

}
\keyword{internal}

+ 3
- 3
man/bulma_document.Rd Näytä tiedosto

@@ -15,9 +15,9 @@ bulma_document(..., css = NULL, fig_width = 10, fig_height = 7,
quotes to curly quotes, --- to em-dashes, -- to en-dashes, and ... to
ellipses.}
\item{theme}{Visual theme ("default", "cerulean", "journal", "flatly",
"readable", "spacelab", "united", "cosmo", "lumen", "paper", "sandstone",
"simplex", or "yeti"). Pass \code{NULL} for no theme (in this case you can
use the \code{css} parameter to add your own styles).}
"darkly", "readable", "spacelab", "united", "cosmo", "lumen", "paper",
"sandstone", "simplex", or "yeti"). Pass \code{NULL} for no theme (in this
case you can use the \code{css} parameter to add your own styles).}
\item{self_contained}{Produce a standalone HTML file with no external
dependencies, using data: URIs to incorporate the contents of linked
scripts, stylesheets, images, and videos. Note that even for self contained

Loading…
Peruuta
Tallenna