aboutsummaryrefslogtreecommitdiff
path: root/docs/_book/gitbook/gitbook-plugin-fontsettings
diff options
context:
space:
mode:
authorJakob Stendahl <14180120+JakobST1n@users.noreply.github.com>2018-12-01 00:28:28 +0100
committerGitHub <noreply@github.com>2018-12-01 00:28:28 +0100
commit19df9946b438b38b9a4f3f57ad002981a1ae1eaf (patch)
treee8eb839a305502584e31e1b1a96c70406b9b6255 /docs/_book/gitbook/gitbook-plugin-fontsettings
parentfd7a1b51126f8b8f889807cb7d56bb3626a0e0b5 (diff)
parent7ec685de6e441af1f614bb9d18e25c047d21466b (diff)
downloadLuxcena-Neo-19df9946b438b38b9a4f3f57ad002981a1ae1eaf.tar.gz
Luxcena-Neo-19df9946b438b38b9a4f3f57ad002981a1ae1eaf.zip
Merge pull request #6 from JakobST1n/dev
Written docs, finished CLI
Diffstat (limited to 'docs/_book/gitbook/gitbook-plugin-fontsettings')
-rw-r--r--docs/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js240
-rw-r--r--docs/_book/gitbook/gitbook-plugin-fontsettings/website.css291
2 files changed, 531 insertions, 0 deletions
diff --git a/docs/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js b/docs/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js
new file mode 100644
index 0000000..ff7be71
--- /dev/null
+++ b/docs/_book/gitbook/gitbook-plugin-fontsettings/fontsettings.js
@@ -0,0 +1,240 @@
+require(['gitbook', 'jquery'], function(gitbook, $) {
+ // Configuration
+ var MAX_SIZE = 4,
+ MIN_SIZE = 0,
+ BUTTON_ID;
+
+ // Current fontsettings state
+ var fontState;
+
+ // Default themes
+ var THEMES = [
+ {
+ config: 'white',
+ text: 'White',
+ id: 0
+ },
+ {
+ config: 'sepia',
+ text: 'Sepia',
+ id: 1
+ },
+ {
+ config: 'night',
+ text: 'Night',
+ id: 2
+ }
+ ];
+
+ // Default font families
+ var FAMILIES = [
+ {
+ config: 'serif',
+ text: 'Serif',
+ id: 0
+ },
+ {
+ config: 'sans',
+ text: 'Sans',
+ id: 1
+ }
+ ];
+
+ // Return configured themes
+ function getThemes() {
+ return THEMES;
+ }
+
+ // Modify configured themes
+ function setThemes(themes) {
+ THEMES = themes;
+ updateButtons();
+ }
+
+ // Return configured font families
+ function getFamilies() {
+ return FAMILIES;
+ }
+
+ // Modify configured font families
+ function setFamilies(families) {
+ FAMILIES = families;
+ updateButtons();
+ }
+
+ // Save current font settings
+ function saveFontSettings() {
+ gitbook.storage.set('fontState', fontState);
+ update();
+ }
+
+ // Increase font size
+ function enlargeFontSize(e) {
+ e.preventDefault();
+ if (fontState.size >= MAX_SIZE) return;
+
+ fontState.size++;
+ saveFontSettings();
+ }
+
+ // Decrease font size
+ function reduceFontSize(e) {
+ e.preventDefault();
+ if (fontState.size <= MIN_SIZE) return;
+
+ fontState.size--;
+ saveFontSettings();
+ }
+
+ // Change font family
+ function changeFontFamily(configName, e) {
+ if (e && e instanceof Event) {
+ e.preventDefault();
+ }
+
+ var familyId = getFontFamilyId(configName);
+ fontState.family = familyId;
+ saveFontSettings();
+ }
+
+ // Change type of color theme
+ function changeColorTheme(configName, e) {
+ if (e && e instanceof Event) {
+ e.preventDefault();
+ }
+
+ var $book = gitbook.state.$book;
+
+ // Remove currently applied color theme
+ if (fontState.theme !== 0)
+ $book.removeClass('color-theme-'+fontState.theme);
+
+ // Set new color theme
+ var themeId = getThemeId(configName);
+ fontState.theme = themeId;
+ if (fontState.theme !== 0)
+ $book.addClass('color-theme-'+fontState.theme);
+
+ saveFontSettings();
+ }
+
+ // Return the correct id for a font-family config key
+ // Default to first font-family
+ function getFontFamilyId(configName) {
+ // Search for plugin configured font family
+ var configFamily = $.grep(FAMILIES, function(family) {
+ return family.config == configName;
+ })[0];
+ // Fallback to default font family
+ return (!!configFamily)? configFamily.id : 0;
+ }
+
+ // Return the correct id for a theme config key
+ // Default to first theme
+ function getThemeId(configName) {
+ // Search for plugin configured theme
+ var configTheme = $.grep(THEMES, function(theme) {
+ return theme.config == configName;
+ })[0];
+ // Fallback to default theme
+ return (!!configTheme)? configTheme.id : 0;
+ }
+
+ function update() {
+ var $book = gitbook.state.$book;
+
+ $('.font-settings .font-family-list li').removeClass('active');
+ $('.font-settings .font-family-list li:nth-child('+(fontState.family+1)+')').addClass('active');
+
+ $book[0].className = $book[0].className.replace(/\bfont-\S+/g, '');
+ $book.addClass('font-size-'+fontState.size);
+ $book.addClass('font-family-'+fontState.family);
+
+ if(fontState.theme !== 0) {
+ $book[0].className = $book[0].className.replace(/\bcolor-theme-\S+/g, '');
+ $book.addClass('color-theme-'+fontState.theme);
+ }
+ }
+
+ function init(config) {
+ // Search for plugin configured font family
+ var configFamily = getFontFamilyId(config.family),
+ configTheme = getThemeId(config.theme);
+
+ // Instantiate font state object
+ fontState = gitbook.storage.get('fontState', {
+ size: config.size || 2,
+ family: configFamily,
+ theme: configTheme
+ });
+
+ update();
+ }
+
+ function updateButtons() {
+ // Remove existing fontsettings buttons
+ if (!!BUTTON_ID) {
+ gitbook.toolbar.removeButton(BUTTON_ID);
+ }
+
+ // Create buttons in toolbar
+ BUTTON_ID = gitbook.toolbar.createButton({
+ icon: 'fa fa-font',
+ label: 'Font Settings',
+ className: 'font-settings',
+ dropdown: [
+ [
+ {
+ text: 'A',
+ className: 'font-reduce',
+ onClick: reduceFontSize
+ },
+ {
+ text: 'A',
+ className: 'font-enlarge',
+ onClick: enlargeFontSize
+ }
+ ],
+ $.map(FAMILIES, function(family) {
+ family.onClick = function(e) {
+ return changeFontFamily(family.config, e);
+ };
+
+ return family;
+ }),
+ $.map(THEMES, function(theme) {
+ theme.onClick = function(e) {
+ return changeColorTheme(theme.config, e);
+ };
+
+ return theme;
+ })
+ ]
+ });
+ }
+
+ // Init configuration at start
+ gitbook.events.bind('start', function(e, config) {
+ var opts = config.fontsettings;
+
+ // Generate buttons at start
+ updateButtons();
+
+ // Init current settings
+ init(opts);
+ });
+
+ // Expose API
+ gitbook.fontsettings = {
+ enlargeFontSize: enlargeFontSize,
+ reduceFontSize: reduceFontSize,
+ setTheme: changeColorTheme,
+ setFamily: changeFontFamily,
+ getThemes: getThemes,
+ setThemes: setThemes,
+ getFamilies: getFamilies,
+ setFamilies: setFamilies
+ };
+});
+
+
diff --git a/docs/_book/gitbook/gitbook-plugin-fontsettings/website.css b/docs/_book/gitbook/gitbook-plugin-fontsettings/website.css
new file mode 100644
index 0000000..26591fe
--- /dev/null
+++ b/docs/_book/gitbook/gitbook-plugin-fontsettings/website.css
@@ -0,0 +1,291 @@
+/*
+ * Theme 1
+ */
+.color-theme-1 .dropdown-menu {
+ background-color: #111111;
+ border-color: #7e888b;
+}
+.color-theme-1 .dropdown-menu .dropdown-caret .caret-inner {
+ border-bottom: 9px solid #111111;
+}
+.color-theme-1 .dropdown-menu .buttons {
+ border-color: #7e888b;
+}
+.color-theme-1 .dropdown-menu .button {
+ color: #afa790;
+}
+.color-theme-1 .dropdown-menu .button:hover {
+ color: #73553c;
+}
+/*
+ * Theme 2
+ */
+.color-theme-2 .dropdown-menu {
+ background-color: #2d3143;
+ border-color: #272a3a;
+}
+.color-theme-2 .dropdown-menu .dropdown-caret .caret-inner {
+ border-bottom: 9px solid #2d3143;
+}
+.color-theme-2 .dropdown-menu .buttons {
+ border-color: #272a3a;
+}
+.color-theme-2 .dropdown-menu .button {
+ color: #62677f;
+}
+.color-theme-2 .dropdown-menu .button:hover {
+ color: #f4f4f5;
+}
+.book .book-header .font-settings .font-enlarge {
+ line-height: 30px;
+ font-size: 1.4em;
+}
+.book .book-header .font-settings .font-reduce {
+ line-height: 30px;
+ font-size: 1em;
+}
+.book.color-theme-1 .book-body {
+ color: #704214;
+ background: #f3eacb;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section {
+ background: #f3eacb;
+}
+.book.color-theme-2 .book-body {
+ color: #bdcadb;
+ background: #1c1f2b;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section {
+ background: #1c1f2b;
+}
+.book.font-size-0 .book-body .page-inner section {
+ font-size: 1.2rem;
+}
+.book.font-size-1 .book-body .page-inner section {
+ font-size: 1.4rem;
+}
+.book.font-size-2 .book-body .page-inner section {
+ font-size: 1.6rem;
+}
+.book.font-size-3 .book-body .page-inner section {
+ font-size: 2.2rem;
+}
+.book.font-size-4 .book-body .page-inner section {
+ font-size: 4rem;
+}
+.book.font-family-0 {
+ font-family: Georgia, serif;
+}
+.book.font-family-1 {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal {
+ color: #704214;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal a {
+ color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h3,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h4,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h5,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
+ color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h1,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h2 {
+ border-color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal h6 {
+ color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal hr {
+ background-color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal blockquote {
+ border-color: inherit;
+}
+.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 {
+ background: #fdf6e3;
+ color: #657b83;
+ border-color: #f8df9c;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal .highlight {
+ background-color: inherit;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table th,
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table td {
+ border-color: #f5d06c;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr {
+ color: inherit;
+ background-color: #fdf6e3;
+ border-color: #444444;
+}
+.book.color-theme-1 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
+ background-color: #fbeecb;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal {
+ color: #bdcadb;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal a {
+ color: #3eb1d0;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h3,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h4,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h5,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
+ color: #fffffa;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h1,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h2 {
+ border-color: #373b4e;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal h6 {
+ color: #373b4e;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal hr {
+ background-color: #373b4e;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal blockquote {
+ border-color: #373b4e;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal pre,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal code {
+ color: #9dbed8;
+ background: #2d3143;
+ border-color: #2d3143;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal .highlight {
+ background-color: #282a39;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table th,
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table td {
+ border-color: #3b3f54;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr {
+ color: #b6c2d2;
+ background-color: #2d3143;
+ border-color: #3b3f54;
+}
+.book.color-theme-2 .book-body .page-wrapper .page-inner section.normal table tr:nth-child(2n) {
+ background-color: #35394b;
+}
+.book.color-theme-1 .book-header {
+ color: #afa790;
+ background: transparent;
+}
+.book.color-theme-1 .book-header .btn {
+ color: #afa790;
+}
+.book.color-theme-1 .book-header .btn:hover {
+ color: #73553c;
+ background: none;
+}
+.book.color-theme-1 .book-header h1 {
+ color: #704214;
+}
+.book.color-theme-2 .book-header {
+ color: #7e888b;
+ background: transparent;
+}
+.book.color-theme-2 .book-header .btn {
+ color: #3b3f54;
+}
+.book.color-theme-2 .book-header .btn:hover {
+ color: #fffff5;
+ background: none;
+}
+.book.color-theme-2 .book-header h1 {
+ color: #bdcadb;
+}
+.book.color-theme-1 .book-body .navigation {
+ color: #afa790;
+}
+.book.color-theme-1 .book-body .navigation:hover {
+ color: #73553c;
+}
+.book.color-theme-2 .book-body .navigation {
+ color: #383f52;
+}
+.book.color-theme-2 .book-body .navigation:hover {
+ color: #fffff5;
+}
+/*
+ * Theme 1
+ */
+.book.color-theme-1 .book-summary {
+ color: #afa790;
+ background: #111111;
+ border-right: 1px solid rgba(0, 0, 0, 0.07);
+}
+.book.color-theme-1 .book-summary .book-search {
+ background: transparent;
+}
+.book.color-theme-1 .book-summary .book-search input,
+.book.color-theme-1 .book-summary .book-search input:focus {
+ border: 1px solid transparent;
+}
+.book.color-theme-1 .book-summary ul.summary li.divider {
+ background: #7e888b;
+ box-shadow: none;
+}
+.book.color-theme-1 .book-summary ul.summary li i.fa-check {
+ color: #33cc33;
+}
+.book.color-theme-1 .book-summary ul.summary li.done > a {
+ color: #877f6a;
+}
+.book.color-theme-1 .book-summary ul.summary li a,
+.book.color-theme-1 .book-summary ul.summary li span {
+ color: #877f6a;
+ background: transparent;
+ font-weight: normal;
+}
+.book.color-theme-1 .book-summary ul.summary li.active > a,
+.book.color-theme-1 .book-summary ul.summary li a:hover {
+ color: #704214;
+ background: transparent;
+ font-weight: normal;
+}
+/*
+ * Theme 2
+ */
+.book.color-theme-2 .book-summary {
+ color: #bcc1d2;
+ background: #2d3143;
+ border-right: none;
+}
+.book.color-theme-2 .book-summary .book-search {
+ background: transparent;
+}
+.book.color-theme-2 .book-summary .book-search input,
+.book.color-theme-2 .book-summary .book-search input:focus {
+ border: 1px solid transparent;
+}
+.book.color-theme-2 .book-summary ul.summary li.divider {
+ background: #272a3a;
+ box-shadow: none;
+}
+.book.color-theme-2 .book-summary ul.summary li i.fa-check {
+ color: #33cc33;
+}
+.book.color-theme-2 .book-summary ul.summary li.done > a {
+ color: #62687f;
+}
+.book.color-theme-2 .book-summary ul.summary li a,
+.book.color-theme-2 .book-summary ul.summary li span {
+ color: #c1c6d7;
+ background: transparent;
+ font-weight: 600;
+}
+.book.color-theme-2 .book-summary ul.summary li.active > a,
+.book.color-theme-2 .book-summary ul.summary li a:hover {
+ color: #f4f4f5;
+ background: #252737;
+ font-weight: 600;
+}