|
| 1 | +"use strict"; |
| 2 | + |
| 3 | +// Copyright (c) Anymail Contributors. |
| 4 | +// All rights reserved. |
| 5 | +// |
| 6 | +// Redistribution and use in source and binary forms, with or without modification, |
| 7 | +// are permitted provided that the following conditions are met: |
| 8 | +// |
| 9 | +// 1. Redistributions of source code must retain the above copyright notice, |
| 10 | +// this list of conditions and the following disclaimer. |
| 11 | +// |
| 12 | +// 2. Redistributions in binary form must reproduce the above copyright |
| 13 | +// notice, this list of conditions and the following disclaimer in the |
| 14 | +// documentation and/or other materials provided with the distribution. |
| 15 | +// |
| 16 | +// 3. Neither the name of the copyright holder nor the names of its contributors |
| 17 | +// may be used to endorse or promote products derived from this software |
| 18 | +// without specific prior written permission. |
| 19 | +// |
| 20 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 21 | +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 22 | +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 23 | +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 24 | +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 25 | +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 26 | +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 27 | +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 29 | +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 | + |
| 31 | +// Source: |
| 32 | +// https://github.com/anymail/django-anymail/blob/4c443f5515d1d5269a95cb54cf75057c56a3b150/docs/_static/version-alert.js |
| 33 | +// following instructions here: |
| 34 | +// https://michaelgoerz.net/notes/showing-a-warning-for-the-latest-documentation-on-readthedocs.html |
| 35 | + |
| 36 | +function warnOnLatestVersion() { |
| 37 | + |
| 38 | + // The warning text and link is really specific to RTD hosting, |
| 39 | + // so we can just check their global to determine version: |
| 40 | + if (!window.READTHEDOCS_DATA || window.READTHEDOCS_DATA.version !== "latest") { |
| 41 | + return; // not latest, or not on RTD |
| 42 | + } |
| 43 | + |
| 44 | + var warning = document.createElement('div'); |
| 45 | + warning.setAttribute('class', 'admonition danger'); |
| 46 | + warning.innerHTML = "<p class='first admonition-title'>Note</p> " + |
| 47 | + "<p class='last'> " + |
| 48 | + "This document is for an <strong>unreleased development version</strong>. " + |
| 49 | + "Documentation is available for the <a href='/en/stable/'>current stable release</a>, " + |
| 50 | + "or for older versions through the “v:” menu at bottom right." + |
| 51 | + "</p>"; |
| 52 | + warning.querySelector('a').href = window.location.pathname.replace('/latest', '/stable'); |
| 53 | + |
| 54 | + // modified from original to work better w/ pydata sphinx theme |
| 55 | + var parent = document.querySelector('main') || document.body; |
| 56 | + parent.insertBefore(warning, parent.firstChild); |
| 57 | +} |
| 58 | + |
| 59 | +document.addEventListener('DOMContentLoaded', warnOnLatestVersion); |
0 commit comments