├── .eslintrc ├── .gitignore ├── README.md ├── assets ├── plugin.css └── plugin.js ├── index.js └── package.json /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "rules": { 3 | "indent": [ 2, 4 ], 4 | "quotes": [ 2, "single" ], 5 | "linebreak-style": [ 2, "unix" ], 6 | "semi": [ 2, "always" ], 7 | "no-unused-vars": [ 2, { 8 | "vars": "all", 9 | "args": "none" 10 | } ], 11 | "spaced-comment": [ 2, "always" ] 12 | }, 13 | "env": { 14 | "node": true, 15 | "mocha": true, 16 | "browser": true 17 | }, 18 | "extends": "eslint:recommended" 19 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## gitbook-plugin-versions 2 | 3 | Display a `` element will be created with the given `options` and placed at the top of the book summary. When the user selects one of the options, they are taken to that URL. 55 | 56 | The `gitbookConfigURL` variable is a publicly accessible URL to your `book.json`. If this is present, the plugin will fetch the latest config when the page loads, so even older versions of your book will have updated `options`. 57 | 58 | ### Credits 59 | 60 | Original work by [@mjackson](https://github.com/mjackson). 61 | -------------------------------------------------------------------------------- /assets/plugin.css: -------------------------------------------------------------------------------- 1 | .versions-select { 2 | display: table; 3 | width: 100%; 4 | height: 50px; 5 | padding: 0px 12px; 6 | } 7 | 8 | .versions-select > div { 9 | display: table-cell; 10 | text-align: center; 11 | vertical-align: middle; 12 | } 13 | 14 | .versions-select select { 15 | width: 100%; 16 | } 17 | -------------------------------------------------------------------------------- /assets/plugin.js: -------------------------------------------------------------------------------- 1 | require(['gitbook', 'jQuery'], function (gitbook, $) { 2 | var versions = [], 3 | current = undefined, 4 | pluginConfig = {}; 5 | 6 | // Update the select with a list of versions 7 | function updateVersions(_versions) { 8 | versions = _versions || versions; 9 | current = $('.versions-select select').val() || current; 10 | 11 | // Cleanup existing selector 12 | $('.versions-select').remove(); 13 | 14 | if (versions.length == 0) return; 15 | 16 | var $li = $('
  • ', { 17 | 'class': 'versions-select', 18 | 'html': '
    ' 19 | }); 20 | var $select = $li.find('select'); 21 | 22 | $.each(versions, function(i, version) { 23 | var $option = $('