This commit is contained in:
Jeremy Kidwell 2019-03-14 19:04:29 +00:00
parent a93fabdf61
commit 513e98aaac
23 changed files with 196 additions and 383 deletions

View file

@ -58,3 +58,42 @@ span.search-highlight {
overflow: visible !important;
}
}
.kable_wrapper {
border-spacing: 20px 0;
border-collapse: separate;
border: none;
margin: auto;
}
.kable_wrapper > tbody > tr > td {
vertical-align: top;
}
.book .book-body .page-wrapper .page-inner section.normal table tr.header {
border-top-width: 2px;
}
.book .book-body .page-wrapper .page-inner section.normal table tr:last-child td {
border-bottom-width: 2px;
}
.book .book-body .page-wrapper .page-inner section.normal table td, .book .book-body .page-wrapper .page-inner section.normal table th {
border-left: none;
border-right: none;
}
.book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr, .book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr > td {
border-top: none;
}
.book .book-body .page-wrapper .page-inner section.normal table.kable_wrapper > tbody > tr:last-child > td {
border-bottom: none;
}
div.theorem, div.lemma, div.corollary, div.proposition, div.conjecture {
font-style: italic;
}
span.theorem, span.lemma, span.corollary, span.proposition, span.conjecture {
font-style: normal;
}
div.proof:after {
content: "\25a2";
float: right;
}
.header-section-number {
padding-right: .5em;
}

View file

@ -104,7 +104,8 @@
background-color: inherit;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
border-color: inherit;
border-color: #c4b29f;
opacity: 0.9;
}
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal pre,
.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal code {

View file

@ -12,12 +12,13 @@
.book .book-summary .book-search input:hover {
width: 100%;
background: transparent;
border: 1px solid transparent;
border: 1px solid #ccc;
box-shadow: none;
outline: none;
line-height: 22px;
padding: 7px 4px;
color: inherit;
box-sizing: border-box;
}
.book.with-search .book-summary .book-search {
top: 0px;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
require(["jQuery"], function(jQuery) {
gitbook.require(["jQuery"], function(jQuery) {
/*
* jQuery Highlight plugin

File diff suppressed because one or more lines are too long

View file

@ -1,4 +1,4 @@
require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var gs = gitbook.storage;
@ -16,6 +16,18 @@ require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
}
});
// add the History button (file history on Github)
var history = config.history;
if (history && history.link) gitbook.toolbar.createButton({
icon: 'fa fa-history',
label: history.text || 'History',
position: 'left',
onClick: function(e) {
e.preventDefault();
window.open(history.link);
}
});
var down = config.download;
var normalizeDownload = function() {
if (!down || !(down instanceof Array) || down.length === 0) return;
@ -175,31 +187,43 @@ require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
});
var bookBody = $('.book-body'), bookInner = bookBody.find('.body-inner');
var chapterTitle = function() {
return bookInner.find('.page-inner').find('h1,h2').first().text();
};
var bookTitle = function() {
return bookInner.find('.book-header > h1').first().text();
};
var saveScrollPos = function(e) {
// save scroll position before page is reloaded
gs.set('bodyScrollTop', {
body: bookBody.scrollTop(),
inner: bookInner.scrollTop(),
title: bookInner.find('.page-inner').find('h1,h2').first().text()
focused: document.hasFocus(),
title: chapterTitle()
});
};
$(document).on('servr:reload', saveScrollPos);
// check if the page is loaded in the RStudio preview window
var inRStudio = function() {
// check if the page is loaded in an iframe (e.g. the RStudio preview window)
var inIFrame = function() {
var inIframe = true;
try { inIframe = window.self !== window.top; } catch (e) {}
if (!inIframe) return false;
return /^\/rmd_output\/[0-9]+\/.*$/.test(window.location.pathname);
return inIframe;
};
if (inRStudio()) $(window).on('blur', saveScrollPos);
if (inRStudio()) $(window).on('unload', saveScrollPos);
$(window).on('blur unload', function(e) {
if (inIFrame()) saveScrollPos(e);
gs.set('bookTitle', bookTitle());
});
$(document).ready(function(e) {
$(function(e) {
if (gs.get('bookTitle', '') !== bookTitle()) localStorage.clear();
var pos = gs.get('bodyScrollTop');
if (pos && pos.title === bookInner.find('.page-inner').find('h1,h2').first().text()) {
if (pos.body !== 0) bookBody.scrollTop(pos.body);
if (pos.inner !== 0) bookInner.scrollTop(pos.inner);
if (pos) {
if (pos.title === chapterTitle()) {
if (pos.body !== 0) bookBody.scrollTop(pos.body);
if (pos.inner !== 0) bookInner.scrollTop(pos.inner);
}
if (pos.focused) bookInner.find('.page-wrapper').focus();
}
// clear book body scroll position
gs.remove('bodyScrollTop');

View file

@ -1,4 +1,4 @@
require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var fontState;
var THEMES = {

View file

@ -1,6 +1,6 @@
require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var index = null;
var $searchInput, $searchForm;
var $searchInput, $searchLabel, $searchForm;
var $highlighted, hi = 0, hiOpts = { className: 'search-highlight' };
var collapse = false;
@ -92,6 +92,7 @@ require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
// Create search form
function createForm(value) {
if ($searchForm) $searchForm.remove();
if ($searchLabel) $searchLabel.remove();
if ($searchInput) $searchInput.remove();
$searchForm = $('<div>', {
@ -99,13 +100,22 @@ require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
'role': 'search'
});
$searchLabel = $('<label>', {
'for': 'search-box',
'aria-hidden': 'false',
'hidden': ''
});
$searchInput = $('<input>', {
'id': 'search-box',
'type': 'search',
'class': 'form-control',
'val': value,
'placeholder': 'Type to search'
});
$searchLabel.append("Type to search");
$searchLabel.appendTo($searchForm);
$searchInput.appendTo($searchForm);
$searchForm.prependTo(gitbook.state.$book.find('.book-summary'));
}
@ -180,7 +190,7 @@ require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
scrollToHighlighted();
}
}).on("input", ".book-search input", function(e) {
var q = $(this).val();
var q = $(this).val().trim();
if (q.length === 0) {
gitbook.sidebar.filter(null);
gitbook.storage.remove("keyword");

View file

@ -1,5 +1,15 @@
require(["gitbook", "lodash"], function(gitbook, _) {
gitbook.require(["gitbook", "lodash", "jQuery"], function(gitbook, _, $) {
var SITES = {
'github': {
'label': 'Github',
'icon': 'fa fa-github',
'onClick': function(e) {
e.preventDefault();
var repo = $('meta[name="github-repo"]').attr('content');
if (typeof repo === 'undefined') throw("Github repo not defined");
window.open("https://github.com/"+repo);
}
},
'facebook': {
'label': 'Facebook',
'icon': 'fa fa-facebook',
@ -24,6 +34,14 @@ require(["gitbook", "lodash"], function(gitbook, _) {
window.open("https://plus.google.com/share?url="+encodeURIComponent(location.href));
}
},
'linkedin': {
'label': 'LinkedIn',
'icon': 'fa fa-linkedin',
'onClick': function(e) {
e.preventDefault();
window.open("https://www.linkedin.com/shareArticle?mini=true&url="+encodeURIComponent(location.href)+"&title="+encodeURIComponent(document.title));
}
},
'weibo': {
'label': 'Weibo',
'icon': 'fa fa-weibo',