From d4dd75cb49e7b1c9dc51a2b36a0ce0ba1449102a Mon Sep 17 00:00:00 2001 From: Konrad Malawski Date: Sat, 22 Aug 2015 18:35:20 +0200 Subject: [PATCH] +doc #18295 add close button with 1day delay to reappear --- akka-docs/_sphinx/themes/akka/static/docs.css | 12 ++- .../_sphinx/themes/akka/static/warnOldDocs.js | 95 ++++++++++++++----- 2 files changed, 81 insertions(+), 26 deletions(-) diff --git a/akka-docs/_sphinx/themes/akka/static/docs.css b/akka-docs/_sphinx/themes/akka/static/docs.css index d3ae5b6bb3..c5842c0e38 100644 --- a/akka-docs/_sphinx/themes/akka/static/docs.css +++ b/akka-docs/_sphinx/themes/akka/static/docs.css @@ -187,9 +187,10 @@ div.align-center { width: 100%; text-align: center; } p.caption { width: 80%; text-align: justify; font-size: 0.95em; font-style: italic; position: relative; left: 10%; } + /* floaty warning about old version of docs */ #floaty-warning { - display: block; + display: none; position: fixed; bottom: 0; left: 0; @@ -215,3 +216,12 @@ p.caption { width: 80%; text-align: justify; font-size: 0.95em; font-style: ital font-weight: bold; text-decoration: underline; } + +#close-floaty-window { + position: absolute; + top: 1em; + right: 2em; + color: white; + font-weight: normal; + text-decoration: none; +} \ No newline at end of file diff --git a/akka-docs/_sphinx/themes/akka/static/warnOldDocs.js b/akka-docs/_sphinx/themes/akka/static/warnOldDocs.js index 2577d5dc93..44a1783279 100644 --- a/akka-docs/_sphinx/themes/akka/static/warnOldDocs.js +++ b/akka-docs/_sphinx/themes/akka/static/warnOldDocs.js @@ -30,48 +30,63 @@ function showVersionWarning(version, akkaVersionsData, seriesInfo) { console.log("Current version info", seriesInfo); var isOutdated = !!seriesInfo.outdated; - var isLatestInSeries = version != seriesInfo.latest; + var isLatestInSeries = version == seriesInfo.latest; + var needsToShow = false; if (isOutdated) { + needsToShow = true; $floatyWarning.addClass("warning"); var instead = akkaVersionsData[seriesInfo.instead].latest; console.log("Akka " + version + " is outdated. Suggesting 'latest' of ", seriesInfo.instead, "by 'instead' key."); - var unsupportedMessage = '

' + - 'This version of Akka (' + version + ') has been end-of-lifed and is currently not supported!
' + - 'Please upgrade to Akka ' + instead + ' or Typesafe Reactive Platform as soon as possible.' + - '

'; - $floatyWarning.append(unsupportedMessage); + $floatyWarning + .append( + '

' + + 'This version of Akka (' + version + ') has been end-of-lifed and is currently not supported!
' + + 'Please upgrade to Akka ' + instead + ' or Typesafe Reactive Platform as soon as possible.' + + '

'); } - if (isLatestInSeries) { + if (!isLatestInSeries) { + needsToShow = true; $floatyWarning - .append('

' + + .append( + '

' + 'You are browsing the docs for Akka ' + version + ', ' + 'however the latest release in this series is: ' + '' + seriesInfo.latest + '.
' + '

'); } - // add bottom clicky link "to same page" if (isOutdated) { - $floatyWarning.append( - '

' + - 'Click here to go to the same page on the ' + akkaVersionsData[seriesInfo.instead].latest + ' version of the docs.' + - '

') - } else if (isLatestInSeries && isOutdated) { - $floatyWarning.append( - '

' + - 'Click here to go to the same page on the ' + seriesInfo.latest + ' version of the docs.' + - '

') + $floatyWarning + .append( + '

' + + 'Click here to go to the same page on the ' + akkaVersionsData[seriesInfo.instead].latest + ' version of the docs.' + + '

'); + } else if (!isLatestInSeries) { + $floatyWarning + .append( + '

' + + 'Click here to go to the same page on the ' + seriesInfo.latest + ' version of the docs.' + + '

') } - $floatyWarning - .hide() - .prependTo("body") - .show() - .delay(10 * 1000) - .fadeOut() + if (needsToShow && !outdatedVersionWasAcked(version)) { + var $close = $('Close [X]') + .click(function () { + ackOutdatedVersionForADay(version); + $floatyWarning.hide(); + }); + + $floatyWarning + .hide() + .append($close) + .prependTo("body") + .show() + .delay(10 * 1000) + .fadeOut(); + } } // e.g. "docs/akka/2.3.10/scala/persistence.html" => "2.3.10" @@ -90,7 +105,37 @@ function browsedAkkaVersion() { function versionsJsonUri() { if (window.location.pathname.includes("stream-and-http")) - return "http://doc.akka.io/docs/akka-stream-and-http-experimental/versions.json" + return "http://doc.akka.io/docs/akka-stream-and-http-experimental/versions.json"; else return "http://doc.akka.io/docs/akka/versions.json"; } + +// --- ack outdated versions --- + +function ackOutdatedVersionCookieName(version) { + return "ack-outdated-" + version; +} + +function ackOutdatedVersionForADay(version) { + function setCookie(cname, cvalue, exdays) { + var d = new Date(); + d.setTime(d.getTime() + (exdays*24*60*60*1000)); + var expires = "expires="+d.toUTCString(); + document.cookie = cname + "=" + cvalue + "; " + expires; + } + setCookie(ackOutdatedVersionCookieName(version), 'true', 1) +} +function outdatedVersionWasAcked(version) { + function getCookie(cname) { + var name = cname + "="; + var ca = document.cookie.split(';'); + for(var i=0; i